Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_TOOL_PARTICLEANIMATOR_H__
00009 #define __SP_TOOL_PARTICLEANIMATOR_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_PARTICLEANIMATOR
00015
00016
00017 #include "SceneGraph/spSceneGraph.hpp"
00018
00019
00020 namespace sp
00021 {
00022 namespace tool
00023 {
00024
00025
00026
00027
00028
00029
00030 enum EParticleAttribute
00031 {
00032 PARTICLE_LOOP,
00033 PARTICLE_ONESHOT,
00034 };
00035
00036 enum EParticleBlendMode
00037 {
00038 PARTICLE_NOBLENDING,
00039 PARTICLE_BLENDIN,
00040 PARTICLE_BLENDOUT,
00041 };
00042
00043
00044
00045
00046
00047
00048 struct SParticle
00049 {
00050 scene::Billboard* Object;
00051
00052 dim::vector3df Translation;
00053 dim::vector3df Gravity;
00054 dim::vector3df Rotation;
00055 dim::vector3df Transformation;
00056
00057 u64 Time;
00058 u64 Endurance;
00059 f32 Alpha;
00060 f32 BlendSpeed;
00061 EParticleBlendMode BlendMode;
00062
00063 EParticleAttribute Attribute;
00064 };
00065
00066 typedef bool (*PFNPARTICLECALLBACKPROC)(SParticle* Object);
00067
00068
00075 class SP_EXPORT ParticleAnimator
00076 {
00077
00078 public:
00079
00080 ParticleAnimator();
00081 virtual ~ParticleAnimator();
00082
00083 virtual SParticle* addParticle(
00084 scene::Billboard* Object, const EParticleAttribute Attribute, const u64 Endurance, const f32 BlendSpeed,
00085 const dim::vector3df &Impulse, const dim::vector3df &Gravity = 0.0f,
00086 const dim::vector3df &Rotation = 0.0f, const dim::vector3df &Transformation = 0.0f
00087 );
00088 virtual SParticle* addParticle(const SParticle &Object);
00089
00090 virtual void removeParticle(scene::Billboard* &Object, bool isDeleteBillboard = false);
00091 virtual void removeParticle(SParticle* &Object, bool isDeleteBillboard = false);
00092
00093 virtual void setParent(scene::SceneNode* Parent, bool isGlobal = false);
00094
00095 virtual void setDestructionCallback(const PFNPARTICLECALLBACKPROC DestructionProc);
00096 virtual void setEnduranceCallback(const PFNPARTICLECALLBACKPROC EnduranceProc);
00097
00099 virtual void update();
00100
00101
00102
00103 inline void setBoundingBox(const dim::aabbox3df &BoundBox)
00104 {
00105 BoundBox_ = BoundBox;
00106 }
00107 inline dim::aabbox3df getBoundingBox() const
00108 {
00109 return BoundBox_;
00110 }
00111
00112 inline void setSpeed(const f32 Speed)
00113 {
00114 AnimSpeed_ = Speed;
00115 }
00116 inline f32 getSpeed() const
00117 {
00118 return AnimSpeed_;
00119 }
00120
00121 inline scene::SceneNode* getParent() const
00122 {
00123 return Parent_;
00124 }
00125
00126 protected:
00127
00128
00129
00130 virtual bool updateParticle(std::list<SParticle*>::iterator &it);
00131
00132 virtual void setParticleAlpha(SParticle* Obj, const f32 Alpha);
00133 virtual void setParticleAlpha(SParticle* Obj);
00134
00135
00136
00137 std::list<SParticle*> ParticleList_;
00138 scene::SceneNode* Parent_;
00139 bool ParentGlobal_;
00140
00141 dim::aabbox3df BoundBox_;
00142
00143 f32 AnimSpeed_;
00144
00145 PFNPARTICLECALLBACKPROC pDestructionProc_;
00146 PFNPARTICLECALLBACKPROC pEnduranceProc_;
00147
00148 };
00149
00150
00151 }
00152
00153 }
00154
00155
00156 #endif
00157
00158 #endif
00159
00160
00161
00162