PDA

View Full Version : Collision detection !!!



Shadow
06-19-2000, 06:38 PM
What is the best way to check collisions
and field of view for AI ?

sebastian
06-19-2000, 10:22 PM
one can't explain that in general, it just depends on what game or app you want to code, but there are many ways for it ( maybe start with a simple function to detect whether a point is inside a polygon )

06-24-2000, 07:52 PM
this is some sample code from one of my glprograms
you basically make a small clip plane and when you move this clip plane(bullet, car, ect...)if something is going to be rendered inside this clip plane(polygon,wall,ect..)it is reported as a collision!

read up on ->

glRenderMode(GL_SELECT);

also ->

glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3); glEnable(GL_CLIP_PLANE4); glEnable(GL_CLIP_PLANE5);

and..->

glInitNames();
if (left){glTranslated(-a/angle,-y2,-z);} else{glTranslated(a/angle,-y2,-z);}
glPushName(h1);//wall
glDrawArrays(GL_QUADS,33,4);//wall
glPopName();

glRenderMode(GL_RENDER);
glPopMatrix();

if (hit[3]>=1)//wall
{wallhit();}
it's pretty simple!
hope this helps!