00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef particle_api_h
00010 #define particle_api_h
00011
00012 #include "pDomain.h"
00013
00014 namespace PAPI {
00016 const int P_VERSION = 220;
00017
00019 const float P_MAXFLOAT = 1.0e16f;
00020
00022 const float P_EPS = 1e-3f;
00023
00025 const size_t P_MAXINT = 0x7fffffff;
00026
00028 typedef void (*P_PARTICLE_CALLBACK)(struct Particle_t &particle, puint64 data);
00029
00030 class PInternalState_t;
00031 class PInternalSourceState_t;
00032
00040 class PContextSourceState_t
00041 {
00042 public:
00048 void Color(const pVec &color, const float alpha = 1.0f);
00049
00055 void Color(const float red, const float green, const float blue, const float alpha = 1.0f);
00056
00067 void Color(const pDomain &cdom);
00068
00079 void Color(const pDomain &cdom,
00080 const pDomain &adom
00081 );
00082
00088 void Data(const puint64 data);
00089
00095 void Size(const pVec &size);
00096
00107 void Size(const pDomain &dom);
00108
00114 void Mass(const float mass);
00115
00117 void RotVelocity(const pVec &v);
00118
00125 void RotVelocity(const pDomain &dom);
00126
00135 void StartingAge(const float age,
00136 const float sigma = 0.0f
00137 );
00138
00144 void UpVec(const pVec &v);
00145
00152 void UpVec(const pDomain &dom);
00153
00159 void Velocity(const pVec &vel);
00160
00164 void Velocity(const pDomain &dom);
00165
00171 void VertexB(const pVec &v);
00172
00178 void VertexB(const pDomain &dom);
00179
00185 void VertexBTracks(const bool track_vertex = true);
00186
00190 void ResetSourceState();
00191
00192 protected:
00193 PInternalSourceState_t *PSS;
00194 void InternalSetup(PInternalSourceState_t *Sr);
00195 };
00196
00216 class PContextActionList_t
00217 {
00218 public:
00226 void Seed(const unsigned int seed);
00227
00258 void TimeStep(const float new_dt);
00259
00271 void CallActionList(const int action_list_num);
00272
00277 void DeleteActionLists(const int action_list_num,
00278 const int action_list_count = 1
00279 );
00280
00284 void EndActionList();
00285
00290 int GenActionLists(const int action_list_count = 1
00291 );
00292
00299 void NewActionList(const int action_list_num);
00300
00301 protected:
00302 PInternalState_t *PS;
00303 void InternalSetup(PInternalState_t *Sr);
00304 PInternalState_t *getInternalState() const;
00305 };
00306
00321 class PContextParticleGroup_t
00322 {
00323 public:
00331 void CopyGroup(const int p_src_group_num,
00332 const size_t index = 0,
00333 const size_t copy_count = P_MAXINT
00334 );
00335
00339 void CurrentGroup(const int p_group_num);
00340
00348 void DeleteParticleGroups(const int p_group_num,
00349 const int p_group_count = 1
00350 );
00351
00357 int GenParticleGroups(const int p_group_count = 1,
00358 const size_t max_particles = 0
00359 );
00360
00364 size_t GetGroupCount();
00365
00369 size_t GetMaxParticles();
00370
00390 size_t GetParticles(const size_t index,
00391 const size_t count,
00392 float *position = NULL,
00393 float *color = NULL,
00394 float *vel = NULL,
00395 float *size = NULL,
00396 float *age = NULL
00397 );
00398
00407 size_t GetParticlePointer(float *&ptr,
00408 size_t &stride,
00409 size_t &pos3Ofs,
00410 size_t &posB3Ofs,
00411 size_t &size3Ofs,
00412 size_t &vel3Ofs,
00413 size_t &velB3Ofs,
00414 size_t &color3Ofs,
00415 size_t &alpha1Ofs,
00416 size_t &age1Ofs,
00417 size_t &up3Ofs,
00418 size_t &rvel3Ofs,
00419 size_t &upB3Ofs,
00420 size_t &mass1Ofs,
00421 size_t &data1Ofs
00422 );
00423
00429 void SetMaxParticles(const size_t max_count);
00430
00439 void BirthCallback(P_PARTICLE_CALLBACK callback,
00440 puint64 group_data = 0
00441 );
00442
00451 void DeathCallback(P_PARTICLE_CALLBACK callback,
00452 puint64 group_data = 0
00453 );
00454
00462 void SetWorkingSetSize(const int set_size_bytes);
00463
00464 protected:
00465 PInternalState_t *PS;
00466 void InternalSetup(PInternalState_t *Sr);
00467 };
00468
00489 class PContextActions_t
00490 {
00491 public:
00499 void Avoid(float magnitude,
00500 const float epsilon,
00501 const float look_ahead,
00502 const pDomain &dom
00503 );
00504
00526 void Bounce(float friction,
00527 const float resilience,
00528 const float cutoff,
00529 const pDomain &dom
00530 );
00531
00535 void Callback(P_PARTICLE_CALLBACK callback,
00536 puint64 call_data = 0
00537 );
00538
00540 void CopyVertexB(const bool copy_pos = true,
00541 const bool copy_vel = false
00542 );
00543
00550 void Damping(const pVec &damping,
00551 const float vlow = 0.0f, const float vhigh = P_MAXFLOAT);
00552
00559 void RotDamping(const pVec &damping,
00560 const float vlow = 0.0f, const float vhigh = P_MAXFLOAT);
00561
00573 void Explosion(const pVec ¢er,
00574 const float radius,
00575 const float magnitude,
00576 const float sigma,
00577 const float epsilon = P_EPS
00578 );
00579
00586 void Follow(float magnitude = 1.0f,
00587 const float epsilon = P_EPS,
00588 const float max_radius = P_MAXFLOAT
00589 );
00590
00595 void Gravitate(const float magnitude = 1.0f,
00596 const float epsilon = P_EPS,
00597 const float max_radius = P_MAXFLOAT
00598 );
00599
00604 void Gravity(const pVec &dir);
00605
00610 void Jet(const pDomain &dom,
00611 const pDomain &acc);
00612
00621 void KillOld(const float age_limit,
00622 const bool kill_less_than = false
00623 );
00624
00630 void MatchVelocity(const float magnitude = 1.0f,
00631 const float epsilon = P_EPS,
00632 const float max_radius = P_MAXFLOAT
00633 );
00634
00640 void MatchRotVelocity(const float magnitude = 1.0f,
00641 const float epsilon = P_EPS,
00642 const float max_radius = P_MAXFLOAT
00643 );
00644
00653 void Move(const bool move_velocity = true,
00654 const bool move_rotational_velocity = true
00655 );
00656
00660 void OrbitLine(const pVec &p,
00661 const pVec &axis,
00662 const float magnitude = 1.0f,
00663 const float epsilon = P_EPS,
00664 const float max_radius = P_MAXFLOAT
00665 );
00666
00670 void OrbitPoint(const pVec ¢er,
00671 const float magnitude = 1.0f,
00672 const float epsilon = P_EPS,
00673 const float max_radius = P_MAXFLOAT
00674 );
00675
00681 void RandomAccel(const pDomain &dom);
00682
00692 void RandomDisplace(const pDomain &dom);
00693
00698 void RandomVelocity(const pDomain &dom);
00699
00704 void RandomRotVelocity(const pDomain &dom);
00705
00723 void Restore(const float time,
00724 const bool vel = true,
00725 const bool rvel = true
00726 );
00727
00731 void Sink(const bool kill_inside,
00732 const pDomain &dom);
00733
00740 void SinkVelocity(const bool kill_inside,
00741 const pDomain &dom);
00742
00748 void Sort(const pVec &eye,
00749 const pVec &look,
00750 const bool front_to_back = false,
00751 const bool clamp_negative = false
00752 );
00753
00767 void Source(const float particle_rate,
00768 const pDomain &dom
00769 );
00770
00777 void SpeedLimit(const float min_speed, const float max_speed = P_MAXFLOAT);
00778
00786 void TargetColor(const pVec &color,
00787 const float alpha,
00788 const float scale
00789 );
00790
00801 void TargetSize(const pVec &size,
00802 const pVec &scale
00803 );
00804
00813 void TargetVelocity(const pVec &vel,
00814 const float scale
00815 );
00816
00825 void TargetRotVelocity(const pVec &rvel,
00826 const float scale
00827 );
00828
00841 void Vertex(const pVec &v,
00842 puint64 data = 0
00843 );
00844
00848 void Vortex(
00849 const pVec ¢er,
00850 const pVec &axis,
00851 const float tightnessExponent,
00852 const float max_radius,
00853 const float inSpeed,
00854 const float upSpeed,
00855 const float aroundSpeed
00856 );
00857
00858 protected:
00859 PInternalState_t *PS;
00860 void InternalSetup(PInternalState_t *Sr);
00861 };
00862
00868 class ParticleContext_t : public PContextActionList_t, public PContextParticleGroup_t, public PContextActions_t, public PContextSourceState_t
00869 {
00870 public:
00872 ParticleContext_t();
00873
00875 ~ParticleContext_t();
00876 };
00877
00878 };
00879
00880 #endif