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

Explosion.h

Go to the documentation of this file.
00001 
00007 #ifndef _EXPLOSION_H_
00008 #define _EXPLOSION_H_
00009 
00010 #include "Log.h"
00011 #include "../Common/OS/Windows.h"
00012 #include "../Graphics/OpenGL/OpenGLRenderer.h"
00013 #include "../Math/Math.h"
00014 #include "../Math/Vector.h"
00015 
00016 #define NUM_EXPLOSION_PARTICLES 50
00017 #define NUM_EXPLOSION_DEBRIS    30
00018 
00019 #define EXPLOSION_RAND (2.0f * ((float)rand() / (float)RAND_MAX)) - 1.0f
00020 
00021 struct explosionParticle {
00022         Vec3 position;
00023         Vec3 velocity;
00024         Vec4 color;
00025 };
00026 
00027 struct explosionDebris {
00028         Vec3 position;
00029         Vec3 velocity;
00030         Vec3 rotation;
00031         Vec3 rotationSpeed;
00032         Vec4 color;
00033         Vec3 scale;
00034 };
00035 
00036 class Explosion {
00037         public:
00038                 Explosion();
00039                 Explosion(Vec3 pos, float power = 1.0f, bool sphere = false);
00040                 void explode(Vec3 pos, float power = 1.0f, bool sphere = false);
00041                 virtual ~Explosion();
00042 
00043                 void drawAndUpdate(float dTime);
00044                 bool isAlive() { return life > 0.0f; }
00045 
00046         protected:
00047                 Vec3 newVelocity(bool sphere = false);
00048 
00049         protected:
00050                 float life;
00051                 float totLife;
00052                 float power;
00053                 explosionParticle       particles[NUM_EXPLOSION_PARTICLES];
00054                 explosionDebris         debris[NUM_EXPLOSION_DEBRIS];
00055 };
00056 
00057 #endif

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