From 74b86470aec99b87a1f3545b7d3799dbf0c1e90c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 15:26:35 +0000 Subject: RailVehicleClass now renders bogie shadows as well as body --- game/vehicles/railVehicle.cpp | 2 +- game/vehicles/railVehicleClass.cpp | 7 ++++++- game/vehicles/railVehicleClass.h | 2 +- test/test-render.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index bcde68f..cbe36a6 100644 --- a/game/vehicles/railVehicle.cpp +++ b/game/vehicles/railVehicle.cpp @@ -20,7 +20,7 @@ RailVehicle::render(const SceneShader & shader) const void RailVehicle::shadows(const ShadowMapper & shadowMapper) const { - rvClass->shadows(shadowMapper, location); + rvClass->shadows(shadowMapper, location, bogies); } void diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 90a06bd..41ef5e9 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -64,10 +64,15 @@ RailVehicleClass::render( } } void -RailVehicleClass::shadows(const ShadowMapper & shadowMapper, const Location & location) const +RailVehicleClass::shadows( + const ShadowMapper & shadowMapper, const Location & location, const std::array & bl) const { shadowMapper.dynamicPoint.use(location); bodyMesh->Draw(); + for (auto b = 0U; b < bogies.size(); ++b) { + shadowMapper.dynamicPoint.setModel(bl[b]); + bogies[b]->Draw(); + } } float diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h index c50dacc..a2222fb 100644 --- a/game/vehicles/railVehicleClass.h +++ b/game/vehicles/railVehicleClass.h @@ -18,7 +18,7 @@ public: RailVehicleClass(); void render(const SceneShader &, const Location &, const std::array &) const; - void shadows(const ShadowMapper &, const Location &) const; + void shadows(const ShadowMapper &, const Location &, const std::array &) const; std::array bogies; Mesh::Ptr bodyMesh; diff --git a/test/test-render.cpp b/test/test-render.cpp index 7db847d..7771760 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -29,8 +29,8 @@ class TestScene : public SceneProvider { content(const SceneShader & shader) const override { terrain.render(shader); - train.render(shader, Location {{52, 50, 2}}, {Location {}, Location {}}); - train.render(shader, Location {{52, 30, 2}}, {Location {}, Location {}}); + train.render(shader, Location {{52, 50, 2}}, {Location {{52, 56, 2}}, Location {{52, 44, 2}}}); + train.render(shader, Location {{52, 30, 2}}, {Location {{52, 36, 2}}, Location {{52, 24, 2}}}); } void lights(const SceneShader &) const override @@ -40,8 +40,8 @@ class TestScene : public SceneProvider { shadows(const ShadowMapper & shadowMapper) const override { terrain.shadows(shadowMapper); - train.shadows(shadowMapper, Location {{52, 50, 2}}); - train.shadows(shadowMapper, Location {{52, 30, 2}}); + train.shadows(shadowMapper, Location {{52, 50, 2}}, {Location {{52, 56, 2}}, Location {{52, 44, 2}}}); + train.shadows(shadowMapper, Location {{52, 30, 2}}, {Location {{52, 36, 2}}, Location {{52, 24, 2}}}); } }; -- cgit v1.2.3