Thrive
light_system.h
1 #pragma once
2 
3 #include "engine/component.h"
4 #include "engine/system.h"
5 #include "engine/touchable.h"
6 
7 #include <memory>
8 #include <OgreLight.h>
9 
10 #include <iostream>
11 
12 namespace luabind {
13 class scope;
14 }
15 
16 namespace thrive {
17 
21 class OgreLightComponent : public Component {
22  COMPONENT(OgreLight)
23 
24 public:
25 
29  struct Properties : public Touchable {
33  Ogre::Real attenuationConstant = 1.0f;
34 
38  Ogre::Real attenuationLinear = 0.5f;
39 
43  Ogre::Real attenuationQuadratic = 0.75f;
44 
48  Ogre::Real attenuationRange = 10.0f;
49 
55  Ogre::ColourValue diffuseColour = Ogre::ColourValue::White;
56 
62  Ogre::ColourValue specularColour = Ogre::ColourValue::White;
63 
67  Ogre::Real spotlightFalloff = 1.0f;
68 
72  Ogre::Degree spotlightInnerAngle = Ogre::Degree(30);
73 
77  Ogre::Real spotlightNearClipDistance = 10.0f;
78 
82  Ogre::Degree spotlightOuterAngle = Ogre::Degree(60);
83 
92  Ogre::Light::LightTypes type = Ogre::Light::LT_POINT;
93 
94  };
95 
122  static luabind::scope
123  luaBindings();
124 
125  void
126  load(
128  ) override;
129 
140  void setRange(
141  Ogre::Real range
142  );
143 
145  storage() const override;
146 
150  Ogre::Light* m_light = nullptr;
151 
155  Properties
157 
158 };
159 
160 
164 class OgreLightSystem : public System {
165 
166 public:
167 
176  static luabind::scope
177  luaBindings();
178 
182  OgreLightSystem();
183 
188 
193  void init(GameState* gameState) override;
194 
198  void shutdown() override;
199 
203  void update(int, int) override;
204 
205 private:
206 
207  struct Implementation;
208  std::unique_ptr<Implementation> m_impl;
209 };
210 
211 }
212 
Helper class for keeping track of changing data.
Definition: touchable.h:18
void init(GameState *gameState) override
Initializes the system.
Definition: light_system.cpp:144
Ogre::Light * m_light
Internal light, don't use this directly.
Definition: light_system.h:150
Ogre::Degree spotlightOuterAngle
Spotlight outer angle.
Definition: light_system.h:82
Creates lights and updates their properties.
Definition: light_system.h:164
Ogre::Real spotlightFalloff
Spotlight falloff.
Definition: light_system.h:67
Base class for components.
Definition: component.h:31
void update(int, int) override
Updates the system.
Definition: light_system.cpp:163
A system handles one specific part of the game.
Definition: system.h:23
Ogre::Real spotlightNearClipDistance
Spotlight near clip distance.
Definition: light_system.h:77
StorageContainer storage() const override
Serializes the component.
Definition: light_system.cpp:88
void setRange(Ogre::Real range)
Convenience function for setting sensible attenuation values.
Definition: light_system.cpp:21
Ogre::ColourValue diffuseColour
The diffuse colour.
Definition: light_system.h:55
void shutdown() override
Shuts the system down.
Definition: light_system.cpp:155
OgreLightSystem()
Constructor.
Definition: light_system.cpp:134
Definition: bullet_to_ogre_system.h:5
Definition: bullet_ogre_conversion.h:6
Ogre::Real attenuationLinear
Attenuation linear factor.
Definition: light_system.h:38
Properties.
Definition: light_system.h:29
GameState * gameState() const
Returns the system's game state.
Definition: system.cpp:183
Ogre::Real attenuationQuadratic
Attenuation quadratic factor.
Definition: light_system.h:43
Represents a distinct set of active systems and entities.
Definition: game_state.h:41
Ogre::Real attenuationRange
Attenuation range.
Definition: light_system.h:48
Ogre::Degree spotlightInnerAngle
Spotlight inner angle.
Definition: light_system.h:72
Ogre::ColourValue specularColour
The specular colour.
Definition: light_system.h:62
~OgreLightSystem()
Destructor.
Definition: light_system.cpp:140
static luabind::scope luaBindings()
Lua bindings.
Definition: light_system.cpp:33
static luabind::scope luaBindings()
Lua bindings.
Definition: light_system.cpp:112
Properties m_properties
Properties.
Definition: light_system.h:156
Ogre::Light::LightTypes type
The light's type.
Definition: light_system.h:92
A key-value storage for serialization.
Definition: serialization.h:36
Ogre::Real attenuationConstant
Attenuation constant factor.
Definition: light_system.h:33
void load(const StorageContainer &storage) override
Loads the component.
Definition: light_system.cpp:67
A component for a light.
Definition: light_system.h:21