PDA

View Full Version : Mesh Intersecton

David Doria
06-06-2008, 11:44 AM
I have a vrml model (wml file) that I need to shoot some rays at to get the distance from a point (similar to ray tracing, but i just need the coordinates of the intersection, nothing about the light). Do I have to determine the intersection of the ray with every triangle in the mesh, then take the closest one? or is there a better way to do this?

Thanks,

Dave

dletozeun
06-06-2008, 01:56 PM
http://www.cs.virginia.edu/~gfx/Courses/...ntersection.pdf (http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection .pdf)
http://www.devmaster.net/wiki/Ray-triangle_intersection

David Doria
06-06-2008, 07:04 PM
Right right, I am familiar with some of those methods for determining if a ray intersects a triangle, but if I am shooting thousands of rays at a mesh made of thousands of triangles, it seems like there should be some built in method of intersecting a ray with the whole mesh, ie.

Ray.Intersect(Mesh)

or something, so I don't have to implement the actual loop to go through the triangles. Am I way off base here?

Thanks,

Dave

rgpc
06-06-2008, 09:19 PM
You can optimize the process by first testing against the Bounding box (or sphere) of each object. You could also implement something like an Oct Tree to "split up" your mesh (so you test against the various levels of the Oct tree until you get to the lowest level, then you test against the poly's in that Oct Tree). But ultimately, if you want to know where your ray hits your mesh, then you'll have to test against each of the poly's in the mesh. The only "built in" method is to use Picking (which I've never done) - but that has it's own set of issues when dealing with individual poly's (as I understand it).

David Doria
06-07-2008, 08:32 AM
Does anyone have/know where I can get some canned c++ code to do some of this stuff (loading an obj file, triangle intersection, mesh intersection, etc)?