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.
Sorry for refreshing this old topic but i need to get uvmesh via rhinocommon and i cant find proper way to do it i can access mapping vertices but remeshing from points won’t give me original uvmesh to work further with it. GetMeshes() doesn’t have uvmesh enum.
@nathanletwory i have already them but i can only get list of points from foreach (Point2f coord in mesh.TextureCoordinates) there’s no uvmesh here. Remeshing those points won’t give me original uvmesh and it is very easy to mess up things at this point.
I see i’ve done it now but i wonder what if uv islands are disconnected but i assume that referring to original mesh faces indexes will be good enough to recreate uvmesh properly - so far it works (i thought earlier it wouldn’t be possible this way) - i also thought there is somewhere hidden method If i’ll need an explanation i’ll post here - Thanks guys for quick response i hope i’ll be able to solve this on my own
It will be one mesh, to get the islands seperated you could split into disjoint pieces with Mesh.SplitDisjointPieces after unwrapping or, explode the render mesh and unwrap each island individually.
Take care with overlaps when _UnpackTextures was used…
_
c.
@clement would you mind showing how to get islands for mesh ??
I get nice islands for any brep using instanceMesh = instance.GetMeshes(MeshType.Render); but when i have mesh my trouble start and i can’t even get proper uvmesh back - it is bit odd but it sometimes work and sometimes not - especially when i change uvs by hand but i think im just missing something here.
On left those from c# on right proper extracted uvmesh and mesh while uvediting.
@clement i want to get uvs then generate points in uv domain and get it back on mesh via pointAt using barycentric coords and i got that already but im missing sometimes few triangles or remeshed uvs are messed up and sometimes everything works ok - i supose i have to explode mesh to individual triangles and then remesh eachone on uv.