Hey, hears what i do to keep the quads facing the camera. It's is very unoptimised, but still runs quickly :)
VertexCoords(fire_surface,fire\pindex+0,fire\x+Sin(fire\ang)*fire\size,fire\y+Cos(fire\ang)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+1,fire\x+Sin(fire\ang+90)*fire\size,fire\y+Cos(fire\ang+90)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+2,fire\x+Sin(fire\ang-90)*fire\size,fire\y+Cos(fire\ang-90)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+3,fire\x+Sin(fire\ang+180)*fire\size,fire\y+Cos(fire\ang+180)*fire\size,fire\z)
Ok, this first bit, sets the vertex co-ordinates for the z rotation, basically the spin the quad has.
Vertexcoords (SURFACE, INDEX of vertex,
Now thats the surface of the mesh. and the index of the vertex. The next bit is the x,y,z co-ords of the quad.
fire\x the x co-ord of the quad + Sin(fire\angle)*fire\size
The fire\angle is the angle of the z rotation. The fire\size is the size of the quad. Now in the other three you'll see i've added +180,+90 or -90 to the fire\angle bit.
This is because each vertex is 90 degs apart from each other.
fire_xdist(0)=Sin(fire\ang)*fire\size
fire_xdist(1)=Sin(fire\ang+90)*fire\size
fire_xdist(2)=Sin(fire\ang-90)*fire\size
fire_xdist(3)=Sin(fire\ang+180)*fire\size
fire_ycoord(0)=Cos(fire\ang)*fire\size
fire_ycoord(1)=Cos(fire\ang+90)*fire\size
fire_ycoord(2)=Cos(fire\ang-90)*fire\size
fire_ycoord(3)=Cos(fire\ang+180)*fire\size
Now this peice of code gets the distances between the centre of the quad and the vertex point and stores them in an array.
For loop=0 To 3
VertexCoords(fire_surface,fire\pindex+loop ,fire_xdist(loop), fire\y+fire_ycoord(loop)*Cos(cam_rot_x) ,fire\z+Sin(cam_rot_x)*fire_ycoord(loop) )
Next
This part performs the rotation on the X Axis. This must be done before the Y Axis is rotated, or it won't work right. I'll explain that more if you want.
fire_zdist(0)=Sin(cam_rot_x)*fire_ycoord(0)
fire_zdist(1)=Sin(cam_rot_x)*fire_ycoord(1)
fire_zdist(2)=Sin(cam_rot_x)*fire_ycoord(2)
fire_zdist(3)=Sin(cam_rot_x)*fire_ycoord(3)
fire_ycoord(0)=fire_ycoord(0)*Cos(cam_rot_x)
fire_ycoord(1)=fire_ycoord(1)*Cos(cam_rot_x)
fire_ycoord(2)=fire_ycoord(2)*Cos(cam_rot_x)
fire_ycoord(3)=fire_ycoord(3)*Cos(cam_rot_x)
This bit again stores the updated distances of the vertexs and such for usage in the next rotation stage. The reason i'm using arrays for all of this is i don't want to keep calling VertexX, VertexY and VertexZ, because i've heard with large meshes, this can take time.
For loop=0 To 3
VertexCoords(fire_surface,fire\pindex+loop ,fire\x+ (fire_xdist(loop)*Sin(cam_rot_y)) - (fire_zdist(loop)*Cos(cam_rot_y)), fire\y+fire_ycoord(loop) ,fire\z+(fire_zdist(loop)*Sin(cam_rot_y)) - (fire_xdist(loop)*-Cos(cam_rot_y)) )
Next
This part performs the last rotation on the Y Axis, by using the updated values in the array.
Weeeeshh, hope that helps some. If you want a demo, plz post back. :) It's tough and i'm glad i could help someone out with this :)
Here's the whole algorithim for it
VertexCoords(fire_surface,fire\pindex+0,fire\x+Sin(fire\ang)*fire\size,fire\y+Cos(fire\ang)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+1,fire\x+Sin(fire\ang+90)*fire\size,fire\y+Cos(fire\ang+90)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+2,fire\x+Sin(fire\ang-90)*fire\size,fire\y+Cos(fire\ang-90)*fire\size,fire\z)
VertexCoords(fire_surface,fire\pindex+3,fire\x+Sin(fire\ang+180)*fire\size,fire\y+Cos(fire\ang+180)*fire\size,fire\z)
fire_xdist(0)=Sin(fire\ang)*fire\size
fire_xdist(1)=Sin(fire\ang+90)*fire\size
fire_xdist(2)=Sin(fire\ang-90)*fire\size
fire_xdist(3)=Sin(fire\ang+180)*fire\size
fire_ycoord(0)=Cos(fire\ang)*fire\size
fire_ycoord(1)=Cos(fire\ang+90)*fire\size
fire_ycoord(2)=Cos(fire\ang-90)*fire\size
fire_ycoord(3)=Cos(fire\ang+180)*fire\size
For loop=0 To 3
VertexCoords(fire_surface,fire\pindex+loop ,fire_xdist(loop), fire\y+fire_ycoord(loop)*Cos(cam_rot_x) ,fire\z+Sin(cam_rot_x)*fire_ycoord(loop) )
Next
fire_zdist(0)=Sin(cam_rot_x)*fire_ycoord(0)
fire_zdist(1)=Sin(cam_rot_x)*fire_ycoord(1)
fire_zdist(2)=Sin(cam_rot_x)*fire_ycoord(2)
fire_zdist(3)=Sin(cam_rot_x)*fire_ycoord(3)
fire_ycoord(0)=fire_ycoord(0)*Cos(cam_rot_x)
fire_ycoord(1)=fire_ycoord(1)*Cos(cam_rot_x)
fire_ycoord(2)=fire_ycoord(2)*Cos(cam_rot_x)
fire_ycoord(3)=fire_ycoord(3)*Cos(cam_rot_x)
For loop=0 To 3
VertexCoords(fire_surface,fire\pindex+loop ,fire\x+ (fire_xdist(loop)*Sin(cam_rot_y)) - (fire_zdist(loop)*Cos(cam_rot_y)), fire\y+fire_ycoord(loop) ,fire\z+(fire_zdist(loop)*Sin(cam_rot_y)) - (fire_xdist(loop)*-Cos(cam_rot_y)) )
Next