Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

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

Started by gammaGT Aug 10, 2006 at 7:47 AM 0 replies 550+ views
Original Post
gammaGT
gammaGT
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
--I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
gammaGT
gammaGT
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
--I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.