Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2006, 6:41:58 PM (19 years ago)
Author:
amaechler
Message:

branches/atmosphere_engine: cosmetics2

File:
1 edited

Legend:

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

    r7646 r7652  
    2020
    2121#include "glincl.h"
    22 // #include "debug.h"
    23 
     22#include "p_node.h"
    2423#include "state.h"
    2524#include "spark_particles.h"
     
    3736RainEffect::RainEffect(const TiXmlElement* root)
    3837{
    39   this->setClassID(CL_RAIN_EFFECT, "RainEffect");
     38        this->setClassID(CL_RAIN_EFFECT, "RainEffect");
    4039
    41   if (root != NULL)
    42     this->loadParams(root);
     40        this->init();
    4341
    44   // this->soundSource.setSourceNode(this);
     42        if (root != NULL)
     43                this->loadParams(root);
    4544
    46   //load sound
    47   if (this->rainBuffer != NULL)
    48     ResourceManager::getInstance()->unload(this->rainBuffer);
    49   this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
     45        //load sound
     46        if (this->rainBuffer != NULL)
     47                ResourceManager::getInstance()->unload(this->rainBuffer);
     48        this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    5049
    51   this->init();
    52 
    53   this->activate();
     50        this->activate();
    5451}
    5552
    5653RainEffect::~RainEffect()
    5754{
    58   this->deactivate();
     55        this->deactivate();
    5956}
    6057
     
    6360        WeatherEffect::loadParams(root);
    6461
     62        LoadParam(root, "moverain", this, RainEffect, setMoveRain);
    6563        LoadParam(root, "coord", this, RainEffect, setRainCoord);
    6664        LoadParam(root, "size", this, RainEffect, setRainSize);
    6765        LoadParam(root, "rate", this, RainEffect, setRainRate);
    6866        LoadParam(root, "velocity", this, RainEffect, setRainVelocity);
     67        LoadParam(root, "life", this, RainEffect, setRainLife);
    6968}
    7069
     
    7271bool RainEffect::init()
    7372{
    74   this->emitter = new PlaneEmitter(this->rainSize);
     73        //Default values
     74        this->rainCoord = Vector(500, 500, 500);
     75        this->rainSize = Vector2D(1000, 1000);
     76        this->rainRate = 5000;
     77        this->rainVelocity = -300;
     78        this->rainLife = 2;
    7579
     80        this->emitter = new PlaneEmitter(this->rainSize);
    7681}
    7782
     
    8186bool RainEffect::activate()
    8287{
    83         PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity );
     88        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" );
    8489
    8590        if (unlikely(RainEffect::rainParticles == NULL))
    8691        {
    87                 RainEffect::rainParticles = new SparkParticles(10000);
     92                RainEffect::rainParticles = new SparkParticles(50000);
    8893                RainEffect::rainParticles->setName("RainParticles");
    89                 RainEffect::rainParticles->setLifeSpan(2, 2);
     94                RainEffect::rainParticles->setLifeSpan(this->rainLife, 2);
    9095                RainEffect::rainParticles->setRadius(0.02, 0.02);
    9196                RainEffect::rainParticles->setRadius(0.01, 0.01);
     
    98103
    99104        this->emitter->setSystem(RainEffect::rainParticles);
    100 
    101         // RainEffect::rainParticles->debug();
    102105
    103106        this->emitter->setRelCoor(this->rainCoord);
     
    115118bool RainEffect::deactivate()
    116119{
    117   PRINTF(0)("Deactivating RainEffect\n");
     120        PRINTF(0)("Deactivating RainEffect\n");
    118121
    119   this->emitter->setSystem(NULL);
     122        this->emitter->setSystem(NULL);
    120123}
    121124
    122125void RainEffect::tick (float dt)
    123126{
     127        //float distance = (State::getCameraNode()->getAbsCoor() - rainCoord).len();
     128       
     129        // PRINTF(0)( "RainEffect, coords: %f, %f, %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z );
    124130
     131        //if (this->rainMove) {
     132                //PRINTF(0)( "Moving Rain" );
     133        //      this->rainCoord = State::getCameraNode()->getAbsCoor();
     134        //      this->emitter->setRelCoor(this->rainCoord.x +150, this->rainCoord.y+700, this->rainCoord.z+150);
     135        //}
    125136}
Note: See TracChangeset for help on using the changeset viewer.