diff options
author | Aki <please@ignore.pl> | 2022-06-05 12:02:17 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-06-05 12:20:49 +0200 |
commit | b08f360cf92e76fabf5b762bf79032f60f751e30 (patch) | |
tree | 1bea4571ad78876fdec744462712ea9859edb055 /View.cpp | |
parent | 5cb5322feddfe75fe09bffef5b648062a1eb5958 (diff) | |
download | derelict-b08f360cf92e76fabf5b762bf79032f60f751e30.zip derelict-b08f360cf92e76fabf5b762bf79032f60f751e30.tar.gz derelict-b08f360cf92e76fabf5b762bf79032f60f751e30.tar.bz2 |
Added cameraman to handle camera
Diffstat (limited to 'View.cpp')
-rw-r--r-- | View.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -19,19 +19,13 @@ const Color LINE {240, 240, 240, 160}; View::View(std::vector<Grid> grids, Timeline timeline) : - m_camera {}, + m_cameraman {}, m_grids {grids}, m_labels {}, m_grid {0}, m_active {nullptr}, m_timeline {timeline} { - m_camera.position = Vector3{10.0f, 10.0f, 10.0f}; - m_camera.target = Vector3{0.0f, 0.0f, 0.0f}; - m_camera.up = Vector3{0.0f, 1.0f, 0.0f}; - m_camera.fovy = 45; - m_camera.projection = CAMERA_PERSPECTIVE; - SetCameraMode(m_camera, CAMERA_ORBITAL); } @@ -48,8 +42,8 @@ View::update(const float dt) if (m_grid >= m_grids.size()) m_grid = 0; } + m_cameraman.update(dt); m_timeline.move(dt * 60); - UpdateCamera(&m_camera); const int height = GetScreenHeight(); const int width = GetScreenWidth(); const auto& wrecks = m_grids.at(m_grid).wrecks; @@ -57,12 +51,12 @@ View::update(const float dt) m_labels.reserve(wrecks.size()); const auto mouse = GetMousePosition(); for (const auto& wreck : wrecks) { - const auto pos = GetWorldToScreen(wreck.position, m_camera); - const auto base = GetWorldToScreen({wreck.position.x, 0.0f, wreck.position.z}, m_camera); + const auto pos = GetWorldToScreen(wreck.position, m_cameraman.camera); + const auto base = GetWorldToScreen({wreck.position.x, 0.0f, wreck.position.z}, m_cameraman.camera); if (0 > pos.x || width < pos.x || 0 > pos.y || height < pos.y) if (0 > base.x || width < base.x || 0 > base.y || height < base.y) continue; - const auto depth = dist(m_camera.position, wreck.position); + const auto depth = dist(m_cameraman.camera.position, wreck.position); const auto length = dist(pos, base); const bool hover = 8.0f > dist(mouse, pos); m_labels.push_back( @@ -86,7 +80,7 @@ View::draw() const { BeginDrawing(); ClearBackground(BACKGROUND); - BeginMode3D(m_camera); + BeginMode3D(m_cameraman.camera); DrawGrid(12, 1.0f); EndMode3D(); for (const auto& point : m_labels) { |