def buildEyeShaper(): createLattice( [nt.Transform(u'LT_eyeball_geo'), nt.Transform(u'RT_eyeball_geo')], [ nt.Mesh(u'CT_face_geoShape'), nt.Mesh(u'LT_brow_geoShape'), nt.Mesh(u'RT_brow_geoShape') ]) # add placement locs pGrp = nt.Transform(u'CT_eyeLattice_placement_grp') import rigger.modules.placementGrp as placementGrp reload(placementGrp) placementGrp.mirrorAllPlacements(pGrp) # create bnds import rigger.modules.face as face bndGrp = face.createBndsFromPlacement(pGrp) # motion sys # mesh is passed in for legacy reasons face.buildSecondaryControlSystem(pGrp, bndGrp, mesh=None) priCtlMappings = { 'LT_midUp_eyeShaper_pri_ctrl': { u'LT_inUp_eyeShaper_bnd': 1, u'LT_midUp_eyeShaper_bnd': 1, u'LT_outUp_eyeShaper_bnd': 1 }, 'LT_midLow_eyeShaper_pri_ctrl': { u'LT_inLow_eyeShaper_bnd': 1, u'LT_midLow_eyeShaper_bnd': 1, u'LT_outLow_eyeShaper_bnd': 1 }, 'RT_midUp_eyeShaper_pri_ctrl': { u'RT_inUp_eyeShaper_bnd': 1, u'RT_midUp_eyeShaper_bnd': 1, u'RT_outUp_eyeShaper_bnd': 1 }, 'RT_midLow_eyeShaper_pri_ctrl': { u'RT_inLow_eyeShaper_bnd': 1, u'RT_midLow_eyeShaper_bnd': 1, u'RT_outLow_eyeShaper_bnd': 1 } } import rigger.modules.priCtl as priCtl reload(priCtl) priCtl.setupPriCtlSecondPass(priCtlMappings)
def build(): ''' ''' mesh = nt.Mesh(u'CT_face_geoShape') placementGrp = nt.Transform(u'CT_placement_grp') #---------------------------------------------------------------------- bind if 'bind' in data.build_actions: bindGrp = face.createBndsFromPlacement(placementGrp) else: bindGrp = nt.Transform(u'CT_bnd_grp') #--------------------------------------------------------- sec motion system if 'sec_motion_system' in data.build_actions: face.buildSecondaryControlSystem(placementGrp, bindGrp, mesh) #------------------------------------------------------------ pri ctl system first if 'primary_ctl_system_first' in data.build_actions: # run a simple first pass # which can be used to block out mappings bndsForPriCtls = data.all_bnds_for_priCtls priCtl.setupPriCtlFirstPass(bindGrp, bndsForPriCtls) priCtl.driveAttachedPriCtlsRun(bindGrp) #------------------------------------------------------------ pri ctl system second if 'primary_ctl_system_second' in data.build_actions: if data.priCtlMappings: # if priCtlMappings is set up, use the data priCtlMappings = data.priCtlMappings priCtl.setupPriCtlSecondPass(priCtlMappings) priCtl.driveAttachedPriCtlsRun(bindGrp) else: pm.warning('no data for pri ctl system') #-------------------------------------------------------------- load weights if 'load_weights' in data.build_actions: priCtlMappings = data.priCtlMappings priCtl.setPriCtlFirstPassWeights(priCtlMappings) #--------------------------------------------------------------------- clean if 'clean' in data.build_actions: print 'clean' face.cleanFaceRig() #---------------------------------------------------------------------- eyes if 'eyes' in data.build_actions: buildEyeRig(placementGrp) #------------------------------------------------------------------ eyeballs if 'eyeballs' in data.build_actions: #------------------------------------------ EYEBALL RIG (SIMPLE AIM CONSTRAINTS) eye.buildEyeballRig() eye.addEyeAim(prefix='LT_', distance=25) # BROKEN if there is already a # node named LT_eyeball_grp!!! eye.addEyeAim(prefix='RT_', distance=25) # BROKEN #--------------------------------------------------------------- sticky lips if 'sticky_lips' in data.build_actions: pass
def build(): ''' ''' mesh = nt.Mesh(u'CT_hat_simplegeoShape') placementGrp = nt.Transform(u'CT_placement_grp') #---------------------------------------------------------------------- bind if 'bind' in data.build_actions: bindGrp = face.createBndsFromPlacement(placementGrp) pm.refresh() else: bindGrp = nt.Transform(u'CT_bnd_grp') #--------------------------------------------------------- sec motion system if 'sec_motion_system' in data.build_actions: face.buildSecondaryControlSystem(placementGrp, bindGrp, mesh) pm.refresh() #------------------------------------------------------------ pri ctl system first if 'primary_ctl_system_first' in data.build_actions: # run a simple first pass # which can be used to block out mappings bndsForPriCtls = data.all_bnds_for_priCtls priCtl.setupPriCtlFirstPass(bindGrp, bndsForPriCtls) priCtl.driveAttachedPriCtlsRun(bindGrp) #------------------------------------------------------------ pri ctl system second if 'primary_ctl_system_second' in data.build_actions: if data.priCtlMappings: # if priCtlMappings is set up, use the data priCtlMappings = data.priCtlMappings priCtl.setupPriCtlSecondPass(priCtlMappings) priCtl.driveAttachedPriCtlsRun(bindGrp) pm.refresh() else: pm.warning('no data for pri ctl system') #-------------------------------------------------------------- load weights if 'load_weights' in data.build_actions: priCtlWeights = data.priCtlWeights priCtl.setPriCtlSecondPassWeights(priCtlWeights) pm.refresh() #--------------------------------------------------------------------- clean if 'clean' in data.build_actions: print 'clean' face.cleanFaceRig() pm.select(cl=True) pm.refresh()
def buildBndVertMap(): ''' ''' bndGrp = nt.Transform(u'CT_bnd_grp') baseMesh = nt.Mesh(u'CT_face_geoShape') allBnds = bndGrp.getChildren(ad=True, type='joint') bndVertMap = {} for bnd in allBnds: bndPos = bnd.getTranslation(space='world') closestVertId = closestVertexOnMesh(baseMesh, bndPos) bndVertMap[bnd.name()] = closestVertId return bndVertMap
def assignAllPriWeightsByDelta(corrMesh, priCtl, calcChannels=('tx', 'ty', 'tz'), avgChannels=('rx', 'ry', 'rz', 'sx', 'sy', 'sz')): ''' corrMesh = nt.Mesh(u'smile_correctiveShape') priCtl = nt.Transform(u'LT_corner_lip_pri_ctrl') assume neutral position before running ''' bndGrp = nt.Transform(u'CT_bnd_grp') baseMesh = nt.Mesh(u'CT_base_corrective_bsgShape') bndVertMap = buildBndVertMap() allBnds = bndGrp.getChildren(ad=True, type='joint') for bnd in allBnds: assignPriWeightsByDelta(bnd, priCtl, baseMesh, corrMesh, bndVertMap, calcChannels, avgChannels)
def setAllAcsPosByDelta(): ''' import rigger.utils.assignAcsByBlendshape as acs reload(acs) acs.setAllAcsPosByDelta() ''' bndGrp = nt.Transform(u'CT_bnd_grp') allBnds = bndGrp.getChildren(ad=True, type='joint') # don't change movers allBnds = [ bnd for bnd in allBnds if 'Mover' not in bnd.name() and 'CT__base' not in bnd.name() and 'CT__jaw' not in bnd.name() ] # bndVertMap = assignPriWeightsByBlendshape.buildBndVertMap() corrMesh = nt.Mesh(u'LT_allBrowsUp_bsgShape1') for bnd in allBnds: try: setAcsPosByDelta(bnd, corrMesh) except AttributeError as e: print 'hello' print e
Created on Oct 11, 2014 @author: Leon ''' import pymel.core as pm import pymel.core.nodetypes as nt from pymel.core.language import Mel mel = Mel() #--------------------------------------------------------- PUPIL AND IRIS DILATE import rigger.modules.dilate as dilate reload(dilate) # left iris geo = nt.Mesh(u'LT_eyeball_geoShape') pivotGeo = pm.PyNode(u'LT_lens_geoShape.vtx[133]') tipGeo = geo.vtx[133:144] ctl = nt.Transform(u'LT_eye_ctl') name = '_iris' keys = { 'sx': { 0.01: 0.01, 1: 1, 2: 2 }, 'sy': { 0.01: 0.01, 1: 1, 2: 2 },
def build(): ''' ''' mesh = nt.Mesh(u'CT_face_geoShape') placementGrp = nt.Transform(u'CT_placement_grp') #---------------------------------------------------------------------- bind if 'bind' in data.build_actions: bindGrp = face.createBndsFromPlacement(placementGrp) pm.refresh() else: bindGrp = nt.Transform(u'CT_bnd_grp') #--------------------------------------------------------- sec motion system if 'sec_motion_system' in data.build_actions: face.buildSecondaryControlSystem(placementGrp, bindGrp, mesh) pm.refresh() #------------------------------------------------------------ pri ctl system first if 'primary_ctl_system_first' in data.build_actions: # run a simple first pass # which can be used to block out mappings bndsForPriCtls = data.all_bnds_for_priCtls priCtl.setupPriCtlFirstPass(bindGrp, bndsForPriCtls) priCtl.driveAttachedPriCtlsRun(bindGrp) #------------------------------------------------------------ pri ctl system second if 'primary_ctl_system_second' in data.build_actions: if data.priCtlMappings: # if priCtlMappings is set up, use the data priCtlMappings = data.priCtlMappings priCtl.setupPriCtlSecondPass(priCtlMappings) priCtl.driveAttachedPriCtlsRun(bindGrp) pm.refresh() else: pm.warning('no data for pri ctl system') #-------------------------------------------------------------- load weights if 'load_weights' in data.build_actions: priCtlWeights = data.priCtlWeights priCtl.setPriCtlSecondPassWeights(priCtlWeights) pm.refresh() #--------------------------------------------------------------------- clean if 'clean' in data.build_actions: print 'clean' face.cleanFaceRig() pm.select(cl=True) pm.refresh() #--------------------------------------------------------------- skin_layers if 'skin_layers' in data.build_actions: mll = skin.setupSkinLayers(None, layers=[ 'base', 'jaw', 'cheeks', 'crease', 'lips', 'mouthbag', 'nose', 'brow' ]) _, skn = mll.getTargetInfo() pm.PyNode(skn).skinningMethod.set(1) pm.PyNode(skn).deformUserNormals.set(0) #---------------------------------------------------------------------- eyes if 'eyes' in data.build_actions: buildEyeRig(placementGrp) #------------------------------------------------------------------ eyeballs if 'eyeballs' in data.build_actions: #------------------------------------------ EYEBALL RIG (SIMPLE AIM CONSTRAINTS) eye.buildEyeballRig() eye.addEyeAim(prefix='LT_', distance=25) # BROKEN if there is already a # node named LT_eyeball_grp!!! eye.addEyeAim(prefix='RT_', distance=25) # BROKEN #--------------------------------------------------------------- fleshy_eyes if 'fleshy_eyes' in data.build_actions: import rigger.modules.poseReader as poseReader reload(poseReader) xfo = pm.PyNode('LT_eyeball_bnd') poseReader.radial_pose_reader(xfo) xfo = pm.PyNode('RT_eyeball_bnd') poseReader.radial_pose_reader(xfo) eye.addFleshyEye() #--------------------------------------------------------------- sticky lips if 'sticky_lips' in data.build_actions: import rigger.modules.sticky as sticky reload(sticky) sticky.Sticky(up_bnd=pm.PyNode('CT_upper_lip_bnd'), low_bnd=pm.PyNode('CT_lower_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSide_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('LT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('LT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('LT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSide_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSide_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperSneer_lip_bnd'), low_bnd=pm.PyNode('RT_lowerSneer_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.Sticky(up_bnd=pm.PyNode('RT_upperPinch_lip_bnd'), low_bnd=pm.PyNode('RT_lowerPinch_lip_bnd'), center=pm.PyNode('CT__jaw_pri_ctrl')) sticky.addStickyToFRS() sticky.patchOldSticky() #----------------------------------------------------------------- auto_sdks if 'auto_sdks' in data.build_actions: import utils.rigging as rt pCtl = pm.PyNode('CT__mouthMover_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', suffix='_autoRotate') rt.connectSDK(pCtl.tx, offsetGrp.ry, {-1.2: -15, 0: 0, 1.2: 15}) rt.connectSDK(pCtl.tx, offsetGrp.rz, {-1.2: -12, 0: 0, 1.2: 12}) rt.connectSDK(pCtl.tx, offsetGrp.tz, {-1.2: 0.4, 0: 0, 1.2: 0.4}) # squint pCtl = pm.PyNode('LT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0: 0, 1: 0.5}) pCtl = pm.PyNode('RT__squint_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'parent', suffix='_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {0: 0, 1: 0.5}) # inbrow import rigger.modules.secCtl as secCtl reload(secCtl) sCtl = pm.PyNode('LT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0: 0, -1: 0.2}) sCtl = pm.PyNode('RT_in_brow_ctrl') offsetGrp = secCtl.addOffset(sCtl, 'parent', suffix='_autoVolume') rt.connectSDK(sCtl.tx, offsetGrp.tz, {0: 0, 1: 0.2}) if 'finish_mathilda' in data.build_actions: # a few mathilda specific things to finalize rig # for demo reel purposes # 1. lock all TZs for better volume allCtls = pm.ls('*_ctrl', type='transform') for ctl in allCtls: ctl.tz.set(l=True, k=False) # 2. hide eye aim locators eyeAimLocs = [ nt.Transform(u'LT_eye_aim_loc'), nt.Transform(u'RT_eye_aim_loc') ] for loc in eyeAimLocs: loc.v.set(False) # 3. go to object mode so we can select controls pm.selectMode(object=True) # 4. bind tongue and teeth geos = [ nt.Transform(u'CT_lowerGums_geo'), nt.Transform(u'CT_tongue_geo'), nt.Transform(u'CT_lowerTeeth_geo') ] for geo in geos: pm.parentConstraint(pm.PyNode('CT__jaw_bnd'), geo, mo=True) ''' # 5. reference all geos to make it easier to select controls allGeos = pm.PyNode('CT_geo_grp').getChildren(ad=True, type='mesh') for geo in allGeos: geo.overrideEnabled.set(True) geo.overrideDisplayType.set(True) ''' # 6. smooth face mesh to make it look nicer pm.PyNode('CT_face_geoShape').displaySmoothMesh.set(2)
@author: Leon ''' import pymel.core as pm import pymel.core.nodetypes as nt from pymel.core.language import Mel mel = Mel() importedNodes = pm.ls('eyeSpec_rig_v003:*') side = 'LT_' for n in importedNodes: if 'shape' not in n.nodeType(i=True): newName = side + n.stripNamespace() print newName n.rename(newName) faceCtl = nt.Transform('CT_face_ctrl') eyeMover = nt.Transform(side + '_eyeMover_pri_ctrl_negator') eyeCtl = nt.Transform(side + 'eye_ctl') eyeSpecHm = nt.Transform(side + 'eyeSpec_cth') eyeCtl | eyeSpecHm eyeSpecHm.setMatrix(pm.dt.Matrix()) faceCtl | eyeSpecHm pm.pointConstraint(eyeMover, eyeSpecHm) eyeSpecGeo = nt.Mesh(side + 'eyeSpec_geoShape') eyeLensGeo = nt.Mesh(side + 'lens_geoShape') pm.select(eyeSpecGeo, eyeLensGeo, r=True)
# create offset for cheek pri ctrl pCtl = pm.PyNode('LT_cheek_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', '_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {-1: -0.25, 0: 0, 1: 0.5}) # create offset for cheek pri ctrl pCtl = pm.PyNode('RT_cheek_pri_ctrl') offsetGrp = priCtl.addOffset(pCtl, 'child', '_autoVolume') rt.connectSDK(pCtl.ty, offsetGrp.tz, {-1: -0.25, 0: 0, 1: 0.5}) #------------------------------------------------------------ EYE SQUASH LATTICE import rigger.modules.eyeLattice as eyeLattice reload(eyeLattice) eyeGeos = [nt.Transform(u'LT_eyeball_geo'), nt.Transform(u'RT_eyeball_geo')] faceGeos = [ nt.Mesh(u'LT_eyeIris_geoShape'), nt.Mesh(u'RT_eyeIris_geoShape'), nt.Mesh(u'LT_eyeLash_geoShape'), nt.Mesh(u'RT_eyeLash_geoShape'), nt.Mesh(u'CT_face_geoShape') ] latticeGrp = eyeLattice.createLattice(eyeGeos, faceGeos) # set latticeGrp xform from pymel.core.datatypes import Matrix latticeGrpXform = Matrix( [[1.31887392826, 0.0, 0.0, 0.0], [0.0, 2.05176168568, 0.0, 0.0], [0.0, 0.0, 2.44573893765, 0.0], [0.00162200337874, -111.225338771, -5.69868431046, 1.0]]) latticeGrp.setMatrix(latticeGrpXform, worldSpace=True) eyeShaperCtg = eyeLattice.createLatticeControls()