camera.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef CAMERA_H
  2. #define CAMERA_H
  3. // ===============================
  4. // AUTHOR : Angel Ortiz (angelo12 AT vt DOT edu)
  5. // CREATE DATE : 2018-07-10
  6. // PURPOSE : To contain all camera and visibility related data. Also perform
  7. // view frustrum culling of a given AABB against the six planes of the
  8. // camera frustrum. It allows for two types of movement, user controlled
  9. // or orbiting mode.
  10. // ===============================
  11. // SPECIAL NOTES: Some of the vectors saved in the camera are somewhat redundant, but
  12. // they are kept because I believe that recalculating them each frame is not really
  13. // worth it performance wise. I haven't profiled it however so who knows.
  14. // ===============================
  15. //Headers
  16. #include "matrix.h"
  17. #include "vector3D.h"
  18. #include "geometry.h"
  19. #include "displayManager.h"
  20. struct Camera{
  21. Camera();
  22. //Visibility and geometry member variables
  23. Matrix4 viewMatrix;
  24. Matrix4 projectionMatrix;
  25. Frustrum cameraFrustrum{DisplayManager::SCREEN_ASPECT_RATIO};
  26. //View frustrum culling
  27. bool checkVisibility(AABox *bounds);
  28. //Updates the camera matrices with the user input obtained in the input class
  29. void update(unsigned int deltaT);
  30. void resetCamera();
  31. //Position and direction of camera, used to build view matrix
  32. Vector3f position{0,0,8};
  33. Vector3f target{0,0,0};
  34. Vector3f up{0,1,0};
  35. Vector3f front{0, 0, -1};
  36. Vector3f side;
  37. //Values related to orbiting mode
  38. float radius = 2;
  39. float period = 30; //in seconds
  40. bool orbiting = true;
  41. //Momentary fixed camera speed (FPS dependent)
  42. float camSpeed = 0.1f;
  43. float pitch = 0;
  44. float yaw = -90;
  45. };
  46. #endif