Archive for October, 2015

So for Morpheus 2, the customization asset uses a blendshape head that needed to be connected to a unified body for the setup to work right. To do that I wanted to do wrap on a blendshape going into the unified body geo blendshape setup. However, we only wanted the head verts affected. If you’re not doing a procedural setup, you can simply paint out the other verts on the blendshape’s channel. Looking into a procedural solution required finding a few code chunks.

Googling on this stuff produced few helpful results so hopefully this can help someone else should they find themselves looking into these things.

First chunk we needed was the setAttr command on setting specific blendshape target weights. This one was a hard one to track down for whatever reason but here it is:

inputTarget[0] — this is the index of the shape on the blendshape node we want

inputTargetGroup[1] –As best I understand it this is the target information for 1, or when the shape is fully on

targetWeights[563] — this is the vertex id of the vertice in question

1.0 — value to set

As I had a head mesh that was gonna deform that same head that had been unified with the body to have a single mesh for easier skinning/shaping use, I needed the verts I wanted to mask on (for the head verts) and off (for the rest). So first all the verts are turned off, then the verts we wanted turned back on are done so with something like this:

for vtx in range(0,mc.polyEvaluate('M1_Head_geo',v=True)):#...for each vertice of the head geo
pos = distance.returnWorldSpacePosition('M1_Head_geo.vtx[{0}]'.format(vtx))#...grab the position with our use of mc.pointPosition is the cgm.lib.distance module
val = distance.returnClosestPointOnMeshInfoFromPos(pos,'M1_UnifiedBase_GEO')['closestVertexIndex']#...get the closest vertice id from the unified mesh using our use of maya point on surface stuff. Again in cgm.lib.distance
mc.setAttr('unifiedBridge_blendShape.inputTarget[0].inputTargetGroup[1].targetWeights[{0}]'.format(val),1.0)#...then our vertice value is plugged in to the set attr chain

This is utilized with some modification during the setup process for a customization asset.