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

This topic is 4922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
Quote:
 Original post by be17_17ywhy 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_17yHow 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 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...

##### 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 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

np

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634138
• Total Posts
3015758
×