Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ParticleSystem.h

Go to the documentation of this file.
00001 
00007 #ifndef _PARTICLESYSTEM_H_
00008 #define _PARTICLESYSTEM_H_
00009 
00010 //#pragma once
00011 
00012 #include "Particle.h"
00013 #include "Camera.h"
00014 #include "../Common/OS/Windows.h"
00015 //#include <windows.h>
00016 #include "../Math/Math.h"
00017 
00018 #define MAX_PARTICLES   1000
00019 
00020 #define MIN_SPEED               0.0f
00021 #define MIN_LIFETIME    0.1f
00022 #define MIN_SPREAD              0.01f
00023 #define MIN_EMISSION    1.0f
00024 #define MIN_SIZE                0.5f
00025 #define MIN_GRAVITY             -5.0f
00026 #define MIN_ALPHA               0.0f
00027 
00028 #define MAX_SPEED               250.0f
00029 #define MAX_LIFETIME    10.0f
00030 #define MAX_SPREAD              180.0f
00031 #define MAX_EMISSION    1000.0f
00032 #define MAX_SIZE                10.0f
00033 #define MAX_GRAVITY             5.0f
00034 #define MAX_ALPHA               1.0f
00035 
00036 #define PARTICLESYSTEM_SUN              9
00037 #define PARTICLESYSTEM_SPAWN    8
00038 
00039 //#define PARTICLE_MAX_TEXTURES 5
00040 #define MAX_PRESETS             9
00041 
00042 
00043 //#define RANDOM_NUM    (((float)rand()-(float)rand())/RAND_MAX)        //(float)rand()
00044 //#define Clamp(x, min, max) x=(x<min ? min : (x<max? x : max));
00045 
00046 class ParticleSystem {
00047         public:
00048                 ParticleSystem();
00049                 ~ParticleSystem();
00050                 bool update(float dTime, bool absoluteTime = false);
00051                 void move(Vec3 location);
00052                 Vec3 getPos() { return m_location; }
00053                 void getLocation(Vec3 &location);
00054                 unsigned int numParticles();
00055                 void setRenderer(void *renderer);
00056                 void loadPreset(unsigned int preset);
00057 
00058                 bool isMoving();
00059                 bool isColliding();
00060                 bool isAttractive();
00061 
00062                 void start() { m_alive = true; }
00063                 void die() { m_alive = false; }
00064                 bool isAlive() { return m_alive; }
00065 
00066                 virtual void draw() = 0;
00067                 virtual bool drawAndUpdate(Camera *camera, float dTime, bool absoluteTime = false, bool billboard = true) = 0;
00068 
00069         public:
00070                 void* m_renderer;
00071 
00072                 int m_textureID;
00073                 unsigned int m_particlesPerSec;
00074                 unsigned int m_particlesAlive;
00075 
00076                 Vec3 m_prevLocation;
00077                 Vec3 m_location;
00078                 Vec3 m_velocity;
00079                 Vec3 m_direction;
00080                 Vec3 m_baseLocation;
00081 
00082                 float m_gravityStart;
00083                 float m_gravityVar;
00084                 float m_gravityEnd;
00085 
00086                 float m_sizeStart;
00087                 float m_sizeVar;
00088                 float m_sizeEnd;
00089 
00090                 float m_alphaStart;
00091                 float m_alphaVar;
00092                 float m_alphaEnd;
00093 
00094                 float m_speed;
00095                 float m_speedVar;
00096 
00097                 float m_life;
00098                 float m_lifeVar;
00099 
00100                 Vec4 m_colorStart;
00101                 Vec4 m_colorVar;
00102                 Vec4 m_colorEnd;
00103 
00104                 float m_theta;
00105 
00106                 float m_age;
00107 
00108                 float m_timeLastUpdate;
00109                 float m_emissionResidue;
00110 
00111                 bool m_isMoving;
00112                 bool m_isAttractive;
00113                 bool m_isSuppressed;
00114                 bool m_isColliding;
00115 
00116                 bool m_alive;
00117 
00118                 Particle m_particles[MAX_PARTICLES];
00119 };
00120 
00121 #endif

Generated on Sun Jun 5 15:47:05 2005 for Defacto by  doxygen 1.4.3