Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TODO 2
- // Make the red sphere rotate around the bouncing blue sphere (create a model matrix)
- // 1 turn should be done in 1 seconds - use variable "t" which is time in seconds
- // the red sphere should rotate around the other one (use mvp)
- // the red sphere should be half sized than the other sphere
- // the red sphere should rotate around the other with radius stored in "planetDistance" variable
- // Use glm::rotate, glm::translate, glm::scale
- // Store the resulting transform in "sphere2model" variable
- // Hint - there are 2 possibilities how to do it, either by 2x translate or translate + rotate
- // Hint 2 - sphere1model should be the last applied transform
- glm::mat4 sphere2model = glm::mat4(1); //store it here
- glm::vec3 position2 = position + glm::vec3(planetDistance, 0, 0);
- 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););
- //TODO 3
- //Change the code so that the mouse wheel moves the moon further away or closer to the planet
- //React to SDL_BUTTON_WHEELDOWN and SDL_BUTTON_WHEELUP
- //Like:
- //if(button == SDL_BUTTON_WHEELDOWN) then do something, similarly for SDL_BUTTON_WHEELUP
- if (button == SDL_BUTTON_WHEELDOWN)
- {
- planetDistance += 0.25f;
- redraw();
- }
- if (button == SDL_BUTTON_WHEELUP)
- {
- planetDistance -= 0.25f;
- redraw();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement