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