Changeset 9869 in orxonox.OLD for trunk/src/lib/graphics/light.h
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/light.h
r8255 r9869 25 25 class Light : public PNode 26 26 { 27 public: 28 Light(const TiXmlElement* root = NULL); 29 virtual ~Light(); 30 31 virtual void loadParams(const TiXmlElement* root); 32 33 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); 34 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); 35 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation); 36 void setSpotDirection(const Vector& direction); 37 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); }; 38 void setSpotCutoff(GLfloat cutoff); 39 40 /** @returns the lightNumber*/ 41 int getLightNumber() const {return this->lightNumber;} 42 43 virtual void draw() const; 44 45 void debug() const; 46 47 // attributes 48 private: 49 int lightNumber; //!< The number of this Light. 50 GLfloat diffuseColor[4]; //!< The Diffuse Color this Light emmits. 51 GLfloat specularColor[4]; //!< The specular Color of this Light. 52 float constantAttenuation; //!< The Factor of the the Constant Attenuation. 53 float linearAttenuation; //!< The Factor of the the Linear Attenuation. 54 float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation. 55 GLfloat spotDirection[4]; //!< The direction of the Spot Light. 56 GLfloat spotCutoff; //!< The cutoff Angle of the Light Source 27 ObjectListDeclaration(Light); 28 public: 29 Light(const TiXmlElement* root = NULL); 30 virtual ~Light(); 31 32 virtual void loadParams(const TiXmlElement* root); 33 34 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); 35 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); 36 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation); 37 void setSpotDirection(const Vector& direction); 38 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); }; 39 void setSpotCutoff(GLfloat cutoff); 40 41 /** @returns the lightNumber*/ 42 int getLightNumber() const {return this->lightNumber;} 43 44 virtual void draw() const; 45 46 void debug() const; 47 48 // attributes 49 private: 50 int lightNumber; //!< The number of this Light. 51 GLfloat diffuseColor[4]; //!< The Diffuse Color this Light emmits. 52 GLfloat specularColor[4]; //!< The specular Color of this Light. 53 float constantAttenuation; //!< The Factor of the the Constant Attenuation. 54 float linearAttenuation; //!< The Factor of the the Linear Attenuation. 55 float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation. 56 GLfloat spotDirection[4]; //!< The direction of the Spot Light. 57 GLfloat spotCutoff; //!< The cutoff Angle of the Light Source 57 58 }; 58 59 60 59 60 61 61 62 //! A class that handles Lights 62 63 /** … … 87 88 */ 88 89 class LightManager : public BaseObject 89 90 friend class Light;90 { 91 ObjectListDeclaration(LightManager); 91 92 92 public: 93 virtual ~LightManager(); 94 /** @returns a Pointer to the only object of this Class */ 95 inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager(); return singletonRef; }; 93 friend class Light; 94 public: 95 virtual ~LightManager(); 96 /** @returns a Pointer to the only object of this Class */ 97 inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager(); return singletonRef; }; 96 98 97 98 99 virtual void loadParams(const TiXmlElement* root); 100 void loadLights(const TiXmlElement* root); 99 101 100 101 102 102 void setAmbientColor(GLfloat r, GLfloat g, GLfloat b); 103 // HACK: Assuming r = g = b values 104 inline GLfloat getAmbientColor() { return this->ambientColor[0]; } 103 105 104 105 106 Light* getLight(int lightNumber) const; 107 inline Light* getLight() const { return this->currentLight; }; 106 108 107 109 void draw() const; 108 110 109 111 void debug() const; 110 112 111 112 113 private: 114 LightManager(); 113 115 114 115 116 int registerLight(Light* light); 117 void unregisterLight(Light* light); 116 118 117 118 119 119 private: 120 static LightManager* singletonRef; //!< This is the LightHandlers Reference. 121 GLfloat ambientColor[4]; //!< The ambient Color of the scene. 120 122 121 122 123 Light** lights; //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues. 124 Light* currentLight; //!< The current Light, we are working with. 123 125 124 126 };
Note: See TracChangeset
for help on using the changeset viewer.