00001 #ifndef SPIRAL_EMITTER_OPERATOR
00002 #define SPIRAL_EMITTER_OPERATOR
00003
00004 #include "gmtl/Math.h"
00005 #include "ani/Dynamics/Operator.h"
00006 #include "ani/Dynamics/DynamicSystem.h"
00007 #include "ani/Dynamics/operators/Emitter.h"
00008
00009 namespace ani
00010 {
00011
00013 template<class __EntityType>
00014 class SpiralEmitter : public Emitter<__EntityType>
00015 {
00016 public:
00017 typedef boost::shared_ptr<__EntityType> EntityTypePtr;
00018
00019 public:
00020 SpiralEmitter() : Emitter<__EntityType>(), x(0), velocitizer(0), pos( 0,0,0 ) {}
00021 virtual ~SpiralEmitter() {}
00022 void setPosition( float x, float y, float z )
00023 {
00024 pos.set( x, y, z );
00025 }
00026
00027 virtual void exec( DynamicSystem<__EntityType>& sys )
00028 {
00029 for (x += sys.timeDelta(); x > mRate; x -= mRate )
00030 {
00031 velocitizer += 0.75f * ps.timeDelta();
00032 if (velocitizer > 1.0f || velocitizer <= 0)
00033 velocitizer = 0.0f;
00034 EntityTypePtr p( new __EntityType );
00035 p->setMass( 1.0f );
00036 gmtl::Vec3f velocity( gmtl::Math::sin( velocitizer * TWO_PI_F ) * 5.0f, 19.6f, gmtl::Math::cos( velocitizer * TWO_PI_F ) * 5.0f );
00037 gmtl::Vec4f color( 0.3f, 0.2f, 1.0f, 1.0f );
00038 p->setVelocity( velocity );
00039 p->setPosition( pos );
00040 p->setColor( color );
00041 p->setAgeOfDeath( 10 );
00042 sys.add( p );
00043 }
00044
00045 if (x < 0) x = 0;
00046 }
00047
00048 float x;
00049 float velocitizer;
00050 gmtl::Vec3f pos;
00051 };
00052
00053
00054 }
00055
00056 #endif