Public Group

# collision detection(polyhedron)

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

## 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 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.

1. 1
Rutin
73
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633426
• Total Posts
3011816
• ### Who's Online (See full list)

There are no registered users currently online

×