Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2006, 5:20:24 PM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine

File:
1 edited

Legend:

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

    r7572 r7577  
    2828#include "parser/tinyxml/tinyxml.h"
    2929#include <algorithm>
     30#include "box_emitter.h"
     31#include "spark_particles.h"
     32
    3033
    3134using namespace std;
     
    3740  this->setClassID(CL_RAIN_EFFECT, "RainEffect");
    3841
    39 //   this->rainMode = GL_LINEAR;
    40 //   this->rainDensity = 0.001f;
    41 //   this->rainStart = 10.0f;
    42 //   this->rainEnd = 1000.0f;
     42  // BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
     43
     44//         <name>RainEmitter</name>
     45//         <rel-coor>-1200, 300, 0</rel-coor>
     46//         <rel-dir>3.1412, 0, 0, 1</rel-dir>
     47//         <spread>0,.3</spread>
     48//         <emission-velocity>500,50</emission-velocity>
     49//         <size>1000, 1000</size>
     50//         <rate>5000</rate>
     51
     52  this->emitter = new BoxEmitter(Vector(1000, 300, 100), 20000, 1000, M_2_PI);
     53  this->emitter->setRelCoor(100, 0, 0);
     54  // this->emitter->setParent(this);
     55  this->emitter->setSpread(0, 0.3);
    4356
    4457  if (root != NULL)
     
    4861}
    4962
    50 
    51 
    5263RainEffect::~RainEffect()
    5364{
     
    6071  WeatherEffect::loadParams(root);
    6172
    62 //   LoadParam(root, "rain-mode", this, RainEffect, setRainMode);
    63 //   LoadParam(root, "rain-density", this, RainEffect, setRainDensity);
    64 //   LoadParam(root, "rain-color", this, RainEffect, setRainColor);
    65 
     73//   LoadParam(root, "rel-coor", this, RainEffect, setRainMode);
     74//
     75//   LoadParam(root, "rate", this, RainEffect, setRainColor);
     76//   LoadParam(root, "velocity", this, RainEffect, setRainColor);
     77//   LoadParam(root, "angle", this, RainEffect, setRainColor);
     78//
     79//   LoadParam(root, "spread", this, RainEffect, setRainColor);
     80
     81  // BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
     82
     83  this->emitter = new BoxEmitter(Vector(0, 1000, 0), 20000, 4000, 1);
     84  this->emitter->setRelCoor(0, 100, 0);
     85  // this->emitter->setParent(this);
     86  this->emitter->setSpread(0, 0.3);
     87
     88// LOAD_PARAM_START_CYCLE(root, element);
     89//   {
     90//     element->ToText();
     91//     // PER-PARTICLE-ATTRIBUTES:
     92//     LoadParam_CYCLE(element, "radius", this, ParticleSystem, setRadius)
     93//     .describe("The Radius of each particle over time (TimeIndex [0-1], radius at TimeIndex, randomRadius at TimeIndex)");
     94//
     95//     LoadParam_CYCLE(element, "mass", this, ParticleSystem, setMass)
     96//     .describe("The Mass of each particle over time (TimeIndex: [0-1], mass at TimeIndex, randomMass at TimeIndex)");
     97//
     98//     LoadParam_CYCLE(element, "color", this, ParticleSystem, setColor)
     99//     .describe("The Color of each particle over time (TimeIndex: [0-1], red: [0-1], green: [0-1], blue: [0-1], alpha: [0-1])");
     100//   }
     101//   LOAD_PARAM_END_CYCLE(element);
    66102
    67103}
     
    70106{}
    71107
    72 
     108SparkParticles* RainEffect::rainParticles = NULL;
    73109
    74110bool RainEffect::activate()
    75111{
    76   PRINTF(0)("Activating Rain Effect\n");
     112//   PRINTF(0)( "Enabling Rain Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->rainMode, this->rainDensity, this->rainStart, this->rainEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
     113        PRINTF(0)("Activating Rain Effect\n");
     114
     115        if (unlikely(RainEffect::rainParticles == NULL))
     116        {
     117                RainEffect::rainParticles = new SparkParticles(10000);
     118                RainEffect::rainParticles->setName("RainParticles");
     119                RainEffect::rainParticles->setLifeSpan(2, 2);
     120                RainEffect::rainParticles->setRadius(0.05, 0.05);
     121                RainEffect::rainParticles->setRadius(0.04, 0.04);
     122                RainEffect::rainParticles->setRadius(0.03, 0.03);
     123                RainEffect::rainParticles->setColor(0, 0, 0, 1, .3);
     124                RainEffect::rainParticles->setColor(0.5, 0.5, 0.5, 1, 0.2);
     125                RainEffect::rainParticles->setColor(0.8, 0.8, 0.2, 0.3, 0.3);
     126                RainEffect::rainParticles->setColor(1, 0.5, 0.5, 1, 0);
     127
     128//      <life-span>2,2</life-span>
     129//      <radius>0, 0.05, 0.05</radius>
     130//      <radius>1, 0.05, 0.05</radius>
     131//      <mass>0,1, .05</mass>
     132//      <color>0, 0, 0, 1, .3</color>
     133//      <color>.5, .5, .5, 1, .2</color>
     134//      <color>1,0.5, .5,1, .0</color>
     135//      <precache>2</precache>
     136//      <emitters>
     137//       <PlaneEmitter>
     138
     139//       </PlaneEmitter>
     140//      </emitters>
     141
     142        }
     143
     144        this->emitter->setSystem(RainEffect::rainParticles);
     145//      this->size = 4.0;
     146
     147        RainEffect::rainParticles->debug();
     148//      this->updateNode(0);
     149        this->emitter->setEmissionRate(5000.0);
     150        this->emitter->setEmissionVelocity(50.0);
     151
     152//      this->setHealth(200);
     153
    77154}
    78155
     
    81158{
    82159  PRINTF(0)("Deactivating Rain Effect\n");
    83 //      glDisable(GL_RAIN);
     160
     161  this->emitter->setSystem(NULL);
     162 // this->lifeCycle = 0.0;
     163 // this->toList(OM_NULL);
     164
     165//  GarbageCollector::getInstance()->collect(this);
     166//  this->toList(OM_DEAD);
     167
    84168}
    85169
Note: See TracChangeset for help on using the changeset viewer.