diff options
Diffstat (limited to 'game/scenary/illuminator.h')
-rw-r--r-- | game/scenary/illuminator.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h new file mode 100644 index 0000000..893e5c7 --- /dev/null +++ b/game/scenary/illuminator.h @@ -0,0 +1,60 @@ +#pragma once + +#include "assetFactory/asset.h" +#include "gfx/gl/instanceVertices.h" +#include "gfx/renderable.h" + +class SceneShader; +class Location; +class Texture; + +class Illuminator : public Asset, public Renderable, public StdTypeDefs<Illuminator> { + Mesh::Ptr bodyMesh; + std::shared_ptr<Texture> 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::mat4, 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; +}; |