blob: 44bd5834b82450bb91436f5f5d0cd9fa6d7bd301 (
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
|
#pragma once
#include "assetFactory/asset.h"
#include "gfx/gl/instanceVertices.h"
#include "gfx/models/texture.h"
#include "gfx/renderable.h"
class SceneShader;
class Location;
class Illuminator : public Asset, public Renderable, public StdTypeDefs<Illuminator> {
Mesh::Ptr bodyMesh;
Texture::Ptr texture;
glVertexArray instanceVAO;
std::optional<glVertexArray> instancesSpotLightVAO, instancesPointLightVAO;
public:
struct LightCommonVertex {
RelativePosition3D position;
RGB colour;
RelativeDistance kq;
};
struct SpotLightVertex : LightCommonVertex {
Direction3D direction;
Angle arc;
};
struct PointLightVertex : LightCommonVertex { };
struct SpotLight : Persistence::Persistable, SpotLightVertex, StdTypeDefs<SpotLight> {
private:
friend Persistence::SelectionPtrBase<std::shared_ptr<SpotLight>>;
bool persist(Persistence::PersistenceStore & store) override;
};
struct PointLight : Persistence::Persistable, PointLightVertex, StdTypeDefs<PointLight> {
private:
friend Persistence::SelectionPtrBase<std::shared_ptr<PointLight>>;
bool persist(Persistence::PersistenceStore & store) override;
};
public:
using LocationVertex = std::pair<glm::mat3, GlobalPosition3D>;
mutable InstanceVertices<LocationVertex> instances;
mutable InstanceVertices<SpotLightVertex> instancesSpotLight;
mutable InstanceVertices<PointLightVertex> instancesPointLight;
void render(const SceneShader &) const override;
void lights(const SceneShader &) const override;
protected:
friend Persistence::SelectionPtrBase<std::shared_ptr<Illuminator>>;
bool persist(Persistence::PersistenceStore & store) override;
void postLoad() override;
std::vector<SpotLight::Ptr> spotLight;
std::vector<PointLight::Ptr> pointLight;
std::vector<InstanceVertices<SpotLightVertex>::InstanceProxy> spotLightInstances;
std::vector<InstanceVertices<PointLightVertex>::InstanceProxy> pointLightInstances;
};
|