Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Better technique for Mirroring Blendshapes?

Better technique for Mirroring Blendshapes?

Anonymous
Not applicable
997 Views
0 Replies
Message 1 of 1

Better technique for Mirroring Blendshapes?

Anonymous
Not applicable

Hi,

 

I'm using the method for mirroring blendshapes that involves wrap deformers. The method works great for models under around 5,000 verts but after that it takes quite a while to calculate. 

 

I was wondering if there's any information out there on how to do this process a little more efficiently. 

 

Thanks,

 

Ben

 

 

Here's my script for reference:

import maya.cmds as cmds


# takes your base mesh (1) and the shape that you want to mirror (2) and creates the inverse blendshape
# assumes we want to mirror in -x

def mirrorBlendshape():
    sel = cmds.ls(sl=1, o=1)
    base = sel[0]
    shape = sel[1]
    # target mesh is the one that will recieve the blendshape and be mirrored
    target = cmds.duplicate(base, returnRootsOnly=1)
    # the invShape mesh is the one that will be the final inverted blenshape
    invShape = cmds.duplicate(base, returnRootsOnly=1)

    # create our blendshape, mirror the mesh, create the wrap deformer, and apply the blendshape
    bs = cmds.blendShape(shape, target)
    cmds.xform(target, s=(-1, 1, 1))
    cmds.select(invShape[0], target[0], add=1)

    cmds.CreateWrap()
    # "inflate" our mesh to the correct mirrored position using our blendshape. BIG calculation
    cmds.setAttr(bs[0] + "." + shape, 1)

    hist = cmds.listHistory(invShape)
    index = hist.index(target[0] + "BaseShape")
    # delete the history on our final shape so that we can delete the shape we used to make it
    cmds.delete(invShape, constructionHistory=1)

    cmds.select(target[0] + "BaseShape")
    x = cmds.pickWalk(d="up")
    # delete our base shape node
    cmds.delete(x)
    
    # delete our target shape so we're just left with the shape we want
    cmds.delete(target)
    return invShape


mirrorBlendshape()

 

 

0 Likes
998 Views
0 Replies
Replies (0)