Camera.cpp 899 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "client/math/Camera.h"
  2. Camera::Camera(const Ray& ray) : ray(ray) {
  3. }
  4. const Vector& Camera::getBack() const {
  5. return back;
  6. }
  7. const Vector& Camera::getRight() const {
  8. return right;
  9. }
  10. const Vector& Camera::getUp() const {
  11. return up;
  12. }
  13. const Vector& Camera::getFlatBack() const {
  14. return flatBack;
  15. }
  16. const Vector& Camera::getFlatRight() const {
  17. return flatRight;
  18. }
  19. const Vector& Camera::getFlatUp() const {
  20. return flatUp;
  21. }
  22. const Vector& Camera::getPosition() const {
  23. return position;
  24. }
  25. void Camera::update(float lag) {
  26. back = ray.getDirection(lag);
  27. right.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
  28. up.set(back).cross(right).normalize();
  29. flatBack.set(back).setY(0.0f).normalize();
  30. flatRight.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
  31. flatUp.set(0.0f, 1.0f, 0.0f);
  32. position = ray.getPosition(lag);
  33. }