Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4437 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Jun 1, 2005, 5:24:24 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: ParticleEmitter now loadable

Location:
orxonox/trunk/src/lib/particles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/particles/particle_emitter.cc

    r4381 r4437  
    2121#include "particle_engine.h"
    2222
     23#include "load_param.h"
    2324#include "debug.h"
    2425#include "stdlibincl.h"
     
    3334                  float velocity)
    3435{
     36}
     37
     38ParticleEmitter::ParticleEmitter(const TiXmlElement* root)
     39{
    3540   this->setClassID(CL_PARTICLE_EMITTER, "ParticleEmitter");
    3641
    37    this->type = EMITTER_DOT;
    38    this->emitterSize = 1.0;
    39    this->direction = direction;
    40    this->setSpread(angle);
    41    this->setEmissionRate(emissionRate);
    42    this->setEmissionVelocity(velocity);
    43 
    4442   this->saveTime = 0.0;
    4543
     44   if (root)
     45     this->loadParams(root);
     46
    4647   ParticleEngine::getInstance()->addEmitter(this);
    4748}
    4849
    49 
    50 
    5150/**
    5251   \brief standard destructor
     
    5857}
    5958
     59void ParticleEmitter::loadParams(const TiXmlElement* root)
     60{
     61  static_cast<PNode*>(this)->loadParams(root);
     62
     63  LoadParam<ParticleEmitter>(root, "type", this, &ParticleEmitter::setType)
     64    .describe("What type of emitter is this [dot, plane, cube, sphere].");
     65
     66  LoadParam<ParticleEmitter>(root, "size", this, &ParticleEmitter::setSize)
     67    .describe("How big the emitter is (no effect on dot-emitters)");
     68
     69  LoadParam<ParticleEmitter>(root, "rate", this, &ParticleEmitter::setEmissionRate)
     70    .describe("How many particles should be emittet from this emitter");
     71
     72  LoadParam<ParticleEmitter>(root, "emission-velocity", this, &ParticleEmitter::setEmissionVelocity)
     73    .describe("How fast the particles are emittet (their initial speed)");
     74 
     75  LoadParam<ParticleEmitter>(root, "spread", this, &ParticleEmitter::setSpread)
     76    .describe("The angle the particles are emitted from (angle, deviation)");
     77
     78}
    6079
    6180/**
     
    82101  this->type = type;
    83102}
     103
     104/**
     105   \param the type of emitter
     106*/
     107void ParticleEmitter::setType(const char* type)
     108{
     109  if (!strcmp(type, "plane"))
     110    this->type = EMITTER_PLANE;
     111  else if (!strcmp(type, "cube"))
     112    this->type = EMITTER_CUBE;
     113  else if (!strcmp(type, "sphere"))
     114    this->type = EMITTER_SPHERE;
     115  else
     116    this->type = EMITTER_DOT;
     117}
     118
    84119
    85120void ParticleEmitter::setSize(float emitterSize)
  • orxonox/trunk/src/lib/particles/particle_emitter.h

    r4381 r4437  
    1212struct Particle;
    1313class ParticleSystem;
     14class TiXmlElement;
    1415
    1516//! The form of the Emitter to emit from
     
    2526  ParticleEmitter(const Vector& direction, float angle = .5,
    2627                  float emissionRate = 1.0, float velocity = 1.0);
     28  ParticleEmitter(const TiXmlElement* root);
    2729  virtual ~ParticleEmitter(void);
     30 
     31  void loadParams(const TiXmlElement* root);
    2832
    2933  /* controlling the emitter: interface */
     
    3438  /* controlling the behavour: these can be used as Animation interfaces */
    3539  void setType(EMITTER_TYPE type);
     40  void setType(const char* type);
    3641  void setSize(float emitterSize);
    3742  void setEmissionRate(float emissionRate);
Note: See TracChangeset for help on using the changeset viewer.