Jump to content
  • Advertisement
Sign in to follow this  
gammaGT

[MDX] Intersection testing (via Mesh.Intersect(...))

This topic is 4362 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 folks! I have some issues testing intersection between two meshes on triangle level. That's what I do: Vector3[] rays = Vector3.TransformCoordinate(Vector3.TransformCoordinate(node.GetIntersectionRays(ref device), node.combinedTransform), Matrix.Invert(this.combinedTransform)); IntersectInformation info; for (int i = 0; i < rays.Length - 1; i++) { if (this.nodeMesh.Intersect(rays, rays[i + 1] - rays, out info)) { if (info.Dist < Vector3.Length(rays[i + 1] - rays)) { m_bCollision = true; node.m_bCollision = true; return; } } } I thought to have done everything properly... I apply the Mesh's combined transform to the (untransformed) vertices and then the inverse transform of the Mesh I call Mesh.Intersect(...) on. Still, I get Intersections when there can't be any. Can someone have a look at the code and tell me, if I erred somewhere? Thanks, Martin

Share this post


Link to post
Share on other sites
Advertisement
I solved it!
Apart from some smaller bugs and inefficiencies in my code, that I fixed, the main problem was the length of the vector representing the ray's direction. It has to have to have the length of 1. Even though I can't really tell why that is so, I don't get any wrong intersections when normalizing the direction vector.

So long,

Martin

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!