Radium Engine  1.5.0
DirLight.hpp
1 #pragma once
2 
3 #include <Engine/RaEngine.hpp>
4 #include <Engine/Scene/Light.hpp>
5 
6 namespace Ra {
7 namespace Engine {
8 namespace Scene {
9 
10 class Entity;
11 
15 class RA_ENGINE_API DirectionalLight final : public Ra::Engine::Scene::Light
16 {
17  public:
18  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
19 
20  explicit DirectionalLight( Entity* entity, const std::string& name = "dirlight" );
21  ~DirectionalLight() override = default;
22 
23  void setDirection( const Eigen::Matrix<Scalar, 3, 1>& dir ) override;
24  inline const Eigen::Matrix<Scalar, 3, 1>& getDirection() const;
25 
26  std::string getShaderInclude() const override;
27 
28  private:
29  Eigen::Matrix<Scalar, 3, 1> m_direction { 0, -1, 0 };
30 };
31 
32 // ---------------------------------------------------------------------------------------------
33 // ---- inline methods implementation
34 
35 inline void DirectionalLight::setDirection( const Eigen::Matrix<Scalar, 3, 1>& dir ) {
36  m_direction = dir.normalized();
37  getRenderParameters().addParameter( "light.directional.direction", m_direction );
38 }
39 
40 inline const Eigen::Matrix<Scalar, 3, 1>& DirectionalLight::getDirection() const {
41  return m_direction;
42 }
43 
44 } // namespace Scene
45 } // namespace Engine
46 } // namespace Ra
void addParameter(const std::string &name, T value, typename std::enable_if<!std::is_class< T > {}, bool >::type=true)
Add a parameter by value.
void setDirection(const Eigen::Matrix< Scalar, 3, 1 > &dir) override
Definition: DirLight.hpp:35
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:95
Definition: Cage.cpp:3