Инструмент масштабирования

This commit is contained in:
parent 8e60904f65
commit 8188172f33
3 changed files with 47 additions and 2 deletions

View File

@ -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

View File

@ -404,7 +404,8 @@ int main(void)
// Инструменты
Transform transform;
Rotate rotate;
TRS& currentTool = rotate;
Scale scale;
TRS& currentTool = scale;
// Пока не произойдет событие запроса закрытия окна
while(!glfwWindowShouldClose(window))

View File

@ -97,4 +97,39 @@ void Rotate::process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos)
if (etc > 0)
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);
}
}