Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/particleEngine/src/lib/graphics/particles/particle_system.h @ 3938

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

orxonox/branches/particleEngine: inherit speed from emitter is now also an option
for this i had to write a new PNode function, getVelocity (patrick: you could also use this one in the shoot-class, maybe).

File size: 2.6 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//! An enumerator for the different types of particles.
13typedef enum PARTICLE_TYPE {PARTICLE_DOT,
14                            PARTICLE_SPRITE,
15                            PARTICLE_MULTI_SPRITE,
16                            PARTICLE_OBJECT,
17                            PARTICLE_MULTI_OBJECT,
18                            PARTICLE_PRIMITIVE};
19
20#define PARTICLE_DEFAULT_MAX_COUNT 200         //!< a default count of particles in the system.
21#define PARTICLE_DEFAULT_TYPE  PARTICLE_SPRITE //!< A default type of the system.
22
23// FORWARD DEFINITION
24class Material;
25class ParticleEmitter;
26
27
28//! A struct for one Particle
29typedef struct Particle
30{
31  float timeToLive;           //!< The time this particle lives from NOW on.
32  Vector position;            //!< The current position of this particle.
33  Vector velocity;            //!< The current velocity of this particle.
34  Quaternion rotation;        //!< The current rotation of this particle.
35  float mass;                 //!< The mass of this particle.
36  float radius;               //!< The current size of this particle.
37  float radiusIt;             //!< The difference of the Size per second.
38
39  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
40};
41
42//! A class to handle particle Systems
43class ParticleSystem : public BaseObject {
44  friend class ParticleEmitter;
45
46 public:
47  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
48  virtual ~ParticleSystem();
49
50  void setMaterial(Material* material);
51  void setInheritSpeed(float value);
52  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
53  void setRadius(float startRadius, float endRadius, float randomRadius = 0.0);
54  void setConserve(float conserve);
55  void setMass(float mass, float randomMass);
56
57  void tick(float dt);
58  void draw(void);
59
60 private:
61  float conserve;            //!< How much energy gets conserved to the next Tick.
62  float lifeSpan;            //!< Initial lifetime of a Particle.
63  float randomLifeSpan;
64  float startRadius;
65  float endRadius;
66  float randomRadius;
67  float initialMass;
68  float randomInitialMass;
69  float inheritSpeed;
70
71  // particles
72  int maxCount;              //!< The maximum count of Particles.
73  int count;                 //!< The current count of Particles.
74  PARTICLE_TYPE particleType;//!< A type for all the Particles
75  Material* material;        //!< A Material for all the Particles.
76  Particle* particles;       //!< A list of particles of this System.
77
78
79  void addParticle(Vector position, Vector velocity, unsigned int data = 0);
80 
81};
82
83#endif /* _PARTICLE_SYSTEM_H */
Note: See TracBrowser for help on using the repository browser.