First some guidelines that are good to remember when working with texture coordinates on surfaces and polysurfaces:
- Texture coordinates are defined by texture mappings. Default texture mapping is surface parameter mapping. It uses the surface parameterisation to generate texture coordinates.
Custom render mesh providers can modify the shape of an object and also override its texture coordinates.
- Render meshes are created and controlled by Rhino core and any changes to them have undefined behavior.
Custom mapping is a special type of texture mapping. It is used to apply texture coordinates from another geometry. This video demonstrates the idea. Custom mapping can also be set from a plug-in. This feature has been in the C++ SDK for a while and is also included in the 6.15 version of RhinoCommon (available along the first Rhino 6.15 release candidate in early May).
In general UVEditor shows the object render mesh projected to the texture coordinate space. But if the object has custom mapping and the mapping geometry is mesh then UVEditor shows the custom mapping mesh projected to texture space. This exception is due to the fact that UVEditor was originally designed to modify the texture coordinates of the custom mapping mesh.
Unwrap command applies custom mapping. It makes a copy of the render mesh, flattens it and uses the flattened vertex positions to generate texture coordinates to another copy of the render mesh which is then set as the geometry for a custom mapping.
You can use the same pattern:
- Make a copy of the render mesh.
- Modify the texture coordinates as you like.
- Create a new custom mapping and set the modified mesh as the mapping geometry.
- Set the new custom mapping as the texture mapping for the object.