diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-05 00:30:13 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-02-05 00:30:13 +0000 |
commit | c1ea14d1c96de18448c0c3779d30b7e1e4451f61 (patch) | |
tree | b97edc04e70495caf49545dc30ed9936d1986d07 /game/network/rail.h | |
parent | Create terrain as collection of meshes (diff) | |
download | ilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.tar.bz2 ilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.tar.xz ilt-c1ea14d1c96de18448c0c3779d30b7e1e4451f61.zip |
Initial commit generating some basic rail network
Diffstat (limited to 'game/network/rail.h')
-rw-r--r-- | game/network/rail.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/game/network/rail.h b/game/network/rail.h new file mode 100644 index 0000000..ef119bc --- /dev/null +++ b/game/network/rail.h @@ -0,0 +1,52 @@ +#ifndef RAILLINKS_H +#define RAILLINKS_H + +#include "collection.hpp" +#include "game/worldobject.h" +#include "gfx/models/mesh.h" +#include "gfx/models/vertex.hpp" +#include "gfx/renderable.h" +#include "link.h" +#include <glm/glm.hpp> +#include <memory> +#include <set> +#include <vector> +class Shader; +class Texture; + +// A piece of rail track +class RailLink : public Link, public Renderable { +public: + using Link::Link; + + void render(const Shader &) const override; + +protected: + RailLink(); + Collection<Mesh, false> meshes; + std::vector<Vertex> vertices; + std::vector<unsigned int> indices; +}; + +class RailLinkStraight : public RailLink { +public: + RailLinkStraight(End, End); +}; + +template<typename T> concept RailLinkConcept = std::is_base_of_v<RailLink, T>; + +class RailLinks : public Renderable, public WorldObject { +public: + RailLinks(); + template<RailLinkConcept T> std::shared_ptr<T> addLink(glm::vec3, glm::vec3); + +private: + using Nodes = std::set<NodePtr, PtrSorter<NodePtr>>; + Collection<RailLink> links; + Nodes nodes; + void render(const Shader &) const override; + void tick(TickDuration elapsed) override; + std::shared_ptr<Texture> texture; +}; + +#endif |