Caelum
SkyLight.h
1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2008 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef CAELUM__SKYLIGHT_H
22 #define CAELUM__SKYLIGHT_H
23 
24 #include "CameraBoundElement.h"
25 
26 namespace Caelum
27 {
31  class CAELUM_EXPORT BaseSkyLight : public CameraBoundElement
32  {
33  protected:
35  Ogre::Light *mMainLight;
36 
38  Ogre::SceneNode *mNode;
39 
41  float mRadius;
42 
44  Ogre::Vector3 mDirection;
45 
47  Ogre::ColourValue mBodyColour;
48 
50  Ogre::ColourValue mLightColour;
51 
53  Ogre::ColourValue mDiffuseMultiplier;
54 
56  Ogre::ColourValue mSpecularMultiplier;
57 
61  Ogre::ColourValue mAmbientMultiplier;
62 
65 
68 
71 
72  public:
77  BaseSkyLight (
78  Ogre::SceneManager *sceneMgr,
79  Ogre::SceneNode *caelumRootNode);
80 
82  virtual ~BaseSkyLight () = 0;
83 
89  virtual void update (
90  const Ogre::Vector3& direction,
91  const Ogre::ColourValue &lightColour,
92  const Ogre::ColourValue &bodyColour);
93 
95  const Ogre::Vector3 getLightDirection () const;
96 
98  virtual void setLightDirection (const Ogre::Vector3 &dir);
99 
101  const Ogre::ColourValue getBodyColour () const;
102 
104  virtual void setBodyColour (const Ogre::ColourValue &colour);
105 
107  const Ogre::ColourValue getLightColour () const;
108 
110  virtual void setLightColour (const Ogre::ColourValue &colour);
111 
113  void setDiffuseMultiplier (const Ogre::ColourValue &diffuse);
114 
116  const Ogre::ColourValue getDiffuseMultiplier () const;
117 
119  void setSpecularMultiplier (const Ogre::ColourValue &specular);
120 
122  const Ogre::ColourValue getSpecularMultiplier () const;
123 
127  void setAmbientMultiplier (const Ogre::ColourValue &ambient);
128 
130  const Ogre::ColourValue getAmbientMultiplier () const;
131 
133  Ogre::Light* getMainLight() const;
134 
136  inline bool getAutoDisable() const { return mAutoDisableLight; }
137 
143  inline void setAutoDisable(bool value) { mAutoDisableLight = value; }
144 
146  inline Ogre::Real getAutoDisableThreshold() const { return mAutoDisableThreshold; }
147 
149  inline void setAutoDisableThreshold(Ogre::Real value) { mAutoDisableThreshold = value; }
150 
151  static const Ogre::Real DEFAULT_AUTO_DISABLE_THRESHOLD;
152 
154  inline void setForceDisable(bool value) { mForceDisableLight = value; }
155  inline bool getForceDisable() const { return mForceDisableLight; }
156 
157  virtual void setQueryFlags (uint flags) = 0;
158  virtual uint getQueryFlags () const = 0;
159  virtual void setVisibilityFlags (uint flags) = 0;
160  virtual uint getVisibilityFlags () const = 0;
161 
162  protected:
164  virtual void setFarRadius (Ogre::Real radius);
165 
167  void setMainLightColour(const Ogre::ColourValue &colour);
168 
171  bool shouldEnableLight(const Ogre::ColourValue &colour);
172  };
173 }
174 
175 #endif // CAELUM__SKYLIGHT_H
Ogre::Real mAutoDisableThreshold
Threshold beneath which the light is automatically disabled.
Definition: SkyLight.h:67
Ogre::Real getAutoDisableThreshold() const
Get the auto-disable threshold.
Definition: SkyLight.h:146
void setAutoDisableThreshold(Ogre::Real value)
Set the auto-disable threshold.
Definition: SkyLight.h:149
float mRadius
Base distance of the light.
Definition: SkyLight.h:41
Base class for sky lights (sun and moon).
Definition: SkyLight.h:31
Ogre::SceneNode * mNode
The sun scene node.
Definition: SkyLight.h:38
bool mForceDisableLight
If the light is always disabled. Separate from the mAutoDisable mechanism.
Definition: SkyLight.h:70
bool mAutoDisableLight
If the light is automatically disabled beneath mAutoDisableThreshold.
Definition: SkyLight.h:64
Ogre::ColourValue mLightColour
Sun light colour, as set by setLightColour.
Definition: SkyLight.h:50
Ogre::ColourValue mDiffuseMultiplier
Colour multiplier for light diffuse colour.
Definition: SkyLight.h:53
Ogre::ColourValue mBodyColour
Body sphere colour, as set by setBodyColour.
Definition: SkyLight.h:47
Ogre::Light * mMainLight
The main directional light.
Definition: SkyLight.h:35
A camera-bound element.
void setAutoDisable(bool value)
Turn on and off auto-disabling of the light when too dim.
Definition: SkyLight.h:143
Ogre::ColourValue mSpecularMultiplier
Colour multiplier for light specular colour.
Definition: SkyLight.h:56
Ogre::Vector3 mDirection
The latest normalised sun direction.
Definition: SkyLight.h:44
bool getAutoDisable() const
Check if the light is automatically disabled.
Definition: SkyLight.h:136
Ogre::ColourValue mAmbientMultiplier
Colour multiplier for ambient light colour.
Definition: SkyLight.h:61
void setForceDisable(bool value)
Disable the light by force; without taking intensity into account.
Definition: SkyLight.h:154
Caelum namespace.
Definition: Astronomy.cpp:24