Skip to content
Snippets Groups Projects
Commit d06510bf authored by Martin Štourač's avatar Martin Štourač
Browse files

added scale to frame

parent 98c9c505
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
virtual glm::vec3 getFrontVec() { return frontVec; } virtual glm::vec3 getFrontVec() { return frontVec; }
virtual glm::vec3 getUpVec() { return upVec; } virtual glm::vec3 getUpVec() { return upVec; }
virtual void setFrontVec() = 0; virtual void setFrontVec() = 0;
//void setUpVec(); // TO DO // void setUpVec(); // TO DO
void setStep(float dt); void setStep(float dt);
void setSpeed(float new_speed); void setSpeed(float new_speed);
......
...@@ -13,7 +13,7 @@ class Frame ...@@ -13,7 +13,7 @@ class Frame
{ {
glm::vec3 positionVec = glm::vec3(0.0f, 0.0f, 0.0f); glm::vec3 positionVec = glm::vec3(0.0f, 0.0f, 0.0f);
glm::quat rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); glm::quat rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
// TO DO: scale glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f);
public: public:
Frame(glm::vec3 position, glm::vec3 rotation = glm::vec3(0, 0, 0)) Frame(glm::vec3 position, glm::vec3 rotation = glm::vec3(0, 0, 0))
...@@ -24,6 +24,7 @@ public: ...@@ -24,6 +24,7 @@ public:
glm::vec3 getPosition() { return positionVec; } glm::vec3 getPosition() { return positionVec; }
glm::quat getRotation() { return rotationQuat; } glm::quat getRotation() { return rotationQuat; }
glm::vec3 getScale() { return scale; }
// Normalize? // Normalize?
glm::vec3 getRotationAxisX() { return glm::vec3(glm::axis(rotationQuat).x, 0, 0); } glm::vec3 getRotationAxisX() { return glm::vec3(glm::axis(rotationQuat).x, 0, 0); }
...@@ -32,14 +33,16 @@ public: ...@@ -32,14 +33,16 @@ public:
glm::mat4 getTranslationMat() { return glm::translate(glm::mat4(1.0f), positionVec); } glm::mat4 getTranslationMat() { return glm::translate(glm::mat4(1.0f), positionVec); }
glm::mat4 getRotationMat() { return glm::toMat4(rotationQuat); } glm::mat4 getRotationMat() { return glm::toMat4(rotationQuat); }
glm::mat4 getScaleMat() { return glm::scale(glm::mat4(1.0f), scale); }
glm::mat4 getModelMat() { return getTranslationMat() * getRotationMat(); } glm::mat4 getModelMat() { return getTranslationMat() * getRotationMat() * getScaleMat(); }
glm::mat4 getViewMat() { return glm::inverse(getModelMat()); } glm::mat4 getViewMat() { return glm::inverse(getModelMat()); }
void setPosVec(glm::vec3 new_position) { positionVec = new_position; } void setPosVec(glm::vec3 new_position) { positionVec = new_position; }
void translatePosVec(glm::vec3 direction) { positionVec += direction; } void translatePosVec(glm::vec3 direction) { positionVec += direction; }
void setRotationQuat(glm::vec3 new_rotation) { rotationQuat = glm::tquat(glm::radians(new_rotation)); } void setRotationQuat(glm::vec3 new_rotation) { rotationQuat = glm::tquat(glm::radians(new_rotation)); }
void rotateRotationQuat(glm::vec3 rotation) { rotationQuat *= glm::tquat(glm::radians(rotation)); } void rotateRotationQuat(glm::vec3 rotation) { rotationQuat *= glm::tquat(glm::radians(rotation)); }
void setScale(glm::vec3 _scale) { scale = _scale; }
}; };
#endif #endif
\ No newline at end of file
...@@ -17,7 +17,6 @@ bool Object::buffer_object() ...@@ -17,7 +17,6 @@ bool Object::buffer_object()
_VBO_vertex.Bind(); _VBO_vertex.Bind();
_VBO_vertex.SendData(getVertices()); _VBO_vertex.SendData(getVertices());
_VAO.LinkVBO(0); _VAO.LinkVBO(0);
//_VBO_vertex.Unbind();
// Normals // Normals
_VBO_normal.Bind(); _VBO_normal.Bind();
_VBO_normal.SendData(getNormals()); _VBO_normal.SendData(getNormals());
...@@ -26,7 +25,6 @@ bool Object::buffer_object() ...@@ -26,7 +25,6 @@ bool Object::buffer_object()
_EBO.Bind(); _EBO.Bind();
_EBO.SendData(getIndices()); _EBO.SendData(getIndices());
// Either unbind all three or none, otherwise no cube
// _VAO.Unbind(); // _VAO.Unbind();
// _VBO.Unbind(); // _VBO.Unbind();
// _EBO.Unbind(); // _EBO.Unbind();
......
...@@ -49,6 +49,7 @@ struct Simulator : public osi::Simulator ...@@ -49,6 +49,7 @@ struct Simulator : public osi::Simulator
std::vector<frame_ptr> obj_frames; std::vector<frame_ptr> obj_frames;
std::vector<obj_control_ptr> obj_controls; std::vector<obj_control_ptr> obj_controls;
// TO DO: std::map for "basic" : shader
std::vector<shader_ptr> myShaders; std::vector<shader_ptr> myShaders;
}; };
......
...@@ -127,8 +127,9 @@ Simulator::Simulator() ...@@ -127,8 +127,9 @@ Simulator::Simulator()
std::make_shared<ObjectController>(*obj_frames[1])} std::make_shared<ObjectController>(*obj_frames[1])}
{ {
objects[1]->setToLight(true); objects[1]->setToLight(true);
obj_frames[1]->setScale(glm::vec3(0.1f, 0.1f, 0.1f));
camera.setWindowSize(window().size()); camera.setWindowSize(window().size());
//obj_control.rotate(glm::vec3(0.0f, 50.0f, 0.0f)); // obj_controls[0]->rotate(glm::vec3(0.0f, 50.0f, 0.0f));
} }
Simulator::~Simulator() {} Simulator::~Simulator() {}
...@@ -139,7 +140,7 @@ void Simulator::update() ...@@ -139,7 +140,7 @@ void Simulator::update()
process_input(); process_input();
process_mouse(); process_mouse();
// obj_control.rotate(glm::vec3(1.0f, 0.0f, 0.0f)); // Rotation around x-axis demo // obj_controls[0]->rotate(glm::vec3(1.0f, 0.0f, 0.0f)); // Rotation around x-axis demo
} }
void Simulator::present() void Simulator::present()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment