Sign in to follow this  

World position of texture coordiantes

This topic is 4271 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

Is there any way to find the position in world/object space of each texture coordinate on a ID3DXMesh? I have'nt tried it, but I am fairly certain the D3DXIntersect function returns the UV coordinates hit by the ray, so as a last resort I could always try sending a bunch of rays at the mesh and record the positions. -Chris

Share this post


Link to post
Share on other sites
I'm not very familiar with the ID3DXMesh interface, but I imagine you should be able to get the data for each vertex. That should include the vertex position, normal, and texture coordinates. Maybe they do something odd like store the texture coordinates in another list somewhere, but it should still be tied to each vertex in some way (perhaps by vertex index?).

Share this post


Link to post
Share on other sites
Quote:
SDK documentation, about D3DXIntersectTri:
The D3DXIntersect function provides a way to understand points in and around a triangle, independent of where the triangle is actually located. This function returns the resulting point by using the following equation: V1 + U(V2 - V1) + V(V3 - V1).

Any point in the plane V1V2V3 can be represented by the barycentric coordinate (U,V). The parameter U controls how much V2 gets weighted into the result, and the parameter V controls how much V3 gets weighted into the result. Lastly, the value of [1 - (U + V)] controls how much V1 gets weighted into the result.

Barycentric coordinates are a form of general coordinates. In this context, using barycentric coordinates represents a change in coordinate systems. What holds true for Cartesian coordinates holds true for barycentric coordinates.

Barycentric coordinates define a point inside a triangle in terms of the triangle's vertices. For a more in-depth description of barycentric coordinates, see Mathworld's Barycentric Coordinates Description.


Hope this helps.

Share this post


Link to post
Share on other sites

This topic is 4271 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.

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