Инструмент масштабирования
This commit is contained in:
		
							parent
							
								
									c0a6c40cd7
								
							
						
					
					
						commit
						8f9a8c1759
					
				@ -3,6 +3,7 @@
 | 
			
		||||
 | 
			
		||||
#define T_SENSITIVITY 0.001
 | 
			
		||||
#define R_SENSITIVITY 1
 | 
			
		||||
#define S_SENSITIVITY 0.00001
 | 
			
		||||
 | 
			
		||||
#include "Model.h"
 | 
			
		||||
 | 
			
		||||
@ -33,4 +34,12 @@ class Rotate : public TRS
 | 
			
		||||
        virtual void process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos); // Взаимодействие с инструментом
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Инструмент масштабирования
 | 
			
		||||
class Scale : public TRS
 | 
			
		||||
{
 | 
			
		||||
    public: 
 | 
			
		||||
        Scale();
 | 
			
		||||
        virtual void process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos); // Взаимодействие с инструментом
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TRS_H
 | 
			
		||||
@ -404,7 +404,8 @@ int main(void)
 | 
			
		||||
    // Инструменты
 | 
			
		||||
    Transform transform;
 | 
			
		||||
    Rotate rotate;
 | 
			
		||||
    TRS& currentTool = rotate; 
 | 
			
		||||
    Scale scale;
 | 
			
		||||
    TRS& currentTool = scale; 
 | 
			
		||||
 | 
			
		||||
    // Пока не произойдет событие запроса закрытия окна
 | 
			
		||||
    while(!glfwWindowShouldClose(window))
 | 
			
		||||
 | 
			
		||||
@ -98,3 +98,38 @@ void Rotate::process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos)
 | 
			
		||||
            selectedObject->dRotation(dVec); 
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Scale::Scale() 
 | 
			
		||||
{
 | 
			
		||||
    tool = loadOBJtoGroupted("../resources/models/tools/scale.obj", "../resources/models/tools/", "../resources/textures/");
 | 
			
		||||
    
 | 
			
		||||
    // Масштабирование
 | 
			
		||||
    tool.scale = glm::vec3(0.3);
 | 
			
		||||
    tool.rotation.y = 180;
 | 
			
		||||
 | 
			
		||||
    // Инициализация дополнительной информации
 | 
			
		||||
    init_etc();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Взаимодействие с инструментом
 | 
			
		||||
void Scale::process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos)
 | 
			
		||||
{
 | 
			
		||||
    // Если есть выбранная модель - рендерим инструмент для неё
 | 
			
		||||
    if (selectedID)
 | 
			
		||||
    {
 | 
			
		||||
        // Указатель на объект
 | 
			
		||||
        Movable* selectedObject = (Movable*) selectedID;
 | 
			
		||||
 | 
			
		||||
        glm::vec3 dVec(0);
 | 
			
		||||
 | 
			
		||||
        if (etc & 01)
 | 
			
		||||
            dVec.x = dpos.x * S_SENSITIVITY;
 | 
			
		||||
        if (etc & 02)
 | 
			
		||||
            dVec.z = dpos.z * S_SENSITIVITY;
 | 
			
		||||
        if (etc & 04)
 | 
			
		||||
            dVec.y = dpos.y * S_SENSITIVITY;    
 | 
			
		||||
 | 
			
		||||
        if (etc > 0)
 | 
			
		||||
            selectedObject->dScale(dVec);   
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user