rjRetargetBlendshape package

Module contents

Retarget your blendshapes between meshes with the same topology.

https://github.com/robertjoosten/rjRetargetBlendshape/raw/master/README.png

Link to Video

Installation

Copy the rjRetargetBlendshape folder to your Maya scripts directory

C:/Users/<USER>/Documents/maya/scripts

Usage

Command line

import rjRetargetBlendshape
rjRetargetBlendshape.convert(
    source,
    blendshape,
    target,
    scale=True, 
    rotate=True, 
    smooth=0, 
    smoothIterations=0,
    space=OpenMaya.MSpace.kObject,
)

Display UI

import rjRetargetBlendshape.ui
rjRetargetBlendshape.ui.show()

Note

Retarget your blendshapes between meshes with the same topology. There are a few options that can be helpful to achieve the desired results.

  • Scaling your delta depending on the size difference between the source and the target vertex.
  • Rotating the delta depending on the normal difference between the source and the target vertex.
  • Smoothing based on the vertex size between the retarget mesh and the blendshape mesh.

Code

rjRetargetBlendshape.asComponent(index, t=<sphinx.ext.autodoc._MockObject object>)

index -> OpenMaya.MFn.kComponent Based on the input type it will create a component type for this tool the following components are being used.

  • OpenMaya.MFn.kMeshVertComponent
  • OpenMaya.MFn.kMeshEdgeComponent
Parameters:
  • index (int/OpenMaya.MIntArray) – indices to create component for
  • t (OpenMaya.MFn.kComponent) – can be all of OpenMaya component types.
Returns:

Initialized components

Return type:

OpenMaya.MFnSingleIndexedComponent

rjRetargetBlendshape.asMDagPath(obj)

OpenMaya.MObject -> OpenMaya.MDagPath

Parameters:obj (OpenMaya.MObject) –
Return type:OpenMaya.MDagPath
rjRetargetBlendshape.asMFnMesh(dag)

OpenMaya.MDagPath -> OpenMaya.MfnMesh

Parameters:dag (OpenMaya.MDagPath) –
Return type:OpenMaya.MfnMesh
rjRetargetBlendshape.asMIntArray(index)

index -> OpenMaya.MIntArray

Parameters:index (int/OpenMaya.MIntArray) – indices
Returns:Array of indices
Return type:OpenMaya.MIntArray
rjRetargetBlendshape.asMObject(path)

str -> OpenMaya.MObject

Parameters:path (str) – Path to Maya object
Return type:OpenMaya.MObject
rjRetargetBlendshape.convert(source, blendshape, target, scale=True, rotate=True, smooth=0, smoothIterations=2, space=<sphinx.ext.autodoc._MockObject object>)

Create a new target based on the difference between the source and blendshape. The target mesh is duplicated and the difference between source and target is transfered onto the duplicated mesh. When transfering both scale and rotation of the delta vectors can be taken into account. Once the data is transfered an Laplacian smoothing algorithm can be applied onto the newly created target to create a more desired result.

Parameters:
  • source (str) –
  • blendshape (str) –
  • target (str) –
  • scale (bool) – Take scale between delta vectors into account
  • rotate (bool) – Take rotation between normal vectors into account
  • smooth (float) – Smoothing strength
  • smoothIterations (int) – Times the smooth algorithm repeats
  • space (OpenMaya.MSpace) –
Raises:

RuntimeError – If the vertex count doesn’t match

Returns:

Name of transfered blendshape mesh

Return type:

str

rjRetargetBlendshape.getAverageLength(dag, component, space)

Get average length of connected edges.

Parameters:
  • dag (OpenMaya.MDagPath) –
  • component (OpenMaya.MFnSingleIndexedComponent) –
  • space (OpenMaya.MSpace) –
Returns:

Average length of the connected edges

Return type:

float

rjRetargetBlendshape.getAveragePosition(dag, component, space)

Get average position of connected vertices.

Parameters:
  • dag (OpenMaya.MDagPath) –
  • component (OpenMaya.MFnSingleIndexedComponent) –
  • space (OpenMaya.MSpace) –
Returns:

Average length of the connected edges

Return type:

OpenMaya.MPoint

rjRetargetBlendshape.getBasename(name)

Strip the parent and namespace data of the provided string.

Parameters:name (str) –
Returns:Base name of parsed object
Return type:str
rjRetargetBlendshape.setLaplacianSmooth(dag, index, space, sourceL, targetL, blendshapeL, smooth)

Laplacian smoothing algorithm, where the average of the neighbouring points are used to smooth the target vertices, based on the factor between the average length of both the source and the target mesh.

Parameters:
  • dag (OpenMaya.MDagPath) –
  • index (int) – Component index
  • space (OpenMaya.MSpace) –
  • sourceL (float) –
  • targetL (float) –
  • blendshapeL (float) –
  • smooth (float) –