00001
00006 #include "PointEmitter.h"
00007 #include "StraightSolver.h"
00008 #include "UniformForce.h"
00009
00010 using namespace GraphicsLib;
00011 using namespace ParticleSystems;
00012
00013 PointEmitter::PointEmitter( int SYSID,
00014 Solver *s,
00015 PARTICLETYPE type,
00016 Vector initVel,
00017 Colour initialColor,
00018 GLfloat pSize,
00019 Point3 initPos,
00020 GLfloat sw) : Emitter(SYSID, s, type, initVel, initialColor, pSize) {
00021 initPosition = initPos;
00022 sweep = sw;
00023 }
00024
00025 PointEmitter::PointEmitter( int SYSID,
00026 Solver *s,
00027 PARTICLETYPE type,
00028 Vector initVel,
00029 Colour initialColor,
00030 GLfloat pSize,
00031 char *TexName,
00032 Point3 initPos,
00033 GLfloat sw) : Emitter(SYSID, s, type, initVel, initialColor, pSize, TexName){
00034 initPosition = initPos;
00035 sweep = sw;
00036 }
00037
00038 PointEmitter::~PointEmitter() {
00039 }
00040
00041
00042 Particle* PointEmitter::emittParticles(void) {
00043
00044 Particle *result;
00045 if(type == POINT) {
00046 #ifdef __SPRITE__
00047 std::cout << "PointEmmitter: Emitting Sphere" << std::endl;
00048 #endif
00049 result = new PointParticle( SYSID,
00050 solver,
00051 initPosition,
00052 withSweep(),
00053 initialColor,
00054 flareColor,
00055 particleSize,
00056 particleSizeFlare,
00057 RandomPosNum(particleLife));
00058 } else if(type == IMAGE) {
00059 #ifdef __SPRITE__
00060 std::cout << "PointEmmitter: Emitting Sprite" << std::endl;
00061 #endif
00062 result = new ImgParticle( SYSID,
00063 solver,
00064 initPosition,
00065 withSweep(),
00066 initialColor,
00067 flareColor,
00068 particleSize,
00069 particleSizeFlare,
00070 RandomPosNum(particleLife),
00071 &texture);
00072 } else if(type == STRIKE) {
00073 #ifdef __SPRITE__
00074 std::cout << "PointEmmitter: Emitting Sphere" << std::endl;
00075 #endif
00076 result = new StrikeParticle( SYSID,
00077 solver,
00078 initPosition,
00079 withSweep(),
00080 initialColor,
00081 flareColor,
00082 particleSize,
00083 particleSizeFlare,
00084 RandomPosNum(particleLife));
00085 }
00086
00087 return result;
00088 }
00089
00090 Vector PointEmitter::withSweep() {
00091
00092 Vector result = initialVelocity;
00093
00094
00095 result.x += RandomNum(sweep);
00096
00097 result.y += RandomNum(sweep);
00098
00099 result.z += RandomNum(sweep);
00100 return result;
00101 }
00102
00103 void PointEmitter::reBirth(Particle *p) {
00104
00105 #ifdef __PERFORMANCE__
00106 std::cout << "PointEmiter: Before setting rebirth" << std::endl;
00107 #endif
00108 p->position = initPosition;
00109 p->size = particleSize;
00110 p->colour = initialColor;
00111 p->faded_colour = flareColor;
00112 p->life = 0;
00113 p->dead = false;
00114 p->velocity=withSweep();
00115 #ifdef __PERFORMANCE__
00116 std::cout << "PointEmiter: after setting rebirth" << std::endl;
00117 #endif
00118 }