Python module
Wig is shipped with the WigUsd python module, which contains:
- Python bindings to the Wig schemas and attributes.
- Additional functions/commands to perform advanced operations on a fur node in a USD stage.
In order to use the python module, first make sure that Wig is loaded in your environment. In your python prompt enter:
>>> import WigUsd
It is then possible to consult the online documentation of the module, e.g.:
>>> help( WigUsd )
>>> help( WigUsd.Export )
Available functions
AttachDeformer
Attach guide curves/surfaces to a WigFurNode prim. This allows the curves/surfaces to deform the strands.
The guide primitives must have a valid SkinningNode API schema applied. The SkinningNode API schema contains relevant binding information that allows the Wig procedural to compute the correct deformation.
It is advised to use the ComputeClumps command to extract the appropriate guide prims since this ensures the SkinningNode API schema is present.
Use AttachDeformer
>>> WigUsd.AttachDeformer( furNodePrim, skinningNodePrim [,params] )
Parameters for AttachDeformer
| Name | Type [Default] | Description |
|---|---|---|
| stage | Usd.Stage | The output stage, if different from the fur node stage. |
| detachExisting | bool [True] | Detach any skinning primitive that is currently attached to the fur node. |
| updateBindings | bool [true] | Recompute the bindings between the fur node and the guide prim. |
ComputeClumps
Detect clumps and/or extract guides from a WigFurNode prim.
When detecting clumps, the resulting clusters are stored on the WigFurNode prim as a new ClumpRegion API schema.
Extracting guide curves requires a valid ClumpRegion API to be defined on the WigFurNode prim. The resulting curves are initialized with binding attributes that are relevant for the WigFurNode. The AttachDeformer command can then be used to make the guide curves deform the fur.
Use Compute Clumps
>>> WigUsd.ComputeClumps( furNodePrim [,params] )
Parameters for Compute Clumps
| Name | Type [Default] | Description |
|---|---|---|
| stage | Usd.Stage | The output stage, if different from the fur node stage. |
| regionName | string ["default"] | The name of the ClumpRegion schema to be used. |
| detectClumps | bool [False] | Detect clumps and replace the attributes of the current ClumpRegion schema. |
| buildSurfaces | bool [False] | Reconstruct guide surfaces from the current ClumpRegion. |
| buildClumpCurves | int [0] | Reconstruct guide curves from the current ClumpRegion. Different reconstruction methods can be chosen according to the input value (1:average curve, 2:median strand, 3:skeleton of clump volume). |
| strandLengthThreshold | float [0.95] | Consider only the strands that are longer than a ratio of the longest strand in each clump when extracting clump curves. A value of 0 means keep all strands, whereas 1 means keep only the longest strand of the clump. |
| interval | Gf.Interval | Restrict the animation interval of the output guide prims. The exported prims are considered to be static outside this interval. |
| timeCodes | list(Usd.TimeCode) | A list of time samples at which the guide prims should be exported. An empty list means the prims should be exported at any relevant time within their animation interval. Note that the output prims may contain less samples than given initially, since the strands can be static over a range of samples. |
| numClumps | int [-1] | The number of clumps to be detected. This option is mandatory if detectClumps=True. |
| radius | float [1.0] | The radius to be used during clump detection. This is only relevant when clumps are recovered with the spectral method and not KMeans. |
| numNgbs | int [8] | The number of neighbor strands to be used during clump detection. This is only relevant when clumps are recovered with the spectral method and not KMeans. |
| useKMeans | bool [True] | Use KMeans instead of the spectral method when detecting clumps. KMeans is usually faster, but less robust. |
| numIterKMeans | int [20] | The number of iteration to be used in the KMeans algorithm. This is only relevant when useKMeans=True. |
| strandModeKMeans | int [7] | Indicate which part(s) of the strands should be considered when detecting clumps using KMeans. The relevant sections of a strand are given a value and must be summed together according to: 1(root) + 2(midpoint) + 4(tip). |
| outPrimPath | string ["deformer"] | The path to the resulting guide curves/surfaces. It can be either absolute or relative to the WigFurNode prim. |
Export
Export a WigFurNode prim as a native BasisCurves prim. This can be useful when shipping grooms to 3rd party vendors.
Return a list containing the exported prims.
Use Export
>>> WigUsd.Export( furNodePrim [,params] )
Parameters for Export
| Name | Type [Default] | Description |
|---|---|---|
| stage | Usd.Stage | The output stage, if different from the fur node stage. |
| asCubic | bool [True] | Export cubic curves if set to true, linear curves otherwise. |
| exportWidths | bool [False] | Export the strand widths, as a vertex attribute. |
| exportColors | bool [False] | Export the strand vertex colors. |
| interval | Gf.Interval | Restrict the animation interval of the WigFurNode. The exported prim is considered to be static outside this interval. |
| timeCodes | list(Usd.TimeCode) | A list of time samples at which the WigFurNode should be exported. An empty list means the fur node should be exported at any relevant time within its animation interval. Note that the output prims may contain less samples than given initially, since the strands can be static over a range of samples. |
| primvars | string [""] | A list of comma-separated primvar names to be generated. |
| outPrimPath | Sdf.Path | The path to the output prim, if different from the original prim path. |