particle.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**********************************************************************
  2. *<
  3. FILE: particle.h
  4. DESCRIPTION: Particle system object
  5. CREATED BY: Rolf Berteig
  6. HISTORY: 10-18-95
  7. *> Copyright (c) 1994, All Rights Reserved.
  8. **********************************************************************/
  9. #ifndef __PARTICLE__
  10. #define __PARTICLE__
  11. #include "export.h"
  12. class ParticleSys;
  13. // Custom particle drawing callback
  14. class CustomParticleDisplay {
  15. public:
  16. virtual void DrawParticle(GraphicsWindow *gw,ParticleSys &parts,int i)=0;
  17. };
  18. class ParticleSys {
  19. private:
  20. CustomParticleDisplay *draw;
  21. void DrawGW(GraphicsWindow *gw,DWORD flags,MarkerType type);
  22. public:
  23. Tab<Point3> points; // The particles themselves
  24. Tab<Point3> vels; // Velocities of each particle (optional)
  25. Tab<TimeValue> ages; // Age of each particle (optional)
  26. float size; // World space radius of a particle
  27. // Draws the particle system into the GW
  28. DllExport void Render(GraphicsWindow *gw,MarkerType type=POINT_MRKR);
  29. // Hit tests the particle system. Returns TRUE if a particle is hit.
  30. DllExport BOOL HitTest(GraphicsWindow *gw, HitRegion *hr,
  31. int abortOnHit=FALSE,MarkerType type=POINT_MRKR);
  32. // Gets bounding box
  33. DllExport Box3 BoundBox(Matrix3 *tm=NULL);
  34. // Sets all counts to 0
  35. DllExport void FreeAll();
  36. // Sets the size. Flags indicate if optional params should be allocated
  37. DllExport void SetCount(int c,DWORD flags);
  38. int Count() {return points.Count();}
  39. Point3& operator[](int i) {return points[i];}
  40. // Is particle i alive?
  41. BOOL Alive(int i) {return ages[i]>=0;}
  42. // Sets custom draw callback
  43. void SetCustomDraw(CustomParticleDisplay *d) {draw=d;}
  44. };
  45. // Flags for SetCount()
  46. #define PARTICLE_VELS (1<<0)
  47. #define PARTICLE_AGES (1<<1)
  48. #endif // __PARTICLE__