Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. //TODO 2
  2. // Make the red sphere rotate around the bouncing blue sphere (create a model matrix)
  3. // 1 turn should be done in 1 seconds - use variable "t" which is time in seconds
  4. // the red sphere should rotate around the other one (use mvp)
  5. // the red sphere should be half sized than the other sphere
  6. // the red sphere should rotate around the other with radius stored in "planetDistance" variable
  7. // Use glm::rotate, glm::translate, glm::scale
  8. // Store the resulting transform in "sphere2model" variable
  9. // Hint - there are 2 possibilities how to do it, either by 2x translate or translate + rotate
  10. // Hint 2 - sphere1model should be the last applied transform
  11. glm::mat4 sphere2model = glm::mat4(1); //store it here
  12.  
  13. glm::vec3 position2 = position + glm::vec3(planetDistance, 0, 0);
  14. sphere2model = glm::rotate(glm::radians(360 * t), glm::vec3(0, 1, 0)) * glm::translate(position2) * glm::scale(glm::vec3(0.5f, 0.5f, 0.5f););
  15.  
  16.  
  17. //TODO 3
  18. //Change the code so that the mouse wheel moves the moon further away or closer to the planet
  19. //React to SDL_BUTTON_WHEELDOWN and SDL_BUTTON_WHEELUP
  20. //Like:
  21. //if(button == SDL_BUTTON_WHEELDOWN) then do something, similarly for SDL_BUTTON_WHEELUP
  22. if (button == SDL_BUTTON_WHEELDOWN)
  23. {
  24. planetDistance += 0.25f;
  25. redraw();
  26. }
  27. if (button == SDL_BUTTON_WHEELUP)
  28. {
  29. planetDistance -= 0.25f;
  30. redraw();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement