Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8119 in orxonox.OLD


Ignore:
Timestamp:
Jun 2, 2006, 12:16:09 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: added function to slowly start rain

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

Legend:

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

    r8084 r8119  
    5757bool CloudEffect::init()
    5858{
    59   PRINTF(1)("Initializing CloudEffect\n");
     59        PRINTF(1)("Initializing CloudEffect\n");
    6060
    61   this->sphereObj = gluNewQuadric();
    62   //this->setParentMode(PNODE_MOVEMENT);
     61        this->sphereObj = gluNewQuadric();
     62        //this->setParentMode(PNODE_MOVEMENT);
    6363
    64   gluQuadricTexture(this->sphereObj, GL_TRUE);
    65   gluQuadricOrientation(this->sphereObj, GLU_INSIDE);
     64        gluQuadricTexture(this->sphereObj, GL_TRUE);
     65        gluQuadricOrientation(this->sphereObj, GLU_INSIDE);
    6666
     67        this->setRadius(1900.0);
    6768
    68   this->setRadius(1900.0);
     69        mover = 0.0f;
    6970
    70   mover = 0.0f;
    71 
    72   // Initializing default values
    73   this->cloudSpeed = 1.0f;
     71        // Initializing default values
     72        this->cloudSpeed = 1.0f;
    7473        this->cloudTexture = "pictures/sky/cloud1.jpg";
    7574}
     
    9089
    9190        this->cloudMaterial = new Material("Sky");
    92   this->cloudMaterial->setIllum(3);
    93   this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
    94   this->cloudMaterial->setDiffuseMap(this->cloudTexture);
     91        this->cloudMaterial->setIllum(3);
     92        this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
     93        this->cloudMaterial->setDiffuseMap(this->cloudTexture);
    9594}
    9695
     
    108107        */
    109108
    110   glMatrixMode(GL_MODELVIEW);
    111   glPushMatrix();
     109        glMatrixMode(GL_MODELVIEW);
     110        glPushMatrix();
    112111
    113   // Move sphere along with the camera
    114   Vector r = State::getCameraNode()->getAbsCoor();
    115   glTranslatef(r.x, r.y, r.z);
     112        // Move sphere along with the camera
     113        Vector r = State::getCameraNode()->getAbsCoor();
     114        glTranslatef(r.x, r.y, r.z);
    116115
    117116        // Sky movement
    118117        glRotatef(mover, 0, 0, 1);
    119118
    120   cloudMaterial->select();
    121   gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
    122   glPopMatrix();
     119        cloudMaterial->select();
     120        gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
     121        glPopMatrix();
    123122}
    124123
    125124void CloudEffect::tick (float dt)
    126125{
    127   mover = mover + this->cloudSpeed * dt;
     126        mover = mover + this->cloudSpeed * dt;
    128127}
    129128
    130129
    131130/**
    132  *  sets the Radius of the Sphere.
    133  * @param radius The Radius of The Sphere
     131*  sets the Radius of the Sphere.
     132* @param radius The Radius of The Sphere
    134133*/
    135134void CloudEffect::setRadius(float radius)
    136135{
    137   this->sphereRadius = radius;
     136        this->sphereRadius = radius;
    138137}
    139138
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8079 r8119  
    4040                void initialize(char* fileName);
    4141
    42                 GLUquadricObj*                  sphereObj;                                                      // A Placeholder for the SkySphere.
    43                 Material*                                               cloudMaterial;                                  // A Material for the SkySphere.
    44                 float                                                           sphereRadius;                                           // Radius of the SkySphere.
    45                 float                                                   mover;
    46                 float                                                           cloudSpeed;
    47                 std::string                             cloudTexture;
     42                GLUquadricObj*                  sphereObj;              // A Placeholder for the Sphere.
     43                Material*                       cloudMaterial;          // A Material for the Sphere.
     44                float                           sphereRadius;           // Radius of the Sphere.
     45
     46                float                           mover;
     47                float                           cloudSpeed;
     48                std::string                     cloudTexture;
    4849
    4950                inline void setCloudTexture(const std::string& file) { this->cloudTexture = file; }
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r8074 r8119  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4Copyright (C) 2004 orx
    55
    6    This program is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 2, or (at your option)
    9    any later version.
     6This program is free software; you can redistribute it and/or modify
     7it under the terms of the GNU General Public License as published by
     8the Free Software Foundation; either version 2, or (at your option)
     9any later version.
    1010
    1111### File Specific:
    12    main-programmer: hdavid, amaechler
     12main-programmer: hdavid, amaechler
    1313*/
    1414
     
    3131SHELL_COMMAND(activate, RainEffect, activateRain);
    3232SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
     33
     34SHELL_COMMAND(startRaining, RainEffect, startRaining);
    3335
    3436using namespace std;
     
    5961        }
    6062
    61   if(rainActivate)
    62          this->activate();
     63        if(rainActivate)
     64                this->activate();
    6365}
    6466
     
    8486        LoadParam(root, "life", this, RainEffect, setRainLife);
    8587        LoadParam(root, "wind", this, RainEffect, setRainWind);
    86  
    87   LOAD_PARAM_START_CYCLE(root, element);
    88   {
    89     LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption);
    90   }
    91   LOAD_PARAM_END_CYCLE(element);
    92  
     88
     89        LOAD_PARAM_START_CYCLE(root, element);
     90        {
     91                LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption);
     92        }
     93        LOAD_PARAM_END_CYCLE(element);
     94
    9395}
    9496
     
    9799{
    98100        //Default values
    99   this->rainActivate = false;
    100   this->rainMove = false;
     101        this->rainActivate = false;
     102        this->rainMove = false;
    101103        this->rainCoord = Vector(500, 500, 500);
    102104        this->rainSize = Vector2D(1000, 1000);
     
    108110
    109111        this->emitter = new PlaneEmitter(this->rainSize);
    110  
    111   lightMan = LightManager::getInstance();
     112
     113        lightMan = LightManager::getInstance();
    112114}
    113115
     
    145147        if (this->rainWindForce > 0)
    146148                this->soundSource.loop(this->windBuffer, 0.5f);
    147  
    148   lightMan->setAmbientColor(.1,.1,.1);
     149
     150        lightMan->setAmbientColor(.1,.1,.1);
    149151}
    150152
     
    156158
    157159        this->soundSource.stop();
    158  
    159   lightMan->setAmbientColor(1,1,1);
     160
     161        lightMan->setAmbientColor(1,1,1);
    160162}
    161163
     
    167169        }
    168170}
     171
     172/**
     173*  Slowly starts rain
     174*  @param duration duration of the fade in process in seconds
     175*/
     176void RainEffect::startRaining(float duration)
     177{
     178        // use alpha in color to fade in
     179        // increase radius for more "heavy" rain
     180        // increase sound volume
     181}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r8074 r8119  
    3535                virtual bool deactivate();
    3636
    37     void activateRain() { this->activate(); }
    38     void deactivateRain() { this->deactivate(); }
     37                virtual void tick(float dt);
    3938
    40                 virtual void tick(float dt);
     39                inline void activateRain() { this->activate(); }
     40                inline void deactivateRain() { this->deactivate(); }
    4141
    4242                inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
     
    4646                inline void setRainLife(float life) { this->rainLife = life; }
    4747                inline void setRainWind(int force) { this->rainWindForce = force; }
    48                 inline void setRainOption(const std::string& option) { if (option == "moverain") this->rainMove = true;
    49                                                                                 if (option == "activate") this->rainActivate = true; }
     48                inline void setRainOption(const std::string& option) {
     49                        if (option == "moverain") this->rainMove = true;
     50                        if (option == "activate") this->rainActivate = true;
     51                }
    5052
     53                void startRaining(float duration);
    5154
    5255        private:
    53                 static SparkParticles*                                          rainParticles;
    54                 ParticleEmitter*                                                                        emitter;
     56                static SparkParticles*                  rainParticles;
     57                ParticleEmitter*                        emitter;
    5558
    56                 Vector                                                                                                          rainCoord;
    57                 Vector2D                                                                                                        rainSize;
    58                 GLfloat                                                                                                         rainRate;
    59                 GLfloat                                                                                                         rainVelocity;
    60                 GLfloat                                                                                                         rainLife;
    61                 GLfloat                                                                                                         rainMaxParticles;
    62                 int                                                                                                                             rainWindForce;
    63                 bool                                                                                                                    rainMove;
    64     bool                              rainActivate;
     59                Vector                                  rainCoord;
     60                Vector2D                                rainSize;
     61                GLfloat                                 rainRate;
     62                GLfloat                                 rainVelocity;
     63                GLfloat                                 rainLife;
     64                GLfloat                                 rainMaxParticles;
     65                int                                     rainWindForce;
     66                bool                                    rainMove;
     67                bool                                    rainActivate;
    6568
    6669                OrxSound::SoundSource                   soundSource;
    6770                OrxSound::SoundBuffer*                  rainBuffer;
    6871                OrxSound::SoundBuffer*                  windBuffer;
    69    
    70     LightManager* lightMan;
     72
     73                LightManager* lightMan;
    7174};
    7275
    73 
    7476#endif  /* _RAIN_EFFECT */
Note: See TracChangeset for help on using the changeset viewer.