/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererCore/Lights/PointLightComponent.h
101 строка
4 KB
Sanakan8472
Area Lights (#1908)
20 апр 2026, 20:27
Не верифицирован
20 апр 2026, 20:27
bdf6e41
Код
Авторство
О чём код?
#pragma once #include <RendererCore/Lights/LightComponent.h> #include <RendererCore/Pipeline/Declarations.h> #include <RendererCore/Textures/TextureCubeResource.h> using ezPointLightComponentManager = ezComponentManager<class ezPointLightComponent, ezBlockStorageType::Compact>; /// \brief The render data object for point lights. class EZ_RENDERERCORE_DLL ezPointLightRenderData : public ezLightRenderData { EZ_ADD_DYNAMIC_REFLECTION(ezPointLightRenderData, ezLightRenderData); public: float m_fRange; float m_fLength; ezQuat m_qGlobalRotation; }; /// \brief Adds a dynamic point light to the scene, optionally casting shadows. /// /// For performance reasons, prefer to use ezSpotLightComponent where possible. /// Do not use shadows just to limit the light cone, when a spot light could achieve the same. class EZ_RENDERERCORE_DLL ezPointLightComponent : public ezLightComponent { EZ_DECLARE_COMPONENT_TYPE(ezPointLightComponent, ezLightComponent, ezPointLightComponentManager); ////////////////////////////////////////////////////////////////////////// // ezComponent public: virtual void SerializeComponent(ezWorldWriter& inout_stream) const override; virtual void DeserializeComponent(ezWorldReader& inout_stream) override; ////////////////////////////////////////////////////////////////////////// // ezRenderComponent public: virtual ezResult GetLocalBounds(ezBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, ezMsgUpdateLocalBounds& ref_msg) override; ////////////////////////////////////////////////////////////////////////// // ezPointLightComponent public: ezPointLightComponent(); ~ezPointLightComponent(); /// \brief Sets the radius of the lightsource. If zero, the radius is automatically determined from the intensity. void SetRange(float fRange); // [ property ] float GetRange() const; // [ property ] /// \brief Returns the final radius of the lightsource. float GetEffectiveRange() const; /// \brief Sets the length of the tube. Zero means the light is a point light. void SetLength(float fLength); // [ property ] float GetLength() const; // [ property ] /// \brief Radius of the tube's cross-section. Affects the size of specular highlights. Zero means the light is a point light. void SetRadius(float fRadius); // [ property ] float GetRadius() const; // [ property ] /// \brief Sets the radius that is used to determine when to fade out shadows. If zero the radius of the lightsource is used. void SetShadowFadeOutRange(float fRange); // [ property ] float GetShadowFadeOutRange() const; // [ property ] // void SetProjectedTextureFile(const char* szFile); // [ property ] // const char* GetProjectedTextureFile() const; // [ property ] // void SetProjectedTexture(const ezTextureCubeResourceHandle& hProjectedTexture); // const ezTextureCubeResourceHandle& GetProjectedTexture() const; protected: void OnMsgExtractRenderData(ezMsgExtractRenderData& msg) const; float m_fLength = 0.0f; float m_fRadius = 0.0f; float m_fRange = 0.0f; float m_fEffectiveRange = 0.0f; float m_fShadowFadeOutRange = 0.0f; // ezTextureCubeResourceHandle m_hProjectedTexture; }; /// Visualizer attribute for point lights. Also renders a tube (capsule) when Length or Radius is non-zero. class EZ_RENDERERCORE_DLL ezPointLightVisualizerAttribute : public ezVisualizerAttribute { EZ_ADD_DYNAMIC_REFLECTION(ezPointLightVisualizerAttribute, ezVisualizerAttribute); public: ezPointLightVisualizerAttribute(); ezPointLightVisualizerAttribute( const char* szLengthProperty, const char* szRadiusProperty, const char* szRangeProperty, const char* szIntensityProperty, const char* szColorProperty); const ezUntrackedString& GetLengthProperty() const { return m_sProperty1; } const ezUntrackedString& GetRadiusProperty() const { return m_sProperty2; } const ezUntrackedString& GetRangeProperty() const { return m_sProperty3; } const ezUntrackedString& GetIntensityProperty() const { return m_sProperty4; } const ezUntrackedString& GetColorProperty() const { return m_sProperty5; } };