Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rotates object around point p
- void rotate_about(float deltaTime, glm::vec3 p, bool ended) {
- glm::vec3 axis = glm::vec3(0,1,0); //rotation axis
- glm::mat4 scale_m = glm::scale(glm::mat4(1.0f), glm::vec3(scale, scale, scale)); //scale matrix
- glm::mat4 rotation = getMatrix(Right, Up, Front, Position); //builds rotation matrix
- rotation = glm::translate(rotation, p - Position );
- rotation = glm::rotate(rotation, ROTATION_SPEED * deltaTime, axis);
- rotation = glm::translate(rotation, Position - p );
- glm::mat4 new_rot = glm::rotate(glm::mat4(1.0f), ROTATION_SPEED * deltaTime, axis);
- Matrix = new_rot * rotation * scale_m;
- //look at point P
- /*Front = glm::normalize(p - start_Position);
- Right = glm::cross(WorldUp, Front);
- Up = glm::cross(Right, Front);*/
- if (ended == true) { //if last iteration of my animation: saves position
- Position.x = Matrix[3][0];
- Position.y = Matrix[3][1];
- Position.z = Matrix[3][2];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement