Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/particles/particle_system.h @ 4017

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

orxonox/trunk: merged particleSystem back into the Trunk
merged with command:
svn merge particleEngine/ ../trunk/ -r 3966:HEAD
U ../trunk/src/lib/graphics/particles/particle_emitter.cc
U ../trunk/src/lib/graphics/particles/particle_system.cc
U ../trunk/src/lib/graphics/particles/particle_system.h

as you can see, no conflicts

File size: 3.5 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;
33
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  Quaternion rotation;        //!< The current rotation of this particle.
42  float mass;                 //!< The mass of this particle.
43  float radius;               //!< The current size of this particle.
44  float radiusIt;             //!< The difference of the Size per second.
45
46  PARTICLE_TYPE type;
47
48  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
49};
50
51//! A class to handle particle Systems
52class ParticleSystem : public BaseObject {
53  friend class ParticleEmitter;
54
55 public:
56  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
57  virtual ~ParticleSystem();
58  void setName(const char* name);
59  const char* getName(void) const;
60
61  void setType(PARTICLE_TYPE particleType, int count = 0);
62  void setMaterial(Material* material);
63  void setInheritSpeed(float value);
64  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
65  void setRadius(float startRadius, float endRadius, float randomStartRadius = 0.0, float randomEndRadius = 0.0);
66  void setConserve(float conserve);
67  void setMass(float mass, float randomMass);
68
69  void tick(float dt);
70  void draw(void);
71
72  void debug(void);
73
74 private:
75  char* name;                // the Name of the Particle System
76
77  float conserve;            //!< How much energy gets conserved to the next Tick.
78  float lifeSpan;            //!< Initial lifetime of a Particle.
79  float randomLifeSpan;
80  float startRadius;
81  float endRadius;
82  float randomStartRadius;
83  float randomEndRadius;
84  float initialMass;
85  float randomInitialMass;
86  float inheritSpeed;
87
88  // particles
89  int maxCount;              //!< The maximum count of Particles.
90  int count;                 //!< The current count of Particles.
91  PARTICLE_TYPE particleType;//!< A type for all the Particles
92  Material* material;        //!< A Material for all the Particles.
93  Particle* particles;       //!< A list of particles of this System.
94
95  GLuint* glID;              //!< A List of different gl-List-ID's
96  GLuint dialectCount;       //!< How many different types of particles are there in the Particle System
97
98  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
99 
100};
101
102#endif /* _PARTICLE_SYSTEM_H */
Note: See TracBrowser for help on using the repository browser.