NAP
directionallightcomponent.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local includes
8 #include "lightcomponent.h"
9 
10 // External includes
11 #include <orthocameracomponent.h>
12 #include <rendergnomoncomponent.h>
13 
14 namespace nap
15 {
16  // Forward declares
17  class DirectionalLightComponentInstance;
18 
26  {
27  RTTI_ENABLE(LightComponent)
29  public:
31  float mProjectionSize = 20.0f;
32  glm::vec2 mClippingPlanes = { 1.0f, 1000.0f };
33  uint mShadowMapSize = 1024;
34  };
35 
36 
44  {
45  RTTI_ENABLE(LightComponentInstance)
46  public:
48  LightComponentInstance(entity, resource) { }
49 
55  virtual bool init(utility::ErrorState& errorState) override;
56 
60  virtual ELightType getLightType() const override { return ELightType::Directional; }
61 
65  virtual EShadowMapType getShadowMapType() const override { return EShadowMapType::Quad; }
66 
67  private:
68 
69  // Shadow camera entity resource
70  std::unique_ptr<Entity> mShadowCamEntity = nullptr;
71  std::unique_ptr<OrthoCameraComponent> mShadowCamComponent = nullptr;
72  std::unique_ptr<RenderFrustumComponent> mShadowFrustrumComponent = nullptr;
73  std::unique_ptr<TransformComponent> mShadowCamXformComponent = nullptr;
74  std::unique_ptr<RenderGnomonComponent> mShadowOriginComponent = nullptr;
75  std::unique_ptr<GnomonMesh> mGnomonMesh = nullptr;
76  };
77 }
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::DirectionalLightComponentInstance::getLightType
virtual ELightType getLightType() const override
Definition: directionallightcomponent.h:60
nap::LightComponentInstance
Definition: lightcomponent.h:209
nap::ELightType::Directional
@ Directional
nap::LightComponent
Definition: lightcomponent.h:134
nap::utility::ErrorState
Definition: errorstate.h:19
nap::EShadowMapType
EShadowMapType
Definition: lightcomponent.h:36
nap::DirectionalLightComponent::mShadowCamera
ComponentPtr< OrthoCameraComponent > mShadowCamera
Property: 'ShadowCamera' Camera that produces the depth texture for a directional light.
Definition: directionallightcomponent.h:30
nap::EntityInstance
Definition: entity.h:34
nap::DirectionalLightComponent
Definition: directionallightcomponent.h:25
nap::Component
Definition: component.h:151
nap::ELightType
ELightType
Definition: lightcomponent.h:25
nap
Definition: templateapp.h:17
nap::DirectionalLightComponentInstance
Definition: directionallightcomponent.h:43
nap::DirectionalLightComponentInstance::getShadowMapType
virtual EShadowMapType getShadowMapType() const override
Definition: directionallightcomponent.h:65
nap::ComponentPtr
Definition: component.h:31
nap::DirectionalLightComponentInstance::DirectionalLightComponentInstance
DirectionalLightComponentInstance(EntityInstance &entity, Component &resource)
Definition: directionallightcomponent.h:47
nap::EShadowMapType::Quad
@ Quad