diff options
Diffstat (limited to 'game')
-rw-r--r-- | game/terrain.cpp | 8 | ||||
-rw-r--r-- | game/terrain.h | 1 | ||||
-rw-r--r-- | game/vehicles/railVehicle.cpp | 6 | ||||
-rw-r--r-- | game/vehicles/railVehicle.h | 2 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.cpp | 7 | ||||
-rw-r--r-- | game/vehicles/railVehicleClass.h | 2 | ||||
-rw-r--r-- | game/vehicles/train.cpp | 5 | ||||
-rw-r--r-- | game/vehicles/train.h | 2 |
8 files changed, 33 insertions, 0 deletions
diff --git a/game/terrain.cpp b/game/terrain.cpp index 31f7fb1..f798254 100644 --- a/game/terrain.cpp +++ b/game/terrain.cpp @@ -7,6 +7,7 @@ #include <cstddef> #include <filesystem> #include <gfx/gl/sceneShader.h> +#include <gfx/gl/shadowMapper.h> #include <gfx/image.h> #include <gfx/models/mesh.h> #include <gfx/models/vertex.hpp> @@ -93,3 +94,10 @@ Terrain::render(const SceneShader & shader) const water->bind(); meshes.apply(&Mesh::Draw); } + +void +Terrain::shadows(const ShadowMapper & shadowMapper) const +{ + shadowMapper.fixedPoint.use(); + meshes.apply(&Mesh::Draw); +} diff --git a/game/terrain.h b/game/terrain.h index 70f947c..879d173 100644 --- a/game/terrain.h +++ b/game/terrain.h @@ -16,6 +16,7 @@ public: explicit Terrain(std::shared_ptr<GeoData>); void render(const SceneShader & shader) const override; + void shadows(const ShadowMapper &) const override; void tick(TickDuration) override; float waveCycle {0.F}; 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; |