View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

# 3d collision

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

1 reply to this topic

### #1flashlaser  Members

Posted 03 October 2001 - 03:13 AM

I am making a GTA syle game and I am stuck on the collision detection. I read another tutorial on collision and I got an idea from it. Tell me if this will work. My car is a mesh, so I will loop though each vector(vertex) of the car and input into my collision detection function added with another vector showing where the car will move. The function will then loop though each triangle in my city mesh and find its plane then work out if the which side of the triangle plane the car vertex will be if is moved. If the loop ends without collison being TRUE then the car is moved, else the car remains where it is. Here''s some pesudo code- D3DXVECTOR3 pos; D3DXVECTOR3 movepos; for(i=0;ipos=carVerice+movepos; collision(pos); } if (collision!=TRUE) { x=movepos.x; y=movepos.y; z=movepost.z; } VOID collision(D3DXVECTOR3 &pos) { for (each triangle of city mesh) { findPlane(); checkWhichSideOfPlanePosIsOn(); if (collision) { collision = TRUE; } } } Is there any problems with my idea. If not can someone expand my code more, like show how me code for finding the plane, etc. Any help will be helpful.

### #2Scarab0  Members

Posted 03 October 2001 - 03:42 AM

Well I can think of two problems at least with this method.
1) Looping through all vertices of a mesh and checking them against every triangle in the map is slow.
2) If some vertices are on one side of a triangle-plane and some are on the other side, then the mesh collides with the plane of the triangle and not the triangle itself. So collision could be set to TRUE even when there is no collision.

I am not sure how you could best fix these problems, it depends a bit on how your level is stored in memory and stuff like that. But if I were to make a GTA like game, I''d probably use something like a BSP tree or octree for the level and an octree or obb-tree for the car mesh.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.