Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


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.

  • You cannot reply to this topic
1 reply to this topic

#1 flashlaser   Members   -  Reputation: 122

Like
Likes
Like

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.

Sponsor:

#2 Scarab0   Members   -  Reputation: 122

Like
Likes
Like

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.



PARTNERS