NAP
pointlightcomponent.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 <perspcameracomponent.h>
12 #include <rendergnomoncomponent.h>
13 
14 namespace nap
15 {
16  // Forward declares
17  class PointLightComponentInstance;
18 
26  class NAPAPI PointLightComponent : public LightComponent
27  {
28  RTTI_ENABLE(LightComponent)
30  public:
31  float mAttenuation = 0.1f;
32  glm::vec2 mClippingPlanes = { 1.0f, 1000.0f };
33  uint mShadowMapSize = 512;
34  };
35 
36 
45  {
46  RTTI_ENABLE(LightComponentInstance)
47  public:
49  LightComponentInstance(entity, resource) { }
50 
56  virtual bool init(utility::ErrorState& errorState) override;
57 
61  virtual ELightType getLightType() const override { return ELightType::Point; }
62 
66  virtual EShadowMapType getShadowMapType() const override { return EShadowMapType::Cube; }
67 
72  float getAttenuation() const { return mAttenuation; }
73 
78  void setAttenuation(float attenuation) { mAttenuation = attenuation; }
79 
80  float mAttenuation = 0.1f;
81 
82  private:
83  // Shadow camera entity resource
84  std::unique_ptr<Entity> mShadowCamEntity = nullptr;
85  std::unique_ptr<PerspCameraComponent> mShadowCamComponent = nullptr;
86  std::unique_ptr<TransformComponent> mShadowCamXformComponent = nullptr;
87  std::unique_ptr<RenderGnomonComponent> mShadowOriginComponent = nullptr;
88  std::unique_ptr<GnomonMesh> mGnomonMesh = nullptr;
89  };
90 }
nap::uint
unsigned int uint
Definition: numeric.h:23
nap::ELightType::Point
@ Point
nap::PointLightComponentInstance::getAttenuation
float getAttenuation() const
Definition: pointlightcomponent.h:72
nap::LightComponentInstance
Definition: lightcomponent.h:209
nap::PointLightComponentInstance::PointLightComponentInstance
PointLightComponentInstance(EntityInstance &entity, Component &resource)
Definition: pointlightcomponent.h:48
nap::LightComponent
Definition: lightcomponent.h:134
nap::utility::ErrorState
Definition: errorstate.h:19
nap::EShadowMapType
EShadowMapType
Definition: lightcomponent.h:36
nap::PointLightComponentInstance::setAttenuation
void setAttenuation(float attenuation)
Definition: pointlightcomponent.h:78
nap::EShadowMapType::Cube
@ Cube
nap::PointLightComponentInstance::getLightType
virtual ELightType getLightType() const override
Definition: pointlightcomponent.h:61
nap::EntityInstance
Definition: entity.h:34
nap::Component
Definition: component.h:151
nap::ELightType
ELightType
Definition: lightcomponent.h:25
nap::PointLightComponent
Definition: pointlightcomponent.h:26
nap
Definition: templateapp.h:17
nap::PointLightComponentInstance::getShadowMapType
virtual EShadowMapType getShadowMapType() const override
Definition: pointlightcomponent.h:66
nap::PointLightComponentInstance
Definition: pointlightcomponent.h:44