Changeset 4735 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 30, 2005, 12:41:19 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/light.cc
r4734 r4735 44 44 }; 45 45 46 47 46 /** 48 47 \param lightNumber the Light Number to initiate … … 86 85 // set values (defaults) 87 86 this->lightNumber = lightNumber; 88 this->setPosition(0,0,0);89 87 this->setDiffuseColor(1.0, 1.0, 1.0); 90 88 this->setSpecularColor(1.0, 1.0, 1.0); … … 110 108 .describe("the cuttoff of the Spotlight"); 111 109 } 112 113 /**114 \brief Sets a Position for the Light.115 \param position The new position of the Light.116 \todo patrick: is it ok to set a Light Position even if it is derived from p_node??117 */118 void Light::setPosition(const Vector& position)119 {120 this->lightPosition[0] = position.x;121 this->lightPosition[1] = position.y;122 this->lightPosition[2] = position.z;123 this->lightPosition[3] = 0.0;124 125 this->setAbsCoor(position);126 127 glLightfv (lightsV[this->lightNumber], GL_POSITION, this->lightPosition);128 }129 130 131 /**132 \brief Sets a Position of this Light.133 \param x the x-coordinate134 \param y the y-coordinate135 \param z the z-coordinate136 */137 void Light::setPosition(GLfloat x, GLfloat y, GLfloat z)138 {139 this->setPosition(Vector(x, y, z));140 }141 142 110 143 111 /** … … 215 183 glLightf(lightsV[this->lightNumber], GL_SPOT_CUTOFF, cutoff); 216 184 } 217 218 219 /**220 \returns the Position of the Light221 */222 Vector Light::getPosition() const223 {224 return Vector(this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);225 }226 227 185 228 186 /** … … 251 209 PRINT(0)("OFF\n"); 252 210 253 PRINT(0)(" Position: %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);254 211 PRINT(0)(" DiffuseColor: %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]); 255 212 PRINT(0)(" SpecularColor: %f/%f/%f\n", this->specularColor[0], this->specularColor[1], this->specularColor[2]); … … 309 266 } 310 267 268 /** 269 \param root the XML-element to load the LightManager's settings from 270 */ 271 void LightManager::loadParams(const TiXmlElement* root) 272 { 273 LoadParam<LightManager>(root, "Lights", this, &LightManager::loadLights) 274 .describe("an XML-Element to load lights from."); 275 276 LoadParam<LightManager>(root, "ambient-color", this, &LightManager::setAmbientColor) 277 .describe("sets the ambient Color of the Environmental Light"); 278 } 279 280 /** 281 \param root The XML-element to load Lights from 282 */ 283 void LightManager::loadLights(const TiXmlElement* root) 284 { 285 const TiXmlElement* element = root->FirstChildElement(); 286 287 while (element != NULL) 288 { 289 Factory::getFirst()->fabricate(element); 290 291 element = element->NextSiblingElement(); 292 } 293 } 311 294 312 295 /** … … 421 404 } 422 405 423 424 /**425 \brief sets The Position of the currently selected Light426 \param position the new Position427 */428 void LightManager::setPosition(Vector position)429 {430 this->currentLight->setPosition(position);431 }432 433 434 /**435 \brief Sets a Position for the currently selected Light.436 \param x the x-coordinate437 \param y the y-coordinate438 \param z the z-coordinate439 */440 void LightManager::setPosition(GLfloat x, GLfloat y, GLfloat z)441 {442 if (!this->currentLight)443 {444 PRINTF(2)("no Light defined yet. Please define at least one light first befor editing.\n");445 return;446 }447 this->currentLight->setPosition(x, y, z);448 }449 450 451 406 /** 452 407 \brief sets an emitting Diffuse color of the currently selected Light … … 528 483 this->currentLight->setSpotCutoff(cutoff); 529 484 } 530 531 532 // get Attributes533 /**534 \returns the Position of the Light535 */536 Vector LightManager::getPosition(void) const537 {538 if (!this->currentLight)539 {540 PRINTF(2)("no Light defined yet\n");541 return Vector(.0, .0, .0);542 }543 else544 return this->currentLight->getPosition();545 }546 547 548 /**549 \returns the Position of Light550 \param lightNumber lightnumber551 */552 Vector LightManager::getPosition(int lightNumber) const553 {554 if (!this->lights[lightNumber])555 {556 PRINTF(2)("no Light defined yet\n");557 return Vector(.0,.0,.0);558 }559 else560 return this->lights[lightNumber]->getPosition();561 }562 563 485 564 486 /** -
orxonox/trunk/src/lib/graphics/light.h
r4734 r4735 33 33 void loadParams(const TiXmlElement* root); 34 34 35 void setPosition(const Vector& position);36 void setPosition(GLfloat x, GLfloat y, GLfloat z);37 Vector getPosition() const;38 39 35 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); 40 36 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); … … 54 50 private: 55 51 int lightNumber; //!< The number of this Light. 56 GLfloat lightPosition[4]; //!< The Position of this Light.57 52 GLfloat diffuseColor[4]; //!< The Diffuse Color this Light emmits. 58 53 GLfloat specularColor[4]; //!< The specular Color of this Light. … … 115 110 116 111 void loadParams(const TiXmlElement* root); 112 void loadLights(const TiXmlElement* root); 117 113 118 114 // set Attributes … … 128 124 129 125 //set Attributes 130 void setPosition(Vector position);131 void setPosition(GLfloat x, GLfloat y, GLfloat z);132 126 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b); 133 127 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b); … … 141 135 142 136 Light* getLight(int lightNumber) const; 137 Light* getLight() const { return this->currentLight; }; 143 138 144 139 void debug(void) const;
Note: See TracChangeset
for help on using the changeset viewer.