Skip to main content
gamedev.net
🔒 Locked

colision detection

Started by a_metalhead 2 replies 600+ views
Original Post
a_metalhead
a_metalhead
hey, i have a 3d game, an i was wondering is there was some way to do colisoin without having to put all the meshs in an array and doing a foreach statment, as that is rather CPU intesive... if you have an exapmle thatle be great... by the way, im doing this in managed directX... thanks! ~metalhead
Scythen
Scythen
First step is to create bounding volumes for those meshes and test them first.
Only test at the poly level once you find the colliding BVs.
Any type of BV will be better than doing per-poly tests on every one of your meshes.

Even a flat list of BVs will be much faster [wow]

The D3DX library has bounding box and sphere functions to calculate them for meshes. I believe there are intersection tests as well.

After you get that working, look into some form of data structure to minimize the number of objects that need to be tested. Anything from a simple tree hierarchy to a quad tree system or kd tree or octree.

My advice is just move to the BVs first.
Supernat02
Supernat02
Collision detection is a HUGE subject. It could be done many different ways and would depend on exactly what kind of game you are making in some instances. If you anticipate having a lot of "alive" objects in your game and a large game world where you only inhabit a small portion of it at a time, then you will want to have an algorithm for reducing the number of collision tests you do. An octree or quadtree are good examples. If you know exactly where you are in the world, you know that portion of the world (through using the tree) contains a certain number of objects. You can then test only those objects for collision.

You probably want to use simplified collision detection, though sometimes you want to know exactly where on the mesh the collision took place. Let's say you don't for now though. You would have a box, sphere, or cylinder representing the extents of every object that you want to test. A sphere is the easiest, because you can see if the two objects you are testing collide by subtracting their center points and verifying that the distance between the points is less than the sums of their radii. That's just an example, but it can get much more complicated. Look out bounding boxes, Axis Aligned Bounding Boxes AABB, collision detection, etc for more information. I'd suggest reading some books or tutorials online.

Good luck,
Chris
Chris ByersMicrosoft DirectX MVP - 2005
a_metalhead
a_metalhead
uh...the game im making is a FPS... and its not gonna be all the complcated, im just doing for xp, as this is only the second 3d game iv made and i jsut got into managed directX less than a week ago... i dont realy understand what you are saying, could yo usimplafy it or point me to a online tut? thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.