Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3598 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Mar 18, 2005, 12:00:42 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: doxygen-tags

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r3597 r3598  
    2727int lightsV[] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7};
    2828
     29
     30/**
     31   \param lightNumber the Light Number to initiate
     32*/
    2933Light::Light(int lightNumber)
    3034{
     
    4044}
    4145
     46/**
     47   \brief destroys a Light
     48*/
    4249Light::~Light(void)
    4350{
     
    5764  this->lightPosition[3] = 0.0;
    5865
    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.
    6473   \param x the x-coordinate
    6574   \param y the y-coordinate
     
    6877void Light::setPosition(GLfloat x, GLfloat y, GLfloat z)
    6978{
    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
    8084   \param r red
    8185   \param g green
     
    8993  this->diffuseColor[3] = 1.0;
    9094
    91   glLightfv (GL_LIGHT0, GL_DIFFUSE, this->diffuseColor);
    92 }
    93 
    94 /**
    95    \brief sets an emitting Ambient color for the Light
     95  glLightfv (lightsV[this->lightNumber], GL_DIFFUSE, this->diffuseColor);
     96}
     97
     98/**
     99   \brief sets an emitting Specular color of this Light
    96100   \param r red
    97101   \param g green
     
    105109  this->specularColor[3] = 1.0;
    106110
    107   glLightfv (GL_LIGHT0, GL_SPECULAR, this->specularColor);
     111  glLightfv (lightsV[this->lightNumber], GL_SPECULAR, this->specularColor);
    108112}
    109113
    110114/**
    111115   \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
    116119*/
    117120void Light::setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation)
     
    139142}
    140143
    141 
    142144/**
    143145   \brief sets the cutoff angle of the Light.
     
    150152}
    151153
     154/**
     155   \returns the Position of the Light
     156*/
     157Vector 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*/
    152165void Light::draw()
    153166{
     
    156169}
    157170
     171/**
     172   \brief Prints out some nice formated debug information about the Light
     173*/
    158174void Light::debug(void)
    159175{
     
    196212   
    197213   first disables Lighting
    198    then deletes all the lights
     214
    199215   then deletes the rest of the allocated memory
    200216   and in the end sets the singleton Reference to zero.
     
    291307    }
    292308
    293   this->deleteLight(this->currentLight->lightNumber);
     309  this->deleteLight(this->currentLight->getLightNumber());
    294310}
    295311
     
    308324}
    309325
     326/**
     327   \brief draws all the Lights in their appropriate position
     328*/
     329void 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
    310340// set Attributes
    311341/**
     
    325355}
    326356
     357/**
     358   \brief sets The Position of the currently selected Light
     359   \param position the new Position
     360*/
    327361void LightManager::setPosition(Vector position)
    328362{
    329363  this->currentLight->setPosition(position);
    330364}
     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*/
    331372void LightManager::setPosition(GLfloat x, GLfloat y, GLfloat z)
    332373{
    333374  this->currentLight->setPosition(x, y, z);
    334375}
     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*/
    335383void LightManager::setDiffuseColor(GLfloat r, GLfloat g, GLfloat b)
    336384{
    337385  this->currentLight->setDiffuseColor(r,g,b);
    338386}
     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*/
    339394void LightManager::setSpecularColor(GLfloat r, GLfloat g, GLfloat b)
    340395{
    341396  this->currentLight->setSpecularColor(r, g, b);
    342397}
     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*/
    343405void LightManager::setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation)
    344406{
    345407  this->currentLight->setAttenuation(constantAttenuation, linearAttenuation, quadraticAttenuation);
    346408}
     409
     410
     411/**
     412   \brief stets the direction of the Spot Light.
     413   \param direction The direction of the Spot Light.
     414*/
    347415void LightManager::setSpotDirection(Vector direction)
    348416{
    349417  this->currentLight->setSpotDirection(direction);
    350418}
     419
     420/**
     421   \brief sets the cutoff angle of the Light.
     422   \param cutoff The cutoff angle.
     423*/
    351424void LightManager::setSpotCutoff(GLfloat cutoff)
    352425{
     
    366439    }
    367440  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*/
     448Vector 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
    370456
    371457/**
     
    379465  PRINT(0)("Reference: %p\n", LightManager::singletonRef);
    380466  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());
    382468  PRINT(0)("Ambient Color: %f:%f:%f\n", this->ambientColor[0], this->ambientColor[0], this->ambientColor[0]);
    383469  PRINT(0)("=== Lights ===\n");
  • orxonox/trunk/src/light.h

    r3597 r3598  
    1414#include "glincl.h"
    1515
    16 //! The maximum number of Lights this OpenGL-implementation supports
     16//! The maximum number of Lights this OpenGL-implementation supports.
    1717#define NUMBEROFLIGHTS GL_MAX_LIGHTS
    1818
     
    2020class Vector;
    2121
    22 //! A struct that holds information about a Light
     22//! A class that handles Lights. The LightManager operates on this.
    2323class Light : public WorldEntity
    2424{
    2525 public:
    2626  Light(int lightNumber);
    27   ~Light(void);
     27  virtual ~Light(void);
    2828
    2929  void setPosition(Vector position);
     
    3535  void setSpotCutoff(GLfloat cutoff);
    3636
     37  Vector getPosition();
     38  /** \returns the lightNumber*/
     39  int getLightNumber(void) {return this->lightNumber;}
     40 
    3741  virtual void draw();
    3842
     43  void debug(void);
     44
    3945  // attributes
    40 
     46 private:
    4147  int lightNumber;            //!< The number of this Light.
    4248  GLfloat lightPosition[4];   //!< The Position of this Light.
     
    4854  GLfloat spotDirection[4];   //!< The direction of the Spot Light.
    4955  GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
    50 
    51   void debug(void);
    5256};
    5357
     
    8185  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
    8286
     87  void draw();
     88
    8389  //set Attributes
    8490  void setPosition(Vector position);
     
    9298  // get Attributes
    9399  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 
    107102  void debug(void);
    108103};
  • orxonox/trunk/src/story_entities/world.cc

    r3597 r3598  
    300300  lightMan->setAmbientColor(.1,.1,.1);
    301301  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);
    304304  lightMan->setDiffuseColor(1,1,1);
    305305  //  lightMan->addLight(1);
     
    465465  testFont->printText(0, 0, 1, "orxonox_" PACKAGE_VERSION);
    466466
     467  lightMan->draw();
    467468}
    468469
Note: See TracChangeset for help on using the changeset viewer.