Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4735 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Jun 30, 2005, 12:41:19 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: lights loadable

Location:
orxonox/trunk/src/lib/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/light.cc

    r4734 r4735  
    4444};
    4545
    46 
    4746/**
    4847   \param lightNumber the Light Number to initiate
     
    8685  // set values (defaults)
    8786  this->lightNumber = lightNumber;
    88   this->setPosition(0,0,0);
    8987  this->setDiffuseColor(1.0, 1.0, 1.0);
    9088  this->setSpecularColor(1.0, 1.0, 1.0);
     
    110108      .describe("the cuttoff of the Spotlight");
    111109}
    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-coordinate
    134    \param y the y-coordinate
    135    \param z the z-coordinate
    136 */
    137 void Light::setPosition(GLfloat x, GLfloat y, GLfloat z)
    138 {
    139   this->setPosition(Vector(x, y, z));
    140 }
    141 
    142110
    143111/**
     
    215183  glLightf(lightsV[this->lightNumber], GL_SPOT_CUTOFF, cutoff);
    216184}
    217 
    218 
    219 /**
    220    \returns the Position of the Light
    221 */
    222 Vector Light::getPosition() const
    223 {
    224   return Vector(this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);
    225 }
    226 
    227185
    228186/**
     
    251209    PRINT(0)("OFF\n");
    252210
    253   PRINT(0)(" Position:      %f/%f/%f\n", this->lightPosition[0], this->lightPosition[1], this->lightPosition[2]);
    254211  PRINT(0)(" DiffuseColor:  %f/%f/%f\n", this->diffuseColor[0], this->diffuseColor[1], this->diffuseColor[2]);
    255212  PRINT(0)(" SpecularColor: %f/%f/%f\n", this->specularColor[0], this->specularColor[1], this->specularColor[2]);
     
    309266}
    310267
     268/**
     269  \param root the XML-element to load the LightManager's settings from
     270 */
     271void 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 */
     283void 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}
    311294
    312295/**
     
    421404}
    422405
    423 
    424 /**
    425    \brief sets The Position of the currently selected Light
    426    \param position the new Position
    427 */
    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-coordinate
    437    \param y the y-coordinate
    438    \param z the z-coordinate
    439 */
    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 
    451406/**
    452407   \brief sets an emitting Diffuse color of the currently selected Light
     
    528483  this->currentLight->setSpotCutoff(cutoff);
    529484}
    530 
    531 
    532 // get Attributes
    533 /**
    534    \returns the Position of the Light
    535 */
    536 Vector LightManager::getPosition(void) const
    537 {
    538   if (!this->currentLight)
    539     {
    540       PRINTF(2)("no Light defined yet\n");
    541       return Vector(.0, .0, .0);
    542     }
    543   else
    544     return this->currentLight->getPosition();
    545 }
    546 
    547 
    548 /**
    549    \returns the Position of Light
    550    \param lightNumber lightnumber
    551 */
    552 Vector LightManager::getPosition(int lightNumber) const
    553 {
    554   if (!this->lights[lightNumber])
    555     {
    556       PRINTF(2)("no Light defined yet\n");
    557       return Vector(.0,.0,.0);
    558     }
    559   else
    560     return this->lights[lightNumber]->getPosition();
    561 }
    562 
    563485
    564486/**
  • orxonox/trunk/src/lib/graphics/light.h

    r4734 r4735  
    3333  void loadParams(const TiXmlElement* root);
    3434
    35   void setPosition(const Vector& position);
    36   void setPosition(GLfloat x, GLfloat y, GLfloat z);
    37   Vector getPosition() const;
    38 
    3935  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    4036  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     
    5450 private:
    5551  int              lightNumber;               //!< The number of this Light.
    56   GLfloat          lightPosition[4];          //!< The Position of this Light.
    5752  GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
    5853  GLfloat          specularColor[4];          //!< The specular Color of this Light.
     
    115110
    116111  void loadParams(const TiXmlElement* root);
     112  void loadLights(const TiXmlElement* root);
    117113
    118114  // set Attributes
     
    128124
    129125  //set Attributes
    130   void setPosition(Vector position);
    131   void setPosition(GLfloat x, GLfloat y, GLfloat z);
    132126  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    133127  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     
    141135
    142136  Light* getLight(int lightNumber) const;
     137  Light* getLight() const { return this->currentLight; };
    143138
    144139  void debug(void) const;
Note: See TracChangeset for help on using the changeset viewer.