particle.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: particle.h
00004 
00005     DESCRIPTION: Particle system object
00006 
00007     CREATED BY: Rolf Berteig
00008 
00009     HISTORY: 10-18-95
00010 
00011  *> Copyright (c) 1994, All Rights Reserved.
00012  **********************************************************************/
00013 
00014 #pragma once
00015 
00016 #include "maxheap.h"
00017 #include "meshlib.h"
00018 #include "export.h"
00019 #include "GraphicsTypes.h"
00020 
00021 // forward declarations
00022 class ParticleSys;
00023 
00024 struct SphereData: public MaxHeapOperators{
00025  Point3 center;
00026  float radius,oradius,rsquare,tover4;
00027 };
00028 
00029 // Custom particle drawing callback
00036 class CustomParticleDisplay: public MaxHeapOperators {
00037     public:
00046         virtual BOOL DrawParticle(GraphicsWindow *gw,ParticleSys &parts,int i)=0;
00047     };
00048 
00064 class ParticleSys : public MaxHeapOperators {
00065     private:
00066         CustomParticleDisplay *draw;
00067 
00068         void DrawGW(GraphicsWindow *gw,DWORD flags,MarkerType type);
00069 
00070     public:
00071         Tab<Point3> points;     // The particles themselves
00072         Tab<Point3> vels;       // Velocities of each particle (optional)
00073         Tab<TimeValue> ages;    // Age of each particle (optional)
00074         Tab<float> radius;
00075         Tab<float> tension;
00076         float size;             // World space radius of a particle
00077 
00078 
00079         // Draws the particle system into the GW
00088         DllExport void Render(GraphicsWindow *gw,MarkerType type=POINT_MRKR);
00089         
00090         // Hit tests the particle system. Returns TRUE if a particle is hit.
00107         DllExport BOOL HitTest(GraphicsWindow *gw, HitRegion *hr, 
00108             int abortOnHit=FALSE,MarkerType type=POINT_MRKR);
00109 
00110         // Gets bounding box
00117         DllExport Box3 BoundBox(Matrix3 *tm=NULL);
00118 
00119         // Sets all counts to 0
00123         DllExport void FreeAll();
00124 
00125         // Sets the size. Flags indicate if optional params should be allocated
00137         DllExport void SetCount(int c,DWORD flags);
00138 
00141         int Count() {return points.Count();}
00144         Point3& operator[](int i) {return points[i];}
00145 
00146         // Is particle i alive?
00153         BOOL Alive(int i) {return ages[i]>=0;}
00154 
00155         // Sets custom draw callback
00165         void SetCustomDraw(CustomParticleDisplay *d) {draw=d;}
00166     };
00167 
00168 // Flags for SetCount()
00169 #define PARTICLE_VELS   (1<<0)
00170 #define PARTICLE_AGES   (1<<1)
00171 #define PARTICLE_RADIUS (1<<2)
00172 #define PARTICLE_TENSION (1<<3)
00173 
00174 class MetaParticle: public MaxHeapOperators {
00175     public:
00176         DllExport int CreateMetas(ParticleSys parts,Mesh *mesh,float threshold,float res,float strength,int many=1);
00177         DllExport int CreatePodMetas(SphereData *data,int num,Mesh *mesh,float threshold,float res,int many=1);
00178 };