Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4351 in orxonox.OLD


Ignore:
Timestamp:
May 28, 2005, 12:45:10 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now one can easily define all the initial values via macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/subprojects/particles/particle_fun.cc

    r4349 r4351  
    2121#include "particle_engine.h"
    2222
     23#define PINIT_EMISSION_RATE          50
     24#define PINIT_EMISSION_VELOCITY      5.0
     25#define PINIT_SPREAD_ANGLE           0.1
     26#define PINIT_EMITTER_TYPE           EMITTER_DOT
     27#define PINIT_EMITTER_SIZE           1.0
     28#define PINIT_START_RADIUS           5.0
     29#define PINIT_END_RADIUS             0.0
     30#define PINIT_LIFESPAN               1.0
     31#define PINIT_CONSERVE_FACTOR        1.0
     32#define PINIT_PARTICLE_TYPE          PARTICLE_SPRITE
     33#define PINIT_INHERIT_SPEED          0.0
     34
    2335
    2436void Framework::moduleInit(int argc, char** argv)
    2537{
    2638  // Creating a Test Particle System
    27   ParticleSystem* system = new ParticleSystem(100000, PARTICLE_SPRITE);
    28   system->setRadius(0,0,0,0);
    29   system->setLifeSpan(0);
    30   system->setConserve(1.0);
     39  ParticleSystem* system = new ParticleSystem(100000, PINIT_PARTICLE_TYPE);
     40  system->setRadius(PINIT_START_RADIUS, PINIT_END_RADIUS ,0 ,0);
     41  system->setLifeSpan(PINIT_LIFESPAN);
     42  system->setConserve(PINIT_CONSERVE_FACTOR);
    3143
    3244  // Creating a Test Particle Emitter
    3345  ParticleEmitter* emitter = new ParticleEmitter(Vector(0 , 1, 0));
    34   emitter->setEmissionRate(0);
    35   emitter->setEmissionVelocity(0,0);
    36   emitter->setSpread(0,0);
    37   emitter->setType(EMITTER_DOT);
    38   emitter->setSize(0);
     46  emitter->setEmissionRate(PINIT_EMISSION_RATE);
     47  emitter->setEmissionVelocity(PINIT_EMISSION_VELOCITY ,0);
     48  emitter->setSpread(PINIT_SPREAD_ANGLE ,0);
     49  emitter->setType(PINIT_EMITTER_TYPE);
     50  emitter->setSize(PINIT_EMITTER_SIZE);
    3951  // Add the Flow from the Emitter into the System
    4052  ParticleEngine::getInstance()->addConnection(emitter, system);
     
    123135  const char* name = option->getTitle();
    124136  char* value = option->save();
    125   printf("%s\n", value);
    126137
    127138  ParticleSystem* tmpSys = ParticleEngine::getInstance()->getSystemByNumber(1);
     
    168179          PRINT(3)("ParticleInheritSpeed set to %f\n", atof(value));
    169180        }
    170 
     181      else if (!strcmp(name, "RandomColor"))
     182        {
     183          tmpSys->setColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 1,
     184                           (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, .5,
     185                           (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, (float)rand()/RAND_MAX, 0);
     186        }
    171187    }
    172188  delete value;
     
    191207          Slider* EmissionRate = new Slider("EmissionRate", 0, 1000);
    192208          EmissionRate->connectSignal("value_changed", (void*)EmissionRate, emitterChange );
     209          EmissionRate->setValue(PINIT_EMISSION_RATE);
     210          EmissionRate->redraw();
    193211          emitterBox->fill(EmissionRate);
    194212         
     
    197215          velocity->setExactness(2);
    198216          velocity->connectSignal("value_changed", (void*)velocity, emitterChange );
     217          velocity->setValue(PINIT_EMISSION_VELOCITY);
     218          velocity->redraw();
    199219          emitterBox->fill(velocity);
    200220         
     
    203223          SpreadAngle->setExactness(3);
    204224          SpreadAngle->connectSignal("value_changed", (void*)SpreadAngle, emitterChange );
     225          SpreadAngle->setValue(PINIT_SPREAD_ANGLE);
     226          SpreadAngle->redraw();
    205227          emitterBox->fill(SpreadAngle);
    206228
     
    210232          EmitterType->addItem("EMITTER_PLANE");
    211233          EmitterType->addItem("EMITTER_CUBE");
     234          EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange );
    212235          EmitterType->load("EMITTER_DOT");
    213           EmitterType->connectSignal("changed", (void*)EmitterType, emitterChange );
    214236          emitterBox->fill(EmitterType);
    215237
     
    218240          EmitterSize->setExactness(1);
    219241          EmitterSize->connectSignal("value_changed", (void*)EmitterSize, emitterChange );
     242          EmitterSize->setValue(PINIT_EMITTER_SIZE);
     243          EmitterSize->redraw();
    220244          emitterBox->fill(EmitterSize);
    221245        }
     
    232256          StartRadius->setExactness(3);
    233257          StartRadius->connectSignal("value_changed", (void*)StartRadius, systemChange );
     258          StartRadius->setValue(PINIT_START_RADIUS);
     259          StartRadius->redraw();
    234260          systemBox->fill(StartRadius);
    235261
     
    238264          EndRadius->setExactness(3);
    239265          EndRadius->connectSignal("value_changed", (void*)EndRadius, systemChange );
     266          EndRadius->setValue(PINIT_END_RADIUS);
     267          EndRadius->redraw();
    240268          systemBox->fill(EndRadius);
    241269
     
    244272          LifeSpan->setExactness(3);
    245273          LifeSpan->connectSignal("value_changed", (void*)LifeSpan, systemChange );
     274          LifeSpan->setValue(PINIT_LIFESPAN);
     275          LifeSpan->redraw();
    246276          systemBox->fill(LifeSpan);
    247277         
     
    249279          Slider* ConserveFactor = new Slider("ConserveFactor", 0, 1);
    250280          ConserveFactor->setExactness(3);
    251           ConserveFactor->load("1.0");
    252281          ConserveFactor->connectSignal("value_changed", (void*)ConserveFactor, systemChange );
     282          ConserveFactor->setValue(PINIT_CONSERVE_FACTOR);
     283          ConserveFactor->redraw();
    253284          systemBox->fill(ConserveFactor);
    254285
     
    258289          ParticleType->addItem("PARTICLE_SPARK");
    259290          ParticleType->addItem("PARTICLE_SPRITE");
     291          ParticleType->connectSignal("changed", (void*)ParticleType, systemChange );     
    260292          ParticleType->load("PARTICLE_SPRITE");
    261           ParticleType->connectSignal("changed", (void*)ParticleType, systemChange );     
    262293          systemBox->fill(ParticleType);
    263294         
     
    268299          systemBox->fill(InheritSpeed);
    269300
     301          Button* RandomColor = new Button("RandomColor");
     302          RandomColor->connectSignal("released", (void*)RandomColor, systemChange);
     303          systemBox->fill(RandomColor);
    270304
    271305        }
Note: See TracChangeset for help on using the changeset viewer.