SkinningTools.Maya.tools.shared

Module Contents

Classes

Graph

dijkstra closest path technique (for nurbs and lattice)

Functions

checkEdgeLoop(inMesh, vtx1, vtx2, first=True, maxLength=40)

check relations between 2 vertices if they are on the same loop

convertToCompList(indices, inMesh, comp='vtx')

convert indices to a list of the given component

convertToIndexList(vertList)

convert components given to a list of indices

convertToVertexList(inObject)

convert the given input to a represented point selection for the type of object that is selected:

createWeightedMM(transforms, weights, floatPrecision)

creat matrix multiple based on the weights of the current triangle

dec_loadPlugin(plugin)

load plugin decorator

dec_profile(func)

profiler decorator

dec_repeat(func)

repeat last decorator

dec_timer(func)

debug timer decorator

dec_undo(func)

undo decorator

dijkstra(graph, initial)

dijkstra closest path technique (for nurbs and lattice)

doCorrectSelectionVisualization(skinMesh)

convert the given objects selection to represent the right visualisation in maya

getComponents(meshDag, component)

convert the given input to a list of component indices

getConnectedVerticesMapper(dag)

Create a dictionary where the keys are the indices of the vertices and the

getConnectedVerts(inMesh, vtxSelectionSet)

get seperate groups of vertices that are connected by edges

getDagpath(node, extendToShape=False)

get openmaya data from given object

getJointIndexMap(inSkinCluster)

get a map of how the joints are connected to the skincluster at which index

getMfnSkinCluster(mDag)

get openmaya skincluster data from given object

getNeighbours(mVtxItter, index)

get the direct neighbors of current vertex index connected by edge

getNormals(meshName)

Get the average normal in world space of each vertex on the provided mesh.

getParentShape(inObject)

get the parent object of given object if the current given object is a shape

getPoints(dag)

Get the position in world space of each vertex on the provided mesh.

getPolyOnMesh(point, inMesh)

sget polygonal mesh data of a point on the surface

getTriIndex(inMesh, polygonIndex, triangleIndex)

get the points that create the current triangle

getTriWeight(inMesh, polygonIndex, triangleIndex, u, v)

get the weight of the current coordinate based on the triangles position

getWeights(inMesh)

get the complete weight data of a given mesh

growLatticePoints(points)

get all neighbours of a point on a lattice

selectHierarchy(node)

get the hierarchy of the current given object

setWeights(inMesh, weightData)

set the complete weight data of a given mesh

shortest_path(graph, origin, destination)

shortest path technique (for nurbs and lattice)

skinCluster(inObject=None, silent=False)

get the skincluster from the given mesh

skinConstraint(inMesh, transform, floatPrecision=3)

attach a transform to mesh based on the transforms position

toToEdgeNumber(vtx)

convert vertex to a list of connected edge numbers

traverseHierarchy(inObject)

traverse the hierarchy of the current object to gahter all mesh nodes

SkinningTools.Maya.tools.shared._DEBUG
class SkinningTools.Maya.tools.shared.Graph

dijkstra closest path technique (for nurbs and lattice) implemented from: https://gist.github.com/econchick/4666413 basic idea: http://www.redblobgames.com/pathfinding/a-star/introduction.html

add_edge(self, from_node, to_node, distance)

add the edge information from which we will later search for the shortest path

Parameters
  • from_node (string) – node that will be used as a start position on the segment

  • to_node (string) – node that will be used as the end position on the segment

  • distance (float) – length between the given nodes

add_node(self, value)

add the node which we will later search for the shortest path

Parameters

value (string) – key value to identify the node position

SkinningTools.Maya.tools.shared.checkEdgeLoop(inMesh, vtx1, vtx2, first=True, maxLength=40)

check relations between 2 vertices if they are on the same loop

Parameters
  • inMesh (string) – the mesh on which the vertices are placed

  • vtx1 (string) – the first vertex to gather data from

  • vtx2 (string) – the second vertex to gather data from

  • first (bool) – if True it will only return the first loop found, if False it will return any loop found

  • maxLength (int) – maximum amount of edges to search between before giving up

Returns

list of edges between the 2 vertices

Return type

list

SkinningTools.Maya.tools.shared.convertToCompList(indices, inMesh, comp='vtx')

convert indices to a list of the given component

Parameters
  • indices (list) – list of integers representing the components values

  • inMesh (string) – the name of the mesh

  • comp (string) – the component type

Returns

list of components

Return type

list

SkinningTools.Maya.tools.shared.convertToIndexList(vertList)

convert components given to a list of indices

Parameters

vertList (list) – list of components

Returns

list of integers representing the components values

Return type

list

SkinningTools.Maya.tools.shared.convertToVertexList(inObject)

convert the given input to a represented point selection for the type of object that is selected: polygons : vertices Nurbs : control vertices lattice : points

Parameters

skinMesh (string) – the object to search for a parent

Returns

for polygons a list of vertices, for Nurbs a list of control vertices, for lattice a list of points

Return type

list

SkinningTools.Maya.tools.shared.createWeightedMM(transforms, weights, floatPrecision)

creat matrix multiple based on the weights of the current triangle

Parameters
  • transforms (list) – list of joints that will drive the matrix

  • weights (list) – list of weights on how much the matrix needs to be driven

  • floatPrecision (int) – amount of decimals used to calculate the weight information

Returns

the matrix which holds the positional information

Return type

wtAddMatrix node

SkinningTools.Maya.tools.shared.dec_loadPlugin(plugin)

load plugin decorator loads the given plugin in the current maya scene, should be attached to functions that rely on plugins

Parameters

func (string) – plugin this decorator is attached to

Returns

the result of the given function

Return type

function()

SkinningTools.Maya.tools.shared.dec_profile(func)

profiler decorator run cprofile on wrapped function

Parameters

func (function()) – function this decorator is attached to

Returns

the result of the given function

Return type

function()

SkinningTools.Maya.tools.shared.dec_repeat(func)

repeat last decorator converts the given function to a command that the repeatlast command can take the arguments given are parsed and converted into a string that is added to a mel command. :todo: double check the functionality

Parameters

func (function()) – function this decorator is attached to

Returns

the result of the given function

Return type

function()

SkinningTools.Maya.tools.shared.dec_timer(func)

debug timer decorator times the function for how long it takes to run everything in the function

Parameters

func (string) – plugin this decorator is attached to

Returns

the result of the given function

Return type

function()

SkinningTools.Maya.tools.shared.dec_undo(func)

undo decorator will allow the objects created and changed in maya to be part of a single chunk where possible the decorators is wrapped within a try except finally function to make sure everything is always undoable :note: object created with the use of OpenMaya will not be part of this

Parameters

func (function()) – function this decorator is attached to

Returns

the result of the given function

Return type

function()

SkinningTools.Maya.tools.shared.dijkstra(graph, initial)

dijkstra closest path technique (for nurbs and lattice)

Parameters
  • graph (Graph()) – dictionary information on positions and length for the path to search

  • initial (int) – start index to work from

Returns

objects passed and the full list of the nodes that create the path

Return type

list

SkinningTools.Maya.tools.shared.doCorrectSelectionVisualization(skinMesh)

convert the given objects selection to represent the right visualisation in maya :todo: check if this can be converted to OpenMaya so we can get rid of mel.eval

Parameters

skinMesh (string) – the object to search for a parent

SkinningTools.Maya.tools.shared.getComponents(meshDag, component)

convert the given input to a list of component indices

Parameters
  • meshDag (OpenMaya.MDagPath) – the object to search through

  • component (OpenMaya.MDependNode) – the depend node to check for component flags

Returns

indices of all the components on the current object

Return type

OpenMaya.MIntArray

SkinningTools.Maya.tools.shared.getConnectedVerticesMapper(dag)

Create a dictionary where the keys are the indices of the vertices and the values a list of indices of the connected vertices.

Parameters

dag (MDagPath) –

Returns

Connected vertices mapper

Return type

dict

SkinningTools.Maya.tools.shared.getConnectedVerts(inMesh, vtxSelectionSet)

get seperate groups of vertices that are connected by edges

Parameters
  • inMesh (string) – the mesh to use for gathering data

  • vtxSelectionSet (list) – list of all vertices in our current selection to convert to island groups

Returns

dictionary holding information of all gathered islands

Return type

dict

SkinningTools.Maya.tools.shared.getDagpath(node, extendToShape=False)

get openmaya data from given object

Parameters
  • node (string) – the object to get the openmaya data from

  • extendToShape (bool) – if True will return the path of the shape, if False it will return the path of the transform

Returns

the openmaya object (returns dependnode if the object is not a dagnode)

Return type

MDagPath, MDependNode

SkinningTools.Maya.tools.shared.getJointIndexMap(inSkinCluster)

get a map of how the joints are connected to the skincluster at which index

Parameters

inSkinCluster (string) – the skincluster to use as base

Returns

map of all the joints and how they are conencted to the skincluster

Return type

dict

SkinningTools.Maya.tools.shared.getMfnSkinCluster(mDag)

get openmaya skincluster data from given object

Parameters

node (MDagPath) – the object to get the skinclusterdata from

Returns

the skincluster object

Return type

MFnSkinCluster

SkinningTools.Maya.tools.shared.getNeighbours(mVtxItter, index)

get the direct neighbors of current vertex index connected by edge

Parameters
  • mVtxItter (MItMeshVertex) – the iterator that goes over all vertices

  • index (int) – index of the vertex to get neighbor data from

Returns

set of all neighbours of current index

Return type

set

SkinningTools.Maya.tools.shared.getNormals(meshName)

Get the average normal in world space of each vertex on the provided mesh. The reason why OpenMaya.MItMeshVertex function has to be used is that the MFnMesh class returns incorrect normal results.

Note

using old open maya here as maya 2019.3.1 has a hard crash when gathering normals with new openmaya

Parameters

dag (MDagPath) –

Returns

Normals

Return type

list

SkinningTools.Maya.tools.shared.getParentShape(inObject)

get the parent object of given object if the current given object is a shape

Parameters

inObject (string) – the object to search for a parent

Returns

name of the parent transform

Return type

string

SkinningTools.Maya.tools.shared.getPoints(dag)

Get the position in world space of each vertex on the provided mesh.

Parameters

dag (MDagPath) –

Returns

Points

Return type

list

SkinningTools.Maya.tools.shared.getPolyOnMesh(point, inMesh)

sget polygonal mesh data of a point on the surface

Parameters
  • point (list) – point in space

  • inMesh (string) – the object to get the data form

Returns

all elements close to given point

Return type

faceId, triangleID, u coordinate, v coordinate

SkinningTools.Maya.tools.shared.getTriIndex(inMesh, polygonIndex, triangleIndex)

get the points that create the current triangle

Parameters
  • inMesh (string) – the object to get the data form

  • polygonIndex (int) – index of the current polygon( quad / ngon)

  • triangleIndex (int) – index of the triangle within current polygon

Returns

list of vertices that cover current triangle

Return type

list

SkinningTools.Maya.tools.shared.getTriWeight(inMesh, polygonIndex, triangleIndex, u, v)

get the weight of the current coordinate based on the triangles position

Parameters
  • inMesh (string) – the object to get the data form

  • polygonIndex (int) – index of the current polygon( quad / ngon)

  • triangleIndex (int) – index of the triangle within current polygon

  • u (float) – u coordinate on the texture map

  • v (flaot) – v coordinate on the texture map

Returns

list of joint influences and the weights necessary to attach the point to the triangle

Return type

list

SkinningTools.Maya.tools.shared.getWeights(inMesh)

get the complete weight data of a given mesh weightData = [[value]* joints] * vertices

Parameters

inMesh (string) – the object to get the data from

Returns

list of all weights

Return type

list

SkinningTools.Maya.tools.shared.growLatticePoints(points)

get all neighbours of a point on a lattice

Parameters

points (string) – point on a lattice

Returns

list of neighbouring points

Return type

list

SkinningTools.Maya.tools.shared.selectHierarchy(node)

get the hierarchy of the current given object

Parameters

node (string) – the object to search through

Returns

list of the objects children and current object included

Return type

list

SkinningTools.Maya.tools.shared.setWeights(inMesh, weightData)

set the complete weight data of a given mesh

Parameters
  • inMesh (string) – the object to set the data to

  • weightData (list/MDoubleArray) – full list of weight data [[value]* joints] * vertices

SkinningTools.Maya.tools.shared.shortest_path(graph, origin, destination)

shortest path technique (for nurbs and lattice)

Parameters
  • graph (Graph()) – dictionary information on positions and length for the path to search

  • origin (int) – start index to work from

  • destination (int) – end index to work from

Returns

visited objects on the way, ordered list that represents the shortest path

Return type

list

SkinningTools.Maya.tools.shared.skinCluster(inObject=None, silent=False)

get the skincluster from the given mesh

Parameters
  • inObject (string) – the object to search for a skincluster attachment

  • silent (bool) – if True will return None, if False will open a warning dialog to tell the user no skincluster was found

Returns

name of the skincluster node

Return type

string

SkinningTools.Maya.tools.shared.skinConstraint(inMesh, transform, floatPrecision=3)

attach a transform to mesh based on the transforms position

Parameters
  • inMesh (string) – the object to get the data form

  • transform (string) – transorm object to attach to the skincluster

  • floatPrecision (int) – amount of decimals used to calculate the weight information

SkinningTools.Maya.tools.shared.toToEdgeNumber(vtx)

convert vertex to a list of connected edge numbers

Parameters

vtx (string) – the vertex to gather data from

Returns

list of all connected edges

Return type

list

SkinningTools.Maya.tools.shared.traverseHierarchy(inObject)

traverse the hierarchy of the current object to gahter all mesh nodes

Parameters

inObject (string) – the topnode to search from

Returns

list of all transforms holding mesh shape data

Return type

list