1 //------------------------------------------------------------------------------
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
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.
20 * Definition of a class that maintains the state and operation of a light.
22 #ifndef __SKYLIGHT_HPP__
23 #define __SKYLIGHT_HPP__
27 #include "SkyUtil.hpp"
37 SKY_LIGHT_DIRECTIONAL,
43 SkyLight(SkyLightType eType);
46 // for visualization of light positions / directions.
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; }
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; }
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; }
72 void SetSpotExponent(float rExp) { _rSpotExponent = rExp; _bDirty = true; }
73 void SetSpotCutoff(float rCutoff) { _rSpotCutoff = rCutoff; _bDirty = true; }
75 SKYRESULT Activate(int iLightID);
90 Vec3f _vecAttenuation; // constant, linear, and quadratic attenuation factors.
94 static SkyMaterial *s_pMaterial; // used for rendering the lights during debugging
97 #endif //__SKYLIGHT_HPP__