Sign in to follow this  

bounding sphere colission detection with a wall that is not a straight line

This topic is 4760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, i created a room in 3DS max and exported it as a .x file for directX. i have , in my application a simulation of a person moving through this room, the problem is the colission detection between the person and the walls. i cant do a simple plain/sphere intersection test, as the walls are not straight, they are curvy and in parts are made of semi-circles. i heard of a method where i compare each triangle in the mesh to see if it is inside the bounding sphere of my charachter. is there a function to do this in directX9? can anyone give me details of this method?.

Share this post


Link to post
Share on other sites
I'm not sure if directX has a built in tri-sphere collision detection routine but writing your own isn't that difficult. Take a look at Magic Software for some source code for this as well as many other useful snippets. As far as implementing the collision detection in your game goes, I don't recomend testing every tri against your sphere if you want to keep that framerate up. Remember: the quickest algorithm is the one that never executes. For your situation I'd create a grid around the room and have each grid square contain pointers to the tris that overlap it. Then simply collide the sphere with only the tris in the same grid squares that the sphere overlaps. This way you'll be eliminating most of the tris straight away without having to collide them. For more complex environments with more dynamic objects you may even want to consider using multi-resolution grids or trees. Have fun.

edit: One last thing. Capsules are usualy better to use that spheres for characters since it'll give you a tighter fit whilst still being simple to use.

Share this post


Link to post
Share on other sites
dude. this is all way over my head. the code, in magic software is all c++ code, and i find it almost impossible to read, as im a c# head. can you explain how you would place a grid around the room and then only have one check for each square? i have never implemented colission detection before so it seems very daunting

Share this post


Link to post
Share on other sites
I use C# now, look at my siggy for other languages.
If you are using a vertex/index buffer, references to triangles might be difficult.
Instead of pointers, I suggest indices into the index buffer for the triangles.
I have never written any C++, but I learnt it when I was 11 (started programming at 9) and found it invaluable because all books and articles use it.
I think what MotorHerp was suggesting was a quad tree, or oct tree if your characters can fly or whatever. Search for that.
Hope this helps,

Share this post


Link to post
Share on other sites

This topic is 4760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this