#include "followCameraController.h" #include "game/vehicles/vehicle.h" #include #include #include #include #include #include #include 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::tie(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; } }