Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4493 in orxonox.OLD


Ignore:
Timestamp:
Jun 3, 2005, 2:10:47 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: inheritSpeed now property of particle_emitter. system not friend emitter anymore

Location:
orxonox/trunk/src
Files:
6 edited

Legend:

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

    r4478 r4493  
    3737  this->emitterSize = 1.0;
    3838  this->direction = direction;
     39  this->setInheritSpeed(0);
    3940  this->setSpread(angle);
    4041  this->setEmissionRate(emissionRate);
     
    157158  else
    158159    this->emissionRate = 0.0;
     160}
     161
     162/**
     163   \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem
     164   \param value a Value between zero and one
     165
     166   if you want to change the value of this variable during emission time (to make it more dynamic)
     167   you may want to use the animation class
     168*/
     169void ParticleEmitter::setInheritSpeed(float value)
     170{
     171  if (unlikely(value > 1.0))
     172    this->inheritSpeed = 1;
     173  else if (unlikely(value < 0.0))
     174    this->inheritSpeed = 0;
     175  else
     176    this->inheritSpeed = value;
    159177}
    160178
     
    207225    if (likely(count > 0))
    208226      {
    209         Vector inheritVelocity = this->getVelocity() * system->inheritSpeed;
     227        Vector inheritVelocity = this->getVelocity() * this->inheritSpeed;
    210228        for (int i = 0; i < count; i++)
    211229          // emmits from EMITTER_DOT,
     
    242260void ParticleEmitter::debug(void)
    243261{
    244 
    245 }
     262  PRINT(0)(" Emitter %s\n", this->getName());
     263}
  • orxonox/trunk/src/lib/particles/particle_emitter.h

    r4478 r4493  
    4040  void setSize(float emitterSize);
    4141  void setEmissionRate(float emissionRate);
     42  void setInheritSpeed(float value);
    4243  void setSpread(float angle, float randomAngle = 0.0);
    4344  void setEmissionVelocity(float velocity, float randomVelocity = 0.0);
     
    4950  /** \returns the emissionRate */
    5051  inline float getEmissionRate(void) const { return this->emissionRate; };
     52  /** \returns the inherit-speed-factor */
     53  inline float getInheritSpeed(void) const { return this->inheritSpeed; };
    5154  /** \returns the SpreadAngle of the emitter */
    5255  inline float getSpread(void) { return this->angle; };
     
    6063  EMITTER_TYPE    type;              //!< The type of emitter this is
    6164  float           emitterSize;       //!< The size of the emitter (not for EMITTER_DOT)
     65  float           inheritSpeed;      //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter
    6266  Vector          direction;         //!< emition direction
    6367  float           angle;             //!< max angle from the direction of the emitter
  • orxonox/trunk/src/lib/particles/particle_system.cc

    r4478 r4493  
    4242  this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem");
    4343  this->material = NULL;
    44   this->name = NULL;
    4544  this->maxCount = maxCount;
    4645  this->count = 0;
     
    4948  this->setConserve(1);
    5049  this->setLifeSpan(1);
    51   this->setInheritSpeed(0);
    5250  this->glID = NULL;
    5351  this->setType(type, 1);
     
    123121{
    124122  this->material = material;
    125 }
    126 
    127 /**
    128    \brief how much of the speed from the ParticleEmitter should flow onto the ParticleSystem
    129    \param value a Value between zero and one
    130 
    131    if you want to change the value of this variable during emission time (to make it more dynamic)
    132    you may want to use the animation class
    133 */
    134 void ParticleSystem::setInheritSpeed(float value)
    135 {
    136   if (unlikely(value > 1.0))
    137     this->inheritSpeed = 1;
    138   else if (unlikely(value < 0.0))
    139     this->inheritSpeed = 0;
    140   else
    141     this->inheritSpeed = value;
    142123}
    143124
     
    453434void ParticleSystem::debug(void)
    454435{
    455   PRINT(0)("  ParticleSystem %s\n", this->name);
     436  PRINT(0)("  ParticleSystem %s\n", this->getName());
    456437  PRINT(0)("  ParticleCount: %d, maximumCount: %d :: filled %d%%\n", this->count, this->maxCount, 100*this->count/this->maxCount);
    457438  if (deadList)
  • orxonox/trunk/src/lib/particles/particle_system.h

    r4478 r4493  
    77#define _PARTICLE_SYSTEM_H
    88
    9 #include "base_object.h"
     9#include "world_entity.h"
    1010#include "physics_interface.h"
    1111
     
    4141typedef struct Particle
    4242{
    43   float lifeTime;             //!< The time this particle has to live.
    44   float lifeCycle;            //!< The fraction of time passed. (in percentage of its lifeTime)
     43  float         lifeTime;            //!< The time this particle has to live.
     44  float         lifeCycle;           //!< The fraction of time passed. (in percentage of its lifeTime)
    4545
    46   Vector position;            //!< The current position of this particle.
    47   Vector velocity;            //!< The current velocity of this particle.
    48   Vector extForce;            //!< The external Force that influences this Particle.
    49   Quaternion rotation;        //!< The current rotation of this particle.
    50   float mass;                 //!< The mass of this particle.
    51   float massRand;             //!< A random mass
    52   float radius;               //!< The current size of this particle.
    53   float radiusRand;           //!< a random Radius
     46  Vector        position;            //!< The current position of this particle.
     47  Vector        velocity;            //!< The current velocity of this particle.
     48  Vector        extForce;            //!< The external Force that influences this Particle.
     49  Quaternion    rotation;            //!< The current rotation of this particle.
     50  float         mass;                //!< The mass of this particle.
     51  float         massRand;            //!< A random mass
     52  float         radius;              //!< The current size of this particle.
     53  float         radiusRand;          //!< a random Radius
     54  GLfloat       color [4];           //!< A Color for the particles.
    5455
    55   GLfloat color [4];          //!< A Color for the particles.
    56 
    57   Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
     56  Particle*     next;                //!< pointer to the next particle in the List. (NULL if no preceding one)
    5857};
    5958
    6059//! A class to handle ParticleSystems
    61 class ParticleSystem : public PhysicsInterface {
    62   friend class ParticleEmitter;
     60class ParticleSystem : public WorldEntity, public PhysicsInterface {
    6361 
    6462 public:
     
    6967  void setType(PARTICLE_TYPE particleType, int count = 0);
    7068  void setMaterial(Material* material);
    71   void setInheritSpeed(float value);
    7269  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
    7370  void setConserve(float conserve);
     
    8279  /** \returns the Material that lies on this particles */
    8380  inline const Material* getMaterial(void) const { return this->material; };
    84   /** \returns the inherit-speed-factor */
    85   inline float getInheritSpeed(void) const { return this->inheritSpeed; };
    8681  /** \returns the lifespan of the particles */
    8782  inline float getLifeSpan(void) const { return this->lifeSpan; };
     
    10196  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
    10297
    103   void tick(float dt);
    104   void draw(void) const;
     98  virtual void tick(float dt);
     99  virtual void draw(void) const;
    105100
    106101  void debug(void);
    107102
    108103 private:
    109   char*             name;                //!< the Name of the Particle System
    110 
    111104  float             conserve;            //!< How much energy gets conserved to the next Tick.
    112105  float             lifeSpan;            //!< Initial lifetime of a Particle.
     
    114107  float             initialMass;         //!< The initial Mass of the Particle
    115108  float             randomInitialMass;   //!< The random initial Mass of the Particle
    116   float             inheritSpeed;        //!< How much speed the particle inherits from the Emitters speed \todo move this to the emitter
    117109
    118   // particles
    119110  int               maxCount;            //!< The maximum count of Particles.
    120111  int               count;               //!< The current count of Particles.
     
    128119
    129120  // per particle attributes
    130   QuickAnimation radiusAnim;             //!< Animation of the radius
    131   QuickAnimation randRadiusAnim;         //!< Animation of the random Value of the radius
    132   QuickAnimation massAnim;               //!< Animation of the mass
    133   QuickAnimation randMassAnim;           //!< Animation of the random Mass
    134   QuickAnimation colorAnim[4];           //!< Animation of the 4 colors (r,g,b,a)
     121  QuickAnimation    radiusAnim;          //!< Animation of the radius
     122  QuickAnimation    randRadiusAnim;      //!< Animation of the random Value of the radius
     123  QuickAnimation    massAnim;            //!< Animation of the mass
     124  QuickAnimation    randMassAnim;        //!< Animation of the random Mass
     125  QuickAnimation    colorAnim[4];        //!< Animation of the 4 colors (r,g,b,a)
    135126};
    136127
  • orxonox/trunk/src/subprojects/particles/Makefile.am

    r4492 r4493  
    66
    77particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a \
     8                  $(MAINSRCDIR)/lib/event/libORXevent.a \
     9                  $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a \
    810                  $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
    911                  -lpthread
     
    1416particles_SOURCES= ../framework.cc \
    1517                   particle_fun.cc \
    16                   $(MAINSRCDIR)/lib/particles/particle_engine.cc \
    17                   $(MAINSRCDIR)/lib/particles/particle_system.cc \
    18                   $(MAINSRCDIR)/lib/particles/particle_emitter.cc \
    19                   $(MAINSRCDIR)/lib/graphics/light.cc \
    20                   $(MAINSRCDIR)/util/state.cc \
    21                   $(MAINSRCDIR)/world_entities/camera.cc \
    22                   $(MAINSRCDIR)/lib/graphics/importer/model.cc \
    23                   $(MAINSRCDIR)/lib/graphics/importer/objModel.cc \
    24                   $(MAINSRCDIR)/lib/graphics/importer/primitive_model.cc \
    25                   $(MAINSRCDIR)/lib/graphics/importer/array.cc \
    26                   $(MAINSRCDIR)/lib/graphics/importer/material.cc \
    27                   $(MAINSRCDIR)/lib/graphics/importer/texture.cc \
    28                   $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
    29                   $(MAINSRCDIR)/lib/lang/base_object.cc \
    30                   $(MAINSRCDIR)/lib/math/vector.cc \
    31                   $(MAINSRCDIR)/util/resource_manager.cc \
    32                   $(MAINSRCDIR)/lib/graphics/text_engine.cc \
    33                   $(MAINSRCDIR)/lib/coord/p_node.cc \
    34                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    35                   $(MAINSRCDIR)/lib/gui/gui_gtk.cc
     18                   $(MAINSRCDIR)/lib/particles/particle_engine.cc \
     19                   $(MAINSRCDIR)/lib/particles/particle_system.cc \
     20                   $(MAINSRCDIR)/lib/particles/particle_emitter.cc \
     21                   $(MAINSRCDIR)/lib/graphics/light.cc \
     22                   $(MAINSRCDIR)/util/state.cc \
     23                   $(MAINSRCDIR)/world_entities/camera.cc \
     24                   $(MAINSRCDIR)/lib/graphics/importer/model.cc \
     25                   $(MAINSRCDIR)/lib/graphics/importer/objModel.cc \
     26                   $(MAINSRCDIR)/lib/graphics/importer/primitive_model.cc \
     27                   $(MAINSRCDIR)/lib/graphics/importer/array.cc \
     28                   $(MAINSRCDIR)/lib/graphics/importer/material.cc \
     29                   $(MAINSRCDIR)/lib/graphics/importer/texture.cc \
     30                   $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
     31                   $(MAINSRCDIR)/lib/lang/base_object.cc \
     32                   $(MAINSRCDIR)/lib/math/vector.cc \
     33                   $(MAINSRCDIR)/util/resource_manager.cc \
     34                   $(MAINSRCDIR)/lib/graphics/text_engine.cc \
     35                   $(MAINSRCDIR)/lib/coord/p_node.cc \
     36                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
     37                   $(MAINSRCDIR)/lib/gui/gui_gtk.cc
  • orxonox/trunk/src/subprojects/particles/Makefile.in

    r4492 r4493  
    6868am__DEPENDENCIES_1 =
    6969particles_DEPENDENCIES = $(MAINSRCDIR)/lib/physics/libORXphysics.a \
    70         $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
     70        $(MAINSRCDIR)/lib/event/libORXevent.a \
     71        $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a $(am__DEPENDENCIES_1) \
     72        $(am__DEPENDENCIES_1)
    7173DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
    7274depcomp = $(SHELL) $(top_srcdir)/depcomp
     
    214216MAINSRCDIR = ../..
    215217particles_LDADD = $(MAINSRCDIR)/lib/physics/libORXphysics.a \
     218                  $(MAINSRCDIR)/lib/event/libORXevent.a \
     219                  $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a \
    216220                  $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
    217221                  -lpthread
     
    222226particles_SOURCES = ../framework.cc \
    223227                   particle_fun.cc \
    224                   $(MAINSRCDIR)/lib/particles/particle_engine.cc \
    225                   $(MAINSRCDIR)/lib/particles/particle_system.cc \
    226                   $(MAINSRCDIR)/lib/particles/particle_emitter.cc \
    227                   $(MAINSRCDIR)/lib/graphics/light.cc \
    228                   $(MAINSRCDIR)/util/state.cc \
    229                   $(MAINSRCDIR)/world_entities/camera.cc \
    230                   $(MAINSRCDIR)/lib/graphics/importer/model.cc \
    231                   $(MAINSRCDIR)/lib/graphics/importer/objModel.cc \
    232                   $(MAINSRCDIR)/lib/graphics/importer/primitive_model.cc \
    233                   $(MAINSRCDIR)/lib/graphics/importer/array.cc \
    234                   $(MAINSRCDIR)/lib/graphics/importer/material.cc \
    235                   $(MAINSRCDIR)/lib/graphics/importer/texture.cc \
    236                   $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
    237                   $(MAINSRCDIR)/lib/lang/base_object.cc \
    238                   $(MAINSRCDIR)/lib/math/vector.cc \
    239                   $(MAINSRCDIR)/util/resource_manager.cc \
    240                   $(MAINSRCDIR)/lib/graphics/text_engine.cc \
    241                   $(MAINSRCDIR)/lib/coord/p_node.cc \
    242                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    243                   $(MAINSRCDIR)/lib/gui/gui_gtk.cc
     228                   $(MAINSRCDIR)/lib/particles/particle_engine.cc \
     229                   $(MAINSRCDIR)/lib/particles/particle_system.cc \
     230                   $(MAINSRCDIR)/lib/particles/particle_emitter.cc \
     231                   $(MAINSRCDIR)/lib/graphics/light.cc \
     232                   $(MAINSRCDIR)/util/state.cc \
     233                   $(MAINSRCDIR)/world_entities/camera.cc \
     234                   $(MAINSRCDIR)/lib/graphics/importer/model.cc \
     235                   $(MAINSRCDIR)/lib/graphics/importer/objModel.cc \
     236                   $(MAINSRCDIR)/lib/graphics/importer/primitive_model.cc \
     237                   $(MAINSRCDIR)/lib/graphics/importer/array.cc \
     238                   $(MAINSRCDIR)/lib/graphics/importer/material.cc \
     239                   $(MAINSRCDIR)/lib/graphics/importer/texture.cc \
     240                   $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
     241                   $(MAINSRCDIR)/lib/lang/base_object.cc \
     242                   $(MAINSRCDIR)/lib/math/vector.cc \
     243                   $(MAINSRCDIR)/util/resource_manager.cc \
     244                   $(MAINSRCDIR)/lib/graphics/text_engine.cc \
     245                   $(MAINSRCDIR)/lib/coord/p_node.cc \
     246                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
     247                   $(MAINSRCDIR)/lib/gui/gui_gtk.cc
    244248
    245249all: all-am
Note: See TracChangeset for help on using the changeset viewer.