D3DXIntersect Function

Started by
1 comment, last by clb 12 years, 8 months ago
I have a couple of questions about this function. First, from reading the documentation found here,

http://msdn.microsoft.com/en-us/library/bb172882(v=vs.85).aspx

It seems this function requires the entire mesh to be made from triangles. Is this true? A mesh made from Quads would not work with this function correct?

Second, how does this function query and choose the triangle that a ray intersects with? Does it iterate through every triangle in the mesh or only a subset? Thanks in advance!

xdpixel.com - Practical Computer Graphics

Advertisement

I have a couple of questions about this function. First, from reading the documentation found here,

http://msdn.microsof...2(v=vs.85).aspx

It seems this function requires the entire mesh to be made from triangles. Is this true? A mesh made from Quads would not work with this function correct?


[color=#1C2837][size=2]Second, how does this function query and choose the triangle that a ray intersects with? Does it iterate through every triangle in the mesh or only a subset? Thanks in advance!


1) Well quads are made from two triangles unless your using some fancy software renderer.

2) My guess it would just iterate through the data but use some algorithm to just iterate through a small area near where the ray would be relative to the mesh?

It seems this function requires the entire mesh to be made from triangles. Is this true? A mesh made from Quads would not work with this function correct?


Yes, this function only operates on triangle meshes. If you have a quad mesh, you need to preprocess it to split it down to a triangle mesh, before creating a ID3DXMesh out of it. If you exported your mesh to .X format and load it in using D3DX functions, this will have happened automatically, even if the mesh originally did have quads in it in the modelling software.




Second, how does this function query and choose the triangle that a ray intersects with? Does it iterate through every triangle in the mesh or only a subset? Thanks in advance!



I doubt ID3DXMesh generates any kind of acceleration structure to optimize ray intersection queries, so it will simply iterate through every triangle of the mesh to find the closest triangle intersection. At least I've never seen the D3DX documentations state otherwise. If anyone knows the docs to mention anything about this, it would be nice to know.

This topic is closed to new replies.

Advertisement