blob: 7e1f5ac232b51df3bd9f854b70a0edbf35de96ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#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);
};
class RailLinkCurve : public RailLink {
public:
RailLinkCurve(End, End, glm::vec2);
private:
glm::vec2 centre;
};
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);
template<RailLinkConcept T> std::shared_ptr<T> addLink(glm::vec3, glm::vec3, glm::vec2);
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
|