summaryrefslogtreecommitdiff
path: root/game/vehicles/railVehicleClass.h
blob: 2fda8f7801f4aa27a9adac9104a385b8236c0a21 (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
#pragma once

#include "assetFactory/asset.h"
#include "gfx/gl/instanceVertices.h"
#include "gfx/models/mesh.h"
#include "gfx/renderable.h"
#include <array>
#include <memory>
#include <string>

class SceneShader;
class ShadowMapper;
class Texture;
class Location;

class RailVehicleClass : public Renderable, public Asset {
public:
	void render(const SceneShader & shader) const override;
	void shadows(const ShadowMapper & shadowMapper) const override;

	std::array<Mesh::Ptr, 2> bogies;
	Mesh::Ptr bodyMesh;
	std::shared_ptr<Texture> texture;
	float wheelBase;
	float length;
	float maxSpeed;

	mutable InstanceVertices<glm::mat4> instancesBody;
	mutable std::array<InstanceVertices<glm::mat4>, 2> instancesBogies;

protected:
	friend Persistence::SelectionPtrBase<std::shared_ptr<RailVehicleClass>>;
	bool persist(Persistence::PersistenceStore & store) override;
	void postLoad() override;

private:
	glVertexArray instanceVAO;
	std::array<glVertexArray, 2> instancesBogiesVAO;
};
using RailVehicleClassPtr = std::shared_ptr<RailVehicleClass>;