Radium Engine  1.5.20
Loading...
Searching...
No Matches
PointLight.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4#include <Engine/Scene/Light.hpp>
5
6namespace Ra {
7namespace Engine {
8
9namespace Scene {
10class Entity;
14class RA_ENGINE_API PointLight final : public Ra::Engine::Scene::Light
15{
16 public:
17 explicit PointLight( Entity* entity, const std::string& name = "pointlight" );
18 ~PointLight() override = default;
19
20 void setPosition( const Eigen::Matrix<Scalar, 3, 1>& pos ) override;
21 inline const Eigen::Matrix<Scalar, 3, 1>& getPosition() const;
22
23 inline void setAttenuation( const Attenuation& attenuation );
24 inline void setAttenuation( Scalar constant, Scalar linear, Scalar quadratic );
25 inline const Attenuation& getAttenuation() const;
26
27 std::string getShaderInclude() const override;
28
29 private:
30 Eigen::Matrix<Scalar, 3, 1> m_position { 0, 0, 0 };
31
32 Attenuation m_attenuation { 1, 0, 0 };
33};
34
35// ---------------------------------------------------------------------------------------------
36// ---- inline methods implementation
37
38inline void PointLight::setPosition( const Eigen::Matrix<Scalar, 3, 1>& pos ) {
39 m_position = pos;
40 getRenderParameters().setVariable( "light.point.position", m_position );
41}
42
43inline const Eigen::Matrix<Scalar, 3, 1>& PointLight::getPosition() const {
44 return m_position;
45}
46
47inline void PointLight::setAttenuation( const PointLight::Attenuation& attenuation ) {
48 m_attenuation = attenuation;
49 getRenderParameters().setVariable( "light.point.attenuation.constant", m_attenuation.constant );
50 getRenderParameters().setVariable( "light.point.attenuation.linear", m_attenuation.linear );
51 getRenderParameters().setVariable( "light.point.attenuation.quadratic",
52 m_attenuation.quadratic );
53}
54
55inline void PointLight::setAttenuation( Scalar constant, Scalar linear, Scalar quadratic ) {
56 setAttenuation( { constant, linear, quadratic } );
57}
58
59inline const PointLight::Attenuation& PointLight::getAttenuation() const {
60 return m_attenuation;
61}
62} // namespace Scene
63} // namespace Engine
64} // namespace Ra
void setVariable(const std::string &name, RenderParameters &rp)
overload create ref wrapper for RenderParameters variable
An entity is an scene element. It ties together components with a transform.
Definition Entity.hpp:23
const Data::RenderParameters & getRenderParameters() const
Gives read-only access to the renderParameters of the light.
Definition Light.hpp:93
void setPosition(const Eigen::Matrix< Scalar, 3, 1 > &pos) override
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3