Sign in to follow this  
be17_17y

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

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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



Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.... :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

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