Инструмент масштабирования
This commit is contained in:
		
							parent
							
								
									c0a6c40cd7
								
							
						
					
					
						commit
						8f9a8c1759
					
				@ -3,6 +3,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define T_SENSITIVITY 0.001
 | 
					#define T_SENSITIVITY 0.001
 | 
				
			||||||
#define R_SENSITIVITY 1
 | 
					#define R_SENSITIVITY 1
 | 
				
			||||||
 | 
					#define S_SENSITIVITY 0.00001
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Model.h"
 | 
					#include "Model.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,4 +34,12 @@ class Rotate : public TRS
 | 
				
			|||||||
        virtual void process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos); // Взаимодействие с инструментом
 | 
					        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
 | 
					#endif // TRS_H
 | 
				
			||||||
@ -404,7 +404,8 @@ int main(void)
 | 
				
			|||||||
    // Инструменты
 | 
					    // Инструменты
 | 
				
			||||||
    Transform transform;
 | 
					    Transform transform;
 | 
				
			||||||
    Rotate rotate;
 | 
					    Rotate rotate;
 | 
				
			||||||
    TRS& currentTool = rotate; 
 | 
					    Scale scale;
 | 
				
			||||||
 | 
					    TRS& currentTool = scale; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Пока не произойдет событие запроса закрытия окна
 | 
					    // Пока не произойдет событие запроса закрытия окна
 | 
				
			||||||
    while(!glfwWindowShouldClose(window))
 | 
					    while(!glfwWindowShouldClose(window))
 | 
				
			||||||
 | 
				
			|||||||
@ -97,4 +97,39 @@ void Rotate::process(GLuint64 selectedID, GLuint etc, const glm::vec4& dpos)
 | 
				
			|||||||
        if (etc > 0)
 | 
					        if (etc > 0)
 | 
				
			||||||
            selectedObject->dRotation(dVec); 
 | 
					            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