- Timestamp:
- Mar 18, 2005, 12:00:42 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/light.cc
r3597 r3598 27 27 int lightsV[] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}; 28 28 29 30 /** 31 \param lightNumber the Light Number to initiate 32 */ 29 33 Light::Light(int lightNumber) 30 34 { … … 40 44 } 41 45 46 /** 47 \brief destroys a Light 48 */ 42 49 Light::~Light(void) 43 50 { … … 57 64 this->lightPosition[3] = 0.0; 58 65 59 glLightfv (GL_LIGHT0, GL_POSITION, this->lightPosition); 60 } 61 62 /** 63 \brief Sets a Position for the Light. 66 this->setAbsCoor(&position); 67 68 glLightfv (lightsV[this->lightNumber], GL_POSITION, this->lightPosition); 69 } 70 71 /** 72 \brief Sets a Position of this Light. 64 73 \param x the x-coordinate 65 74 \param y the y-coordinate … … 68 77 void Light::setPosition(GLfloat x, GLfloat y, GLfloat z) 69 78 { 70 this->lightPosition[0] = x; 71 this->lightPosition[1] = y; 72 this->lightPosition[2] = z; 73 this->lightPosition[3] = 0.0; 74 75 glLightfv (GL_LIGHT0, GL_POSITION, this->lightPosition); 76 } 77 78 /** 79 \brief sets an emitting Diffuse color for the Light 79 this->setPosition(Vector(x, y, z)); 80 } 81 82 /** 83 \brief sets an emitting Diffuse color of this Light 80 84 \param r red 81 85 \param g green … … 89 93 this->diffuseColor[3] = 1.0; 90 94 91 glLightfv ( GL_LIGHT0, GL_DIFFUSE, this->diffuseColor);92 } 93 94 /** 95 \brief sets an emitting Ambient color for theLight95 glLightfv (lightsV[this->lightNumber], GL_DIFFUSE, this->diffuseColor); 96 } 97 98 /** 99 \brief sets an emitting Specular color of this Light 96 100 \param r red 97 101 \param g green … … 105 109 this->specularColor[3] = 1.0; 106 110 107 glLightfv ( GL_LIGHT0, GL_SPECULAR, this->specularColor);111 glLightfv (lightsV[this->lightNumber], GL_SPECULAR, this->specularColor); 108 112 } 109 113 110 114 /** 111 115 \brief Sets the AttenuationType of this Light Source 112 \param type the AttenuationType to set 113 \param factor the Factor to multipy the attenuation with 114 115 this actually just sets the following: glLightf(currentLight, type, factor) 116 \param constantAttenuation The Constant Attenuation of the Light 117 \param linearAttenuation The Linear Attenuation of the Light 118 \param quadraticAttenuation The Quadratic Attenuation of the Light 116 119 */ 117 120 void Light::setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation) … … 139 142 } 140 143 141 142 144 /** 143 145 \brief sets the cutoff angle of the Light. … … 150 152 } 151 153 154 /** 155 \returns the Position of the Light 156 */ 157 Vector Light::getPosition() 158 { 159 return Vector(this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]); 160 } 161 162 /** 163 \brief draws this Light. Being a World-entity the possibility to do this lies at hand. 164 */ 152 165 void Light::draw() 153 166 { … … 156 169 } 157 170 171 /** 172 \brief Prints out some nice formated debug information about the Light 173 */ 158 174 void Light::debug(void) 159 175 { … … 196 212 197 213 first disables Lighting 198 then deletes all the lights 214 199 215 then deletes the rest of the allocated memory 200 216 and in the end sets the singleton Reference to zero. … … 291 307 } 292 308 293 this->deleteLight(this->currentLight-> lightNumber);309 this->deleteLight(this->currentLight->getLightNumber()); 294 310 } 295 311 … … 308 324 } 309 325 326 /** 327 \brief draws all the Lights in their appropriate position 328 */ 329 void LightManager::draw() 330 { 331 glMatrixMode(GL_MODELVIEW); 332 glLoadIdentity(); 333 for (int i; i < NUMBEROFLIGHTS; i++) 334 if (this->lights[i]) 335 lights[i]->draw(); 336 } 337 338 339 310 340 // set Attributes 311 341 /** … … 325 355 } 326 356 357 /** 358 \brief sets The Position of the currently selected Light 359 \param position the new Position 360 */ 327 361 void LightManager::setPosition(Vector position) 328 362 { 329 363 this->currentLight->setPosition(position); 330 364 } 365 366 /** 367 \brief Sets a Position for the currently selected Light. 368 \param x the x-coordinate 369 \param y the y-coordinate 370 \param z the z-coordinate 371 */ 331 372 void LightManager::setPosition(GLfloat x, GLfloat y, GLfloat z) 332 373 { 333 374 this->currentLight->setPosition(x, y, z); 334 375 } 376 377 /** 378 \brief sets an emitting Diffuse color of the currently selected Light 379 \param r red 380 \param g green 381 \param b blue 382 */ 335 383 void LightManager::setDiffuseColor(GLfloat r, GLfloat g, GLfloat b) 336 384 { 337 385 this->currentLight->setDiffuseColor(r,g,b); 338 386 } 387 388 /** 389 \brief sets an emitting Specular color of the currently selected Light 390 \param r red 391 \param g green 392 \param b blue 393 */ 339 394 void LightManager::setSpecularColor(GLfloat r, GLfloat g, GLfloat b) 340 395 { 341 396 this->currentLight->setSpecularColor(r, g, b); 342 397 } 398 399 /** 400 \brief Sets the AttenuationType of th currently selecte LightSource Light Source 401 \param constantAttenuation The Constant Attenuation of the Light 402 \param linearAttenuation The Linear Attenuation of the Light 403 \param quadraticAttenuation The Quadratic Attenuation of the Light 404 */ 343 405 void LightManager::setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation) 344 406 { 345 407 this->currentLight->setAttenuation(constantAttenuation, linearAttenuation, quadraticAttenuation); 346 408 } 409 410 411 /** 412 \brief stets the direction of the Spot Light. 413 \param direction The direction of the Spot Light. 414 */ 347 415 void LightManager::setSpotDirection(Vector direction) 348 416 { 349 417 this->currentLight->setSpotDirection(direction); 350 418 } 419 420 /** 421 \brief sets the cutoff angle of the Light. 422 \param cutoff The cutoff angle. 423 */ 351 424 void LightManager::setSpotCutoff(GLfloat cutoff) 352 425 { … … 366 439 } 367 440 else 368 return getPosition(currentLight->lightNumber); 369 } 441 return this->currentLight->getPosition(); 442 } 443 444 /** 445 \returns the Position of Light 446 \param lightNumber lightnumber 447 */ 448 Vector LightManager::getPosition(int lightNumber) 449 { 450 if (!this->lights[lightNumber]) 451 return Vector(.0,.0,.0); 452 else 453 return this->lights[lightNumber]->getPosition(); 454 } 455 370 456 371 457 /** … … 379 465 PRINT(0)("Reference: %p\n", LightManager::singletonRef); 380 466 if (this->currentLight) 381 PRINT(0)("current Light Nr: %d\n", this->currentLight-> lightNumber);467 PRINT(0)("current Light Nr: %d\n", this->currentLight->getLightNumber()); 382 468 PRINT(0)("Ambient Color: %f:%f:%f\n", this->ambientColor[0], this->ambientColor[0], this->ambientColor[0]); 383 469 PRINT(0)("=== Lights ===\n"); -
orxonox/trunk/src/light.h
r3597 r3598 14 14 #include "glincl.h" 15 15 16 //! The maximum number of Lights this OpenGL-implementation supports 16 //! The maximum number of Lights this OpenGL-implementation supports. 17 17 #define NUMBEROFLIGHTS GL_MAX_LIGHTS 18 18 … … 20 20 class Vector; 21 21 22 //! A struct that holds information about a Light22 //! A class that handles Lights. The LightManager operates on this. 23 23 class Light : public WorldEntity 24 24 { 25 25 public: 26 26 Light(int lightNumber); 27 ~Light(void);27 virtual ~Light(void); 28 28 29 29 void setPosition(Vector position); … … 35 35 void setSpotCutoff(GLfloat cutoff); 36 36 37 Vector getPosition(); 38 /** \returns the lightNumber*/ 39 int getLightNumber(void) {return this->lightNumber;} 40 37 41 virtual void draw(); 38 42 43 void debug(void); 44 39 45 // attributes 40 46 private: 41 47 int lightNumber; //!< The number of this Light. 42 48 GLfloat lightPosition[4]; //!< The Position of this Light. … … 48 54 GLfloat spotDirection[4]; //!< The direction of the Spot Light. 49 55 GLfloat spotCutoff; //!< The cutoff Angle of the Light Source 50 51 void debug(void);52 56 }; 53 57 … … 81 85 void setAmbientColor(GLfloat r, GLfloat g, GLfloat b); 82 86 87 void draw(); 88 83 89 //set Attributes 84 90 void setPosition(Vector position); … … 92 98 // get Attributes 93 99 Vector getPosition(void); 94 /** 95 \returns the Position of Light 96 \param lightNumber lightnumber 97 */ 98 inline Vector getPosition(int lightNumber) 99 { 100 if (!this->lights[lightNumber]) 101 return Vector(.0,.0,.0); 102 return Vector(this->lights[lightNumber]->lightPosition[0], 103 this->lights[lightNumber]->lightPosition[1], 104 this->lights[lightNumber]->lightPosition[2]); 105 } 106 100 Vector getPosition(int lightNumber); 101 107 102 void debug(void); 108 103 }; -
orxonox/trunk/src/story_entities/world.cc
r3597 r3598 300 300 lightMan->setAmbientColor(.1,.1,.1); 301 301 lightMan->addLight(); 302 lightMan->setPosition( 10.0, 30.0, 10.0);303 lightMan->setAttenuation(1.0, 0, 0);302 lightMan->setPosition(-5.0, 10.0, -40.0); 303 lightMan->setAttenuation(1.0, 2, 5); 304 304 lightMan->setDiffuseColor(1,1,1); 305 305 // lightMan->addLight(1); … … 465 465 testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION); 466 466 467 lightMan->draw(); 467 468 } 468 469
Note: See TracChangeset
for help on using the changeset viewer.