Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3441 in orxonox.OLD


Ignore:
Timestamp:
Mar 1, 2005, 9:24:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented attenuation

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r3440 r3441  
    250250
    251251/**
     252   \brief Sets the AttenuationType of this Light Source
     253   \param type the AttenuationType to set
     254   \param factor the Factor to multipy the attenuation with
     255
     256   this actually just sets the following: glLightf(currentLight, type, factor)
     257*/
     258void Light::setAttenuation(AttenuationType type, float factor)
     259{
     260  if (!this->currentLight)
     261    {
     262      PRINTF(1)("no Light defined yet\n");
     263      return;
     264    }
     265  this->currentLight->attenuationFactor = factor;
     266  this->currentLight->attenuationType = type;
     267  switch (type)
     268    {
     269    case CONSTANT:
     270      glLightf(lightsV[this->currentLight->lightNumber], GL_CONSTANT_ATTENUATION, factor);
     271      break;
     272    case LINEAR:
     273      glLightf(lightsV[this->currentLight->lightNumber], GL_LINEAR_ATTENUATION, factor);
     274      break;
     275    case QUADRATIC:
     276      glLightf(lightsV[this->currentLight->lightNumber], GL_QUADRATIC_ATTENUATION, factor);
     277      break;
     278    }
     279}
     280
     281
     282/**
    252283   \brief sets the ambient Color of the Scene
    253284   \param r red
     
    263294
    264295  glLightfv (GL_LIGHT0, GL_AMBIENT, this->ambientColor);
    265 
    266296}
    267297
  • orxonox/trunk/src/light.h

    r3440 r3441  
    1515
    1616#define NUMBEROFLIGHTS GL_MAX_LIGHTS
     17
     18enum AttenuationType {CONSTANT, LINEAR, QUADRATIC};
    1719
    1820// FORWARD DEFINITIONS //
     
    3436    GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
    3537    GLfloat specularColor[4];   //!< The specular Color of this Light.
    36     GLint attenuationType;      //!< The AttenuationType of this Light. \todo implements this;
     38    AttenuationType attenuationType;//!< The AttenuationType of this Light.
     39    float attenuationFactor;    //!< the Factor the attenuation should have.
    3740
    3841    LightValue* next;
     
    6467  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    6568  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     69  void setAttenuation(AttenuationType type, float factor);
    6670  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
    6771  // get Attributes
  • orxonox/trunk/src/world.cc

    r3440 r3441  
    174174  light = Light::getInstance();
    175175  light->addLight(0);
    176   light->setPosition(10.0, 10.0, 19.0);
     176  light->setAttenuation(QUADRATIC, 1.0);
     177  light->setPosition(10.0, 100.0, 19.0);
    177178
    178179  //  BezierCurve* tmpCurve = new BezierCurve();
Note: See TracChangeset for help on using the changeset viewer.