Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1.  
  2. if (Keyboard::isPressed(GLFW_KEY_T))
  3. {
  4. is3rdPerson = true;
  5. }
  6. else
  7. {
  8. is3rdPerson = false;
  9. }
  10.  
  11. if (Keyboard::isPressed(GLFW_KEY_LEFT_CONTROL))
  12. {
  13. posZ = posZ - speed;
  14. }
  15. if (Keyboard::isPressed(GLFW_KEY_SPACE))
  16. {
  17. posZ = posZ + speed;
  18. }
  19. // zmiana parametrow kamery w czasie ruchu
  20. if (is3rdPerson)
  21. {
  22. float rotX = (float)cos(rotate * 3.14 / 180) * 1.4f;
  23. float rotY = (float)sin(rotate * 3.14 / 180) * 1.4f;
  24. camera.setPosition(glm::vec3(posX - rotX, posY + rotY, posZ));
  25. }
  26. else
  27. camera.setPosition(glm::vec3(posX, posY, posZ));
  28.  
  29. glm::mat4 camRot = glm::rotate(glm::mat4(1.0f), (rotate + 90), glm::vec3(0.0f, 0.0f, 1.0f));
  30. glm::vec4 up = camRot * glm::vec4(0, 1, 0, 1);
  31.  
  32. float upX = (float)cos((rotate)* 3.14 / 180);
  33. float upY = (float)sin((rotate)* 3.14 / 180);
  34. camera.setUp(glm::vec3(upX, -upY, 1));
  35.  
  36. float camTZ = posZ;
  37. float camTY = posY - 3 * upY;
  38. float camTX = posX + 3 * upX;
  39. camera.setTarget(glm::vec3(camTX, camTY, camTZ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement