Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

branches/atmosphere_engine: cosmetics2

File:
1 edited

Legend:

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

    r7651 r7652  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2        orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4        Copyright (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.
     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.
    1010
    1111### File Specific:
    12    main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    3838SnowEffect::SnowEffect(const TiXmlElement* root)
    3939{
    40   this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
     40        this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
    4141
    42   this->init();
     42        this->init();
    4343
    44   if (root != NULL)
    45     this->loadParams(root);
     44        if (root != NULL)
     45                this->loadParams(root);
    4646
    47   this->activate();
     47        this->activate();
    4848}
    4949
     
    5151SnowEffect::~SnowEffect()
    5252{
    53   this->deactivate();
     53        this->deactivate();
    5454}
    5555
     
    5858void SnowEffect::loadParams(const TiXmlElement* root)
    5959{
    60   WeatherEffect::loadParams(root);
     60        WeatherEffect::loadParams(root);
    6161
    62   LoadParam(root, "numParticles", this, SnowEffect, numParticles);
    63   LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
    64   LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
    65   LoadParam(root, "radius", this, SnowEffect, radius);
    66   LoadParam(root, "mass", this, SnowEffect, mass);
    67   LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
    68   LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
    69   LoadParam(root, "spread", this, SnowEffect, spread);
    70   LoadParam(root, "size", this, SnowEffect, size);
    71   LoadParam(root, "coord", this, SnowEffect, coord);
     62        LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     63        LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     64        LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     65        LoadParam(root, "radius", this, SnowEffect, radius);
     66        LoadParam(root, "mass", this, SnowEffect, mass);
     67        LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     68        LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     69        LoadParam(root, "spread", this, SnowEffect, spread);
     70        LoadParam(root, "size", this, SnowEffect, size);
     71        LoadParam(root, "coord", this, SnowEffect, coord);
    7272}
    7373
    7474bool SnowEffect::init()
    7575{
    76   this->emitter = new PlaneEmitter();
     76        this->emitter = new PlaneEmitter();
    7777
    78   // Default values
    79   particles = 10000;
    80   texture = "maps/snow_flake_01_32x32.png";
    81   life = 8;
    82   randomLife = 2;
    83   snowRadius = 3.5;
    84   randomRadius = 1;
    85   snowMass = 1.0;
    86   randomMass = 0.3;
    87   rate = 900;
    88   velocity = -100;
    89   randomVelocity = 5;
    90   angle = 0;
    91   randomAngle = 0.3;
    92   alpha = 0.5;
    93   snowSize = Vector2D(1200, 1200);
    94   snowCoord = Vector(100, 600, 200);
     78        // Default values
     79        particles = 10000;
     80        texture = "maps/snow_flake_01_32x32.png";
     81        life = 8;
     82        randomLife = 2;
     83        snowRadius = 3.5;
     84        randomRadius = 1;
     85        snowMass = 1.0;
     86        randomMass = 0.3;
     87        rate = 900;
     88        velocity = -100;
     89        randomVelocity = 5;
     90        angle = 0;
     91        randomAngle = 0.3;
     92        alpha = 0.5;
     93        snowSize = Vector2D(1200, 1200);
     94        snowCoord = Vector(100, 600, 200);
    9595
    96   activated = false;
     96        activated = false;
    9797}
    9898
    9999bool SnowEffect::activate()
    100100{
    101   PRINTF(0)("Activating SnowEffect\n");
    102   activated = true;
    103  
    104   SnowEffect::snowParticles = new SpriteParticles(particles);
    105   SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    106   SnowEffect::snowParticles->setMaterialTexture(texture);
    107   SnowEffect::snowParticles->setLifeSpan(life, randomLife);
    108   SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    109   SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius);
    110   SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius);
    111   SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    112   SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    113   SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    114   SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     101        PRINTF(0)("Activating SnowEffect\n");
     102        activated = true;
    115103
    116  
    117   this->emitter->setSystem(SnowEffect::snowParticles);
    118  
    119  // this->updateNode(0);
    120   this->emitter->setRelCoor(snowCoord);
    121   this->emitter->setEmissionRate(rate);
    122   this->emitter->setEmissionVelocity(velocity, randomVelocity);
    123   this->emitter->setSpread(angle, randomAngle);
    124   this->emitter->setSize(snowSize);
     104        SnowEffect::snowParticles = new SpriteParticles(particles);
     105        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
     106        SnowEffect::snowParticles->setMaterialTexture(texture);
     107        SnowEffect::snowParticles->setLifeSpan(life, randomLife);
     108        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     109        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius);
     110        SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius);
     111        SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
     112        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     113        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     114        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     115
     116        this->emitter->setSystem(SnowEffect::snowParticles);
     117
     118// this->updateNode(0);
     119        this->emitter->setRelCoor(snowCoord);
     120        this->emitter->setEmissionRate(rate);
     121        this->emitter->setEmissionVelocity(velocity, randomVelocity);
     122        this->emitter->setSpread(angle, randomAngle);
     123        this->emitter->setSize(snowSize);
    125124}
    126125
     
    128127bool SnowEffect::deactivate()
    129128{
    130   PRINTF(0)("Deactivating SnowEffect\n");
    131   activated = false;
    132  
    133   this->emitter->setSystem(NULL);
     129        PRINTF(0)("Deactivating SnowEffect\n");
     130        activated = false;
     131
     132        this->emitter->setSystem(NULL);
    134133}
    135134
    136135void SnowEffect::activateSnow()
    137136{
    138   this->activate();
     137        this->activate();
    139138}
    140139
    141140void SnowEffect::deactivateSnow()
    142141{
    143   this->deactivate();
     142        this->deactivate();
    144143}
    145144
     
    150149void SnowEffect::tick(float dt)
    151150{
    152   float distance = (State::getCameraNode()->getAbsCoor() - snowCoord).len();
    153   if( activated && ( distance > 0.6*snowSize.x || distance > 0.6*snowSize.y) )
    154     this->deactivate();
    155   if( !activated && ( distance < 0.6*snowSize.x || distance < 0.6*snowSize.y ))
    156     this->activate();
     151        float distance = (State::getCameraNode()->getAbsCoor() - snowCoord).len();
     152        if( activated && ( distance > 0.6*snowSize.x || distance > 0.6*snowSize.y) )
     153                this->deactivate();
     154        if( !activated && ( distance < 0.6*snowSize.x || distance < 0.6*snowSize.y ))
     155                this->activate();
    157156}
    158157
Note: See TracChangeset for help on using the changeset viewer.