Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8455 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 1:12:24 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: fog & changed init & activate fcts from bool to void

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
14 edited

Legend:

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

    r8261 r8455  
    6565
    6666
    67 bool CloudEffect::init()
     67void CloudEffect::init()
    6868{
    6969        PRINTF(1)("Initializing CloudEffect\n");
     
    8484        float bbox[3] = {0};
    8585        cloudModel.GetDimensions(bbox[0], bbox[1], bbox[2]);
    86        
     86
    8787        // Load Shaders
    8888        this->cloudShader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/sky.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/sky.frag");
     
    115115
    116116
    117 bool CloudEffect::activate()
     117void CloudEffect::activate()
    118118{
    119119        PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
     
    122122}
    123123
    124 bool CloudEffect::deactivate()
     124void CloudEffect::deactivate()
    125125{
    126126        PRINTF(0)("Deactivating CloudEffect\n");
     
    133133        if (!this->cloudActivate)
    134134                return;
    135                
     135
    136136        //      glMatrixMode(GL_MODELVIEW);
    137137        //      glPushMatrix();
     
    159159        // glCullFace(GL_BACK);
    160160        // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    161        
     161
    162162        // glLineWidth(3.0f);
    163163
     
    209209
    210210        glPopMatrix();
    211        
     211
    212212}
    213213
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8255 r8455  
    2828                virtual void loadParams(const TiXmlElement* root);
    2929
    30                 virtual bool init();
     30                virtual void init();
    3131
    32                 virtual bool activate();
    33                 virtual bool deactivate();
     32                virtual void activate();
     33                virtual void deactivate();
    3434
    3535                inline void activateCloud() { this->activate(); }
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.cc

    r8445 r8455  
    7171}
    7272
    73 bool FogEffect::init()
    74 {
    75         //default values
    76         this->fogActivate = false;
     73void FogEffect::init()
     74{
     75        // default values
     76        this->fogMode = GL_LINEAR;
     77        this->fogDensity = 0.03;
     78        this->fogStart = 0;
     79        this->fogEnd = 50;
     80        this->colorVector = Vector(0.3, 0.3, 0.3);
     81
     82        // init variables
    7783        this->fogFadeInDuration = 0;
    7884        this->fogFadeOutDuration = 0;
     85        this->fogFadeInDensity = 0;
     86        this->fogFadeOutDensity = 0;
    7987        this->localTimer = 0;
    80        
    81         this->fogMode = GL_LINEAR;
    82         this->fogDensity = 0.05;
    83         this->fogStart = 0;
    84         this->fogEnd = 500;
    85         this->colorVector = Vector(0.3, 0.3, 0.3);
    86 
    87         return 0;
    88 }
    89 
    90 
    91 bool FogEffect::activate()
     88        this->fogActivate = false;
     89        this->fogFadeInActivate = false;
     90        this->fogFadeOutActivate = false;
     91
     92}
     93
     94
     95void FogEffect::activate()
    9296{
    9397        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);
     
    102106        glFogf(GL_FOG_END, this->fogEnd);
    103107
    104         // glFogf(GL_FOG_DENSITY, this->fogDensity);
    105 
     108        if ( this->fogFadeInActivate )
     109                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
     110        else if ( this->fogFadeOutActivate )
     111                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
     112        else
     113                glFogf(GL_FOG_DENSITY, this->fogDensity);
     114               
    106115        glEnable(GL_FOG);
    107116
    108         return 0;
    109 }
    110 
    111 
    112 bool FogEffect::deactivate()
     117}
     118
     119
     120void FogEffect::deactivate()
    113121{
    114122        PRINTF(0)("Deactivating FogEffect\n");
     
    120128        glDisable(GL_FOG);
    121129
    122         return 0;
    123130}
    124131
    125132void FogEffect::draw() const {
    126133
     134        if (!this->fogActivate)
     135                return;
     136
    127137        // If Fog Fade In
    128         if ( this->fogFadeInActivate ) {
     138        if ( this->fogFadeInActivate )
    129139                glFogf(GL_FOG_DENSITY, this->fogFadeInDensity);
    130                 // PRINTF(0)( "this->fogFadeInDensity: %f\n", this->fogFadeInDensity);
    131         }
     140
    132141        // If Fog Fade Out
    133         else if ( this->fogFadeOutActivate )
     142        if ( this->fogFadeOutActivate )
    134143                glFogf(GL_FOG_DENSITY, this->fogFadeOutDensity);
    135 
    136         // Normal Fog activate
    137         else
    138                 glFogf(GL_FOG_DENSITY, this->fogDensity);
    139144
    140145}
     
    147152        if ( this->fogFadeInActivate ) {
    148153                this->localTimer += dt;
    149                 float progress = this->localTimer / this->fogFadeInDuration;
    150                 this->fogFadeInDensity = progress * this->fogDensity;
     154                this->fogFadeInDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity;
    151155
    152156                if ( this->localTimer >= this->fogFadeOutDuration )
    153157                        this->fogFadeInActivate = false;
    154158        }
    155         else if ( this->fogFadeOutActivate ) {
     159
     160        if ( this->fogFadeOutActivate ) {
    156161                this->localTimer += dt;
    157                 float progress = this->localTimer / this->fogFadeInDuration;
    158                 this->fogFadeOutDensity = 1 - progress * this->fogDensity;
     162                this->fogFadeOutDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
    159163
    160164                if ( this->localTimer >= this->fogFadeOutDuration )
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r8443 r8455  
    1818                virtual void loadParams(const TiXmlElement* root);
    1919
    20                 virtual bool init();
     20                virtual void init();
    2121
    22                 virtual bool activate();
    23                 virtual bool deactivate();
     22                virtual void activate();
     23                virtual void deactivate();
    2424
    2525                void activateFog() { this->activate(); }
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc

    r8449 r8455  
    3838{
    3939        this->setClassID(CL_LIGHTENING_EFFECT, "LighteningEffect");
    40  
     40
    4141        this->init();
    4242
     
    7272
    7373
    74 bool LighteningEffect::init()
     74void LighteningEffect::init()
    7575{
    7676        //default values
    7777        this->lighteningActivate = false;
    78        
     78
    7979        this->time = 0.0;
    8080        this->flashFrequency = 4.0f;
     
    8282        this->flashConstTime = 0.1f;
    8383        this->flashRisingTime = 0.03f;
    84        
     84
    8585        this->width = 700.0f;
    8686        this->height = 250.0f;
     
    8989        this->bNewCoordinate = false;
    9090  this->lighteningMove = false;
    91        
     91
    9292        this->seedX = 500.f;
    9393        this->seedZ = 1000.0f;
    9494        this->seedTime = 2.0f;
    95  
     95
    9696  this->mainPosX = 3000;
    9797  this->mainPosY = 900;
    9898  this->mainPosZ = 0;
    99        
     99
    100100        // initialize lightening textures
    101101        this->billboard[0] = new Billboard(NULL);
     
    103103        this->billboard[0]->setSize(this->width, this->height);
    104104        this->billboard[0]->setVisibiliy(false);
    105        
     105
    106106        this->billboard[1] = new Billboard(NULL);
    107107        this->billboard[1]->setTexture("maps/lightning_bolt2.png");
    108108        this->billboard[1]->setSize(this->width, this->height);
    109109        this->billboard[1]->setVisibiliy(false);
    110        
     110
    111111        this->billboard[2] = new Billboard(NULL);
    112112        this->billboard[2]->setTexture("maps/lightning_bolt3.png");
    113113        this->billboard[2]->setSize(this->width, this->height);
    114114        this->billboard[2]->setVisibiliy(false);
    115        
     115
    116116        this->billboard[3] = new Billboard(NULL);
    117117        this->billboard[3]->setTexture("maps/lightning_bolt4.png");
    118118        this->billboard[3]->setSize(this->width, this->height);
    119119        this->billboard[3]->setVisibiliy(false);
    120        
     120
    121121        if (this->lighteningMove) {
    122122                this->cameraCoor = State::getCameraNode()->getAbsCoor();
     
    131131                this->billboard[3]->setAbsCoor(3000,900,0);
    132132        }
    133        
     133
    134134        this->flashLight = new Light();
    135135        this->flashLight->setDiffuseColor(0,0,0);
    136136        this->flashLight->setSpecularColor(0,0,0);
    137        
     137
    138138        /*
    139139        this->soundSource = NULL;
    140140        this->thunderBuffer = NULL;
    141        
     141
    142142        this->soundSource.setSourceNode(this);
    143        
     143
    144144        //load sound
    145145        if (this->thunderBuffer != NULL)
     
    147147        this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
    148148
    149         return 0;
    150149}
    151150
     
    185184
    186185
    187 bool LighteningEffect::activate()
     186void LighteningEffect::activate()
    188187{
    189188        PRINTF(0)( "Activating LighteningEffect\n" );
     
    191190
    192191        this->time = 0;
    193 
    194         return 0;
    195 }
    196 
    197 
    198 bool LighteningEffect::deactivate()
     192}
     193
     194
     195void LighteningEffect::deactivate()
    199196{
    200197        PRINTF(0)("Deactivating LighteningEffect\n");
     
    205202        this->billboard[2]->setVisibiliy(false);
    206203        this->billboard[3]->setVisibiliy(false);
    207 
    208         return 0;
    209204}
    210205
     
    213208        if(!lighteningActivate)
    214209                return;
    215        
     210
    216211        this->time += dt;
    217212
    218213        // TODO: Make random flashing with short light dingsda:)
    219        
     214
    220215        if( this->time > this->flashFrequency) {
    221        
     216
    222217                this->billboard[0]->setVisibiliy(true);
    223218                this->time = 0.0f;
    224        
     219
    225220                this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
    226221
     
    228223                this->flashLight->setDiffuseColor(1,1,1);
    229224                this->flashLight->setSpecularColor(1,1,1);
    230        
     225
    231226                //this->soundSource.play(this->thunderBuffer);
    232227
    233228        } else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime) {
    234        
     229
    235230                this->billboard[3]->setVisibiliy(false);
    236231                this->time = 0.0f;
     
    240235
    241236        }
    242        
     237
    243238        if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime) {
    244        
     239
    245240                this->billboard[2]->setVisibiliy(false);
    246241                this->billboard[3]->setVisibiliy(true);
    247242                // this->flashLight->setDiffuseColor(1,1,1);
    248243                // this->flashLight->setSpecularColor(1,1,1);
    249                
     244
    250245        } else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 ) {
    251        
     246
    252247                this->billboard[1]->setVisibiliy(false);
    253248                this->billboard[2]->setVisibiliy(true);
    254249                //this->flashLight->setDiffuseColor(0,0,0);
    255250                //this->flashLight->setSpecularColor(0,0,0);
    256                
     251
    257252        } else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 ) {
    258        
     253
    259254                this->billboard[0]->setVisibiliy(false);
    260255                this->billboard[1]->setVisibiliy(true);
    261256                //this->flashLight->setDiffuseColor(1,1,1);
    262257                //this->flashLight->setSpecularColor(1,1,1);
    263                
    264         }
    265        
     258
     259        }
     260
    266261        if( this->bNewCoordinate) {
    267262                float posX, posZ;
    268263
    269264                if(this->lighteningMove) {
    270                
     265
    271266                        this->cameraCoor = State::getCameraNode()->getAbsCoor();
    272267                        posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX + this->cameraCoor.x;
     
    274269
    275270                } else {
    276                
     271
    277272                        posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX;
    278273                        posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX;
    279274
    280275                }
    281        
     276
    282277                this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ);
    283278                this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
    284279                this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
    285280                this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
    286                
     281
    287282                this->flashFrequency = this->mainFrequency + this->seedTime * (float)rand()/(float)RAND_MAX;
    288                
     283
    289284                float w = this->width + this->seedWidth * (float)rand()/(float)RAND_MAX;
    290285                float h = this->height + this->seedHeight * (float)rand()/(float)RAND_MAX;
    291                
     286
    292287                this->billboard[0]->setSize(w, h);
    293288                this->billboard[1]->setSize(w, h);
    294289                this->billboard[2]->setSize(w, h);
    295290                this->billboard[3]->setSize(w, h);
    296                
     291
    297292                this->bNewCoordinate = false;
    298293        }
  • branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h

    r8373 r8455  
    2525                virtual void loadParams(const TiXmlElement* root);
    2626
    27                 virtual bool init();
     27                virtual void init();
    2828
    29                 virtual bool activate();
    30                 virtual bool deactivate();
     29                virtual void activate();
     30                virtual void deactivate();
    3131
    32                 inline void activateLightening() { this->activate(); }
    33                 inline void deactivateLightening() { this->deactivate(); }
     32                inline  void activateLightening() { this->activate(); }
     33                inline  void deactivateLightening() { this->deactivate(); }
    3434
    3535                virtual void draw() const;
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8443 r8455  
    105105
    106106
    107 bool RainEffect::init()
     107void RainEffect::init()
    108108{
    109109        //Default values
     
    126126        lightMan = LightManager::getInstance();
    127127        this->rainAmbient = lightMan->getAmbientColor();
    128 
    129         return 0;
    130128}
    131129
     
    133131SparkParticles* RainEffect::rainParticles = NULL;
    134132
    135 bool RainEffect::activate()
     133void RainEffect::activate()
    136134{
    137135        PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" );
     
    168166                lightMan->setAmbientColor(.1,.1,.1);
    169167
    170         return 0;
    171 }
    172 
    173 
    174 bool RainEffect::deactivate()
     168}
     169
     170
     171void RainEffect::deactivate()
    175172{
    176173        PRINTF(0)("Deactivating RainEffect\n");
     
    185182        lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
    186183
    187         return 0;
    188184}
    189185
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8356 r8455  
    3030                virtual void loadParams(const TiXmlElement* root);
    3131
    32                 virtual bool init();
     32                virtual void init();
    3333
    34                 virtual bool activate();
    35                 virtual bool deactivate();
     34                virtual void activate();
     35                virtual void deactivate();
    3636
    3737                inline void activateRain() { this->activate(); }
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.cc

    r8261 r8455  
    7979        LoadParam(root, "size", this, SnowEffect, size);
    8080        LoadParam(root, "coord", this, SnowEffect, coord);
    81  
     81
    8282        LOAD_PARAM_START_CYCLE(root, element);
    8383        {
     
    8787}
    8888
    89 bool SnowEffect::init()
     89void SnowEffect::init()
    9090{
    9191        this->emitter = new PlaneEmitter();
     
    113113}
    114114
    115 bool SnowEffect::activate()
     115void SnowEffect::activate()
    116116{
    117117        PRINTF(0)("Activating SnowEffect\n");
     
    146146
    147147
    148 bool SnowEffect::deactivate()
     148void SnowEffect::deactivate()
    149149{
    150150        PRINTF(0)("Deactivating SnowEffect\n");
     
    171171        /*
    172172        float distance = (State::getCameraNode()->getAbsCoor() - Vector(snowCoord.x, State::getCameraNode()->getAbsCoor().y, snowCoord.z)).len();
    173        
     173
    174174        if(activated)
    175175        {
     
    182182        else if(distance > 0.1*snowSize.x || distance > 0.1*snowSize.y)
    183183        this->alpha = 0.4;
    184        
     184
    185185        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    186186        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     
    197197        else if( distance < 0.1*snowSize.x || distance < 0.1*snowSize.y )
    198198        this->alpha = 0.5;
    199        
     199
    200200        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    201201        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.h

    r8255 r8455  
    2828                virtual void loadParams(const TiXmlElement* root);
    2929
    30                 virtual bool init();
     30                virtual void init();
    3131
    32                 virtual bool activate();
    33                 virtual bool deactivate();
     32                virtual void activate();
     33                virtual void deactivate();
    3434
    3535                inline void activateSnow() { this->activate(); }
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc

    r7810 r8455  
    2929
    3030//#include <GL/glext.h> //OpenGL Extensions
    31 //#include <GL/glxext.h> // GLX Extensions 
     31//#include <GL/glxext.h> // GLX Extensions
    3232
    3333#ifndef GL_EXT_fog_coord
     
    7676}
    7777
    78 bool VolFogEffect::init()
     78void VolFogEffect::init()
    7979{
    8080        PRINTF(0)("Initalize VolFogEffect\n");
     
    9292        // Set fog color
    9393        float fogColor[4] = {0.6f,0.58f,0.79f,0.0f};
    94        
     94
    9595
    9696        glFogCoordfEXT       = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT");
     
    117117
    118118        if (glewGetExtension("GL_EXT_fog_coord"))
    119         {
    120119                PRINTF(0)("GL_EXT_fog_coord extension found\n");
    121                 return true;
    122         }
    123         else
    124         {
    125                 PRINTF(0)("GL_EXT_fog_coord extension NOT found\n");
    126                 return false;
    127         }
    128 }
    129 
    130 
    131 bool VolFogEffect::activate()
     120}
     121
     122
     123void VolFogEffect::activate()
    132124{
    133125        PRINTF(0)("Activating VolFogEffect\n");
    134126}
    135127
    136 bool VolFogEffect::deactivate()
     128void VolFogEffect::deactivate()
    137129{
    138130        PRINTF(0)("Deactivating VolFogEffect\n");
     
    160152        //glEnable(GL_BLEND);
    161153        //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
    162        
     154
    163155        int i;
    164156        glLoadIdentity();
    165157
    166        
     158
    167159        glBegin( GL_LINES );
    168160                glNormal3f(0,1,0);
     
    210202* ticks the effect if there is any time dependancy
    211203*/
    212 void VolFogEffect::tick(float dt)       
    213 {
    214 }
     204void VolFogEffect::tick(float dt)
     205{
     206}
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h

    r7810 r8455  
    1818                virtual void loadParams(const TiXmlElement* root);
    1919
    20                 virtual bool init();
     20                virtual void init();
    2121
    22                 virtual bool activate();
    23                 virtual bool deactivate();
     22                virtual void activate();
     23                virtual void deactivate();
    2424
    2525                virtual void draw() const;
  • branches/atmospheric_engine/src/lib/graphics/effects/weather_effect.cc

    r8255 r8455  
    5555 *  initializes the graphics effect
    5656 */
    57 bool WeatherEffect::init()
     57void WeatherEffect::init()
    5858{}
    5959
  • branches/atmospheric_engine/src/lib/graphics/effects/weather_effect.h

    r7810 r8455  
    1818    virtual void loadParams(const TiXmlElement* root);
    1919
    20     virtual bool init();
     20    virtual void init();
    2121
    22     virtual bool activate() = 0;
    23     virtual bool deactivate() = 0;
     22    virtual void activate();
     23    virtual void deactivate();
    2424
    2525    virtual void draw() const;
    2626    virtual void tick(float dt);
    2727
    28     inline bool isActivated() const { return this->bActivated; }
     28    inline  bool isActivated() const { return this->bActivated; }
    2929
    3030
Note: See TracChangeset for help on using the changeset viewer.