Advertisement
Guest User

sample

a guest
Oct 12th, 2018
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // Rotates object around point p
  2. void rotate_about(float deltaTime, glm::vec3 p, bool ended) {
  3.  
  4. glm::vec3 axis = glm::vec3(0,1,0); //rotation axis
  5. glm::mat4 scale_m = glm::scale(glm::mat4(1.0f), glm::vec3(scale, scale, scale)); //scale matrix
  6. glm::mat4 rotation = getMatrix(Right, Up, Front, Position); //builds rotation matrix
  7.  
  8. rotation = glm::translate(rotation, p - Position );
  9. rotation = glm::rotate(rotation, ROTATION_SPEED * deltaTime, axis);
  10. rotation = glm::translate(rotation, Position - p );
  11.  
  12. glm::mat4 new_rot = glm::rotate(glm::mat4(1.0f), ROTATION_SPEED * deltaTime, axis);
  13.  
  14. Matrix = new_rot * rotation * scale_m;
  15.  
  16. //look at point P
  17. /*Front = glm::normalize(p - start_Position);
  18. Right = glm::cross(WorldUp, Front);
  19. Up = glm::cross(Right, Front);*/
  20.  
  21. if (ended == true) { //if last iteration of my animation: saves position
  22. Position.x = Matrix[3][0];
  23. Position.y = Matrix[3][1];
  24. Position.z = Matrix[3][2];
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement