
#ifndef _FIREPARTICLE
#define _FIREPARTICLE


	class cFireParticle
	{

	public:
		float x,y,z;
		float xa,ya,za;
		float r,g,b;
		float rotx,roty,rotz;
		float size;
		int life;
		float sx,sy,sz;	//spawn points
		int type;

		void xyz(float xx,float yy,float zz)
		{
			x=xx; y=yy; z=zz;
		}

		void accel(float xx,float yy,float zz)
		{
			xa=xx; ya=yy; za=zz;
		}

		void color(float rr,float gg,float bb)
		{
			r=rr; g=gg; b=bb;
		}

		void spawn(float xx,float yy,float zz)
		{
			sx=xx; sy=yy; sz=00;
		}

		void respawn()
		{
			x=sx; y=sy; z=sz;
			accel( ( (((float)rand())/32768) -0.5) /100,
				   ( (((float)rand())/32768) ) /40,
				   ( (((float)rand())/32768) -0.5) /100);
		}

		void move()
		{
			x+=xa;
			y+=ya;
			z+=za;
		}

		void move(float xaa,float yaa,float zaa)
		{
			x+=xa; xa+=xaa;
			y+=ya; ya+=yaa;
			z+=za; za+=zaa;
		}

		void bound2d(float x1,float y1,float x2,float y2,float dampen)
		{
			if ((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2)) return;
			if ((x<x1) && (xa<0)) xa*=-1;
			if ((x>x2) && (xa>0)) xa*=-1;
			if ((y<y1) && (ya<0)) ya*=-1;
			if ((y>y2) && (ya>0)) ya*=-1;
			xa*=dampen; ya*=dampen;
		}

		void bound3d(float x1,float y1,float z1,float x2,float y2,float z2,float dampen)
		{
			if ((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2) && (z>=z1) && (z<=z2)) return;
			if ((x<x1) && (xa<0)) xa*=-1;
			if ((x>x2) && (xa>0)) xa*=-1;
			if ((y<y1) && (ya<0)) ya*=-1;
			if ((y>y2) && (ya>0)) ya*=-1;
			if ((z<z1) && (za<0)) za*=-1;
			if ((z>z2) && (za>0)) za*=-1;
			xa*=dampen; ya*=dampen; za*=dampen;
		}

		void wrap2d(float x1,float y1,float x2,float y2)
		{
			if ((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2)) return;
			if ((x<x1) && (xa<0)) x=x2;
			if ((x>x2) && (xa>0)) x=x1;
			if ((y<y1) && (ya<0)) y=y2;
			if ((y>y2) && (ya>0)) y=y1;
		}

		void translater(float xoffs,float yoffs,float zoffs)
		{
			rotx+=xoffs;
			roty+=yoffs;
			rotz+=zoffs;
		}

		void translate(float xoffs,float yoffs,float zoffs)
		{
			x+=xoffs;
			y+=yoffs;
			z+=zoffs;
		}

		void rotate(float xang,float yang,float zang)
		{
			float radian=(3.141592654/180);
			float tx,ty,tz;
			tx=x+0.1;
			ty=y+0.2;
			tz=z+0.3;

			/************ Rotate around X-Axis *************/
			roty=(cos(xang*radian)*ty)-(sin(xang*radian)*tz);
			rotz=(sin(xang*radian)*ty)+(cos(xang*radian)*tz);
			ty=roty; tz=rotz;

			/************ Rotate around Y-Axis *************/
			rotx=(cos(yang*radian)*tx)+(sin(yang*radian)*tz);
			rotz=(-sin(yang*radian)*tx)+(cos(yang*radian)*tz);
			tx=rotx; tz=rotz;

			/************ Rotate around Z-Axis *************/
			rotx=(cos(zang*radian)*tx)-(sin(zang*radian)*ty);
			roty=(cos(zang*radian)*ty)+(sin(zang*radian)*tx);

			rotx-=0.1;
			roty-=0.2;
			rotz-=0.3;
		}

	};


#endif