]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/SkyLight.hpp
A first attempt at making the clouds3d endian aware. Almost there.
[simgear.git] / simgear / scene / sky / clouds3d / SkyLight.hpp
1 //------------------------------------------------------------------------------
2 // File : SkyLight.hpp
3 //------------------------------------------------------------------------------
4 // SkyWorks : Copyright 2002 Mark J. Harris and
5 //                                              The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its 
8 // documentation for any purpose is hereby granted without fee, provided that 
9 // the above copyright notice appear in all copies and that both that copyright 
10 // notice and this permission notice appear in supporting documentation. 
11 // Binaries may be compiled with this software without any royalties or 
12 // restrictions. 
13 //
14 // The author(s) and The University of North Carolina at Chapel Hill make no 
15 // representations about the suitability of this software for any purpose. 
16 // It is provided "as is" without express or implied warranty.
17 /**
18  * @file SkyLight.hpp
19  * 
20  * Definition of a class that maintains the state and operation of a light.
21  */
22 #ifndef __SKYLIGHT_HPP__
23 #define __SKYLIGHT_HPP__
24
25 #include "vec3f.hpp"
26 #include "vec4f.hpp"
27 #include "SkyUtil.hpp"
28
29 class SkyMaterial;
30
31 class SkyLight
32 {
33 public: // types
34   enum SkyLightType
35   {
36     SKY_LIGHT_POINT,
37     SKY_LIGHT_DIRECTIONAL,
38     SKY_LIGHT_SPOT,
39     SKY_LIGHT_NUM_TYPES
40   };
41
42 public: // methods
43   SkyLight(SkyLightType eType);
44   virtual ~SkyLight();
45
46   // for visualization of light positions / directions.
47   void         Display() const;
48
49   bool         GetEnabled() const               { return _bEnabled;          }
50   SkyLightType GetType() const                  { return _eType;             }
51   const float* GetPosition() const              { return _vecPosition;       }
52   const float* GetDirection() const             { return _vecDirection;      }
53   const float* GetDiffuse() const               { return _vecDiffuse;        }
54   const float* GetAmbient() const               { return _vecAmbient;        }
55   const float* GetSpecular() const              { return _vecSpecular;       }
56   const float* GetAttenuation() const           { return _vecAttenuation;    }
57   float        GetSpotExponent() const          { return _rSpotExponent;     }
58   float        GetSpotCutoff() const            { return _rSpotCutoff;       }
59
60   void         Enable(bool bEnable)             { _bEnabled       = bEnable; _bDirty = true; }
61   void         SetType(const SkyLightType& t)   { _eType          = t;       _bDirty = true; }
62   void         SetPosition(const float pos[3])  
63   { _vecPosition.Set(pos[0], pos[1], pos[2], (_eType != SKY_LIGHT_DIRECTIONAL)); _bDirty = true; }
64   
65   void         SetDirection(const float dir[3]) { _vecDirection.Set(dir[0], dir[1], dir[2], 0); _bDirty = true; }
66   void         SetDiffuse(const float color[4]) { _vecDiffuse.Set(color);    _bDirty = true; }
67   void         SetAmbient(const float color[4]) { _vecAmbient.Set(color);    _bDirty = true; }
68   void         SetSpecular(const float color[4]){ _vecSpecular.Set(color);   _bDirty = true; }
69   void         SetAttenuation(float rConstant, float rLinear, float rQuadratic) 
70   { _vecAttenuation.Set(rConstant, rLinear, rQuadratic);        _bDirty = true; }
71   
72   void         SetSpotExponent(float rExp)      { _rSpotExponent  = rExp;    _bDirty = true; }
73   void         SetSpotCutoff(float rCutoff)     { _rSpotCutoff    = rCutoff; _bDirty = true; }
74     
75   SKYRESULT    Activate(int iLightID);
76
77 protected: // data
78   bool  _bEnabled;
79   bool  _bDirty;
80
81   int   _iLastGLID;
82
83   SkyLightType _eType;
84
85   Vec4f _vecPosition;
86   Vec4f _vecDirection;
87   Vec4f _vecDiffuse;
88   Vec4f _vecAmbient;
89   Vec4f _vecSpecular;
90   Vec3f _vecAttenuation;  // constant, linear, and quadratic attenuation factors.
91   float _rSpotExponent;
92   float _rSpotCutoff;
93
94   static SkyMaterial *s_pMaterial;  // used for rendering the lights during debugging
95 };
96
97 #endif //__SKYLIGHT_HPP__