Sign in to follow this  
akaitora

D3DXIntersect Function

Recommended Posts

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

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

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!

Share this post


Link to post
Share on other sites
[quote name='akaitora' timestamp='1313804760' post='4851457']
I have a couple of questions about this function. First, from reading the documentation found here,

[url="http://msdn.microsoft.com/en-us/library/bb172882(v=vs.85).aspx"]http://msdn.microsof...2(v=vs.85).aspx[/url]

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![/size][/color]
[/quote]

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?

Share this post


Link to post
Share on other sites
[quote name='akaitora' timestamp='1313804760' post='4851457']
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?
[/quote]

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.


[quote name='akaitora' timestamp='1313804760' post='4851457']

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!


[/quote]
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.

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