summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-03 03:41:32 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-03 03:41:32 +0000
commitaa75b018f3b97c72b57de68867417cbda51439c3 (patch)
tree446efaad2727ae6bff6433e8bfbf590e99d5e310 /game/vehicles
parentAdd GL_DEBUG_OUTPUT with boost test error handling to test-render context (diff)
downloadilt-aa75b018f3b97c72b57de68867417cbda51439c3.tar.bz2
ilt-aa75b018f3b97c72b57de68867417cbda51439c3.tar.xz
ilt-aa75b018f3b97c72b57de68867417cbda51439c3.zip
Initial commit of the shadow map generator and shadows render interface
Lots of hard coding, buggy in places, far from great, but the basics work.
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/railVehicle.cpp6
-rw-r--r--game/vehicles/railVehicle.h2
-rw-r--r--game/vehicles/railVehicleClass.cpp7
-rw-r--r--game/vehicles/railVehicleClass.h2
-rw-r--r--game/vehicles/train.cpp5
-rw-r--r--game/vehicles/train.h2
6 files changed, 24 insertions, 0 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index 0cf4e72..bcde68f 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -18,6 +18,12 @@ RailVehicle::render(const SceneShader & shader) const
}
void
+RailVehicle::shadows(const ShadowMapper & shadowMapper) const
+{
+ rvClass->shadows(shadowMapper, location);
+}
+
+void
RailVehicle::move(const Train * t, float & trailBy)
{
const auto overhang {(rvClass->length - rvClass->wheelBase) / 2};
diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h
index 39900cc..f172a28 100644
--- a/game/vehicles/railVehicle.h
+++ b/game/vehicles/railVehicle.h
@@ -10,6 +10,7 @@
#include <utility>
class SceneShader;
+class ShadowMapper;
class Ray;
class Train;
@@ -20,6 +21,7 @@ public:
void move(const Train *, float & trailBy);
void render(const SceneShader & shader) const override;
+ void shadows(const ShadowMapper & shadowMapper) const override;
[[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;
Location location;
diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp
index 5bcdc6e..dff1416 100644
--- a/game/vehicles/railVehicleClass.cpp
+++ b/game/vehicles/railVehicleClass.cpp
@@ -1,5 +1,6 @@
#include "railVehicleClass.h"
#include "gfx/gl/sceneShader.h"
+#include "gfx/gl/shadowMapper.h"
#include "gfx/models/mesh.h"
#include "gfx/models/obj.h"
#include "gfx/models/texture.h"
@@ -50,6 +51,12 @@ RailVehicleClass::render(
bogies[b]->Draw();
}
}
+void
+RailVehicleClass::shadows(const ShadowMapper & shadowMapper, const Location & location) const
+{
+ shadowMapper.dynamicPoint.use(location);
+ bodyMesh->Draw();
+}
float
RailVehicleClass::bogieOffset(ObjParser & o)
diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h
index 7249e76..bd74ab9 100644
--- a/game/vehicles/railVehicleClass.h
+++ b/game/vehicles/railVehicleClass.h
@@ -6,6 +6,7 @@
#include <string>
class SceneShader;
+class ShadowMapper;
class Texture;
class ObjParser;
class Location;
@@ -15,6 +16,7 @@ public:
explicit RailVehicleClass(const std::string & name);
void render(const SceneShader &, const Location &, const std::array<Location, 2> &) const;
+ void shadows(const ShadowMapper &, const Location &) const;
std::array<Mesh::Ptr, 2> bogies;
Mesh::Ptr bodyMesh;
diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp
index 8fb48f5..0332c04 100644
--- a/game/vehicles/train.cpp
+++ b/game/vehicles/train.cpp
@@ -16,6 +16,11 @@ Train::render(const SceneShader & shader) const
{
apply(&Renderable::render, shader);
}
+void
+Train::shadows(const ShadowMapper & shadowMapper) const
+{
+ apply(&Renderable::shadows, shadowMapper);
+}
Location
Train::getBogiePosition(float linkDist, float dist) const
diff --git a/game/vehicles/train.h b/game/vehicles/train.h
index dfdcf62..91f7ddb 100644
--- a/game/vehicles/train.h
+++ b/game/vehicles/train.h
@@ -14,6 +14,7 @@
#include <vector>
class SceneShader;
+class ShadowMapper;
class Ray;
class Train : public Vehicle, public Collection<RailVehicle, false>, public Can<Go>, public Can<Idle> {
@@ -27,6 +28,7 @@ public:
}
void render(const SceneShader & shader) const override;
+ void shadows(const ShadowMapper & shadowMapper) const override;
[[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;