Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/graphics/light.h


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/light.h

    r8255 r9869  
    2525class Light : public PNode
    2626{
    27         public:
    28                 Light(const TiXmlElement* root = NULL);
    29                 virtual ~Light();
    30                
    31                 virtual void loadParams(const TiXmlElement* root);
    32                
    33                 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    34                 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
    35                 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
    36                 void setSpotDirection(const Vector& direction);
    37                 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
    38                 void setSpotCutoff(GLfloat cutoff);
    39                
    40                 /** @returns the lightNumber*/
    41                 int getLightNumber() const {return this->lightNumber;}
    42                
    43                 virtual void draw() const;
    44                
    45                 void debug() const;
    46        
    47         // attributes
    48         private:
    49                 int              lightNumber;               //!< The number of this Light.
    50                 GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
    51                 GLfloat          specularColor[4];          //!< The specular Color of this Light.
    52                 float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
    53                 float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
    54                 float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
    55                 GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
    56                 GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
     27  ObjectListDeclaration(Light);
     28public:
     29  Light(const TiXmlElement* root = NULL);
     30  virtual ~Light();
     31
     32  virtual void loadParams(const TiXmlElement* root);
     33
     34  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     35  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     36  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
     37  void setSpotDirection(const Vector& direction);
     38  void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
     39  void setSpotCutoff(GLfloat cutoff);
     40
     41  /** @returns the lightNumber*/
     42  int getLightNumber() const {return this->lightNumber;}
     43
     44  virtual void draw() const;
     45
     46  void debug() const;
     47
     48  // attributes
     49private:
     50  int              lightNumber;               //!< The number of this Light.
     51  GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
     52  GLfloat          specularColor[4];          //!< The specular Color of this Light.
     53  float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
     54  float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
     55  float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
     56  GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
     57  GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
    5758};
    58        
    59        
    60        
     59
     60
     61
    6162//! A class that handles Lights
    6263/**
     
    8788*/
    8889class LightManager : public BaseObject
    89         {
    90         friend class Light;
     90{
     91  ObjectListDeclaration(LightManager);
    9192
    92         public:
    93                 virtual ~LightManager();
    94                 /** @returns a Pointer to the only object of this Class */
    95                 inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
     93  friend class Light;
     94public:
     95  virtual ~LightManager();
     96  /** @returns a Pointer to the only object of this Class */
     97  inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
    9698
    97                 virtual void loadParams(const TiXmlElement* root);
    98                 void loadLights(const TiXmlElement* root);
     99  virtual void loadParams(const TiXmlElement* root);
     100  void loadLights(const TiXmlElement* root);
    99101
    100                 void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
    101                 // HACK: Assuming r = g = b values
    102                 inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
     102  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     103  // HACK: Assuming r = g = b values
     104inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
    103105
    104                 Light* getLight(int lightNumber) const;
    105                 inline Light* getLight() const { return this->currentLight; };
     106  Light* getLight(int lightNumber) const;
     107  inline Light* getLight() const { return this->currentLight; };
    106108
    107                 void draw() const;
     109  void draw() const;
    108110
    109                 void debug() const;
     111  void debug() const;
    110112
    111         private:
    112                 LightManager();
     113private:
     114  LightManager();
    113115
    114                 int  registerLight(Light* light);
    115                 void unregisterLight(Light* light);
     116  int  registerLight(Light* light);
     117  void unregisterLight(Light* light);
    116118
    117         private:
    118                 static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
    119                 GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
     119private:
     120  static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
     121  GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
    120122
    121                 Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
    122                 Light*                  currentLight;       //!< The current Light, we are working with.
     123  Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
     124  Light*                  currentLight;       //!< The current Light, we are working with.
    123125
    124126};
Note: See TracChangeset for help on using the changeset viewer.