   polygon / point collision test needed
  Hi, I am writing my own graphic engine, but I have some problem to handle collision with 2 meshes,I placed my word and his vertices vertex[0].x ...vertex[0].zvertex[1].x ...vertex[1].zvertex[2].x ...vertex[2].zbut I can't handle collision routine that can return if 2 bodies has collision.can you helpme please!1) I need to find plane distance to player position,but I cant do that.2) Detect if point is inside of polygon3) Make responce, compute new player position if it take place of colliison.:)   
Quote:Original post by dmitriydHi, I am writing my own graphic engine, but I have some problem to handle collision with 2 meshes,I placed my word and his vertices vertex[0].x ...vertex[0].zvertex[1].x ...vertex[1].zvertex[2].x ...vertex[2].zbut I can't handle collision routine that can return if 2 bodies has collision.can you helpme please!1) I need to find plane distance to player position,but I cant do that.2) Detect if point is inside of polygon3) Make responce, compute new player position if it take place of colliison.:)A few quick points:1. Graphics engines usually don't include things like collision detection and response. Do you mean 'game engine', perhaps?2. Intersection tests in 3-d are not usually implemented in terms of individual points and polygons. Instead, simple bounding shapes (such as spheres, boxes, and capsules) are used to approximate more complex shapes, and the intersection tests are performed using these simpler proxies.3. With respect to finding the distance from the player position to a plane, what do you mean by 'I can't do that'? If you're having problems with this process, you'll definitely want to get them resolved before moving on to more complex geometrical queries.4. This depends on your goals somewhat, but you might consider using a pre-existing physics library instead (collision detection and response is generally non-trivial and can take a lot of time and effort to get right when implemented from scratch).   ;Well, I write my "game engine" youll right not like "ghraphic engine"I have problem to write collision test routine, I have problem with plane equation ,its return an invalid value.here is the code:int world_plane_collision_3ds_md2(WORLD *a, MODEL *b){int j=0,i=0;int a1,b1,c1;int result=0;VERTEX3D p[3];OBJECT_INFO*objaux2; objaux2=a->model->objects;while (objaux2 != NULL){   for(i=0; i < objaux2->num_faces; i++)  {a1=objaux2->face.vertex[0];    b1=objaux2->face.vertex[1];    c1=objaux2->face.vertex[2];    p[0] = objaux2->vertex[a1];    p[1] = objaux2->vertex[b1];    p[2] = objaux2->vertex[c1]; collision_result = do_collision(b->radius,b->position,&b->position_final,p[0],p[1],p[2]);  } objaux2=objaux2->next;}    return 0;} end the "do_collision" routine:int do_collision(float radius,VERTEX3D position,VERTEX3D *new_position,VERTEX3D p1,VERTEX3D p2, VERTEX3D p3){float D=0,distance=0;float A=0,B=0;int k;VERTEX3D triangle[3];VERTEX3D normal; /*** Plane equation: Ax + Bx + Cx + D = 0 ==> D = -(Ax + Bx +Cx)******/normal = calculate_normal(p1,p2,p3); D = -dot_product(normal , p1);distance = dot_product(normal, position) + D ;model_plane_distance = absolute(distance);if(absolute(distance) < radius )return 1;else return 0;};  Un-retiring this thread so OP can reply instead of posting new threads.   