World position of texture coordiantes

Started by
1 comment, last by sirob 18 years ago
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
Advertisement
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?).
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.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement