I have many partical effects for wepions, explotions and ship trails.
I'm unable to use depth testing for the particals, so i have been doing a test, that will find the order of how close objects are, then draw them in in a order farthest to cloesist. The more advanced my game is getting the less and less preactical this method is getting.
I've been working on projecting and doing a pixel check to see if anything is infront but that is not working.
Is there an easier method to solve this problem?
Below is the check code for a paticluar partical. It doesnt work it shows there is always somthing infront of the partical.
Help with an alternative, or a fix to my code would really make my day
double sx,sy,sz, depth;
GLdouble modelMatrix[16]; // The model matrix.
GLdouble projMatrix[16]; // The projection matrix.
GLint viewport[4]; // The viewport.
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); // Load the matricies and viewport.
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);
//Find partical on screen
gluProject(plas1p[0].Gxpos(),plas1p[0].Gypos(),plas1p[0].Gzpos(),modelMatrix,projMatrix,viewport,&sx,&sy,&sz);
//If the partical is on screen
if(sx < viewport[2] && sx >= 0 && sy < viewport[3] && sy >= 0 )
{
//Read pixels
glReadPixels((sx),(int)(sy),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&depth);
//somthing is infront of the partical
if(depth < sz)
//apply a black texture
glBindTexture(GL_TEXTURE_2D,g_Texture[9]);
else
//apply the proper texture
glBindTexture(GL_TEXTURE_2D,g_Texture[10]);
}
[edited by - skow on June 24, 2003 12:21:24 AM]