Sign in to follow this  
jammy5202

collision intersections

Recommended Posts

I am trying to use D3DXIntersect to do collision detection between two meshes. Does it only return the closest triangle to intersect the ray? I am producing the a ray from each vertex of the first object for the position? For the rays direction vector i am using the velocity vector normalized. I am not sure if this is correct as i have not been able to find much online about it. At the momenent is misses the collision or stops miles before the collision.

Share this post


Link to post
Share on other sites
D3DXIntersect returns the ID (index) of the face of the closest intersection, although it can return all intersections if you supply an extra LPD3DXBUFFER to hold all information.

However, I think you are using it mistakenly.
You are sending a ray from each vertex of a mesh, towards the direction of its velocity. D3DXIntersect just tells you whether this ray intersects another mesh;
what you are actually doing now, is testing whether the "projection" of a mesh along its velocity, intersects another mesh. Clearly, this way you may get an intersection even if they are infinitely away from each other.
The Intersect functions of the extension library are meant for ray-triangle intersection problems, like mesh picking with the cursor.

If you have any questions about D3DXIntersect, just ask, however I think you'd be better off with some other method if you want actual "mesh to mesh" collision detection.

Share this post


Link to post
Share on other sites
what method should i use for mesh to mesh collision?

I have manged to get this to work this was but some times it misses the collision by a little bit.

Share this post


Link to post
Share on other sites
unfortunately I don't think I "qualify" to answer that question... definitely, I can suggest a method or two (roughly), but I'm sure that other posters will be more helpful with this :)

Share this post


Link to post
Share on other sites
Quote:
Original post by jammy5202
what method should i use for mesh to mesh collision?
As someusername said, D3DXIntersect() may not be the best way to accomplish what you want.

In general, mesh vs. mesh intersection is pretty hard, and (AFAIK at least) isn't used that often in practice. More commonly, game objects are represented by proxies (simple bounding volumes such as spheres, cylinders, boxes, and so on, or convex hulls) that are much easier to perform intersection tests on.

What algorithm would be a good choice depends on the circumstances, so perhaps you could tell us what the collision detection is for, and why you feel you need a mesh-mesh test.

Share this post


Link to post
Share on other sites
I am creating a bowling simulation for university which requires i have a broad phase and narrow phase of collision detection. At the moment i am using a compination of bounding boxes and spheres to test each object againist each other in the broad phase collisions.

In the narrow phase i am using the D3DXintersect using the ray from each vertex againist the triangles of another mesh. It seems to work as i only have 11 meshes in the whole simulation.

Share this post


Link to post
Share on other sites

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