#ifndef _MODELVIEW #define _MODELVIEW #include #include #include "glm/mat4x4.hpp" #include class Model { public: std::stack modelstack; Model() { glm::mat4 id(1.0); modelstack.push(id); } void glTranslate(float x, float y, float z) { glm::mat4 Trans = glm::translate(glm::mat4(1.0f), glm::vec3(x, y, z)); modelstack.top() = modelstack.top() * Trans; } void glRotate(float degree, float x, float y, float z) { glm::mat4 rot = glm::rotate(glm::mat4(1.0f), glm::radians(degree), glm::vec3(x, y, z)); modelstack.top() = modelstack.top() * rot; } void glScale(float x, float y, float z) { glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(x, y, z)); modelstack.top() = modelstack.top() * scale; } void glPushMatrix() { glm::mat4 t = getMatrix(); modelstack.push(t); } glm::mat4 getMatrix() { if (modelstack.size() > 0) return modelstack.top(); return glm::mat4(1.0); } void glPopMatrix() { modelstack.pop(); } }; #endif