Constants for paint mode
A wrapper object to call functionality from ngSkinLayer command. Most operations operate on current selection, or on target mesh that was set in advance. All edit operations are undoable.
from ngSkinTools.mllInterface import MllInterface mll = MllInterface() mll.setCurrentMesh('myMesh') mll.initLayers() id = mll.createLayer('initial weights') mll.setInfluenceWeights(id,0,[0.0,0.0,1.0,1.0]) ...
Set mesh we’ll be working on with in this wrapper. Use None to operate on current selection instead.
Parameters: mesh (str) – mesh node name/path
initializes layer data node setup for target mesh
returns true if layer data is available for target mesh
Return type: bool
get layer that is marked as selected on MLL side; current layer is used for many things, for example, as a paint target.
Return type: int
Returns a tuple with mesh and skin cluster node names where skinLayer data is (or can be) attached.
If current mesh (or selection) is not suitable for attaching layers, returns None
Return type: (str,str)
For initialized layer info, returns number of vertices layer manager sees in the mesh. This might be different to actual vertex count in the mesh, if mesh has post-skin cluster mesh modifiers (as vertex merge or smooth)
Return type: int
get layer name by ID
Parameters: layerId (int) – layer ID Return type: str
set layer name by ID
Returns layer opacity as float between
Set opacity for given layer. Use values between
True, if layer on/off flag is turned on
Turn layer on/off. Use
Falsefor ‘enabled’ value.
returns iterator to layer list; each element is a tuple:
(layer ID, layer name)
returns iterator to layer influences. each element is a tuple
(influence name,influence logical index)
returns layer mask weights as float list. if mask is not initialized, returns empty list
Set mask for given layer. Supply float list for weights, e.g.
[0.0,1.0,0.6]. Supply empty list to set mask into uninitialized state.
returns layer DQ weights as float list. if DQ weights are not painted for this layer, returns empty list
Set dual-quaternion weights for given layer. Supply float list for weights, e.g.
[0.0,1.0,0.6]. Supply empty list to set into uninitialized state.
returns influence weights as float list. :param influence: either a logical influence index or named influences “mask”, “dq”
setInfluenceWeights(layerId, influence, weights, undoEnabled=True)¶
Set weights for given influence in a layer. Provide weights as float list; vertex count should match result of
getVertCount()If weight values are higher than 1.0, they will be capped at 1.0.
remembers current weights and restores them after undo; redo restores weights that were there before first undo
sets layer weights buffer size no less than X influences
creates new layer with given name and returns it’s ID; when forceEmpty flag is set to true, layer weights will not be populated from skin cluster.
Returns: layer ID Return type: int
Deletes given layer in target mesh
Set current layer :param int layerId: layerId earlier obtained via createLayer; can be None, will equate to having to current layer
universal way to set current paint target.
Parameters: paintTarget – influence index or named paint target:
if there is a named target selected, returns “mask” or “dq”; if no target is selected, returns
None; otherwise returns influence index
Get axis that is used in the mirror operation. Can be one of: ‘x’, ‘y’, ‘z’, or ‘undefined’
mirrorLayerWeights(layerId, mirrorWidth=0.0, mirrorLayerWeights=True, mirrorLayerMask=True, mirrorDualQuaternion=True, mirrorDirection=1)¶
Mirror weights in a layer.
- layerId (int) – id of a target layer
- mirrorWidth (float) – width of a seam axis
- mirrorLayerMask (bool) – should mask be mirrored?
- mirrorLayerWeights (bool) – should weights be mirrored?
- mirrorDualQuaternion (bool) – should dual quaternion blend weights be mirrored?
- mirrorDirection (int) – direction to mirror; use MirrorDirection constants for reference.
Parameters: influencesMapping (dict) – a “source->destination”
- mirrorAxis – ‘X’, ‘Y’ or ‘Z’
- vertexTransferMode – ‘uvSpace’, ‘closestPoint’
starts batch data update mode, putting layer data into suspended state - certain internal updates are switched off, making multiple layer data changes like setLayerWeights or setLayerOpacity run faster; updates will take place when endDataUpdate is called.
begin..endDataUpdate() pairs can be stacked (e.g. methods inside begin..end can call begin..end themselves) - updates will resume only when most outer pair finishes executing.
end batch update.
a helper method to use in a “with” statement, e.g.:
with mll.batchUpdateContext(): mll.setLayerWeights(...) mll.setLayerOpacity(...)
this is the same as:
mll.beginDataUpdate() try: mll.setLayerWeights(...) mll.setLayerOpacity(...) finally: mll.endDataUpdate()
create an in-memory reference mesh with layer manager initialized; this mesh and layer info can be accessed later by setting target mesh to MllInterface.TARGET_REFERENCE_MESH.
- vertices (list) – a float array, listing x y z for first vertex, then second, etc;
- triangles (list) – an int array, listing vertex IDs for first triangle, then second, etc.
Returns: a list of floats, where each three values is a vertex XYZ for reference mesh vertices
Returns: a list of integers, where each three values describe mesh vert IDs that make up a triangle in the reference mesh
Returns: current value of “influence limit per vertex” setting for this mesh.
0is returned when there’s no limit.
Set max number of influences permitted for this mesh/skin cluster. This limit will be applied as a post-processing filter, before writting data to skin cluster.
See ngSkinTools user manual for more info on this mechanic.
Parameters: limit (int) – max number of influences allowed; provide
Noneto remove the limit.
Returns: list of logical indexes for all influences in this skin cluster
Returns: list of influence names for all influences in this skin cluster
Returns coordinates for influence pivots for all influences in this skin cluster;
Returns: a list where each element is 3-float tuple, e.g.
Returns a list of influences in this skin cluster, where each influence is represented as
Return type: List[ngSkinTools.importExport.InfluenceInfo]
transferWeights(targetMesh, influencesMapping, vertexTransferMode=None)¶
Transfer weights from self.mesh onto the targetMesh. Layers are always appended to the list of existing layers; if you wish to replace old layers, delete them after the transfer (doing so before might deform the mesh and mess up vertex transfer associations).
- targetMesh (str) – a mesh to perform transfer to
- influencesMapping (dict) – a dictionary of [source influence logical ID]->destination influence logical ID
- vertexTransferMode (str) – “closestPoint”,”uvSpace” or “vertexId”
Merges given layer the layer below it.
Parameters: layerId (int) – layer to be merged
Remove weights in influence weights lower than provided threshold; upscale remaining weights, preserving transparency of the layer.
- layerId (int) – layer to be processed; if not provided, will use currently active layer
- threshold (float) – weights below this value will be set to 0
remove weights in layer mask lower than provided threshold;
A helper class for MllInterface.batchUpdateContext() method, helping implement “with” statement setup/teardown functionality