Loading src/gfx/include/gfx/control.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public: void setStep(float dt); void setSpeed(float new_speed); void teleport(glm::vec3 new_position) { bound_frame.setPositionVec(new_position); } void teleport(glm::vec3 new_position) { bound_frame.setPosVec(new_position); } void move(const std::unordered_set<std::string> &pressed_keys); void forward(); Loading src/gfx/include/gfx/frame.hpp +8 −7 Original line number Diff line number Diff line Loading @@ -15,21 +15,22 @@ class Frame glm::quat rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); public: Frame(glm::vec3 position, glm::vec3 rotation) Frame(glm::vec3 position, glm::vec3 rotation = glm::vec3(0, 0, 0)) : positionVec{position} { setrotationQuat(rotation); setRotationQuat(rotation); } glm::vec3 getPosition() { return positionVec; } glm::quat getRotation() { return rotationQuat; } //get modelMatrix() //get inverse ( view) matice glm::mat4 getModelMat() { return glm::translate(glm::mat4(1.0f), positionVec); } glm::mat4 getViewMat() { return glm::inverse(getModelMat()); } glm::mat4 getRotationMat() { return glm::toMat4(rotationQuat); } void setPositionVec(glm::vec3 new_position) { positionVec = new_position; } void setrotationQuat(glm::vec3 new_rotation) { rotationQuat *= glm::tquat(glm::radians(new_rotation)); } // rozdělit na set a rotate + translate void setPosVec(glm::vec3 new_position) { positionVec = new_position; } void translatePosVec(glm::vec3 direction) { positionVec += direction; } void setRotationQuat(glm::vec3 new_rotation) { rotationQuat = glm::tquat(glm::radians(new_rotation)); } void rotateRotationQuat(glm::vec3 rotation) { rotationQuat *= glm::tquat(glm::radians(rotation)); } }; #endif No newline at end of file src/gfx/include/gfx/vao.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ public: void Unbind(); void Delete(); void LinkVBO(unsigned int layout_loc); // , unsigned int layout void LinkVBO(unsigned int layout_loc); }; #endif No newline at end of file src/gfx/src/control.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -27,30 +27,30 @@ void Controller::move(const std::unordered_set<std::string> &pressed_keys) void Controller::forward() { bound_frame.setPositionVec(bound_frame.getPosition() + step * frontVec); bound_frame.translatePosVec(step * frontVec); } void Controller::backward() { bound_frame.setPositionVec(bound_frame.getPosition() - step * frontVec); bound_frame.translatePosVec(-step * frontVec); } void Controller::left() { bound_frame.setPositionVec(bound_frame.getPosition() - step * glm::normalize(glm::cross(frontVec, upVec))); bound_frame.translatePosVec(-step * glm::normalize(glm::cross(frontVec, upVec))); } void Controller::right() { bound_frame.setPositionVec(bound_frame.getPosition() + step * glm::normalize(glm::cross(frontVec, upVec))); bound_frame.translatePosVec(step * glm::normalize(glm::cross(frontVec, upVec))); } void Controller::up() { bound_frame.setPositionVec(bound_frame.getPosition() + step * upVec); bound_frame.translatePosVec(step * upVec); } void Controller::down() { bound_frame.setPositionVec(bound_frame.getPosition() - step * upVec); bound_frame.translatePosVec(-step * upVec); } void Controller::rotate(glm::vec3 rotational_difference) { bound_frame.setrotationQuat(rotational_difference); bound_frame.rotateRotationQuat(rotational_difference); } No newline at end of file src/gfx/src/render.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -69,11 +69,7 @@ void gfx_draw(Shader &myShader, // glm::vec3(0.0f, 1.0f, 0.0f)); /* ---------------------------------------------------------------- */ glm::mat4 model = glm::mat4(1.0f); glm::mat4 rotated = obj_frame.getRotationMat() * model; glm::mat4 translated = glm::translate(model, obj_frame.getPosition()); model = translated * rotated; glm::mat4 model = obj_frame.getModelMat() * obj_frame.getRotationMat(); glm::mat4 view; view = glm::lookAt(cam_frame.getPosition(), cam_frame.getPosition() + cam_control.getFrontVec(), cam_control.getUpVec()); Loading Loading
src/gfx/include/gfx/control.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public: void setStep(float dt); void setSpeed(float new_speed); void teleport(glm::vec3 new_position) { bound_frame.setPositionVec(new_position); } void teleport(glm::vec3 new_position) { bound_frame.setPosVec(new_position); } void move(const std::unordered_set<std::string> &pressed_keys); void forward(); Loading
src/gfx/include/gfx/frame.hpp +8 −7 Original line number Diff line number Diff line Loading @@ -15,21 +15,22 @@ class Frame glm::quat rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f); public: Frame(glm::vec3 position, glm::vec3 rotation) Frame(glm::vec3 position, glm::vec3 rotation = glm::vec3(0, 0, 0)) : positionVec{position} { setrotationQuat(rotation); setRotationQuat(rotation); } glm::vec3 getPosition() { return positionVec; } glm::quat getRotation() { return rotationQuat; } //get modelMatrix() //get inverse ( view) matice glm::mat4 getModelMat() { return glm::translate(glm::mat4(1.0f), positionVec); } glm::mat4 getViewMat() { return glm::inverse(getModelMat()); } glm::mat4 getRotationMat() { return glm::toMat4(rotationQuat); } void setPositionVec(glm::vec3 new_position) { positionVec = new_position; } void setrotationQuat(glm::vec3 new_rotation) { rotationQuat *= glm::tquat(glm::radians(new_rotation)); } // rozdělit na set a rotate + translate void setPosVec(glm::vec3 new_position) { positionVec = new_position; } void translatePosVec(glm::vec3 direction) { positionVec += direction; } void setRotationQuat(glm::vec3 new_rotation) { rotationQuat = glm::tquat(glm::radians(new_rotation)); } void rotateRotationQuat(glm::vec3 rotation) { rotationQuat *= glm::tquat(glm::radians(rotation)); } }; #endif No newline at end of file
src/gfx/include/gfx/vao.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ public: void Unbind(); void Delete(); void LinkVBO(unsigned int layout_loc); // , unsigned int layout void LinkVBO(unsigned int layout_loc); }; #endif No newline at end of file
src/gfx/src/control.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -27,30 +27,30 @@ void Controller::move(const std::unordered_set<std::string> &pressed_keys) void Controller::forward() { bound_frame.setPositionVec(bound_frame.getPosition() + step * frontVec); bound_frame.translatePosVec(step * frontVec); } void Controller::backward() { bound_frame.setPositionVec(bound_frame.getPosition() - step * frontVec); bound_frame.translatePosVec(-step * frontVec); } void Controller::left() { bound_frame.setPositionVec(bound_frame.getPosition() - step * glm::normalize(glm::cross(frontVec, upVec))); bound_frame.translatePosVec(-step * glm::normalize(glm::cross(frontVec, upVec))); } void Controller::right() { bound_frame.setPositionVec(bound_frame.getPosition() + step * glm::normalize(glm::cross(frontVec, upVec))); bound_frame.translatePosVec(step * glm::normalize(glm::cross(frontVec, upVec))); } void Controller::up() { bound_frame.setPositionVec(bound_frame.getPosition() + step * upVec); bound_frame.translatePosVec(step * upVec); } void Controller::down() { bound_frame.setPositionVec(bound_frame.getPosition() - step * upVec); bound_frame.translatePosVec(-step * upVec); } void Controller::rotate(glm::vec3 rotational_difference) { bound_frame.setrotationQuat(rotational_difference); bound_frame.rotateRotationQuat(rotational_difference); } No newline at end of file
src/gfx/src/render.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -69,11 +69,7 @@ void gfx_draw(Shader &myShader, // glm::vec3(0.0f, 1.0f, 0.0f)); /* ---------------------------------------------------------------- */ glm::mat4 model = glm::mat4(1.0f); glm::mat4 rotated = obj_frame.getRotationMat() * model; glm::mat4 translated = glm::translate(model, obj_frame.getPosition()); model = translated * rotated; glm::mat4 model = obj_frame.getModelMat() * obj_frame.getRotationMat(); glm::mat4 view; view = glm::lookAt(cam_frame.getPosition(), cam_frame.getPosition() + cam_control.getFrontVec(), cam_control.getUpVec()); Loading