From 54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 14:27:23 +0000 Subject: Support and load factory asset directly into a RailVehicleClass instance --- game/vehicles/railVehicleClass.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'game/vehicles/railVehicleClass.cpp') diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index dff1416..7052396 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -39,6 +39,15 @@ RailVehicleClass::RailVehicleClass(std::unique_ptr o, std::shared_ptr bogies[1] = m.at("Bogie2"); } +RailVehicleClass::RailVehicleClass() { } + +bool +RailVehicleClass::persist(Persistence::PersistenceStore & store) +{ + return STORE_TYPE && STORE_MEMBER(maxSpeed) && STORE_NAME_HELPER("bogie", bogies, Asset::MeshArrayConstruct) + && STORE_HELPER(bodyMesh, Asset::MeshConstruct) && Asset::persist(store); +} + void RailVehicleClass::render( const SceneShader & shader, const Location & location, const std::array & bl) const -- cgit v1.2.3 From ca7611dcf999f55ea17d5cd4f53e5a836ec51cd1 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 14:59:02 +0000 Subject: RailVehicleClass texture might be null --- game/vehicles/railVehicleClass.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'game/vehicles/railVehicleClass.cpp') diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 7052396..c0740cc 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -53,7 +53,9 @@ RailVehicleClass::render( const SceneShader & shader, const Location & location, const std::array & bl) const { shader.basic.use(location); - texture->bind(); + if (texture) { + texture->bind(); + } bodyMesh->Draw(); for (auto b = 0U; b < bogies.size(); ++b) { shader.basic.setModel(bl[b]); -- cgit v1.2.3 From c8ecaaddeee46900540e24e096f86306e77493f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 15:12:30 +0000 Subject: Load length, wheelBase and maxSpeed RailVehicleClass properties from XML Adjusts bogie position to appear correct according to wheelBase --- game/vehicles/railVehicleClass.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'game/vehicles/railVehicleClass.cpp') diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index c0740cc..90a06bd 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -44,7 +44,8 @@ RailVehicleClass::RailVehicleClass() { } bool RailVehicleClass::persist(Persistence::PersistenceStore & store) { - return STORE_TYPE && STORE_MEMBER(maxSpeed) && STORE_NAME_HELPER("bogie", bogies, Asset::MeshArrayConstruct) + return STORE_TYPE && STORE_MEMBER(length) && STORE_MEMBER(wheelBase) && STORE_MEMBER(maxSpeed) + && STORE_NAME_HELPER("bogie", bogies, Asset::MeshArrayConstruct) && STORE_HELPER(bodyMesh, Asset::MeshConstruct) && Asset::persist(store); } -- cgit v1.2.3 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/railVehicleClass.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'game/vehicles/railVehicleClass.cpp') 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 -- cgit v1.2.3