Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TRANSFORM_H
- #define TRANSFORM_H
- #define GLEW_STATIC
- #include <iostream>
- #include <glm/glm.hpp>
- #include <glm/gtx/transform.hpp>
- #include <GL/glew.h>
- using namespace std;
- class Transform
- {
- public:
- Transform(const glm::vec3& pos = glm::vec3(),const glm::vec3& rot = glm::vec3(),const glm::vec3& scale = glm::vec3(1,1,1))
- {
- m_pos = pos;
- m_rot = rot;
- m_scale = scale;
- }
- inline glm::mat4 getModel()
- {
- glm::mat4 posMatrix = glm::translate(m_pos);
- glm::mat4 rotXMatrix = glm::rotate(m_rot.x,glm::vec3(1,0,0));
- glm::mat4 rotYMatrix = glm::rotate(m_rot.y,glm::vec3(0,1,0));
- glm::mat4 rotZMatrix = glm::rotate(m_rot.z,glm::vec3(0,0,1));
- glm::mat4 scaleMatrix = glm::scale(m_scale);
- glm::mat4 rotMatrix = rotZMatrix * rotYMatrix * rotXMatrix;
- return posMatrix * rotMatrix * scaleMatrix;
- }
- inline glm::vec3& getPos(){return m_pos;}
- inline glm::vec3& getRot(){return m_rot;}
- inline glm::vec3& getScale(){return m_scale;}
- inline void setPos(glm::vec3 pos){m_pos = pos;}
- inline void setRot(glm::vec3 rot){m_rot = rot;}
- inline void setScale(glm::vec3 scale){m_scale = scale;}
- inline void setRotX(float x){m_rot.x = x;}
- inline void setRotY(float y){m_rot.y = y;}
- inline void setRotZ(float z){m_rot.z = z;}
- protected:
- private:
- glm::vec3 m_pos;
- glm::vec3 m_rot;
- glm::vec3 m_scale;
- };
- #endif // TRANSFORM_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement