src/thirdparty/particles/ParticleDLL/actions.h

Go to the documentation of this file.
00001 // actions.h
00002 //
00003 // Copyright 1998-2006 by David K. McAllister.
00004 //
00005 // These structures store the details of actions for action lists
00006 
00007 #ifndef PARTICLEACTIONS_H
00008 #define PARTICLEACTIONS_H
00009 
00010 // domain includes particle group and vector.
00011 #include "pDomain.h"
00012 #include "ParticleGroup.h"
00013 
00014 // How many particles will fit in cache?
00015 // Assume the cache is 2 MB, but only use 1.75 MB of it.
00016 #define PWorkingSetSize (0x1c0000 / sizeof(Particle))
00017 
00018 // This method actually does the particle's action.
00019 #define EXEC_METHOD void Execute(ParticleGroup &pg, ParticleList::iterator ibegin, ParticleList::iterator iend)
00020 
00021 struct PActionBase
00022 {
00023     static float dt;    // This is copied to here from global state.
00024 
00025     bool GetKillsParticles() { return bKillsParticles; }
00026     bool GetDoNotSegment() { return bDoNotSegment; }
00027 
00028     void SetKillsParticles(const bool v) { bKillsParticles = v; }
00029     void SetDoNotSegment(const bool v) { bDoNotSegment = v; }
00030 
00031     virtual EXEC_METHOD = 0;
00032 
00033     virtual ~PActionBase(){}
00034 private:
00035     // These are used for doing optimizations where we perform all actions to a working set of particles,
00036     // then to the next working set, etc. to improve cache coherency.
00037     // This doesn't work if the application of an action to a particle is a function of other particles in the group
00038     bool bKillsParticles; // True if this action can kill particles
00039     bool bDoNotSegment;   // True if this action can't be segmented
00040 };
00041 
00043 // Data types derived from PActionBase.
00044 
00045 struct PAAvoid : public PActionBase
00046 {
00047     pDomain *position;  // Avoid region
00048     float look_ahead;   // how many time units ahead to look
00049     float magnitude;    // what percent of the way to go each time
00050     float epsilon;              // add to r^2 for softening
00051 
00052     EXEC_METHOD;
00053 
00054     ~PAAvoid() {delete position;}
00055 
00056     void Exec(const PDTriangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00057     void Exec(const PDRectangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00058     void Exec(const PDPlane &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00059     void Exec(const PDSphere &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00060     void Exec(const PDDisc &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00061 };
00062 
00063 struct PABounce : public PActionBase
00064 {
00065     pDomain *position;  // Bounce region
00066     float oneMinusFriction;     // Friction tangent to surface
00067     float resilience;   // Resilence perpendicular to surface
00068     float cutoffSqr;    // cutoff velocity; friction applies iff v > cutoff
00069 
00070     EXEC_METHOD;
00071 
00072     ~PABounce() {delete position;}
00073 
00074     void Exec(const PDTriangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00075     void Exec(const PDRectangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00076     void Exec(const PDPlane &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00077     void Exec(const PDSphere &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00078     void Exec(const PDDisc &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00079 };
00080 
00081 struct PACallActionList : public PActionBase
00082 {
00083     int action_list_num; // The action list number to call
00084 
00085     EXEC_METHOD;
00086 };
00087 
00088 struct PACopyVertexB : public PActionBase
00089 {
00090     bool copy_pos;              // True to copy pos to posB.
00091     bool copy_vel;              // True to copy vel to velB.
00092 
00093     EXEC_METHOD;
00094 };
00095 
00096 struct PADamping : public PActionBase
00097 {
00098     pVec damping;           // Damping constant applied to velocity
00099     float vlowSqr;              // Low and high cutoff velocities
00100     float vhighSqr;
00101 
00102     EXEC_METHOD;
00103 };
00104 
00105 struct PARotDamping : public PActionBase
00106 {
00107     pVec damping;           // Damping constant applied to velocity
00108     float vlowSqr;              // Low and high cutoff velocities
00109     float vhighSqr;
00110 
00111     EXEC_METHOD;
00112 };
00113 
00114 struct PAExplosion : public PActionBase
00115 {
00116     pVec center;                // The center of the explosion
00117     float velocity;             // Of shock wave
00118     float magnitude;    // At unit radius
00119     float stdev;                // Sharpness or width of shock wave
00120     float age;                  // How long it's been going on
00121     float epsilon;              // Softening parameter
00122 
00123     EXEC_METHOD;
00124 };
00125 
00126 struct PAFollow : public PActionBase
00127 {
00128     float magnitude;    // The grav of each particle
00129     float epsilon;              // Softening parameter
00130     float max_radius;   // Only influence particles within max_radius
00131 
00132     EXEC_METHOD;
00133 };
00134 
00135 struct PAFountain : public PActionBase
00136 {
00137     PActionBase *AL;    // A pointer to the data for all the actions.
00138 
00139     EXEC_METHOD;
00140 };
00141 
00142 struct PAGravitate : public PActionBase
00143 {
00144     float magnitude;    // The grav of each particle
00145     float epsilon;              // Softening parameter
00146     float max_radius;   // Only influence particles within max_radius
00147 
00148     EXEC_METHOD;
00149 };
00150 
00151 struct PAGravity : public PActionBase
00152 {
00153     pVec direction;         // Amount to increment velocity
00154 
00155     EXEC_METHOD;
00156 };
00157 
00158 struct PAJet : public PActionBase
00159 {
00160     pDomain *dom;               // Accelerate particles that are within this domain
00161     pDomain *acc;               // Acceleration vector domain
00162 
00163     EXEC_METHOD;
00164 
00165     ~PAJet() {delete dom; delete acc;}
00166 };
00167 
00168 struct PAKillOld : public PActionBase
00169 {
00170     float age_limit;            // Exact age at which to kill particles.
00171     bool kill_less_than;        // True to kill particles less than limit.
00172 
00173     EXEC_METHOD;
00174 };
00175 
00176 struct PAMatchVelocity : public PActionBase
00177 {
00178     float magnitude;    // The grav of each particle
00179     float epsilon;              // Softening parameter
00180     float max_radius;   // Only influence particles within max_radius
00181 
00182     EXEC_METHOD;
00183 };
00184 
00185 struct PAMatchRotVelocity : public PActionBase
00186 {
00187     float magnitude;    // The grav of each particle
00188     float epsilon;              // Softening parameter
00189     float max_radius;   // Only influence particles within max_radius
00190 
00191     EXEC_METHOD;
00192 };
00193 
00194 struct PAMove : public PActionBase
00195 {
00196 
00197     EXEC_METHOD;
00198 };
00199 
00200 struct PAOrbitLine : public PActionBase
00201 {
00202     pVec p, axis;           // Endpoints of line to which particles are attracted
00203     float magnitude;    // Scales acceleration
00204     float epsilon;              // Softening parameter
00205     float max_radius;   // Only influence particles within max_radius
00206 
00207     EXEC_METHOD;
00208 };
00209 
00210 struct PAOrbitPoint : public PActionBase
00211 {
00212     pVec center;                // Point to which particles are attracted
00213     float magnitude;    // Scales acceleration
00214     float epsilon;              // Softening parameter
00215     float max_radius;   // Only influence particles within max_radius
00216 
00217     EXEC_METHOD;
00218 };
00219 
00220 struct PARandomAccel : public PActionBase
00221 {
00222     pDomain *gen_acc;   // The domain of random accelerations.
00223 
00224     EXEC_METHOD;
00225 
00226     ~PARandomAccel() {delete gen_acc;}
00227 };
00228 
00229 struct PARandomDisplace : public PActionBase
00230 {
00231     pDomain *gen_disp;  // The domain of random displacements.
00232 
00233     EXEC_METHOD;
00234 
00235     ~PARandomDisplace() {delete gen_disp;}
00236 };
00237 
00238 struct PARandomVelocity : public PActionBase
00239 {
00240     pDomain *gen_vel;   // The domain of random velocities.
00241 
00242     EXEC_METHOD;
00243 
00244     ~PARandomVelocity() {delete gen_vel;}
00245 };
00246 
00247 struct PARandomRotVelocity : public PActionBase
00248 {
00249     pDomain *gen_vel;   // The domain of random velocities.
00250 
00251     EXEC_METHOD;
00252 
00253     ~PARandomRotVelocity() {delete gen_vel;}
00254 };
00255 
00256 struct PARestore : public PActionBase
00257 {
00258     float time_left;    // Time remaining until they should be in position.
00259     bool restore_velocity;
00260     bool restore_rvelocity;
00261 
00262     EXEC_METHOD;
00263 };
00264 
00265 struct PASink : public PActionBase
00266 {
00267     bool kill_inside;   // True to dispose of particles *inside* domain
00268     pDomain *position;  // Disposal region
00269 
00270     EXEC_METHOD;
00271 
00272     ~PASink() {delete position;}
00273 };
00274 
00275 struct PASinkVelocity : public PActionBase
00276 {
00277     bool kill_inside;   // True to dispose of particles with vel *inside* domain
00278     pDomain *velocity;  // Disposal region
00279 
00280     EXEC_METHOD;
00281 
00282     ~PASinkVelocity() {delete velocity;}
00283 };
00284 
00285 struct PASort : public PActionBase
00286 {
00287     pVec Eye;           // A point on the line to project onto
00288     pVec Look;          // The direction for which to sort particles
00289 
00290     EXEC_METHOD;
00291 };
00292 
00293 struct PASource : public PActionBase
00294 {
00295     pDomain *position;  // Choose a position in this domain.
00296     pDomain *positionB; // Choose a positionB in this domain.
00297     pDomain *upVec;         // Choose an up vector in this domain
00298     pDomain *velocity;  // Choose a velocity in this domain.
00299     pDomain *rvelocity; // Choose a rotation velocity in this domain.
00300     pDomain *size;              // Choose a size in this domain.
00301     pDomain *color;             // Choose a color in this domain.
00302     pDomain *alpha;             // Choose an alpha in this domain.
00303     float particle_rate;        // Particles to generate per unit time
00304     float age;                  // Initial age of the particles
00305     float age_sigma;    // St. dev. of initial age of the particles
00306     bool vertexB_tracks;        // True to get positionB from position.
00307 
00308     EXEC_METHOD;
00309 
00310     ~PASource()
00311     {
00312         delete position;        // Choose a position in this domain.
00313         delete positionB;       // Choose a positionB in this domain.
00314         delete upVec;       // Choose an up vector in this domain
00315         delete velocity;        // Choose a velocity in this domain.
00316         delete rvelocity;       // Choose a rotation velocity in this domain.
00317         delete size;            // Choose a size in this domain.
00318         delete color;           // Choose a color in this domain.
00319         delete alpha;           // Choose an alpha in this domain.
00320     }
00321 };
00322 
00323 struct PASpeedLimit : public PActionBase
00324 {
00325     float min_speed;            // Clamp speed to this minimum.
00326     float max_speed;            // Clamp speed to this maximum.
00327 
00328     EXEC_METHOD;
00329 };
00330 
00331 struct PATargetColor : public PActionBase
00332 {
00333     pVec color;             // Color to shift towards
00334     float alpha;                // Alpha value to shift towards
00335     float scale;                // Amount to shift by (1 == all the way)
00336 
00337     EXEC_METHOD;
00338 };
00339 
00340 struct PATargetSize : public PActionBase
00341 {
00342     pVec size;          // Size to shift towards
00343     pVec scale;         // Amount to shift by per frame (1 == all the way)
00344 
00345     EXEC_METHOD;
00346 };
00347 
00348 struct PATargetVelocity : public PActionBase
00349 {
00350     pVec velocity;          // Velocity to shift towards
00351     float scale;                // Amount to shift by (1 == all the way)
00352 
00353     EXEC_METHOD;
00354 };
00355 
00356 struct PATargetRotVelocity : public PActionBase
00357 {
00358     pVec velocity;          // Velocity to shift towards
00359     float scale;                // Amount to shift by (1 == all the way)
00360 
00361     EXEC_METHOD;
00362 };
00363 
00364 struct PAVortex : public PActionBase
00365 {
00366     pVec tip;               // Tip of vortex
00367     pVec axis;              // Axis around which vortex is applied
00368     float magnitude;    // Scale for rotation around axis
00369     float tightnessExponent; // Raise to this power to create vortex-like silhouette
00370     float rotSpeed;     // How fast to rotate around
00371     float epsilon;              // Softening parameter
00372     float max_radius;   // Only influence particles within max_radius
00373 
00374     EXEC_METHOD;
00375 };
00376 
00377 #endif // PARTICLEACTIONS_H

Generated on Sat Mar 15 22:55:58 2008 for Armagetron Advanced by  doxygen 1.5.4