Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
DirectionalLightComponent.h
Go to the documentation of this file.
1#pragma once
2
4#include <glm/glm.hpp>
5
6namespace Engine::Components
7{
11 class DirectionalLight : public Logic
12 {
13 public:
14 static constexpr bool IsUnique = true;
15 static constexpr const char * ComponentName = "DirectionalLight";
16
18 Entities::Scene * owningScene,
19 const glm::vec3 & color = glm::vec3( 1.0f ),
20 float intensity = 1.0f,
21 bool castsShadows = true,
22 float angularDiameterDegrees = 0.53f
23 );
24
25 [[nodiscard]] std::string getComponentName() const override { return ComponentName; }
26
27 void beginPlay() override;
28 void endPlay() override;
29
30 [[nodiscard]] const glm::vec3 & getColor() const { return color_; }
31 [[nodiscard]] float getIntensity() const { return intensity_; }
32 [[nodiscard]] bool isEnabled() const { return enabled_; }
33 [[nodiscard]] bool castsShadows() const { return castsShadows_; }
34 [[nodiscard]] float getAngularDiameterDegrees() const { return angularDiameterDegrees_; }
35 [[nodiscard]] const glm::vec3 & getDirectionOverride() const { return directionOverride_; }
36 [[nodiscard]] bool hasDirectionOverride() const { return hasDirectionOverride_; }
37
38 void setColor( const glm::vec3 & color );
39 void setIntensity( float intensity );
40 void setEnabled( bool enabled );
42 void setAngularDiameterDegrees( float angularDiameterDegrees );
43 void setDirectionOverride( const glm::vec3 & direction );
45
46 private:
47 void syncEcsData() const;
48
49 glm::vec3 color_{ 1.0f };
50 float intensity_ = 1.0f;
51 bool enabled_ = true;
52 bool castsShadows_ = true;
54 glm::vec3 directionOverride_{ 0.0f, -1.0f, 0.0f };
56 };
57} // namespace Engine::Components
static constexpr const char * ComponentName
void setCastsShadows(bool castsShadows)
void setAngularDiameterDegrees(float angularDiameterDegrees)
void setIntensity(float intensity)
void endPlay() override
Called when the component is removed or the game ends.
void beginPlay() override
Called when the component is added to the scene or the game starts.
DirectionalLight(Entities::Scene *owningScene, const glm::vec3 &color=glm::vec3(1.0f), float intensity=1.0f, bool castsShadows=true, float angularDiameterDegrees=0.53f)
std::string getComponentName() const override
Gets the component type name for debugging/UI.
void setDirectionOverride(const glm::vec3 &direction)
void setColor(const glm::vec3 &color)
Logic(Entities::Scene *owningScene)
A scene is the overarching structure which can spawn, contain and destroy actors or entities.
Definition Scene.h:56