How to get X and Y position of mesh triangle in world coord. ?

Started by
5 comments, last by Bitem2k 18 years, 8 months ago
I have try picking using mesh intersection.... i got u,v,dist, and face index... why U,V return the value below 1 (0,....) ? (is it okay?) AND after got those all returned value above...How can I get the world position of the triangle(face) i've clicked on the mesh? [Edited by - be17_17y on August 2, 2005 6:49:20 AM]
Advertisement
Sorry im not sure about the picking however there are many articles about this subject. Do a search on this forum and im sure u will find something usefull.

U and V are simply texture coordinates, not actual world space coords. That is why they range from 0 to 1. You may think of U being X and V being Y.
the texture is stretched across the surface of polygons/triangles using these coordinates. See The picture below.




Hope this helps



Quote:Original post by be17_17y
why U,V return the value below 1 (0,....) ? (is it okay?)

Are they barycentric coordinates? You haven't mentioned D3DX, but I'm pretty sure it (as well as alot of other algorithms) return the intersection point as a pair of barycentric coords.

Quote:Original post by be17_17y
How can I get the world position of the triangle(face) i've clicked on the mesh?

The first step would be to take the 3 vertexes making up the face, transform them from model->world space using your world transform matrix (what you'd use in D3DTS_WORLD calls).

Next, once you have the triangle defined in world space you should be able to decode the barycentric coordinates and create a, final, world space point-of-intersection.

It seems my usual maths site, mathworld, is offline at the moment ([oh]) - if it's back up later, try this linke: http://mathworld.wolfram.com/BarycentricCoordinates.html.

Alternatively, a Google search should pull up some methods for converting Barycentric<->Cartesian [smile]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

ThankYou very much Bitem2k,

but i still looking for the answer for finding world coordinate of clicked face...
i had search for many hours, but all i can find is just the explain of picking method...
somebody please help.... :)
To add to what I've said.. D3DXVec3TransformCoord() will allow you to feed in the vertex position and your world matrix, and then get the world-space coordinate.

Once you've got those 3 coordinates for your triangle, feed them into D3DXVec3BaryCentric() and you'll get a single coordinate, in world space, for your intersection.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

sorry, i don't know there's a new replay while i'm typing...:)
is there any example code i can get ???

ThankYou Very Much Mr.Jack
np

This topic is closed to new replies.

Advertisement