blob: c3a5d08dfd2b8c2c0d2e79a93679ef57aeb48ae5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "followCameraController.h"
#include "game/vehicles/vehicle.h"
#include <gfx/camera.h>
#include <glm/glm.hpp>
#include <location.h>
#include <maths.h>
#include <tuple>
#include <utility>
FollowCameraController::FollowCameraController(VehicleWPtr t, Mode m) : target(std::move(t)), mode(m) { }
void
FollowCameraController::updateCamera(Camera * camera) const
{
const auto [pos, rot] = [this]() {
const auto t {target.lock()};
return std::make_pair(t->getLocation().pos, t->getLocation().rot);
}();
switch (mode) {
case Mode::Pan:
camera->lookAt(pos);
break;
case Mode::Ride:
camera->setView(pos + (up * 4.8F), -sincos(rot.y) || 0.F);
break;
case Mode::ISO:
camera->setView(pos + ((up + north + east) * 40.F), glm::normalize(down + south + west),
glm::normalize(up - north - east));
break;
}
}
|