SuperTuxKart
Loading...
Searching...
No Matches
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 <vector>
25
26using namespace irr;
27
28namespace irr
29{
30 namespace scene { class IMesh; }
31}
32
33//#define __LIGHT_NODE_VISUALISATION__
34
35// The actual node
36class LightNode: public scene::ISceneNode
37{
38#ifdef __LIGHT_NODE_VISUALISATION__
39 bool m_viz_added;
40#endif
41
42public:
43 LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float energy, float d, float r, float g, float b);
44 virtual ~LightNode();
45
46 virtual void render() OVERRIDE;
47
48 virtual const core::aabbox3d<f32>& getBoundingBox() const OVERRIDE
49 {
50 return box;
51 }
52
53 virtual void OnRegisterSceneNode() OVERRIDE;
54
55 virtual u32 getMaterialCount() const OVERRIDE { return 1; }
56 virtual bool isPointLight() { return true; }
57
58 float getRadius() const { return m_radius; }
59 float getEnergy() const { return m_energy; }
60 float getEffectiveEnergy() const { return m_energy_multiplier * m_energy; }
61 core::vector3df getColor() const { return core::vector3df(m_color[0], m_color[1], m_color[2]); }
62 void setColor(float r, float g, float b) { m_color[0] = r; m_color[1] = g; m_color[2] = b; }
63
64 float getEnergyMultiplier() const { return m_energy_multiplier; }
65 void setEnergyMultiplier(float newval) { m_energy_multiplier = newval; }
66
67 // For the debug menu
68 void setEnergy(float energy) { m_energy = energy; }
69 void setRadius(float radius) { m_radius = radius; }
70
71protected:
72 static core::aabbox3df box;
73
74 float m_radius;
75 float m_color[3];
76 float m_energy;
77
80};
81
82#endif
Definition: light.hpp:37
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:79