123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include "client/math/Camera.h"
- #include "client/Utils.h"
- Camera::Camera(const Ray& ray) : ray(ray) {
- }
- const Vector& Camera::getBack() const {
- return back;
- }
- const Vector& Camera::getRight() const {
- return right;
- }
- const Vector& Camera::getUp() const {
- return up;
- }
- const Vector& Camera::getFlatBack() const {
- return flatBack;
- }
- const Vector& Camera::getFlatRight() const {
- return flatRight;
- }
- const Vector& Camera::getFlatUp() const {
- return flatUp;
- }
- const Vector& Camera::getPosition() const {
- return position;
- }
- void Camera::update(float lag) {
- back = ray.getDirection(lag);
- right.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
- up.set(back).cross(right).normalize();
-
- flatBack.set(back).setY(0.0f).normalize();
- flatRight.setInverse(back).cross(0.0f, 1.0f, 0.0f).normalize();
- flatUp.set(0.0f, 1.0f, 0.0f);
-
- position = ray.getPosition(lag);
- }
|