From 8188172f332859585e904ae2e4914dc11f8e8f61 Mon Sep 17 00:00:00 2001 From: "R.E. Kovalev" Date: Tue, 4 Apr 2023 17:04:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=20=D0=BC=D0=B0=D1=81=D1=88=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/tools/TRS.h | 9 +++++++++ src/main.cpp | 3 ++- src/tools/TRS.cpp | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 2 deletions(-) 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); + } +}