Plasma Engine  2.0
Loading...
Searching...
No Matches
SpotLightComponent.h
1#pragma once
2
3#include <RendererCore/Lights/LightComponent.h>
4#include <RendererCore/Pipeline/Declarations.h>
5#include <RendererCore/Textures/Texture2DResource.h>
6
8
10class PL_RENDERERCORE_DLL plSpotLightRenderData : public plLightRenderData
11{
12 PL_ADD_DYNAMIC_REFLECTION(plSpotLightRenderData, plLightRenderData);
13
14public:
15 float m_fRange;
16 float m_fFalloff;
17 plAngle m_InnerSpotAngle;
18 plAngle m_OuterSpotAngle;
19 // plTexture2DResourceHandle m_hProjectedTexture;
20};
21
23class PL_RENDERERCORE_DLL plSpotLightComponent : public plLightComponent
24{
26
28 // plComponent
29
30public:
31 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
32 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
33
34
36 // plRenderComponent
37
38public:
39 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
40
41
43 // plSpotLightComponent
44
45public:
48
50 void SetRange(float fRange); // [ property ]
51 float GetRange() const; // [ property ]
52
54 float GetEffectiveRange() const;
55
57 void SetInnerSpotAngle(plAngle spotAngle); // [ property ]
58 plAngle GetInnerSpotAngle() const; // [ property ]
59
61 void SetOuterSpotAngle(plAngle spotAngle); // [ property ]
62 plAngle GetOuterSpotAngle() const; // [ property ]
63
64 void SetFalloff(float fFalloff); // [ property ]
65 float GetFalloff() const; // [ property ]
66
67 // void SetProjectedTextureFile(const char* szFile); // [ property ]
68 // const char* GetProjectedTextureFile() const; // [ property ]
69
70 // void SetProjectedTexture(const plTexture2DResourceHandle& hProjectedTexture);
71 // const plTexture2DResourceHandle& GetProjectedTexture() const;
72
73protected:
74 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
75 plBoundingSphere CalculateBoundingSphere(const plTransform& t, float fRange) const;
76
77 float m_fRange = 0.0f;
78 float m_fEffectiveRange = 0.0f;
79 float m_fFalloff = 0.0f;
80
81 plAngle m_InnerSpotAngle = plAngle::MakeFromDegree(15.0f);
82 plAngle m_OuterSpotAngle = plAngle::MakeFromDegree(30.0f);
83
84 // plTexture2DResourceHandle m_hProjectedTexture;
85};
86
88class PL_RENDERERCORE_DLL plSpotLightVisualizerAttribute : public plVisualizerAttribute
89{
90 PL_ADD_DYNAMIC_REFLECTION(plSpotLightVisualizerAttribute, plVisualizerAttribute);
91
92public:
95 const char* szAngleProperty, const char* szRangeProperty, const char* szIntensityProperty, const char* szColorProperty);
96
97 const plUntrackedString& GetAngleProperty() const { return m_sProperty1; }
98 const plUntrackedString& GetRangeProperty() const { return m_sProperty2; }
99 const plUntrackedString& GetIntensityProperty() const { return m_sProperty3; }
100 const plUntrackedString& GetColorProperty() const { return m_sProperty4; }
101};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromDegree(float fDegree)
Creates an instance of plAngle that was initialized from degree. (Performs a conversion)
Definition Angle_inl.h:33
Definition ComponentManager.h:88
Base class for dynamic light components.
Definition LightComponent.h:26
Base class for light render data objects.
Definition LightComponent.h:10
Adds a spotlight to the scene, optionally casting shadows.
Definition SpotLightComponent.h:24
The render data object for spot lights.
Definition SpotLightComponent.h:11
A special visualizer attribute for spot lights.
Definition SpotLightComponent.h:89
Definition PropertyAttributes.h:780
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
Definition RenderData.h:116
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54