00001
00006 #include "ImgParticle.h"
00007 #ifndef __APPLE__
00008 #include <tiffio.h>
00009 #endif
00010
00011 using namespace GraphicsLib;
00012 using namespace ParticleSystems;
00013
00014
00015 ImgParticle::ImgParticle(int sysId, Solver *sol, Texture *tex) : Particle(sysId,sol) {
00016 texture = tex;
00017 }
00018
00019 ImgParticle::ImgParticle( int sysId,
00020 Solver *sol,
00021 Point3 pos,
00022 Vector vel,
00023 Colour c,
00024 Colour fc,
00025 GLfloat s,
00026 GLfloat fs,
00027 GLfloat ml,
00028 Texture *tex) : Particle(sysId, sol, pos, vel, c,fc,s ,fs ,ml) {
00029 texture = tex;
00030 }
00031
00032 ImgParticle::~ImgParticle() {
00033 }
00034
00035 void ImgParticle::draw(void) {
00036 #ifdef __PERFORMANCE__
00037 std::cout << "IMGParticle: beforedrawing particles" << std::endl;
00038 #endif
00039
00040
00041
00042 float matrix[16];
00043
00044 glGetFloatv(GL_MODELVIEW_MATRIX,matrix);
00045
00046 float x0 = matrix[0] - matrix[1];
00047 float x1 = matrix[0] + matrix[1];
00048
00049 float y0 = matrix[4] - matrix[5];
00050 float y1 = matrix[4] + matrix[5];
00051
00052 float z0 = matrix[8] - matrix[9];
00053 float z1 = matrix[8] + matrix[9];
00054 glPushMatrix();
00055
00056 float s = size;
00057 float x = position.x;
00058 float y = position.y;
00059 float z = position.z;
00060 float xx = old_Position.x;
00061 float yy = old_Position.y;
00062 float zz = old_Position.z;
00063
00064
00065 colour.Use();
00066
00067
00068 glBegin(GL_QUADS);
00069 glTexCoord2d(1,0);glVertex3f(xx - x1*s,yy - y1*s,zz - z1*s);
00070 glTexCoord2d(1,1);glVertex3f(x + x0*s,y + y0*s,z + z0*s);
00071 glTexCoord2d(0,1);glVertex3f(x + x1*s,y + y1*s,z + z1*s);
00072 glTexCoord2d(0,0);glVertex3d(xx - x0*s,yy - y0*s,zz - z0*s);
00073 glEnd();
00074
00075
00076 glPopMatrix();
00077
00078
00079 #ifdef __PERFORMANCE__
00080 std::cout << "IMGParticle: afterdrawing particles" << std::endl;
00081 #endif
00082 }
00083
00084 void ImgParticle::update(void) {
00085
00086
00087 Vector *tmp = &velocity;
00088 solv->nextStep(tmp);
00089 #ifdef __COLLISION__
00090 std::cout << "In particle " << position<< std::endl;
00091 #endif
00092
00093 old_Position = position;
00094 position+=velocity;
00095 size -= flare_size;
00096 colour = colour - faded_colour;
00097 life+=1.0;
00098 if(life>MAXLIFE) {
00099 dead = true;
00100 }
00101 #ifdef __COLLISION__
00102 std::cout << "In particle new" << position<< std::endl;
00103 #endif
00104 }
00105
00106 bool ImgParticle::isDead() {
00107 return dead;
00108 }
00109
00110
00111