diff --git a/include/tools/TRS.h b/include/tools/TRS.h index 22bfaba..53a6af9 100644 --- a/include/tools/TRS.h +++ b/include/tools/TRS.h @@ -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 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index cef032c..24bced6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -404,7 +404,8 @@ int main(void) // Инструменты Transform transform; Rotate rotate; - TRS& currentTool = rotate; + Scale scale; + TRS& currentTool = scale; // Пока не произойдет событие запроса закрытия окна while(!glfwWindowShouldClose(window)) diff --git a/src/tools/TRS.cpp b/src/tools/TRS.cpp index 8de09f0..2712f46 100644 --- a/src/tools/TRS.cpp +++ b/src/tools/TRS.cpp @@ -97,4 +97,39 @@ void Rotate::process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos) if (etc > 0) selectedObject->dRotation(dVec); } -} \ No newline at end of file +} + +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); + } +}