Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/particleSystem: minor fixes. code is nicer now

File size: 3.5 KB
RevLine 
[3245]1/*!
[3925]2    \file particle_system.h
[3329]3
[3245]4*/
[1853]5
[3925]6#ifndef _PARTICLE_SYSTEM_H
7#define _PARTICLE_SYSTEM_H
[1853]8
[3543]9#include "base_object.h"
[3925]10#include "vector.h"
[3930]11
[4001]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
[3956]18
[3930]19//! An enumerator for the different types of particles.
[3956]20typedef enum PARTICLE_TYPE {PARTICLE_DOT = PARTICLE_DOT_MASK,
[4001]21                            PARTICLE_SPARK = PARTICLE_SPARK_MASK,
[3956]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};
[3930]26
[3942]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.
[3930]29
[3925]30// FORWARD DEFINITION
[3926]31class Material;
[3930]32class ParticleEmitter;
[3543]33
[3926]34
[3925]35//! A struct for one Particle
36typedef struct Particle
37{
[3930]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.
[3931]42  float mass;                 //!< The mass of this particle.
[3932]43  float radius;               //!< The current size of this particle.
[3936]44  float radiusIt;             //!< The difference of the Size per second.
[3930]45
[4001]46  PARTICLE_TYPE type;
47
[3931]48  Particle* next;             //!< pointer to the next particle in the List. (NULL if no preceding one)
[3925]49};
[3543]50
[3925]51//! A class to handle particle Systems
52class ParticleSystem : public BaseObject {
[3932]53  friend class ParticleEmitter;
[2036]54
[1904]55 public:
[3934]56  ParticleSystem(unsigned int maxCount = PARTICLE_DEFAULT_MAX_COUNT, PARTICLE_TYPE type = PARTICLE_DEFAULT_TYPE);
[3925]57  virtual ~ParticleSystem();
[3944]58  void setName(const char* name);
59  const char* getName(void) const;
[1853]60
[3942]61  void setType(PARTICLE_TYPE particleType, int count = 0);
[3930]62  void setMaterial(Material* material);
[3938]63  void setInheritSpeed(float value);
[3931]64  void setLifeSpan(float lifeSpan, float randomLifeSpan = 0.0);
[3942]65  void setRadius(float startRadius, float endRadius, float randomStartRadius = 0.0, float randomEndRadius = 0.0);
[3932]66  void setConserve(float conserve);
67  void setMass(float mass, float randomMass);
[3245]68
[3931]69  void tick(float dt);
[3932]70  void draw(void);
[3931]71
[3944]72  void debug(void);
73
[3245]74 private:
[3944]75  char* name;                // the Name of the Particle System
76
[3931]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;
[3942]82  float randomStartRadius;
83  float randomEndRadius;
[3932]84  float initialMass;
85  float randomInitialMass;
[3938]86  float inheritSpeed;
87
[3931]88  // particles
[3934]89  int maxCount;              //!< The maximum count of Particles.
90  int count;                 //!< The current count of Particles.
[3931]91  PARTICLE_TYPE particleType;//!< A type for all the Particles
92  Material* material;        //!< A Material for all the Particles.
[3930]93  Particle* particles;       //!< A list of particles of this System.
[3932]94
[3942]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
[3932]97
[3951]98  void addParticle(const Vector& position, const Vector& velocity, unsigned int data = 0);
[3932]99 
[1853]100};
101
[3925]102#endif /* _PARTICLE_SYSTEM_H */
Note: See TracBrowser for help on using the repository browser.