home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 12 / Example 12.8 / particles.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-30  |  1.2 KB  |  61 lines

  1. #ifndef _RTS_PARTICLES_
  2. #define _RTS_PARTICLES_
  3.  
  4. #include <windows.h>
  5. #include <d3dx9.h>
  6. #include <vector>
  7. #include "debug.h"
  8. #include "shader.h"
  9. #include "effect.h"
  10.  
  11. void LoadParticleResources(IDirect3DDevice9 *Dev);
  12. void UnloadParticleResources();
  13.  
  14. struct PARTICLE
  15. {
  16.     D3DXVECTOR3 position, velocity, acceleration;
  17.     float time_to_live;    
  18.     D3DXCOLOR color;
  19.     bool dead;
  20. };
  21.  
  22. class PARTICLE_SYSTEM : public EFFECT
  23. {
  24.     public:
  25.         PARTICLE_SYSTEM(IDirect3DDevice9 *Dev);
  26.         ~PARTICLE_SYSTEM();
  27.         void Update(float timeDelta);
  28.         void Render();
  29.         bool isDead();
  30.  
  31.         void RenderBatch(int start, int batchSize);
  32.         void PreRender();
  33.         void PostRender();
  34.  
  35.         std::vector<PARTICLE*> m_particles;
  36.         IDirect3DTexture9* m_pTexture;        
  37.         DWORD m_blendMode;
  38.         float m_particleSize;
  39. };
  40.  
  41. class MAGIC_SHOWER : public PARTICLE_SYSTEM
  42. {
  43.     public:
  44.         MAGIC_SHOWER(IDirect3DDevice9 *Dev, int noParticles, D3DXVECTOR3 _origin);
  45.         void Update(float timeDelta);
  46.         bool isDead();
  47.     private:
  48.         D3DXVECTOR3 m_origin;
  49. };
  50.  
  51. class SMOKE : public PARTICLE_SYSTEM
  52. {
  53.     public:
  54.         SMOKE(IDirect3DDevice9 *Dev, int noParticles, D3DXVECTOR3 _origin);
  55.         void Update(float timeDelta);
  56.         bool isDead();
  57.     private:
  58.         D3DXVECTOR3 m_origin;
  59. };
  60.  
  61. #endif