diff options
Diffstat (limited to 'game/network')
-rw-r--r-- | game/network/network.h | 4 | ||||
-rw-r--r-- | game/network/rail.cpp | 22 | ||||
-rw-r--r-- | game/network/rail.h | 3 |
3 files changed, 25 insertions, 4 deletions
diff --git a/game/network/network.h b/game/network/network.h index be0900b..f8739b8 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -14,6 +14,7 @@ #include <utility> class SceneShader; +class Surface; template<typename> class Ray; template<size_t... n> using GenDef = std::tuple<glm::vec<n, GlobalDistance>...>; @@ -47,6 +48,9 @@ public: [[nodiscard]] virtual float findNodeDirection(Node::AnyCPtr) const = 0; + [[nodiscard]] virtual const Surface * getBaseSurface() const = 0; + [[nodiscard]] virtual RelativeDistance getBaseWidth() const = 0; + protected: static void joinLinks(const Link::Ptr & l, const Link::Ptr & ol); static GenCurveDef genCurveDef(const GlobalPosition3D & start, const GlobalPosition3D & end, float startDir); diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 69422aa..dc62cf3 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -1,4 +1,6 @@ #include "rail.h" +#include "game/gamestate.h" +#include "game/geoData.h" #include "network.h" #include <game/network/network.impl.h> // IWYU pragma: keep #include <gfx/gl/sceneShader.h> @@ -8,7 +10,7 @@ template class NetworkOf<RailLink, RailLinkStraight, RailLinkCurve>; constexpr auto RAIL_CROSSSECTION_VERTICES {5U}; -constexpr Size3D RAIL_HEIGHT {0, 0, 250.F}; +constexpr Size3D RAIL_HEIGHT {0, 0, 50.F}; RailLinks::RailLinks() : NetworkOf<RailLink, RailLinkStraight, RailLinkCurve> {"rails.jpg"} { } @@ -74,11 +76,11 @@ RailLinks::addLinksBetween(GlobalPosition3D start, GlobalPosition3D end) } constexpr const std::array<RelativePosition3D, RAIL_CROSSSECTION_VERTICES> railCrossSection {{ - {-1900.F, 0.F, 0.F}, + {-1900.F, 0.F, -RAIL_HEIGHT.z * 2}, {-608.F, 0.F, RAIL_HEIGHT.z}, - {0, 0.F, RAIL_HEIGHT.z * .7F}, + {0, 0.F, RAIL_HEIGHT.z / 2}, {608.F, 0.F, RAIL_HEIGHT.z}, - {1900.F, 0.F, 0.F}, + {1900.F, 0.F, -RAIL_HEIGHT.z * 2}, }}; constexpr const std::array<float, RAIL_CROSSSECTION_VERTICES> railTexturePos { 0.F, @@ -169,3 +171,15 @@ RailLinks::render(const SceneShader & shader) const glBindVertexArray(0); } } + +const Surface * +RailLinks::getBaseSurface() const +{ + return std::dynamic_pointer_cast<Surface>(gameState->assets.at("terrain.surface.gravel")).get(); +} + +RelativeDistance +RailLinks::getBaseWidth() const +{ + return 5'700; +} diff --git a/game/network/rail.h b/game/network/rail.h index 0aae718..fa64eda 100644 --- a/game/network/rail.h +++ b/game/network/rail.h @@ -77,6 +77,9 @@ public: std::shared_ptr<RailLink> addLinksBetween(GlobalPosition3D start, GlobalPosition3D end); void render(const SceneShader &) const override; + [[nodiscard]] const Surface * getBaseSurface() const override; + [[nodiscard]] RelativeDistance getBaseWidth() const override; + private: void tick(TickDuration elapsed) override; }; |