Orxonox  0.0.5 Codename: Arcturus
Light.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
29 #ifndef _Light_H__
30 #define _Light_H__
31 
32 #include "OrxonoxPrereqs.h"
33 
34 #include <string>
35 #include "util/Math.h"
38 
39 namespace orxonox
40 {
42  {
43  public:
44  enum class Type // Copy from the Ogre enum
45  {
47  Point,
49  Directional,
51  Spotlight
52  };
53 
54  public:
55  Light(Context* context);
56  virtual ~Light();
57 
58  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
59 
60  virtual void changedVisibility() override;
61 
62  inline Ogre::Light* getLight()
63  { return this->light_; }
64 
65  inline void setType(Light::Type type)
66  { this->type_ = type; this->updateType(); }
67  inline Light::Type getType() const
68  { return this->type_; }
69 
70  inline void setDiffuseColour(const ColourValue& colour)
71  { this->diffuse_ = colour; this->updateDiffuseColour(); }
72  inline const ColourValue& getDiffuseColour() const
73  { return this->diffuse_; }
74 
75  inline void setSpecularColour(const ColourValue& colour)
76  { this->specular_ = colour; this->updateSpecularColour(); }
77  inline const ColourValue& getSpecularColour() const
78  { return this->specular_; }
79 
80  virtual void setTeamColour(const ColourValue& colour) override
81  { this->setDiffuseColour(colour); this->setSpecularColour(colour); }
82 
116  inline void setAttenuation(const Vector4& attenuation)
117  { this->attenuation_ = attenuation; this->updateAttenuation(); }
118  inline const Vector4& getAttenuation() const
119  { return this->attenuation_; }
120 
129  inline void setSpotlightRange(const Vector3& spotlightRange)
130  { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); }
131  inline const Vector3& getSpotlightRange() const
132  { return this->spotlightRange_; }
133 
134  private:
135  void registerVariables();
136  void setTypeString(const std::string& type);
137  std::string getTypeString() const;
138 
139  void updateType();
140  void updateDiffuseColour();
141  void updateSpecularColour();
142  void updateAttenuation();
143  void updateSpotlightRange();
144 
145  Ogre::Light* light_;
147  ColourValue diffuse_;
148  ColourValue specular_;
149  Vector4 attenuation_;
151  };
152 }
153 
154 #endif /* _Light_H__ */
Ogre::Light * getLight()
Definition: Light.h:62
Definition: ActionpointController.h:68
The StaticEntity is the simplest derivative of the orxonox::WorldEntity class.
Definition: StaticEntity.h:50
Vector4 attenuation_
Definition: Light.h:149
void setSpecularColour(const ColourValue &colour)
Definition: Light.h:75
void setSpotlightRange(const Vector3 &spotlightRange)
Sets the range of a spotlight, i.e.
Definition: Light.h:129
::std::string string
Definition: gtest-port.h:756
void setType(Light::Type type)
Definition: Light.h:65
Type
Definition: Light.h:44
void setDiffuseColour(const ColourValue &colour)
Definition: Light.h:70
Light::Type getType() const
Definition: Light.h:67
ColourValue diffuse_
Definition: Light.h:147
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
const ColourValue & getDiffuseColour() const
Definition: Light.h:72
Definition: Light.h:41
Ogre::Light * light_
Definition: Light.h:145
xmlelement
Definition: Super.h:519
ColourValue specular_
Definition: Light.h:148
Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the ...
virtual void setTeamColour(const ColourValue &colour) override
Definition: Light.h:80
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
const ColourValue & getSpecularColour() const
Definition: Light.h:77
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Definition: TeamColourable.h:39
Definition: Context.h:45
Light::Type type_
Definition: Light.h:146
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
Vector3 spotlightRange_
Definition: Light.h:150
void setAttenuation(const Vector4 &attenuation)
Sets the attenuation parameters of the light source i.e.
Definition: Light.h:116
const Vector4 & getAttenuation() const
Definition: Light.h:118
const Vector3 & getSpotlightRange() const
Definition: Light.h:131