Texture (pixel) coordinates to world coordinates

Hi @silvano,

i´ve done something related in vbscript. The process could work like this:

A nurbs surface or polysurface does not have texture coordinates, but its rendermesh does. So you will only work on mesh objects or the rendermesh in case of a nurbs object. This mesh is then triangulated and unwrapped virtually using your own routine or to make the explanation clear, with the command _ExtractUVMesh. With this 2D representation of your UV mesh, you can evaluate your pixel coordinate in 2D. Usually the UV range is between 0 and 1, if you set a different size for the unwrap, the 2D coordinate you search for is just scaled or divided using the dimensions of the unwrapped mesh.

After getting the 2d coordinate (world space) you find the triangle index which contains the pixel coordinate and work using barycentric coordinates. If you evaluate this barycentric coordinate in the 3d mesh using the triangle index, you get the 3d point.

There is one case where you will not find a proper 3D equvalent, if you evaluate a 2D pixel coordinate which is outside of a mesh island. In this case, you can find the closest 2D triangle and use it`s edge.

c.

1 Like