Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3597 in orxonox.OLD for orxonox/trunk/src/light.h


Ignore:
Timestamp:
Mar 17, 2005, 11:04:59 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: Light is now a World-entity.

File:
1 edited

Legend:

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

    r3588 r3597  
    1717#define NUMBEROFLIGHTS GL_MAX_LIGHTS
    1818
    19 //! Enumerator for the attenuation-Type.
    20 /**
    21    CONSTANT means GL_CONSTANT_ATTENUATION
    22    LINEAR means   GL_LINEAR_ATTENUATION
    23    QUADRATIC means GL_QUADRATIC_ATTENUATION
    24 */
    25 enum AttenuationType {CONSTANT, LINEAR, QUADRATIC};
    26 
    2719// FORWARD DEFINITIONS //
    2820class Vector;
     21
     22//! A struct that holds information about a Light
     23class Light : public WorldEntity
     24{
     25 public:
     26  Light(int lightNumber);
     27  ~Light(void);
     28
     29  void setPosition(Vector position);
     30  void setPosition(GLfloat x, GLfloat y, GLfloat z);
     31  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     32  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     33  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
     34  void setSpotDirection(Vector direction);
     35  void setSpotCutoff(GLfloat cutoff);
     36
     37  virtual void draw();
     38
     39  // attributes
     40
     41  int lightNumber;            //!< The number of this Light.
     42  GLfloat lightPosition[4];   //!< The Position of this Light.
     43  GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
     44  GLfloat specularColor[4];   //!< The specular Color of this Light.
     45  float constantAttenuation;  //!< The Factor of the the Constant Attenuation.
     46  float linearAttenuation;    //!< The Factor of the the Linear Attenuation.
     47  float quadraticAttenuation; //!< The Factor of the the Quadratic Attenuation.
     48  GLfloat spotDirection[4];   //!< The direction of the Spot Light.
     49  GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
     50
     51  void debug(void);
     52};
    2953
    3054//! A class that handles Lights
     
    3256   A Light is a source that emits light rays (photons)
    3357*/
    34 class Light : public BaseObject
     58class LightManager : public BaseObject
    3559{
    3660 private:
    37   //! A struct that holds information about a Light
    38   struct LightValue
    39   {
    40     int lightNumber;            //!< The number of this Light.
    41     GLfloat lightPosition[4];   //!< The Position of this Light.
    42     GLfloat diffuseColor[4];    //!< The Diffuse Color this Light emmits.
    43     GLfloat specularColor[4];   //!< The specular Color of this Light.
    44     AttenuationType attenuationType;//!< The AttenuationType of this Light.
    45     float attenuationFactor;    //!< The Factor the attenuation should have.
    46     GLfloat spotDirection[4];   //!< The direction of the Spot Light.
    47     GLfloat spotCutoff;         //!< The cutoff Angle of the Light Source
    48   };
    49 
    50   static Light* singletonRef;    //!< This is the LightHandlers Reference.
     61  LightManager(void);
     62  void initLight(int LightNumber);
     63 
     64  static LightManager* singletonRef;    //!< This is the LightHandlers Reference.
    5165  GLfloat ambientColor[4];       //!< The ambient Color of the scene.
    5266
    53 
    54   Light(void);
    55 
    56   void init(int LightNumber); 
    57   LightValue** lights;           //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
    58   LightValue* currentLight;      //!< The current Light, we are working with.
     67  Light** lights;                //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
     68  Light* currentLight;           //!< The current Light, we are working with.
    5969 
    6070 public:
    61   static Light* getInstance();
    62   virtual ~Light(void);
     71  static LightManager* getInstance();
     72  virtual ~LightManager(void);
    6373
    6474  // set Attributes
     
    6979  void deleteLight(int lightNumber);
    7080
     81  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     82
     83  //set Attributes
    7184  void setPosition(Vector position);
    7285  void setPosition(GLfloat x, GLfloat y, GLfloat z);
    7386  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    7487  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
    75   void setAttenuation(AttenuationType type, float factor);
    76   void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     88  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
    7789  void setSpotDirection(Vector direction);
    7890  void setSpotCutoff(GLfloat cutoff);
Note: See TracChangeset for help on using the changeset viewer.