Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7649 in orxonox.OLD for branches/atmospheric_engine


Ignore:
Timestamp:
May 17, 2006, 2:24:13 PM (19 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: work on the snow effect

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

Legend:

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

    r7628 r7649  
    2424#include "sprite_particles.h"
    2525#include "plane_emitter.h"
     26#include "shell_command.h"
    2627
    2728#include "parser/tinyxml/tinyxml.h"
    2829
    29 //SHELL_COMMAND(activate, SnowEffect, activateSnow);
     30SHELL_COMMAND(activate, SnowEffect, activateSnow);
     31SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow);
    3032
    3133using namespace std;
     
    3739  this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
    3840
     41  this->init();
     42 
    3943  if (root != NULL)
    4044    this->loadParams(root);
    4145
    42   this->init();
    43 
    4446  this->activate();
    4547}
     
    5759  WeatherEffect::loadParams(root);
    5860
    59 //   LoadParam(root, "snow-mode", this, SnowEffect, setSnowMode);
    60 //   LoadParam(root, "snow-density", this, SnowEffect, setSnowDensity);
    61 //   LoadParam(root, "snow-color", this, SnowEffect, setSnowColor);
    62 
    63 
     61   LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     62   LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     63   LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     64   LoadParam(root, "radius", this, SnowEffect, radius);
     65   LoadParam(root, "mass", this, SnowEffect, mass);
     66   LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     67   LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     68   LoadParam(root, "spread", this, SnowEffect, spread);
     69   LoadParam(root, "size", this, SnowEffect, size);
     70   LoadParam(root, "coord", this, SnowEffect, coord);
    6471}
    6572
     
    6774{
    6875  this->emitter = new PlaneEmitter();
     76 
     77  // Default values
     78  particles = 10000;
     79  texture = "maps/snow_flake_01_32x32.png";
     80  life = 8;
     81  randomLife = 2;
     82  snowRadius = 3.5;
     83  randomRadius = 1;
     84  snowMass = 1.0;
     85  randomMass = 0.3;
     86  rate = 900;
     87  velocity = -200;
     88  randomVelocity = 0;
     89  angle = 0;
     90  randomAngle = 0.3;
     91  snowSize = Vector2D(1200, 1200);
     92  snowCoord = Vector(100, 600, 200);
    6993}
    7094
     
    7599  PRINTF(0)("Activating SnowEffect\n");
    76100 
    77   SnowEffect::snowParticles = new SpriteParticles(10000);
     101  SnowEffect::snowParticles = new SpriteParticles(particles);
    78102  SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    79   SnowEffect::snowParticles->setMaterialTexture("maps/snow_flake_01_32x32.png");
    80   //SnowEffect::snowParticles->setSize(1);
    81   SnowEffect::snowParticles->setLifeSpan(8, 2);
    82   SnowEffect::snowParticles->setRadius(0.0, 5.0, 10.0);
    83   SnowEffect::snowParticles->setRadius(0.2, 5.0, 10);
    84   SnowEffect::snowParticles->setRadius(1.0, 5.0, 10);
    85   SnowEffect::snowParticles->setMass(0, 1.0, .3);
     103  SnowEffect::snowParticles->setMaterialTexture(texture);
     104  SnowEffect::snowParticles->setLifeSpan(life, randomLife);
     105  SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     106  SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius);
     107  SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius);
     108  SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    86109  SnowEffect::snowParticles->setColor(0,1, 1, 1,.5);
    87110  SnowEffect::snowParticles->setColor(.5, .6, .6, .6, .2);
     
    92115 
    93116 // this->updateNode(0);
    94   this->emitter->setEmissionRate(900);
    95   this->emitter->setEmissionVelocity(150, 50);
    96   this->emitter->setSpread(0, .3);
    97   this->emitter->setSize(1200, 1200);
     117  this->emitter->setRelCoor(snowCoord);
     118  this->emitter->setEmissionRate(rate);
     119  this->emitter->setEmissionVelocity(velocity, randomVelocity);
     120  this->emitter->setSpread(angle, randomAngle);
     121  this->emitter->setSize(snowSize);
    98122}
    99123
     
    106130}
    107131
     132void SnowEffect::activateSnow()
     133{
     134  this->activate();
     135}
     136
     137void SnowEffect::deactivateSnow()
     138{
     139  this->deactivate();
     140}
     141
    108142void SnowEffect::draw() const
    109143{
     
    113147{
    114148}
     149
     150void SnowEffect::numParticles(int n)
     151{
     152  this->particles = n;
     153}
     154
     155void SnowEffect::materialTexture(const std::string& texture)
     156{
     157  this->texture = texture;
     158}
     159
     160void SnowEffect::lifeSpan(float lifeSpan, float randomLifeSpan)
     161{
     162  this->life = lifeSpan;
     163  this->randomLife = randomLifeSpan;
     164}
     165
     166void SnowEffect::radius(float radius, float randomRadius)
     167{
     168  this->snowRadius = radius;
     169  this->randomRadius = randomRadius;
     170}
     171
     172void SnowEffect::mass(float mass, float randomMass)
     173{
     174  this->snowMass = mass;
     175  this->randomMass = randomMass;
     176}
     177
     178void SnowEffect::emissionRate(float emissionRate)
     179{
     180  this->rate = emissionRate;
     181}
     182
     183void SnowEffect::emissionVelocity(float velocity, float randomVelocity)
     184{
     185  this->velocity = velocity;
     186  this->randomVelocity = randomVelocity;
     187}
     188
     189void SnowEffect::spread(float angle, float randomAngle)
     190{
     191  this->angle = angle;
     192  this->randomAngle = randomAngle;
     193}
     194
     195void SnowEffect::size(float sizeX, float sizeY)
     196{
     197  this->snowSize = Vector2D(sizeX, sizeY);
     198}
     199
     200void SnowEffect::coord( float coorX, float coorY, float coorZ)
     201{
     202  this->snowCoord = Vector(coorX, coorY, coorZ);
     203}
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.h

    r7576 r7649  
    3131    virtual void draw() const;
    3232    virtual void tick(float dt);
     33
     34    void activateSnow();
     35    void deactivateSnow();
    3336   
    34     void activateSnow();
     37  private:
     38    void numParticles(int n);
     39    void materialTexture(const std::string& texture);
     40    void lifeSpan(float lifeSpan, float randomLifeSpan);
     41    void radius(float radius, float randomRadius);
     42    void mass(float mass, float randomMass);
     43    void emissionRate(float emissionRate);
     44    void emissionVelocity(float velocity, float randomVelocity);
     45    void spread(float angle, float randomAngle);
     46    void size(float sizeX, float sizeY);
     47    void coord(float xCoor, float yCoor, float zCoor);
     48   
     49    int particles;
     50    std::string texture;
     51    float life, randomLife;
     52    float snowRadius, randomRadius;
     53    float snowMass, randomMass;
     54    float rate;
     55    float velocity, randomVelocity;
     56    float angle, randomAngle;
     57    Vector snowCoord;
     58    Vector2D snowSize;
    3559
    36 //     inline void setSnowMode(const std::string& mode) { this->snowMode = this->stringToSnowMode(mode); }
    37 //     inline void setSnowDensity(float density) { this->snowDensity = density; }
    38 //     inline void setSnowRange(float start, float end) { this->snowStart = start; this->snowEnd = end; }
    39 //     inline void setSnowColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
    40   private:
    41 //     GLint                    snowMode;
    42 //     GLfloat                 snowDensity;
    43 //     GLfloat                 snowStart;
    44 //     GLfloat                 snowEnd;
    45 //     Vector                  colorVector;
    4660    static SpriteParticles* snowParticles;
    4761   
Note: See TracChangeset for help on using the changeset viewer.