Changeset 4734 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 29, 2005, 3:05:47 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/light.cc
r4597 r4734 23 23 #include "vector.h" 24 24 #include "debug.h" 25 #include "tinyxml.h" 26 #include "load_param.h" 27 #include "factory.h" 25 28 26 29 using namespace std; 27 30 31 CREATE_FACTORY(Light); 32 28 33 //! Definition of the Lights 29 int lightsV[] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}; 34 int lightsV[] = 35 { 36 GL_LIGHT0, 37 GL_LIGHT1, 38 GL_LIGHT2, 39 GL_LIGHT3, 40 GL_LIGHT4, 41 GL_LIGHT5, 42 GL_LIGHT6, 43 GL_LIGHT7 44 }; 30 45 31 46 … … 34 49 */ 35 50 Light::Light(int lightNumber) 51 { 52 this->init(lightNumber); 53 } 54 55 /** 56 * \param root The XML-element to load the Light from 57 */ 58 Light::Light(const TiXmlElement* root) 59 { 60 this->init(1); 61 this->loadParams(root); 62 } 63 64 /** 65 \brief destroys a Light 66 */ 67 Light::~Light(void) 68 { 69 glDisable(lightsV[this->lightNumber]); 70 } 71 72 /** 73 * \brief initializes a Light 74 */ 75 void Light::init(int lightNumber) 36 76 { 37 77 this->setClassID(CL_LIGHT, "Light"); … … 46 86 // set values (defaults) 47 87 this->lightNumber = lightNumber; 48 this->setPosition(0 .0, 0.0, 0.0);88 this->setPosition(0,0,0); 49 89 this->setDiffuseColor(1.0, 1.0, 1.0); 50 90 this->setSpecularColor(1.0, 1.0, 1.0); 51 91 } 52 92 53 54 /** 55 \brief destroys a Light 56 */ 57 Light::~Light(void) 58 { 59 glDisable(lightsV[this->lightNumber]); 60 } 61 93 /** 94 * \param root The XML-element to load the Light from 95 */ 96 void Light::loadParams(const TiXmlElement* root) 97 { 98 static_cast<PNode*>(this)->loadParams(root); 99 100 LoadParam<Light>(root, "diffuse-color", this, &Light::setDiffuseColor) 101 .describe("sets the diffuse color of the Light (red [0-1], green [0-1], blue [0-1])"); 102 103 LoadParam<Light>(root, "specular-color", this, &Light::setSpecularColor) 104 .describe("sets the specular color of the Light (red [0-1], green [0-1], blue [0-1])"); 105 106 LoadParam<Light>(root, "spot-direction", this, &Light::setSpotDirection) 107 .describe("sets the Direction of the Spot"); 108 109 LoadParam<Light>(root, "spot-cutoff", this, &Light::setSpotCutoff) 110 .describe("the cuttoff of the Spotlight"); 111 } 62 112 63 113 /** … … 66 116 \todo patrick: is it ok to set a Light Position even if it is derived from p_node?? 67 117 */ 68 void Light::setPosition( Vectorposition)118 void Light::setPosition(const Vector& position) 69 119 { 70 120 this->lightPosition[0] = position.x; … … 107 157 } 108 158 109 110 159 /** 111 160 \brief sets an emitting Specular color of this Light … … 147 196 \param direction The direction of the Spot Light. 148 197 */ 149 void Light::setSpotDirection( Vectordirection)198 void Light::setSpotDirection(const Vector& direction) 150 199 { 151 200 this->spotDirection[0] = direction.x; -
orxonox/trunk/src/lib/graphics/light.h
r4519 r4734 1 /*! 1 /*! 2 2 \file light.h 3 3 \brief Handles Lights. … … 20 20 // FORWARD DEFINITIONS // 21 21 class Vector; 22 22 class TiXmlElement; 23 23 24 24 //! A class that handles Lights. The LightManager operates on this. … … 27 27 public: 28 28 Light(int lightNumber); 29 Light(const TiXmlElement* root); 29 30 virtual ~Light(void); 30 31 31 void setPosition(Vector position); 32 void init(int lightNumber); 33 void loadParams(const TiXmlElement* root); 34 35 void setPosition(const Vector& position); 32 36 void setPosition(GLfloat x, GLfloat y, GLfloat z); 33 37 Vector getPosition() const; … … 36 40 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); 37 41 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation); 38 void setSpotDirection(Vector direction); 42 void setSpotDirection(const Vector& direction); 43 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); }; 39 44 void setSpotCutoff(GLfloat cutoff); 40 45 41 46 /** \returns the lightNumber*/ 42 47 int getLightNumber(void) const {return this->lightNumber;} 43 48 44 49 virtual void draw(); 45 50 … … 89 94 To redraw the light use 90 95 \li void draw(); 91 96 92 97 and to delete one just use 93 98 \li void deleteLight(void); … … 96 101 \li void debug(void) const; 97 102 98 You can also operate on the single Lights themselves, by first retreaving them with 103 You can also operate on the single Lights themselves, by first retreaving them with 99 104 \li Light* getLight(int LightNumber); 100 105 \n … … 108 113 /** \returns a Pointer to the only object of this Class */ 109 114 inline static LightManager* getInstance(void) { if (!singletonRef) singletonRef = new LightManager(); return singletonRef; }; 115 116 void loadParams(const TiXmlElement* root); 110 117 111 118 // set Attributes … … 132 139 Vector getPosition(void) const; 133 140 Vector getPosition(int lightNumber) const; 134 141 135 142 Light* getLight(int lightNumber) const; 136 143 137 144 void debug(void) const; 138 145 … … 141 148 LightManager(void); 142 149 void initLight(int LightNumber); 143 150 144 151 145 152 private: … … 149 156 Light** lights; //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues. 150 157 Light* currentLight; //!< The current Light, we are working with. 151 158 152 159 }; 153 160
Note: See TracChangeset
for help on using the changeset viewer.