summaryrefslogtreecommitdiff
path: root/game/vehicles/railVehicleClass.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 01:59:16 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 01:59:16 +0000
commitd4c073a18adaed73973f34c6c39fc15664d9211d (patch)
tree44536af3af0284ab75eae79ef81a5e4452019269 /game/vehicles/railVehicleClass.cpp
parentAdd helper operator to perform vec3*mat4 and perspective divide (diff)
parentRemove old hard coded asset factory test, run entirely from XML load and rend... (diff)
downloadilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.bz2
ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.xz
ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.zip
Merge branch 'model-factory'
Diffstat (limited to 'game/vehicles/railVehicleClass.cpp')
-rw-r--r--game/vehicles/railVehicleClass.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index dff1416..41ef5e9 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -39,12 +39,24 @@ RailVehicleClass::RailVehicleClass(std::unique_ptr<ObjParser> o, std::shared_ptr
bogies[1] = m.at("Bogie2");
}
+RailVehicleClass::RailVehicleClass() { }
+
+bool
+RailVehicleClass::persist(Persistence::PersistenceStore & store)
+{
+ 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);
+}
+
void
RailVehicleClass::render(
const SceneShader & shader, const Location & location, const std::array<Location, 2> & 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]);
@@ -52,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<Location, 2> & 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