SuperTuxKart
light.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2013-2015 Lauri Kasanen
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_LIGHT_HPP
20 #define HEADER_LIGHT_HPP
21 
22 #include <ISceneNode.h>
23 #include <utils/cpp2011.hpp>
24 #include <vector3d.h>
25 #include <vector>
26 
27 using namespace irr;
28 
29 namespace irr
30 {
31  namespace scene { class IMesh; }
32 }
33 
34 struct Spotlight
35 {
36  irr::f32 m_outer_cone;
37  irr::f32 m_inner_cone;
38 };
39 
40 //#define __LIGHT_NODE_VISUALISATION__
41 
42 // The actual node
43 class LightNode: public scene::ISceneNode
44 {
45  Spotlight m_spotlight;
46 #ifdef __LIGHT_NODE_VISUALISATION__
47  bool m_viz_added;
48 #endif
49 
50 public:
51  LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float energy, float d, float r, float g, float b);
52  virtual ~LightNode();
53 
54  virtual void render() OVERRIDE;
55 
56  virtual const core::aabbox3d<f32>& getBoundingBox() const OVERRIDE
57  {
58  return box;
59  }
60 
61  virtual void OnRegisterSceneNode() OVERRIDE;
62 
63  virtual u32 getMaterialCount() const OVERRIDE { return 1; }
64  virtual bool isPointLight() { return true; }
65 
66  float getRadius() const { return m_radius; }
67  float getEnergy() const { return m_energy; }
68  float getEffectiveEnergy() const { return m_energy_multiplier * m_energy; }
69  core::vector3df getColor() const { return core::vector3df(m_color[0], m_color[1], m_color[2]); }
70  void setColor(float r, float g, float b) { m_color[0] = r; m_color[1] = g; m_color[2] = b; }
71 
72  float getEnergyMultiplier() const { return m_energy_multiplier; }
73  void setEnergyMultiplier(float newval) { m_energy_multiplier = newval; }
74 
75  // For the debug menu
76  void setEnergy(float energy) { m_energy = energy; }
77  void setRadius(float radius) { m_radius = radius; }
78  Spotlight& getSpotlightData() { return m_spotlight; }
79 
80 protected:
81  static core::aabbox3df box;
82 
83  float m_radius;
84  float m_color[3];
85  float m_energy;
86 
89 };
90 
91 #endif
Definition: light.hpp:44
float m_energy_multiplier
The energy multiplier is in range [0, 1] and is used to fade in lights when they come in range.
Definition: light.hpp:88
Definition: light.hpp:35