From 687afb09ada73fb4aee932242a3b7ee492e63cb0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Apr 2023 21:31:41 +0100 Subject: Handle rendering of RailVehicles through RailVehicleClass instancing Trains no longer need rendering as their parts are all RVC assets and that just works now. This commit creates some irritating duplication in RVC wrt body/2 bogies all of which are stored separately, but function in exactly the same way. This breaks RV shadows as we have no instancing shadow shaders yet. --- test/test-render.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'test/test-render.cpp') diff --git a/test/test-render.cpp b/test/test-render.cpp index 1643068..0fbeb2b 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -22,6 +22,8 @@ class TestScene : public SceneProvider { std::shared_ptr train1, train2; + const RailVehicleClassPtr brush47rvc = std::dynamic_pointer_cast( + AssetFactory::loadXML(RESDIR "/brush47.xml")->assets.at("brush-47")); Terrain terrain {[]() { auto gd = std::make_shared(GeoData::Limits {{0, 0}, {100, 100}}); @@ -32,19 +34,16 @@ class TestScene : public SceneProvider { public: TestScene() { - const auto assetFactory = AssetFactory::loadXML(RESDIR "/brush47.xml"); - const auto brush47rvc = std::dynamic_pointer_cast(assetFactory->assets.at("brush-47")); train1 = std::make_shared(brush47rvc); - train1->location.pos = {52, 50, 2}; + train1->location.setPosition({52, 50, 2}); train2 = std::make_shared(brush47rvc); - train2->location.pos = {52, 30, 2}; + train2->location.setPosition({52, 30, 2}); } void content(const SceneShader & shader) const override { terrain.render(shader); - train1->render(shader); - train2->render(shader); + brush47rvc->render(shader); } void lights(const SceneShader &) const override @@ -54,8 +53,7 @@ public: shadows(const ShadowMapper & shadowMapper) const override { terrain.shadows(shadowMapper); - train1->shadows(shadowMapper); - train2->shadows(shadowMapper); + brush47rvc->shadows(shadowMapper); } }; -- cgit v1.2.3 From 59cc4b8a7cb25a7ac003eb05794ee94e080ad302 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Apr 2023 21:53:20 +0100 Subject: Fudge RV bogey position the same as we do the body in test-render --- test/test-render.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/test-render.cpp') diff --git a/test/test-render.cpp b/test/test-render.cpp index 0fbeb2b..d5e2d87 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -36,8 +36,12 @@ public: { train1 = std::make_shared(brush47rvc); train1->location.setPosition({52, 50, 2}); + train1->bogies.front().setPosition(train1->bogies.front().position() + train1->location.position()); + train1->bogies.back().setPosition(train1->bogies.back().position() + train1->location.position()); train2 = std::make_shared(brush47rvc); train2->location.setPosition({52, 30, 2}); + train2->bogies.front().setPosition(train2->bogies.front().position() + train2->location.position()); + train2->bogies.back().setPosition(train2->bogies.back().position() + train2->location.position()); } void content(const SceneShader & shader) const override -- cgit v1.2.3