Advertisement Jump to content
Sign in to follow this  

collision detection(polyhedron)

This topic is 4886 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

Hi everyone, i am building a program and in the virtual environment I want the camera bounded with a polyhedron, probably a box, right. but I am just wondering how will I detect the collision with the worlds object? does it have anything to do with the "boundary representation" ? Do i store boundary representation like edgs, vertex and polygon for collision detection check?? I am kind of lost. Thanks alot

Share this post

Link to post
Share on other sites
We were talking about this a while ago, right? IIRC you're doing a walkthrough of an architectural environment of some sort, including obstacles such as furniture and so on.

If you're primarily concerned with your camera, I think the absolute easiest thing to do would be simple static sphere/polygon intersection and collision resolution. Even this will take a little work, but it should be doable. (Note that I'm assuming you want more accurate collision detection than just enclosing everything in an axis-aligned box.)

There are fancier ways to do the following that involve quadratic minimization and so on, but we'll keep it simple. We'll also assume for the moment that you won't need a broad phase, and can afford to check the sphere against every polygon every frame. One final assumption will be that your camera will move relatively small amounts each frame - a little less than its radius at most.

For each polygon, you need to:

1. Find the closest point on the polygon to the sphere center
2. Create a vector from this point to the sphere center
3. Normalize the vector and save the length
4. If the length is less than the sphere radius, move the sphere along the vector by radius-length

The only hard part is finding the closest point on the polygon. For this you'll need:

1. A closest-point-on-plane function
2. A point-in-polygon function
3. A closest-point-on-line-segment function

Find the closest point on the polygon support plane. If it's in the polygon, you're done. Otherwise, find the closest point on each of the polygon edges and choose the one whose distance to the sphere center is least.

This should give you nice, smooth collision detection and response, including natural sliding and stopping.

That's about as simple as that method gets, I think. If you want something even easier to implement, you might consider making your camera a sphere or axis-aligned box, and representing all your other objects as axis-aligned boxes as well.

'Hope some of that will be helpful to you.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!