UV unwrap LSCM SOP

Overview

This sop unfolds an input mesh in UV space and adds vertex uvs .

Add these bindings to your 456.cmd 
omsbind -t sop uvunwraplscm:group prims "First input" "Select the primitives to unwrap" 0 1 poly 0 "" 0
omsbind -t sop uvunwraplscm:seams edges "Seams" "Select the seams" 0 1 edge 0 "" 0
omsbind -t sop uvunwraplscm:hintprim prims "Hint prim" "Select the hint primitive" 0 1 poly 0 "" 0

Usage

This sop works in several modes. Currently the only unwrapping algorithm supported is the basic LSCM, this will be extended in the next release to add ABF (hopefully).

Assuming one open edge in the mesh just apply this sop and the mesh will be unfolded in UV space and a set of vertex uvs will be created.
For proper unwrapping usual a number of edges will be defined as seams, see the help for UVpelt for ideas on where to place seams.

To improve the quality of the uv coordinates 2 things can be done.

Firstly you can manually specify vertices and the coordinates that they should have using the multi parameter pins, you need to supply at least 2 and then the rest of the mesh will be re-aligned to properly include them. If the mesh is symmetrical pick one vertex from either side of the mesh and then specify symmetrical uv coordinates for them. By default the sop will automatically try and figure out two for itself but these are rarely going to be ok for a symmetrical mesh. Two is the minimum number of pinned uvs required to get the mesh to unfold.

The second way to specify the pinned vertices is to select "Use live pin uvs" this will then only use the vertex numbers specified and will get the uv coordinates directly from the input. The suggested workflow for this method is to apply the sop twice the first time use the automatic unwrapping (ie leave the defaults) and modify the uvs of at least 2 vertices using a UVedit sop, then add a second UVunwrapLSCM sop and set the pins to have the prim and vertex numbers of the ones edited, finally turn on "Use live pin uvs".

See the example hipnc files for examples of this in practise.

Parameters

Group The group of primitives to unwrap. 
Seams The edges to cut along when unfolding.
Use seam att Use a point attribute to define the seam. Points with a value greater than 0.9 will be concidered on the seam.
Seam att If "Use seam att" is on this is the name of the attribute to use to determine if points are on the seam or not.
Method The unfolding algorithm.
LSCM with ABF Least Squares Conformal Map with Angle Based Flattening (Not implimented yet)
LSCM Least Squares Conformal Map. The basic unfolding algorithm.
Hint prim Select a primitive that is within the boundary of the seams that you want ot unwrap.
Rotate The distance along the edge to slide point 0 in each edge.
Use range Scale the output uvs to fit in the range specified below
U out range The output range in the U direction
V out range The output range in the V direction.
Number of pins The number of pins to use, must be at least 2 to have any effect.
Pin parameters
Enable pin Enables or disables a particular pin
Pin# Prim/Vert The primitive/poly number and the vertex number of the current pin
Pin uv The uv coordinate of the current pin.
Initialise pin uvs Copy the values for the pin uvs from the input mesh uvs.
Use live pin uvs With this on the pin uvs are taken directly from the input mesh and the manually specified coordinates are ignored and disabled.
Visualise stretching Colour code the stretching of the mesh in UV space. Red = maximum stretching, Blue = minimum stretching.
The UVuniform sop can be used to reduce stretching in uv space.
Add seam colours With this on primitive colours are added to the polys along the seams. The colour is the same for polygons on either side of the seam. This helps to identify which polygons are next to each other in 3D space when the surface is viewed in 2D uv space.
Seam colour Currently there are 2 ways to colour the seams, gradient and random. Gradient walks along the seam and colours the polys on either side of the seam with a colour from the gradient red to blue. Random just picks a random colour, polygons on either side of the seam still get the same colour but in the other direction along the seam they will be random.
Create output group With this on a primitive group is created for the polygons that were unfolded. The members of this group are determined by the hint primitive and the positions of the seams.
Group name The name of the output group.

TODO

1. Add ABF to the LSCM method to improve the unwrap for certain cases.

2. Optimise the code by using SuperLU.