#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 { Mesh::Ptr bodyMesh; std::shared_ptr texture; glVertexArray instanceVAO, 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 { private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; }; struct PointLight : Persistence::Persistable, PointLightVertex, StdTypeDefs { private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; }; public: using LocationVertex = std::pair; mutable InstanceVertices instances; mutable InstanceVertices instancesSpotLight; mutable InstanceVertices instancesPointLight; void render(const SceneShader &) const override; void lights(const SceneShader &) const override; protected: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; void postLoad() override; std::vector spotLight; std::vector pointLight; std::vector::InstanceProxy> spotLightInstances; std::vector::InstanceProxy> pointLightInstances; };