PDA

View Full Version : Quake3 Colision problems



Bruno
03-11-2001, 08:30 AM
Hi

I'm tryng to implement collision detection in my engine, but i'm having some problems,

I'm not using the brushes to detect colision, i'm just tryng to detect colision with the faces..,

Each face as this structure:

typedef struct
{

long start; // First face vertex in the array
long nVertices; // Number of vertices in the face
long TexID; // Texture indice into the texture array
long LmapID; // Lmap ID into the lightmaps array
plane_t p; // plane equation, four floats;
}Faces;

This structure is extracted from a q3 bsp file.
Ok, the way i'm tryng to detect is like this:

For each face,

Normal[0] = next_face->p.A;
Normal[1] = next_face->p.B;
Normal[2] = next_face->p.C;

// Here i get the distance from the camera
to the plane

d = DotProduct(Normal,camera);
d = abs(d);
//I got a radius of 20, from the camera to the planes
if(d<20)
{
colision=1;
}

This works with same planes, but not to all planes..why ? What i'm doing wrong here ?

p.s--> I'm not using curved surfaces.
thanks for any help,

Bruno

AndersO
03-12-2001, 01:48 AM
Looking at the code it looks like you're doing sphere/plane intersection tests, you would need to do sphere/triangle tests to get it to work I think.

The sphere/plane test probably works fine inside convex enviroment, such as inside a cube, but not in concave enviroment or outside a convex. Wich may be the problem you are seeing.

Cheers

[This message has been edited by AndersO (edited 03-12-2001).]