Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/physics/src/lib/graphics/particles/particle_system.h @ 4182

Last change on this file since 4182 was 4182, checked in by bensch, 19 years ago

orxonox/branches/physics: connection of Physical effects should work on ParticleSystems

File size: 3.8 KB
Line 
1/*!
2    \file particle_system.h
3
4*/
5
6#ifndef _PARTICLE_SYSTEM_H
7#define _PARTICLE_SYSTEM_H
8
9#include "base_object.h"
10#include "vector.h"
11
12#define PARTICLE_DOT_MASK           0x000001
13#define PARTICLE_SPARK_MASK         0x000010
14#define PARTICLE_SPRITE_MASK        0x000100
15#define PARTICLE_MODEL_MASK         0x001000
16#define PARTICLE_WORDL_ENTITY_MASK  0x010000
17#define PARTICLE_MULTI_MASK         0x100000
18
19//! An enumerator for the different types of particles.
20typedef enum PARTICLE_TYPE {PARTICLE_DOT = PARTICLE_DOT_MASK,
21                            PARTICLE_SPARK = PARTICLE_SPARK_MASK,
22                            PARTICLE_SPRITE = PARTICLE_SPRITE_MASK,
23                            PARTICLE_MULTI_SPRITE = PARTICLE_SPRITE_MASK | PARTICLE_MULTI_MASK,
24                            PARTICLE_MODEL = PARTICLE_MODEL_MASK,
25                            PARTICLE_MULTI_MODE = PARTICLE_MODEL_MASK | PARTICLE_MULTI_MASK};
26
27#define PARTICLE_DEFAULT_MAX_COUNT    200               //!< a default count of particles in the system.
28#define PARTICLE_DEFAULT_TYPE         PARTICLE_SPRITE   //!< A default type of the system.
29
30// FORWARD DEFINITION
31class Material;
32class ParticleEmitter;
33class Field;
34
35//! A struct for one Particle
36typedef struct Particle
37{
38  float timeToLive;           //!< The time this particle lives from NOW on.
39  Vector position;            //!< The current position of this particle.
40  Vector velocity;            //!< The current velocity of this particle.
41  Vector extForce;            //!< The external Force that influences this Particle.
42  Quaternion rotation;        //!< The current rotation of this particle.
43  float mass;                 //!< The mass of this particle.
44  float radius;               //!< The current size of this particle.
45  float radiusIt;             //!< The difference of the Size per second.
46
47  PARTICLE_TYPE type;
48
49  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
50};
51
52//! A class to handle particle Systems
53class ParticleSystem : public BaseObject {
54  friend class ParticleEmitter;
55
56 public:
57  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT,
58                 PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
59  virtual ~ParticleSystem();
60  void setName(const char* name);
61  const char* getName(void) const;
62
63  void setType(PARTICLE_TYPE particleType, int count = 0);
64  void setMaterial(Material* material);
65  void setInheritSpeed(float value);
66  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
67  void setRadius(float startRadius, float endRadius,
68                 float randomStartRadius = 0.0, float randomEndRadius = 0.0);
69  void setConserve(float conserve);
70  void setMass(float mass, float randomMass);
71
72  void applyField(Field* field);
73
74  void tick(float dt);
75  void draw(float dt);
76
77  void debug(void);
78
79 private:
80  char* name;                // the Name of the Particle System
81
82  float conserve;            //!< How much energy gets conserved to the next Tick.
83  float lifeSpan;            //!< Initial lifetime of a Particle.
84  float randomLifeSpan;
85  float startRadius;
86  float endRadius;
87  float randomStartRadius;
88  float randomEndRadius;
89  float initialMass;
90  float randomInitialMass;
91  float inheritSpeed;
92
93  // particles
94  int maxCount;              //!< The maximum count of Particles.
95  int count;                 //!< The current count of Particles.
96  PARTICLE_TYPE particleType;//!< A type for all the Particles
97  Material* material;        //!< A Material for all the Particles.
98  Particle* particles;       //!< A list of particles of this System.
99  Particle* deadList;        //!< A list of dead Particles in the System.
100
101  GLuint* glID;              //!< A List of different gl-List-ID's
102  GLuint dialectCount;       //!< How many different types of particles are there in the Particle System
103
104  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
105 
106};
107
108#endif /* _PARTICLE_SYSTEM_H */
Note: See TracBrowser for help on using the repository browser.