• 9
• 13
• 9
• 18
• 19

# Collision detection with the following scenario.

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

## Recommended Posts

If I have an object that is travelling through a tube of uniform radius then I can simplify the object's collision with the tube by not allowing it to travel past a certain position depending on the central point of the tube and its radius. However, if the tube is no longer straight and bends in any direction how should I tackle the collision detection between the object and the tube? Should I test the object against the nearest triangles of the tube OR Should I find out at which point the object is at in the tube in order to get the central point at that position and use the center radius movement restriction? This would rely on sampling points of the tube and then finding the closest sample point to the object's current point. Or, do you guys have a better method or some suggestions? Thanks

##### Share on other sites
Could you represent the tube by a series of line segments and use a "distance from point to line" calculation to enforce staying within the radius of the tube (similar to your second option). Then, given the line segment the ball is closest to you could use its vector and the ball's velocity vector to resolve any collisions.

##### Share on other sites
Hey Spa8nky!

I'd say if you try collision detection for ANY complex mesh, you need to partition it. If you have a tube that bends like so...

|||___   |   |   |

You can do some cylindrical collision checks on the ends of the pipe, and sphere (or more cylindrical) checks on the bends. If you want to be precise in a game world and not have to care (ultimately) about what geometry you are currently dealing with, you just pick a volume type to partition a scene or a subset thereof and make comparisons in a hierarchical fashion. It just narrows the playing field down to polygons you NEED to check. Do some research on the topic "Spatial Partitioning".

Any simple mesh you can make special cases for. Spatial partitioning handles pretty much everything else. In examples like the above, you don't need to get crazy... Just approach the problem by breaking down your "goal geometry" into simpler sections.

Another example is if you are trying to collide with a big number '8' with the holes filled. Just two ellipsoid checks, really. You can make them sphere checks by scaling the geometry in the complement set of the ellipsoid by it's radii!

I hope this helps.

Cheers!
-Zyro

##### Share on other sites
Quote:
 Could you represent the tube by a series of line segments

I'm not sure how that would work in this scenario:

Here I have a 3D tube and the object lies inside that tube. I wan't to prevent the object (X) from moving outside the tube:

_______
/
| (X) |
| |
\_______/

If the tube has say 32 sides, how would a series of 2D line segments work?

Quote:
 Just approach the problem by breaking down your "goal geometry" into simpler sections.

What are your thoughts on slicing the tube into segments represented by an AABB and then if the object is intersecting with that AABB, check the object against the triangles of that segment for collision.

Would that be too slow? Would it be easier to break down the tube into cylinders and perform a sphere/cylinder test (object's bounding sphere) and if so I would have to change the collision detection to detect when the sphere leaves the cylinder and keep it inside.

EDIT: What tag do I need for drawing ASCII correctly?

##### Share on other sites
Quote:
 What are your thoughts on slicing the tube into segments represented by an AABB and then if the object is intersecting with that AABB, check the object against the triangles of that segment for collision. Would that be too slow? Would it be easier to break down the tube into cylinders and perform a sphere/cylinder test (object's bounding sphere) and if so I would have to change the collision detection to detect when the sphere leaves the cylinder and keep it inside.

I think you should break it down in whatever fashion you find optimal. What you suggested is along the lines of what I'm saying.

My whole point is to think of it in a similar fashion to an artist. Break down what you want into simpler shapes. A cartoonish tree can be a cylinder and a sphere. A cactus can just be several cylinders. You don't want to vary yourself so much that you lose track of everything in your project. In one of my courses, we only use ellipsoidial volumes to split things up in various partitioning trees like quad, oct, kD and BSP.
You want to be able to even group a series of these volumes together and analyze which polygons you KNOW you are not going to collide.

Say for example I have a nice terrain made of 100 thousand polygons. I would encompass the geometry in a quad tree. I don't want to render this entire terrain at once, so I would check to see what nodes of the quad tree my camera sees. I can reject tens of thousands of polygons this way at once and still be accurate! It's just a matter of quickly finding polygons you know are going to be involved in something.

Again, I bring up spatial partitioning because the whole concept is trying to hasten collision detection for ALL meshes outside of the simple ones like spheres and boxes. (More appropriately, all scenes) It may help you to know that perfect sphere tests are faster than others.

Quote:
 EDIT: What tag do I need for drawing ASCII correctly?

The posts made here on GDnet are written on a layer between (X)HTML and some custom system. An HTML rule is carried over where all extra contiguous white space is removed to enforce certain formatting. I used the <pre> tag to write pre-formatted text.

These 3 seperators were meant to have 3 spaces between them as they go down.
|
|
|

Enter <pre> tag.
|   |      |

I hope this helps.

Cheers!
-Zyro

##### Share on other sites
well I can say using "code" in brackets doesn't work lol

##### Share on other sites
No, no. This is not in the list of tags GDnet uses with square brackets. Use HTML tags. In this case, <pre>.

##### Share on other sites
Quote:
 If the tube has say 32 sides, how would a series of 2D line segments work?

He was probably imagining a series of line segments running along the centre of the tube, that way at any point along the tube you find your closest point on the line (i.e. the centre of the tube at that location) and then work out your radius from that. You can think of the line segments as a simplified representation of your tube: the lines determine the 'path' of your tube and the radius (which I assume is constant) will give its 'thickness'. If you want the radius to change along the way I suppose you can include radius information along with your line segments.

##### Share on other sites
How did you get the pre to show with the angle brackets instead of it just being used as another tag?

##### Share on other sites
Quote:
 You can think of the line segments as a simplified representation of your tube: the lines determine the 'path' of your tube and the radius (which I assume is constant) will give its 'thickness'

Of course! That makes sense as I already have a line representing a path through the centre of the tube. I can now put the segements in AABBs and test for distance from each line, perfect.

Quote:
 The posts made here on GDnet are written on a layer between (X)HTML and some custom system. An HTML rule is carried over where all extra contiguous white space is removed to enforce certain formatting. I used the "pre" tag to write pre-formatted text.

 _______/       \   |       ||   (X) |\_______/Thank you! :D