3 #include <Core/Math/Math.hpp>
4 #include <Engine/RaEngine.hpp>
5 #include <Engine/Scene/Light.hpp>
19 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
21 explicit SpotLight(
Entity* entity,
const std::string& name =
"spotlight" );
24 void setPosition(
const Eigen::Matrix<Scalar, 3, 1>& position )
override;
25 inline const Eigen::Matrix<Scalar, 3, 1>& getPosition()
const;
27 void setDirection(
const Eigen::Matrix<Scalar, 3, 1>& direction )
override;
28 inline const Eigen::Matrix<Scalar, 3, 1>& getDirection()
const;
30 inline void setInnerAngleInRadians( Scalar angle );
31 inline void setOuterAngleInRadians( Scalar angle );
32 inline void setInnerAngleInDegrees( Scalar angle );
33 inline void setOuterAngleInDegrees( Scalar angle );
35 inline Scalar getInnerAngle()
const;
36 inline Scalar getOuterAngle()
const;
38 inline void setAttenuation(
const Attenuation& attenuation );
39 inline void setAttenuation( Scalar constant, Scalar linear, Scalar quadratic );
42 std::string getShaderInclude()
const override;
45 Eigen::Matrix<Scalar, 3, 1> m_position { 0, 0, 0 };
46 Eigen::Matrix<Scalar, 3, 1> m_direction { 0, -1, 0 };
48 Scalar m_innerAngle { Core::Math::PiDiv4 };
49 Scalar m_outerAngle { Core::Math::PiDiv2 };
58 m_position = position;
62 inline const Eigen::Matrix<Scalar, 3, 1>& Scene::SpotLight::getPosition()
const {
67 m_direction = direction.normalized();
71 inline const Eigen::Matrix<Scalar, 3, 1>& SpotLight::getDirection()
const {
75 inline void SpotLight::setInnerAngleInRadians( Scalar angle ) {
80 inline void SpotLight::setOuterAngleInRadians( Scalar angle ) {
85 inline void SpotLight::setInnerAngleInDegrees( Scalar angle ) {
86 m_innerAngle = angle * Core::Math::toRad;
89 inline void SpotLight::setOuterAngleInDegrees( Scalar angle ) {
90 m_outerAngle = Core::Math::toRad *
angle;
93 inline Scalar SpotLight::getInnerAngle()
const {
97 inline Scalar SpotLight::getOuterAngle()
const {
101 inline void SpotLight::setAttenuation(
const Attenuation& attenuation ) {
102 m_attenuation = attenuation;
106 m_attenuation.quadratic );
109 inline void SpotLight::setAttenuation( Scalar constant, Scalar linear, Scalar quadratic ) {
110 setAttenuation( { constant, linear, quadratic } );
113 inline const SpotLight::Attenuation& SpotLight::getAttenuation()
const {
114 return m_attenuation;
void addParameter(const std::string &name, T value, typename std::enable_if<!std::is_class< T > {}, bool >::type=true)
Add a parameter by value.
An entity is an scene element. It ties together components with a transform.
const Data::RenderParameters & getRenderParameters() const
Gives read-only access to the renderParameters of the light.
void setDirection(const Eigen::Matrix< Scalar, 3, 1 > &direction) override
void setPosition(const Eigen::Matrix< Scalar, 3, 1 > &position) override
Scalar angle(const Vector_ &v1, const Vector_ &v2)