Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

particle.h

Go to the documentation of this file.
00001 // Particle Classes    by Alan Baylis 2001
00002 
00003 // Inspired by the work by
00004 // John van der Burg
00005 // Mystic Game Development
00006 // john@mysticgd.com
00007 
00008 #ifndef PARTICLE_H
00009 #define PARTICLE_H
00010 
00011 #include "vector.h"
00012 #include "listnode.h"
00013 #include "tll.h"
00014 
00015 enum ParticleType{spark, roman, bouncy};   // Particle types
00016 
00017 typedef struct ParticleInfo
00018 {
00019     bool Alive;
00020     int Leaf;
00021     VECTOR Pos;
00022     VECTOR OldPos;
00023     VECTOR OrigPos;
00024     VECTOR Velocity;
00025     VECTOR Vertex[4];
00026     float Color[4];
00027     float Energy;
00028     float SizeX;
00029     float SizeY;
00030 } ParticleInfo;
00031 
00032 typedef struct SystemInfo
00033 {
00034     int Id;
00035     int numAlive;
00036     bool Visibility;
00037     int numParticles;
00038     ParticleType Type;
00039     int BlendMode;
00040     unsigned int TexID;
00041     float Color[4];
00042     VECTOR Pos;
00043     VECTOR Normal;
00044     VECTOR InitialVelocity;
00045 } SystemInfo;
00046 
00047 class PARTICLE
00048 {
00049     public:
00050         PARTICLE(){};
00051         ~PARTICLE(){};
00052 
00053         int Compare(const PARTICLE& Particle);
00054         int GetMyPosition() const {return linkPosition;}
00055         void SetMyPosition(int newPosition) {linkPosition = newPosition;}
00056         int linkPosition;
00057 
00058         ParticleInfo PartInfo;
00059 };
00060 
00061 class ParticleSystem
00062 {
00063     public:
00064         ParticleSystem(){};
00065         ~ParticleSystem(){};
00066 
00067         int Compare(const ParticleSystem& ParticleSys);
00068         int GetMyPosition() const {return linkPosition;}
00069         void SetMyPosition(int newPosition) {linkPosition = newPosition;}
00070         int linkPosition;
00071 
00072         LinkedList<PARTICLE> ParticleList;
00073         SystemInfo SysInfo;
00074 
00075         int GetNumAlive();
00076         void SetupParticles();
00077         PARTICLE* Add();
00078         void Remove();
00079 
00080         virtual void SetDefaults(PARTICLE* Particle);
00081         virtual void SetShape(PARTICLE* Particle);
00082         virtual void Update();
00083         virtual void Render(int nodeid);
00084 };
00085 
00086 class ParticleManager
00087 {
00088     public:
00089         ParticleManager(){numSystems = 0;}
00090         ~ParticleManager(){};
00091 
00092         int numSystems;
00093         LinkedList<ParticleSystem> SystemList;
00094 
00095         void SetVisibility(int Id, bool State);
00096         void ToggleVisibility(int Id);
00097         void SetType(int Id, ParticleType Type);
00098         void SetBlendMode(int Id, int BlendMode);
00099         void SetTextureId(int Id, unsigned int TexID);
00100         void SetId(int Id, int newId);
00101         void Remove(int Id);
00102         void RemoveType(ParticleType Type);
00103         void Update();
00104         void Render(int nodeid);
00105         ParticleSystem* Add(ParticleSystem* PartSys);
00106 };
00107 
00108 // Derived Particle Systems
00109 
00110 // spark type
00111 class Spark : public ParticleSystem
00112 {
00113     public:
00114         Spark(){};
00115         ~Spark(){};
00116 
00117         // Override base methods
00118         void Update();
00119         void Render(int nodeid);
00120         void SetShape(PARTICLE* Particle);
00121         void SetDefaults(PARTICLE* Particle);
00122 };
00123 
00124 // Roman candle type
00125 class Roman : public ParticleSystem
00126 {
00127     public:
00128         Roman(){};
00129         ~Roman(){};
00130 
00131         void Update();
00132         void Render(int nodeid);
00133         void SetShape(PARTICLE* Particle);
00134         void SetDefaults(PARTICLE* Particle);
00135 };
00136 
00137 // Bouncing type
00138 class Bouncy : public ParticleSystem
00139 {
00140     public:
00141         Bouncy(){};
00142         ~Bouncy(){};
00143 
00144         void Update();
00145         void Render(int nodeid);
00146         void SetShape(PARTICLE* Particle);
00147         void SetDefaults(PARTICLE* Particle);
00148 };
00149 
00150 void RenderParticles(int nodeid);
00151 void CreateSparks(VECTOR OldPos, VECTOR Pos, VECTOR Normal);
00152 void CreateRomanCandle(VECTOR Pos);
00153 void CreateBouncy(VECTOR Pos);
00154 bool CheckForParticleCollision(PARTICLE* Particle, VECTOR OldPos, VECTOR* Pos, VECTOR* Norm);
00155 
00156 #endif // PARTICLE_H

Generated on Fri Dec 23 05:15:47 2005 for Constructive Solid Geometry by doxygen1.2.15