Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8247 in orxonox.OLD


Ignore:
Timestamp:
Jun 8, 2006, 2:55:02 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: fog activate, cleanups

Location:
branches/atmospheric_engine/src/lib/graphics
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc

    r8242 r8247  
    155155
    156156        // glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    157         glShadeModel(GL_SMOOTH);
    158         glEnable(GL_DEPTH_TEST);
    159         glEnable(GL_CULL_FACE);
    160         glCullFace(GL_BACK);
    161         glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    162        
    163         glLineWidth(3.0f);
     157        // glShadeModel(GL_SMOOTH);
     158        // glEnable(GL_DEPTH_TEST);
     159        // glEnable(GL_CULL_FACE);
     160        // glCullFace(GL_BACK);
     161        // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
     162       
     163        // glLineWidth(3.0f);
    164164
    165165        static float time = 0.0f;
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc

    r8023 r8247  
    3838                this->loadParams(root);
    3939
    40   if( this->fogActivate )
    41          this->activate();
     40        if (this->fogActivate)
     41                this->activate();
    4242}
    4343
     
    5757        LoadParam(root, "range", this, FogEffect, setFogRange);
    5858        LoadParam(root, "color", this, FogEffect, setFogColor);
    59   LoadParam(root, "option", this, FogEffect, setFogOption);
     59
     60        LOAD_PARAM_START_CYCLE(root, element);
     61        {
     62                LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption);
     63        }
     64        LOAD_PARAM_END_CYCLE(element);
    6065}
    6166
     
    6368{
    6469        //default values
    65   this->fogActivate = false;
     70        this->fogActivate = false;
    6671        this->fogMode = GL_EXP2;
    6772        this->fogDensity = 0.001;
    6873        this->fogStart = 0;
    6974        this->fogEnd = 5000;
    70   this->colorVector = Vector(0.7, 0.7, 0.7);
     75        this->colorVector = Vector(0.7, 0.7, 0.7);
    7176}
    72 
    7377
    7478
     
    7680{
    7781        PRINTF(0)( "Enabling FogEffect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
     82
     83        this->fogActivate = true;
    7884
    7985        glEnable(GL_FOG);
     
    95101{
    96102        PRINTF(0)("Deactivating FogEffect\n");
     103
     104        this->fogActivate = false;
     105       
    97106        glDisable(GL_FOG);
    98107}
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r8023 r8247  
    2222                virtual bool activate();
    2323                virtual bool deactivate();
    24    
    25     void activateFog() { this->activate(); }
    26     void deactivateFog() { this->deactivate(); }
     24
     25                void activateFog() { this->activate(); }
     26                void deactivateFog() { this->deactivate(); }
    2727
    2828                inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); }
     
    3030                inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
    3131                inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
    32     inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; }
     32                inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; }
    3333
    3434        private:
    3535                GLint stringToFogMode(const std::string& mode);
    3636
    37         private:
    38                 GLint                   fogMode;
    39                 GLfloat                 fogDensity;
    40                 GLfloat                 fogStart;
    41                 GLfloat                 fogEnd;
    42                 Vector                  colorVector;
    43     bool                     fogActivate;
     37                bool                            fogActivate;
     38
     39                GLint                           fogMode;
     40                GLfloat                         fogDensity;
     41                GLfloat                         fogStart;
     42                GLfloat                         fogEnd;
     43                Vector                          colorVector;
    4444};
    4545
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8242 r8247  
    116116
    117117        lightMan = LightManager::getInstance();
     118        this->rainAmbient = lightMan->getAmbientColor();
    118119}
    119120
     
    163164        this->rainActivate = false;
    164165        this->emitter->setSystem(NULL);
     166
     167        // Stop Sound
    165168        this->soundSource.stop();
    166169
    167         lightMan->setAmbientColor(1,1,1);
     170        // Restore Light Ambient
     171        lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
    168172}
    169173
     
    182186                float progress = this->localTimer / this->rainStartDuration;
    183187
    184                 // PRINTF(0)("Progress %f: \n", progress);
     188                // Dim Light
     189                lightMan->setAmbientColor(1.1 - progress, 1.1 - progress, 1.1 - progress);
    185190
    186191                // use alpha in color to fade in
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8180 r8247  
    7878                float                                   soundRainVolume;
    7979
    80                 LightManager* lightMan;
     80                LightManager*                           lightMan;
     81                GLfloat                                 rainAmbient;
     82
    8183};
    8284
  • branches/atmospheric_engine/src/lib/graphics/light.h

    r6512 r8247  
    11/*!
    2  * @file light.h
    3   *  Handles Lights.
     2* @file light.h
     3*  Handles Lights.
    44
    5     A Light is one of the more important things in a 3D-environment,
    6     without it one sees nothing :)
    7     It is here for diffuse-, specular- and Bump-Mappings.
     5A Light is one of the more important things in a 3D-environment,
     6without it one sees nothing :)
     7It is here for diffuse-, specular- and Bump-Mappings.
    88*/
    99
     
    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        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
    5757};
    58 
    59 
    60 
     58       
     59       
     60       
    6161//! A class that handles Lights
    6262/**
    63    A Light is a source that emits light rays (photons)
     63A Light is a source that emits light rays (photons)
    6464
    65    <b>Usage:</b>\n
    66    First you have to get the Light Manager up and running by using LightManager::getInstance().
    67    This automatically initiates the GL_LIGHTING, and sets some default stuff about the light.\n
    68    Then you will create a new light using:
    69    \li new Light();
     65<b>Usage:</b>\n
     66First you have to get the Light Manager up and running by using LightManager::getInstance().
     67This automatically initiates the GL_LIGHTING, and sets some default stuff about the light.\n
     68Then you will create a new light using:
     69\li new Light();
    7070
    71    if you want to operate on this Light just apply the following functions onto it.
    72        (You can also optain the Light-pointer with LightManager::getInstance()->getLight(lightNumber))
     71if you want to operate on this Light just apply the following functions onto it.
     72(You can also optain the Light-pointer with LightManager::getInstance()->getLight(lightNumber))
    7373
    74    now you can operate on the light as follows:
    75    \li void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    76    \li void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
    77    \li void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
    78    \li void setSpotDirection(Vector direction);
    79    \li void setSpotCutoff(GLfloat cutoff);
    80    \li all PNode stuff also works
     74now you can operate on the light as follows:
     75\li void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     76\li void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     77\li void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
     78\li void setSpotDirection(Vector direction);
     79\li void setSpotCutoff(GLfloat cutoff);
     80\li all PNode stuff also works
    8181
    82    To redraw the light use
    83    \li void draw() const; (this is automatically done by the LightManager)
     82To redraw the light use
     83\li void draw() const; (this is automatically done by the LightManager)
    8484
    85    for some nice output just use:
    86    \li void debug() const; (either on LightManager for a resume or on any Light for single information.)
     85for some nice output just use:
     86\li void debug() const; (either on LightManager for a resume or on any Light for single information.)
    8787*/
    8888class LightManager : public BaseObject
    89 {
    90   friend class Light;
     89        {
     90        friend class Light;
    9191
    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; };
     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; };
    9696
    97   virtual void loadParams(const TiXmlElement* root);
    98   void loadLights(const TiXmlElement* root);
     97                virtual void loadParams(const TiXmlElement* root);
     98                void loadLights(const TiXmlElement* root);
    9999
    100   void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     100                void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     101                // HACK: Assuming r = g = b values
     102                inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
    101103
    102   Light* getLight(int lightNumber) const;
    103   inline Light* getLight() const { return this->currentLight; };
     104                Light* getLight(int lightNumber) const;
     105                inline Light* getLight() const { return this->currentLight; };
    104106
    105   void draw() const;
     107                void draw() const;
    106108
    107   void debug() const;
     109                void debug() const;
    108110
    109  private:
    110   LightManager();
     111        private:
     112                LightManager();
    111113
    112   int  registerLight(Light* light);
    113   void unregisterLight(Light* light);
     114                int  registerLight(Light* light);
     115                void unregisterLight(Light* light);
    114116
    115  private:
    116   static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
    117   GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
     117        private:
     118                static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
     119                GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
    118120
    119   Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
    120   Light*                  currentLight;       //!< The current Light, we are working with.
     121                Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
     122                Light*                  currentLight;       //!< The current Light, we are working with.
    121123
    122124};
Note: See TracChangeset for help on using the changeset viewer.