def doCreateOrientationHelpers(self): """ """ log.debug(">>> addOrientationHelpers") assert self.cls == 'TemplateFactory.go',"Not a TemlateFactory.go instance!" assert mc.objExists(self.m.mNode),"module no longer exists" #Gather limb specific data and check #=================================== #'orientHelpers':'messageSimple',#Orientation helper controls #'orientRootHelper':'messageSimple',#Root orienation helper helperObjects = [] helperObjectGroups = [] returnBuffer = [] root = self.i_templateNull.getMessage('root')[0] objects = self.i_templateNull.getMessage('controlObjects') log.debug(root) log.debug(objects) log.debug(self.foundDirections) #>> Create orient root control #============================= orientRootSize = (distance.returnBoundingBoxSizeToAverage(root,True)*2.5) i_orientRootControl = cgmMeta.cgmObject( curves.createControlCurve('circleArrow1',orientRootSize) ) i_orientRootControl.addAttr('mClass','cgmObject',lock=True) curves.setCurveColorByName(i_orientRootControl.mNode,self.moduleColors[0]) i_orientRootControl.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug i_orientRootControl.addAttr('cgmType',value = 'templateOrientRoot', attrType = 'string', lock=True) i_orientRootControl.doName() #>>> Store it i_orientRootControl.connectParent(self.templateNull,'orientRootHelper','owner')#Connect it to it's object #>>> Position and set up follow groups position.moveParentSnap(i_orientRootControl.mNode,root) i_orientRootControl.parent = root #parent it to the root i_orientRootControl.doGroup(maintain = True)#group while maintainting position mc.pointConstraint(objects[0],i_orientRootControl.parent,maintainOffset = False)#Point contraint orient control to the first helper object mc.aimConstraint(objects[-1],i_orientRootControl.parent,maintainOffset = True, weight = 1, aimVector = [1,0,0], upVector = [0,1,0], worldUpObject = root, worldUpType = 'objectRotation' ) attributes.doSetLockHideKeyableAttr(i_orientRootControl.mNode,True,False,False,['tx','ty','tz','rx','ry','sx','sy','sz','v']) self.i_orientHelpers = []#we're gonna store the instances so we can get them all after parenting and what not #>> Sub controls #============================= if len(objects) == 1:#If a single handle module i_obj = cgmMeta.cgmObject(objects[0]) position.moveOrientSnap(objects[0],root) else: for i,obj in enumerate(objects): log.debug("on %s"%(mc.ls(obj,shortNames=True)[0])) #>>> Create and color size = (distance.returnBoundingBoxSizeToAverage(obj,True)*2) # Get size i_obj = cgmMeta.cgmObject(curves.createControlCurve('circleArrow2Axis',size))#make the curve i_obj.addAttr('mClass','cgmObject',lock=True) curves.setCurveColorByName(i_obj.mNode,self.moduleColors[1]) #>>> Tag and name i_obj.doCopyNameTagsFromObject(obj) i_obj.doStore('cgmType','templateOrientHelper',True) i_obj.doName() #>>> Link it to it's object and append list for full store i_obj.connectParent(obj,'helper','owner')#Connect it to it's object self.i_orientHelpers.append(i_obj) log.debug(i_obj.owner) #>>> initial snapping """ position.movePointSnap(i_obj.mNode,obj) if i < len(objects)-1:#If we have a pair for it, aim at that pairs aim, otherwise, aim at the second to last object constBuffer = mc.aimConstraint(objects[i+1],i_obj.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = self.foundDirections[1], worldUpType = 'vector' ) else: constBuffer = mc.aimConstraint(objects[-2],i_obj.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpVector = self.foundDirections[1], worldUpType = 'vector' ) if constBuffer:mc.delete(constBuffer) #>>> follow groups i_obj.parent = obj i_obj.doGroup(maintain = True) if i < len(objects)-1:#If we have a pair for it, aim at that pairs aim, otherwise, aim at the second to last object mc.aimConstraint(objects[i+1],i_obj.parent,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = [0,1,0], worldUpObject = i_orientRootControl.mNode, worldUpType = 'objectrotation' ) else: constBuffer = mc.aimConstraint(objects[-2],i_obj.parent,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpObject = i_orientRootControl.mNode, worldUpType = 'objectrotation' ) #>>> ConnectVis, lock and hide #mc.connectAttr((visAttr),(helperObj+'.v')) if obj == objects[-1]: attributes.doSetLockHideKeyableAttr(i_obj.mNode,True,False,False,['tx','ty','tz','ry','sx','sy','sz','v']) else: attributes.doSetLockHideKeyableAttr(i_obj.mNode,True,False,False,['tx','ty','tz','rx','ry','sx','sy','sz','v']) #>>> Get data ready to go forward bufferList = [] for o in self.i_orientHelpers: bufferList.append(o.mNode) self.i_templateNull.orientHelpers = bufferList self.i_orientRootHelper = i_orientRootControl log.debug("orientRootHelper: [%s]"%self.i_templateNull.orientRootHelper.getShortName()) log.debug("orientHelpers: %s"%self.i_templateNull.getMessage('orientHelpers')) return True
def createSizeTemplateControl(self): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Generates a sizeTemplateObject. It's been deleted, it recreates it. Guess the size based off of there being a mesh there. If there is no mesh, it sets sets an intial size of a [155,170,29] unit character. ARGUMENTS: self.PuppetNull.nameShort(string) RETURNS: returnList(list) = [startCrv(string),EndCrv(list)] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Get info #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> startColors = modules.returnSettingsData('colorStart') endColors = modules.returnSettingsData('colorEnd') font = mc.getAttr((self.msgSettingsInfo.get() + '.font')) """ checks for there being anything in our geo group """ if not self.geo: return guiFactory.warning( 'Need some geo defined to make this tool worthwhile') boundingBoxSize = modules.returnSettingsDataAsFloat( 'meshlessSizeTemplate') else: boundingBoxSize = distance.returnBoundingBoxSize( self.msgGeoGroup.get()) boundingBox = mc.exactWorldBoundingBox(self.msgGeoGroup.get()) """determine orienation """ maxSize = max(boundingBoxSize) matchIndex = boundingBoxSize.index(maxSize) """Find the pivot of the bounding box """ pivotPosition = distance.returnCenterPivotPosition( self.msgGeoGroup.get()) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Get our positions #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if self.optionPuppetMode.get() == 0: #If bio... if matchIndex == 1 or matchIndex == 0: #Vertical posBuffers = [[0, .5, 0], [0, .75, 0]] width = (boundingBoxSize[0] / 2) height = (boundingBoxSize[1]) depth = boundingBoxSize[2] for cnt, pos in enumerate(posBuffers): posBuffer = posBuffers[cnt] posBuffer[0] = 0 posBuffer[1] = (posBuffer[1] * height) posBuffer[2] = 0 elif matchIndex == 2: #Horizontal posBuffers = [[0, 0, -.33], [0, 0, .66]] width = boundingBoxSize[1] height = boundingBoxSize[2] / 2 depth = (boundingBoxSize[0]) for cnt, pos in enumerate(posBuffers): posBuffer = posBuffers[cnt] posBuffer[0] = 0 posBuffer[1] = boundingBoxSize[1] * .75 posBuffer[2] = (posBuffer[2] * height) else: #Otherwise if matchIndex == 1 or matchIndex == 0: #Vertical width = (boundingBoxSize[0] / 2) height = (boundingBoxSize[1]) depth = boundingBoxSize[2] posBuffers = [[0, boundingBox[1], 0], [0, boundingBox[4], 0]] elif matchIndex == 2: #Horizontal width = boundingBoxSize[0] height = boundingBoxSize[2] / 2 depth = (boundingBoxSize[1]) startHeight = max([boundingBox[4], boundingBox[1]]) - depth / 2 print startHeight posBuffers = [[0, startHeight, boundingBox[2]], [0, startHeight, boundingBox[5]]] # Simple reverse of start pos buffers if the object is pointing negative if self.optionAimAxis < 2: posBuffers.reverse() #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Making the controls #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ make our control object """ startCurves = [] startCurve = curves.createControlCurve('circle', depth * .8) mc.xform(startCurve, t=posBuffers[0], ws=True) attributes.doSetAttr(startCurve, 'rotateOrder', 5) curves.setCurveColorByName(startCurve, startColors[1]) startCurves.append(startCurve) startText = curves.createTextCurve('start', size=depth * .75, font=font) mc.xform(startText, t=posBuffers[0], ws=True) curves.setCurveColorByName(startText, startColors[0]) startCurves.append(startText) endCurves = [] endCurve = curves.createControlCurve('circle', depth * .8) mc.xform(endCurve, t=posBuffers[1], ws=True) curves.setCurveColorByName(endCurve, endColors[1]) attributes.doSetAttr(endCurve, 'rotateOrder', 5) endCurves.append(endCurve) endText = curves.createTextCurve('end', size=depth * .6, font=font) mc.xform(endText, t=posBuffers[1], ws=True) curves.setCurveColorByName(endText, endColors[0]) endCurves.append(endText) """ aiming """ position.aimSnap(startCurve, endCurve, [0, 0, 1], [0, 1, 0]) position.aimSnap(startText, endCurve, [0, 0, 1], [0, 1, 0]) position.aimSnap(endCurve, startCurve, [0, 0, -1], [0, 1, 0]) position.aimSnap(endText, startCurve, [0, 0, -1], [0, 1, 0]) sizeCurveControlStart = curves.combineCurves(startCurves) sizeCurveControlEnd = curves.combineCurves(endCurves) """ store our info to name our objects""" attributes.storeInfo(sizeCurveControlStart, 'cgmName', (self.PuppetNull.nameShort + '.cgmName')) attributes.storeInfo(sizeCurveControlStart, 'cgmDirection', 'start') attributes.storeInfo(sizeCurveControlStart, 'cgmType', 'templateSizeObject') sizeCurveControlStart = NameFactory.doNameObject(sizeCurveControlStart) mc.makeIdentity(sizeCurveControlStart, apply=True, t=True, s=True, r=True) attributes.storeInfo(sizeCurveControlEnd, 'cgmName', (self.PuppetNull.nameShort + '.cgmName')) attributes.storeInfo(sizeCurveControlEnd, 'cgmDirection', 'end') attributes.storeInfo(sizeCurveControlEnd, 'cgmType', 'templateSizeObject') sizeCurveControlEnd = NameFactory.doNameObject(sizeCurveControlEnd) endGroup = rigging.groupMeObject(sizeCurveControlEnd) mc.makeIdentity(sizeCurveControlEnd, apply=True, t=True, s=True, r=True) mc.parentConstraint(sizeCurveControlStart, endGroup, maintainOffset=True) """ make control group """ controlGroup = rigging.groupMeObject(sizeCurveControlStart) attributes.storeInfo(controlGroup, 'cgmName', (self.PuppetNull.nameShort + '.cgmName')) attributes.storeInfo(controlGroup, 'cgmType', 'templateSizeObjectGroup') controlGroup = NameFactory.doNameObject(controlGroup) endGroup = rigging.doParentReturnName(endGroup, controlGroup) #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Getting data ready #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> attributes.storeInfo(controlGroup, 'controlStart', sizeCurveControlStart) attributes.storeInfo(controlGroup, 'controlEnd', sizeCurveControlEnd) attributes.storeInfo(self.PuppetNull.nameShort, 'templateSizeObject', controlGroup) self.templateSizeObjects['root'] = controlGroup self.templateSizeObjects['start'] = sizeCurveControlStart self.templateSizeObjects['end'] = sizeCurveControlEnd returnList = [] returnList.append(sizeCurveControlStart) returnList.append(sizeCurveControlEnd) return returnList
def doMakeLimbTemplate(self): """ Self should be a TemplateFactory.go """ """ returnList = [] templObjNameList = [] templHandleList = [] """ log.debug(">>> doMakeLimbTemplate") assert self.cls == 'TemplateFactory.go',"Not a TemlateFactory.go instance!" #Gather limb specific data and check #============== doCurveDegree = getGoodCurveDegree(self) if not doCurveDegree:raise ValueError,"Curve degree didn't query" #>>>Scale stuff size = returnModuleBaseSize(self.m) lastCountSizeMatch = len(self.corePosList) -1 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Making the template objects #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> templHandleList = [] self.i_controlObjects = [] self.i_locs = [] for i,pos in enumerate(self.corePosList):# Don't like this sizing method but it is what it is for now #>> Make each of our base handles #============================= if i == 0: sizeMultiplier = 1 elif i == lastCountSizeMatch: sizeMultiplier = .8 else: sizeMultiplier = .75 #>>> Create and set attributes on the object i_obj = cgmMeta.cgmObject( curves.createControlCurve('sphere',(size * sizeMultiplier)) ) i_obj.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later curves.setCurveColorByName(i_obj.mNode,self.moduleColors[0]) i_obj.addAttr('cgmName',value = str(self.l_coreNames[i]), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug if self.direction != None: i_obj.addAttr('cgmDirection',value = self.direction,attrType = 'string',lock=True) i_obj.addAttr('cgmType',value = 'templateObject', attrType = 'string',lock=True) i_obj.doName()#Name it mc.move (pos[0], pos[1], pos[2], [i_obj.mNode], a=True) i_obj.parent = self.templateNull #>>> Loc it and store the loc #i_loc = cgmMeta.cgmObject( i_obj.doLoc() ) i_loc = i_obj.doLoc() i_loc.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later i_loc.addAttr('cgmName',value = self.m.getShortName(), attrType = 'string', lock=True) #Add name tag i_loc.addAttr('cgmType',value = 'templateCurveLoc', attrType = 'string', lock=True) #Add Type i_loc.v = False # Turn off visibility i_loc.doName() self.i_locs.append(i_loc) i_obj.connectChildNode(i_loc.mNode,'curveLoc','owner') i_loc.parent = self.templateNull#parent to the templateNull mc.pointConstraint(i_obj.mNode,i_loc.mNode,maintainOffset = False)#Point contraint loc to the object templHandleList.append (i_obj.mNode) self.i_controlObjects.append(i_obj) #>> Make the curve #============================= i_crv = cgmMeta.cgmObject( mc.curve (d=doCurveDegree, p = self.corePosList , os=True) ) i_crv.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later i_crv.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug if self.direction != None: i_crv.addAttr('cgmDirection',value = self.direction, attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug i_crv.addAttr('cgmType',value = 'templateCurve', attrType = 'string', lock=True) curves.setCurveColorByName(i_crv.mNode,self.moduleColors[0]) i_crv.parent = self.templateNull i_crv.doName() i_crv.setDrawingOverrideSettings({'overrideEnabled':1,'overrideDisplayType':2},True) for i,i_obj in enumerate(self.i_controlObjects):#Connect each of our handles ot the cv's of the curve we just made mc.connectAttr ( (i_obj.curveLoc.mNode+'.translate') , ('%s%s%i%s' % (i_crv.mNode, '.controlPoints[', i, ']')), f=True ) self.foundDirections = returnGeneralDirections(self,templHandleList) log.debug("directions: %s"%self.foundDirections ) #>> Create root control #============================= rootSize = (distance.returnBoundingBoxSizeToAverage(templHandleList[0],True)*1.25) i_rootControl = cgmMeta.cgmObject( curves.createControlCurve('cube',rootSize) ) i_rootControl.addAttr('mClass','cgmObject',lock=True) curves.setCurveColorByName(i_rootControl.mNode,self.moduleColors[0]) i_rootControl.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug i_rootControl.addAttr('cgmType',value = 'templateRoot', attrType = 'string', lock=True) if self.direction != None: i_rootControl.addAttr('cgmDirection',value = self.direction, attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug i_rootControl.doName() #>>> Position it if self.m.moduleType in ['clavicle']: position.movePointSnap(i_rootControl.mNode,templHandleList[0]) else: position.movePointSnap(i_rootControl.mNode,templHandleList[0]) #See if there's a better way to do this log.debug("templHandleList: %s"%templHandleList) if self.m.moduleType not in ['foot']: if len(templHandleList)>1: log.info("setting up constraints...") constBuffer = mc.aimConstraint(templHandleList[-1],i_rootControl.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = self.worldUpVector, worldUpType = 'vector' ) mc.delete (constBuffer[0]) elif self.m.getMessage('moduleParent'): #parentTemplateObjects = self.m.moduleParent.templateNull.getMessage('controlObjects') helper = self.m.moduleParent.templateNull.controlObjects[-1].helper.mNode if helper: log.info("helper: %s"%helper) constBuffer = mc.orientConstraint( helper,i_rootControl.mNode,maintainOffset = False) mc.delete (constBuffer[0]) i_rootControl.parent = self.templateNull i_rootControl.doGroup(maintain=True) #>> Store objects #============================= self.i_templateNull.curve = i_crv.mNode self.i_templateNull.root = i_rootControl.mNode self.i_templateNull.controlObjects = templHandleList self.i_rootControl = i_rootControl#link to carry #>> Orientation helpers #============================= """ Make our Orientation Helpers """ doCreateOrientationHelpers(self) doParentControlObjects(self.m) #if self.m.getMessage('moduleParent'):#If we have a moduleParent, constrain it #constrainToParentModule(self.m) return True
def makeLimbTemplate (self): #>>>Curve degree finder if self.optionCurveDegree.get() == 0: doCurveDegree = 1 else: if len(corePositionList) <= 3: doCurveDegree = 1 else: doCurveDegree = len(corePositionList) - 1 #Make some storage vehicles self.templatePosObjectsBuffer = BufferFactory(self.infoNulls['templatePosObjects'].get()) self.templatePosObjectsBuffer.purge() LocatorCatcher = ObjectFactory('') LocatorBuffer = BufferFactory(LocatorCatcher.nameLong) LocatorBuffer.purge() returnList = [] self.templHandleList = [] moduleColors = modules.returnModuleColors(self.ModuleNull.nameShort) #>>>Scale stuff moduleParent = self.msgModuleParent.get() if not moduleParent: length = (distance.returnDistanceBetweenPoints (corePositionList[0],corePositionList[-1])) size = length / self.optionHandles.get() else: #>>>>>>>>>>>>>>>>>>>>> NOT TOUCHED YET parentTemplatePosObjectsInfoNull = modules.returnInfoTypeNull(moduleParent,'templatePosObjects') parentTemplatePosObjectsInfoData = attributes.returnUserAttrsToDict (parentTemplatePosObjectsInfoNull) parentTemplateObjects = [] for key in parentTemplatePosObjectsInfoData.keys(): if (mc.attributeQuery (key,node=parentTemplatePosObjectsInfoNull,msg=True)) == True: if search.returnTagInfo((parentTemplatePosObjectsInfoData[key]),'cgmType') != 'templateCurve': parentTemplateObjects.append (parentTemplatePosObjectsInfoData[key]) createBuffer = curves.createControlCurve('sphere',1) pos = corePositionList[0] mc.move (pos[0], pos[1], pos[2], createBuffer, a=True) closestParentObject = distance.returnClosestObject(createBuffer,parentTemplateObjects) boundingBoxSize = distance.returnBoundingBoxSize (closestParentObject) maxSize = max(boundingBoxSize) size = maxSize *.25 mc.delete(createBuffer) if partType == 'clavicle': size = size * .5 elif partType == 'head': size = size * .75 if (search.returnTagInfo(moduleParent,'cgmModuleType')) == 'clavicle': size = size * 2 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Making the template objects #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> self.TemplateObject = {} #>>> Template objects for cnt,pos in enumerate(corePositionList): #Size multiplier based on PuppetMode, make it take into account module mode eventually if PuppetInstance.optionPuppetMode.get() == 0: if cnt == 0: sizeMultiplier = 1 elif cnt == len(corePositionList) -1: sizeMultiplier = .8 else: sizeMultiplier = .5 else: sizeMultiplier = 1 #make a sphere and move it createBuffer = curves.createControlCurve('sphere',(size * sizeMultiplier)) self.TemplateObject[cnt] = ObjectFactory(createBuffer) # Instance the control to our module obj = self.TemplateObject[cnt] curves.setCurveColorByName(obj.nameLong,moduleColors[0]) obj.store('cgmName',coreNames[cnt]) obj.getNameTagsFromObject(self.ModuleNull.nameLong,['cgmName','cgmType']) obj.store('cgmType','templateObject') obj.doName() mc.move (pos[0], pos[1], pos[2], [obj.nameLong], a=True) #adds it to the list self.templHandleList.append (obj.nameLong) self.templatePosObjectsBuffer.store(obj.nameLong) #Aim the objects position.aimObjects(self.templHandleList, dictionary.axisDirectionsByString[ self.optionAimAxis.get() ], dictionary.axisDirectionsByString[ self.optionUpAxis.get() ], dictionary.axisDirectionsByString[ PuppetInstance.optionUpAxis.get() ]) #>>> Template curve crvName = mc.curve (d=doCurveDegree, p = corePositionList , os=True, n=('%s_%s' %(partName,(typesDictionary.get('templateCurve'))))) self.afTemplateCurve = AttrFactory(self.infoNulls['templatePosObjects'].get(), 'curve','message', value=crvName)# connect it back to our template objects info null curve = ObjectFactory(crvName) # instance it curve.getNameTagsFromObject(self.ModuleNull.nameLong,['cgmType']) #get name tags from the module attributes.storeInfo(crvName,'cgmType','templateCurve') # store type curves.setCurveColorByName(crvName,moduleColors[1]) # set curve color # Make locators to connect the cv's to for cnt,obj in enumerate(self.templHandleList): pointLoc = locators.locMeObject(obj) # make the loc loc = ObjectFactory(pointLoc) #instance it mc.setAttr ((loc.nameShort+'.visibility'),0) # turn off visibility mc.parentConstraint ([obj],[loc.nameShort],mo=False) # parent constrain mc.connectAttr ( (loc.nameShort+'.translate'), ('%s.controlPoints[%i]' % (crvName, cnt)), f=True ) # connect the cv to the loc self.TemplateObject[cnt].store('loc',loc.nameLong) LocatorBuffer.store(loc.nameLong) #>>> Direction and size Stuff """ # Directional data derived from joints generalDirection = logic.returnHorizontalOrVertical(self.templHandleList) if generalDirection == 'vertical' and 'leg' not in self.afModuleType.get(): worldUpVector = [0,0,-1] elif generalDirection == 'vertical' and 'leg' in self.afModuleType.get(): worldUpVector = [0,0,1] else: worldUpVector = [0,1,0] """ # Create root control templateNull = self.msgTemplateNull.get() handleList = copy.copy(self.templatePosObjectsBuffer.bufferList) rootSize = (distance.returnBoundingBoxSizeToAverage(self.templHandleList[0])*1.5) rootCtrl = ObjectFactory(curves.createControlCurve('cube',rootSize)) rootCtrl.getNameTagsFromObject(self.ModuleNull.nameLong) self.msgTemplateRoot = AttrFactory(self.infoNulls['templatePosObjects'].get(), 'root', 'message', value = rootCtrl.nameLong) curves.setCurveColorByName(rootCtrl.nameLong,moduleColors[0]) # move the root if self.afModuleType.get() == 'clavicle': position.movePointSnap(rootCtrl.nameLong,self.templHandleList[0]) else: position.movePointSnap(rootCtrl.nameLong,self.templHandleList[0]) # aim the root position.aimSnap(rootCtrl.nameShort,self.templHandleList[-1], dictionary.axisDirectionsByString[ self.optionAimAxis.get() ], dictionary.axisDirectionsByString[ self.optionUpAxis.get() ], dictionary.axisDirectionsByString[ PuppetInstance.optionUpAxis.get() ]) rootCtrl.store('cgmType','templateRoot') rootCtrl.doName() #>>> Parent the main objcts rootGroup = rootCtrl.doGroup() rootGroup = rigging.doParentReturnName(rootGroup,templateNull) curve.doParent(templateNull) for obj in LocatorBuffer.bufferList: rigging.doParentReturnName(obj,templateNull) mc.delete(LocatorCatcher.nameShort) # delete the locator buffer obj #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>> Orientation helpers #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Make our Orientation Helpers """ orientHelpersReturn = template.addOrientationHelpers(self) masterOrient = orientHelpersReturn[0] orientObjects = orientHelpersReturn[1] return #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>> Control helpers #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> print orientObjects print self.ModuleNull.nameShort print (templateNull+'.visControlHelpers') controlHelpersReturn = addControlHelpers(orientObjects,self.ModuleNull.nameShort,(templateNull+'.visControlHelpers'))""" #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>> Input the saved values if there are any #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # Orientation Helpers """rotBuffer = coreRotationList[-1] #actualName = mc.spaceLocator (n= wantedName) rotCheck = sum(rotBuffer) if rotCheck != 0: mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],masterOrient,os=True) cnt = 0 for obj in orientObjects: rotBuffer = coreRotationList[cnt] rotCheck = sum(rotBuffer) if rotCheck != 0: mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],obj,os=True) cnt +=1 # Control Helpers controlHelpers = controlHelpersReturn[0] cnt = 0 for obj in controlHelpers: posBuffer = controlPositionList[cnt] posCheck = sum(posBuffer) if posCheck != 0: mc.xform(obj,t=[posBuffer[0],posBuffer[1],posBuffer[2]],ws=True) rotBuffer = controlRotationList[cnt] rotCheck = sum(rotBuffer) if rotCheck != 0: mc.rotate(rotBuffer[0],rotBuffer[1],rotBuffer[2],obj,ws=True) scaleBuffer = controlScaleList[cnt] scaleCheck = sum(scaleBuffer) if scaleCheck != 0: mc.scale(scaleBuffer[0],scaleBuffer[1],scaleBuffer[2],obj,absolute=True) cnt +=1 """ #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #>> Final stuff #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ returnList.append(templObjNameList) returnList.append(self.templHandleList) returnList.append(rootCtrl)""" return True
def rigMasterCardCharaterOLD(): spineChain = [] jointChains = [] def skinIt(): #Skin it geoGroupObjects = search.returnAllChildrenObjects('geo_grp', True) #Get our group objects jointChains = getSkinJointChains() for i, g in enumerate([ u'torso_geoGrp', u'armLeft_geoGrp', u'armRight_geoGrp', u'legLeft_geoGrp', u'legRight_geoGrp' ]): geoGroupObjects = search.returnAllChildrenObjects(g, True) toSkin = [] for o in geoGroupObjects: if search.returnObjectType(o) in ['mesh', 'nurbsSurface']: toSkin.append(o) if toSkin: for o in toSkin: toBind = jointChains[i] + [o] mc.skinCluster(toBind, tsb=True, normalizeWeights=True, mi=4, dr=10, polySmoothness=3) else: print("'%s' has nothing to skin!" % g) def orientSkeletonTemplate(): #First unparent the parts so we can orient properly hip = rigging.doParentToWorld('hip_l') heel = rigging.doParentToWorld('heel_l') clav = rigging.doParentToWorld('clavicle_l') palm = rigging.doParentToWorld('palm_l') spineChain = ['root'] spineChain.extend(search.returnChildrenJoints('root')) for j in spineChain: joints.orientJoint(j, 'xzy', 'zup') hipChain = [hip] hipChain.extend(search.returnChildrenJoints(hip)) for j in hipChain: joints.orientJoint(j, 'xzy', 'zup') armChain = [clav] armChain.extend(search.returnChildrenJoints(clav)) for j in armChain: joints.orientJoint(j, 'xyz', 'yup') footChain = [heel] footChain.extend(search.returnChildrenJoints(heel)) for j in footChain: joints.orientJoint(j, 'yzx', 'yup') handChain = [palm] handChain.extend(search.returnChildrenJoints(palm)) for j in handChain: joints.orientJoint(j, 'xzy', 'zup') #Fix the thumb thumbChain = ['thumb1_l'] thumbChain.extend(search.returnChildrenJoints('thumb1_l')) for j in thumbChain: #tweak - taken from Comet's orient mc.xform(j, r=True, os=True, ra=(-20, 0, 0)) mc.joint(j, e=True, zso=True) mc.makeIdentity(j, apply=True) #Fix the Head headChain = ['head1'] headChain.extend(search.returnChildrenJoints('head1')) for j in headChain: joints.orientJoint(j, 'yzx', 'zup') #Reconnect rigging.doParentReturnName(hip, 'root') rigging.doParentReturnName(clav, 'spine5') rigging.doParentReturnName(heel, 'ankle_l') rigging.doParentReturnName(palm, 'wrist_l') return spineChain def getSkinJointChains(): leftArmChain = ['clavicle_l'] leftArmChain.extend(search.returnChildrenJoints('clavicle_l')) rightArmChain = ['clavicle_r'] rightArmChain.extend(search.returnChildrenJoints('clavicle_r')) leftLegChain = ['hip_l'] leftLegChain.extend(search.returnChildrenJoints('hip_l')) rightLegChain = ['hip_r'] rightLegChain.extend(search.returnChildrenJoints('hip_r')) torsoChain.extend(['clavicle_l', 'clavicle_r']) returnList = [ torsoChain, leftArmChain, rightArmChain, leftLegChain, rightLegChain ] return returnList torsoChain = orientSkeletonTemplate() #Get ready for JTD stuff mel.eval('source JTDriggingUI;') mel.eval('source JTDarmRig;') mel.eval('source JTDspineRig;') mel.eval('source JTDneckRig;') mel.eval('source JTDdynParent;') mel.eval('source JTDfingerRig;') mel.eval( 'mirrorJoint -mirrorYZ -mirrorBehavior -searchReplace "_l" "_r" "hip_l";' ) mel.eval( 'mirrorJoint -mirrorYZ -mirrorBehavior -searchReplace "_l" "_r" "clavicle_l";' ) mel.eval('JTDspineRig("%s", "spine1", "spine5", "root", %f, "%s", "");' % (baseName, spineScale, world)) mel.eval('JTDneckRig("%s", "neck1", "head1", %f, "%s", "%s");' % (baseName, spineScale, world, connect)) mel.eval( 'JTDarmRig("%s","clavicle_l","shoulder_l","elbow_l","wrist_l", 3, 1, %f, "%s", "%s");' % (baseName, armScale, world, connect)) mel.eval( 'JTDarmRig("%s","clavicle_r","shoulder_r","elbow_r","wrist_r", 3, 2, %f, "%s", "%s");' % (baseName, armScale, world, connect)) mel.eval( 'JTDlegRig("%s","hip_l","knee_l","ankle_l","heel_l","ball_l", 3, 1, %f, "%s", "%s", 2);' % (baseName, legScale, world, connect)) mel.eval( 'JTDlegRig("%s","hip_r","knee_r","ankle_r","heel_r","ball_r", 3, 2, %f, "%s", "%s", 2);' % (baseName, legScale, world, connect)) #Fingers Left mel.eval( 'JTDfingerRig("wrist_l","","index1_l","index2_l","index3_l", 1, 1, 1, 0, 1, "%s", %f);' % (baseName, fingerScale)) mel.eval( 'JTDfingerRig("wrist_l","","fingers1_l","fingers2_l","fingers3_l", 1, 1, 4, 0, 1, "%s", %f);' % (baseName, fingerScale)) mel.eval( 'JTDfingerRig("wrist_l","","thumb1_l","thumb2_l","thumb3_l", 1, 1, 0, 1, 1, "%s", %f);' % (baseName, fingerScale)) #Fingers Right mel.eval( 'JTDfingerRig("wrist_r","","index1_r","index2_r","index3_r", 1, 1, 1, 0, 2, "%s", %f);' % (baseName, fingerScale)) mel.eval( 'JTDfingerRig("wrist_r","","fingers1_r","fingers2_r","fingers3_r", 1, 1, 4, 0, 2, "%s", %f);' % (baseName, fingerScale)) mel.eval( 'JTDfingerRig("wrist_r","","thumb1_r","thumb2_r","thumb3_r", 1, 1, 0, 1, 2, "%s", %f);' % (baseName, fingerScale)) #new stuff #Head scale attributes.doSetLockHideKeyableAttr('cubey_neck_IK_Cntrl', lock=False, visible=True, keyable=True, channels=['sx', 'sy', 'sz']) mc.setAttr('cubey_neck_IK_Cntrl.sx', keyable=True) mc.setAttr('cubey_neck_IK_Cntrl.sy', keyable=True) mc.setAttr('cubey_neck_IK_Cntrl.sz', keyable=True) mc.scaleConstraint('cubey_neck_IK_Cntrl', 'head1') #Sets and Coloring leftArmSetObjects = [ u'rig_clavicle_l_IK_Cntrl', u'rig_shoulder_l_twist', u'rig_shoulder_l_Bendy', u'rig_elbow_l_Bendy', u'rig_clavicle_l_FK_Cntrl', u'cubey_finger_Cntrl0_l', u'rig_wrist_l_FK', u'rig_wrist_l_SW', u'rig_shoulder_l_FK', u'rig_elbow_l_FK', u'cubey_arm_IK_Cntrl_l', u'rig_wrist_l_GimbleCntrl_l', u'cubey_arm_PV_Cntrl_l' ] # rightArmSetObjects = [ u'rig_clavicle_r_IK_Cntrl', u'rig_shoulder_r_twist', u'rig_shoulder_r_Bendy', u'rig_elbow_r_Bendy', u'rig_clavicle_r_FK_Cntrl', u'cubey_finger_Cntrl0_r', u'rig_wrist_r_FK', u'rig_wrist_r_SW', u'rig_shoulder_r_FK', u'rig_elbow_r_FK', u'cubey_arm_IK_Cntrl_r', u'rig_wrist_r_GimbleCntrl_r', u'cubey_arm_PV_Cntrl_r' ] # centerSetObjects = [ u'rig_spine1_Shoulders', u'rig_spine1_Hips', u'cubey_spine_Root', u'rig_spine1FK3', u'rig_spine1FK2', u'rig_spine1FK1', u'cubey_neck_FK_Cntrl', u'cubey_neck_IK_Cntrl' ] leftLegSetObjects = [ u'rig_ball_l_FK', u'rig_ankle_l_SW', u'rig_hip_l_Bendy', u'rig_knee_l_FK', u'rig_ankle_l_FK', u'rig_hip_l_FK', u'rig_knee_l_Bendy', u'rig_hip_l_twist', u'cubey_leg_GimbleCntrl_l', u'cubey_leg_IKleg_Cntrl_l', u'cubey_leg_PV_Cntrl_l' ] rightLegSetObjects = [ u'rig_ball_r_FK', u'rig_ankle_r_SW', u'rig_hip_r_Bendy', u'rig_knee_r_FK', u'rig_ankle_r_FK', u'rig_hip_r_FK', u'rig_knee_r_Bendy', u'rig_hip_r_twist', u'cubey_leg_GimbleCntrl_r', u'cubey_leg_IKleg_Cntrl_r', u'cubey_leg_PV_Cntrl_r' ] lArmSet = SetFactory.SetFactory('armLeft', 'animation', True) for o in leftArmSetObjects: lArmSet.store(o) #color curves.setCurveColorByName(o, 'blueBright') rArmSet = SetFactory.SetFactory('armRight', 'animation', True) for o in rightArmSetObjects: rArmSet.store(o) #color curves.setCurveColorByName(o, 'redBright') torsoSet = SetFactory.SetFactory('torso', 'animation', True) for o in centerSetObjects: torsoSet.store(o) curves.setCurveColorByName(o, 'yellow') lLegSet = SetFactory.SetFactory('legLeft', 'animation', True) for o in leftLegSetObjects: lLegSet.store(o) curves.setCurveColorByName(o, 'blueBright') rLegSet = SetFactory.SetFactory('legRight', 'animation', True) for o in rightLegSetObjects: rLegSet.store(o) curves.setCurveColorByName(o, 'redBright') bindJoints = search.returnAllChildrenObjects('root') bindJoints.append('root') skinJointsSet = SetFactory.SetFactory('skinJoints', 'td', True) for o in bindJoints: if mc.ls(o, type='joint'): skinJointsSet.store(o) #Set of all sets allSet = SetFactory.SetFactory('all', 'animation', True) allSet.store(rLegSet.nameLong) allSet.store(lLegSet.nameLong) allSet.store(torsoSet.nameLong) allSet.store(lArmSet.nameLong) allSet.store(rArmSet.nameLong) #Skin! skinIt()
def rigMasterCardCharaterOLD(): spineChain = [] jointChains = [] def skinIt(): #Skin it geoGroupObjects = search.returnAllChildrenObjects('geo_grp',True) #Get our group objects jointChains = getSkinJointChains() for i,g in enumerate([u'torso_geoGrp', u'armLeft_geoGrp', u'armRight_geoGrp', u'legLeft_geoGrp', u'legRight_geoGrp']): geoGroupObjects = search.returnAllChildrenObjects(g,True) toSkin = [] for o in geoGroupObjects: if search.returnObjectType(o) in ['mesh','nurbsSurface']: toSkin.append(o) if toSkin: for o in toSkin: toBind = jointChains[i] + [o] mc.skinCluster(toBind, tsb = True, normalizeWeights = True, mi = 4, dr = 10,polySmoothness = 3) else: print ("'%s' has nothing to skin!"%g) def orientSkeletonTemplate(): #First unparent the parts so we can orient properly hip = rigging.doParentToWorld('hip_l') heel = rigging.doParentToWorld('heel_l') clav = rigging.doParentToWorld('clavicle_l') palm = rigging.doParentToWorld('palm_l') spineChain = ['root'] spineChain.extend(search.returnChildrenJoints('root')) for j in spineChain: joints.orientJoint(j,'xzy','zup') hipChain = [hip] hipChain.extend(search.returnChildrenJoints(hip)) for j in hipChain: joints.orientJoint(j,'xzy','zup') armChain = [clav] armChain.extend(search.returnChildrenJoints(clav)) for j in armChain: joints.orientJoint(j,'xyz','yup') footChain = [heel] footChain.extend(search.returnChildrenJoints(heel)) for j in footChain: joints.orientJoint(j,'yzx','yup') handChain = [palm] handChain.extend(search.returnChildrenJoints(palm)) for j in handChain: joints.orientJoint(j,'xzy','zup') #Fix the thumb thumbChain = ['thumb1_l'] thumbChain.extend(search.returnChildrenJoints('thumb1_l')) for j in thumbChain: #tweak - taken from Comet's orient mc.xform(j,r=True,os=True,ra= (-20,0,0)) mc.joint(j,e=True,zso = True) mc.makeIdentity(j,apply=True) #Fix the Head headChain = ['head1'] headChain.extend(search.returnChildrenJoints('head1')) for j in headChain: joints.orientJoint(j,'yzx','zup') #Reconnect rigging.doParentReturnName(hip,'root') rigging.doParentReturnName(clav,'spine5') rigging.doParentReturnName(heel,'ankle_l') rigging.doParentReturnName(palm,'wrist_l') return spineChain def getSkinJointChains(): leftArmChain = ['clavicle_l'] leftArmChain.extend(search.returnChildrenJoints('clavicle_l')) rightArmChain = ['clavicle_r'] rightArmChain.extend(search.returnChildrenJoints('clavicle_r')) leftLegChain = ['hip_l'] leftLegChain.extend(search.returnChildrenJoints('hip_l')) rightLegChain = ['hip_r'] rightLegChain.extend(search.returnChildrenJoints('hip_r')) torsoChain.extend(['clavicle_l','clavicle_r']) returnList = [torsoChain,leftArmChain,rightArmChain,leftLegChain,rightLegChain] return returnList torsoChain = orientSkeletonTemplate() #Get ready for JTD stuff mel.eval('source JTDriggingUI;') mel.eval('source JTDarmRig;') mel.eval('source JTDspineRig;') mel.eval('source JTDneckRig;') mel.eval('source JTDdynParent;') mel.eval('source JTDfingerRig;') mel.eval('mirrorJoint -mirrorYZ -mirrorBehavior -searchReplace "_l" "_r" "hip_l";') mel.eval('mirrorJoint -mirrorYZ -mirrorBehavior -searchReplace "_l" "_r" "clavicle_l";') mel.eval('JTDspineRig("%s", "spine1", "spine5", "root", %f, "%s", "");'%(baseName,spineScale,world)) mel.eval('JTDneckRig("%s", "neck1", "head1", %f, "%s", "%s");'%(baseName,spineScale,world,connect)) mel.eval('JTDarmRig("%s","clavicle_l","shoulder_l","elbow_l","wrist_l", 3, 1, %f, "%s", "%s");'%(baseName,armScale,world,connect)) mel.eval('JTDarmRig("%s","clavicle_r","shoulder_r","elbow_r","wrist_r", 3, 2, %f, "%s", "%s");'%(baseName,armScale,world,connect)) mel.eval('JTDlegRig("%s","hip_l","knee_l","ankle_l","heel_l","ball_l", 3, 1, %f, "%s", "%s", 2);'%(baseName,legScale,world,connect)) mel.eval('JTDlegRig("%s","hip_r","knee_r","ankle_r","heel_r","ball_r", 3, 2, %f, "%s", "%s", 2);'%(baseName,legScale,world,connect)) #Fingers Left mel.eval('JTDfingerRig("wrist_l","","index1_l","index2_l","index3_l", 1, 1, 1, 0, 1, "%s", %f);'%(baseName,fingerScale)) mel.eval('JTDfingerRig("wrist_l","","fingers1_l","fingers2_l","fingers3_l", 1, 1, 4, 0, 1, "%s", %f);'%(baseName,fingerScale)) mel.eval('JTDfingerRig("wrist_l","","thumb1_l","thumb2_l","thumb3_l", 1, 1, 0, 1, 1, "%s", %f);'%(baseName,fingerScale)) #Fingers Right mel.eval('JTDfingerRig("wrist_r","","index1_r","index2_r","index3_r", 1, 1, 1, 0, 2, "%s", %f);'%(baseName,fingerScale)) mel.eval('JTDfingerRig("wrist_r","","fingers1_r","fingers2_r","fingers3_r", 1, 1, 4, 0, 2, "%s", %f);'%(baseName,fingerScale)) mel.eval('JTDfingerRig("wrist_r","","thumb1_r","thumb2_r","thumb3_r", 1, 1, 0, 1, 2, "%s", %f);'%(baseName,fingerScale)) #new stuff #Head scale attributes.doSetLockHideKeyableAttr('cubey_neck_IK_Cntrl',lock = False,visible=True,keyable=True,channels = ['sx','sy','sz']) mc.setAttr('cubey_neck_IK_Cntrl.sx', keyable = True) mc.setAttr('cubey_neck_IK_Cntrl.sy', keyable = True) mc.setAttr('cubey_neck_IK_Cntrl.sz', keyable = True) mc.scaleConstraint('cubey_neck_IK_Cntrl','head1') #Sets and Coloring leftArmSetObjects = [u'rig_clavicle_l_IK_Cntrl', u'rig_shoulder_l_twist', u'rig_shoulder_l_Bendy', u'rig_elbow_l_Bendy', u'rig_clavicle_l_FK_Cntrl', u'cubey_finger_Cntrl0_l', u'rig_wrist_l_FK', u'rig_wrist_l_SW', u'rig_shoulder_l_FK', u'rig_elbow_l_FK', u'cubey_arm_IK_Cntrl_l', u'rig_wrist_l_GimbleCntrl_l', u'cubey_arm_PV_Cntrl_l'] # rightArmSetObjects = [u'rig_clavicle_r_IK_Cntrl', u'rig_shoulder_r_twist', u'rig_shoulder_r_Bendy', u'rig_elbow_r_Bendy', u'rig_clavicle_r_FK_Cntrl', u'cubey_finger_Cntrl0_r', u'rig_wrist_r_FK', u'rig_wrist_r_SW', u'rig_shoulder_r_FK', u'rig_elbow_r_FK', u'cubey_arm_IK_Cntrl_r', u'rig_wrist_r_GimbleCntrl_r', u'cubey_arm_PV_Cntrl_r'] # centerSetObjects = [u'rig_spine1_Shoulders', u'rig_spine1_Hips', u'cubey_spine_Root', u'rig_spine1FK3', u'rig_spine1FK2', u'rig_spine1FK1', u'cubey_neck_FK_Cntrl', u'cubey_neck_IK_Cntrl'] leftLegSetObjects = [u'rig_ball_l_FK', u'rig_ankle_l_SW', u'rig_hip_l_Bendy', u'rig_knee_l_FK', u'rig_ankle_l_FK', u'rig_hip_l_FK', u'rig_knee_l_Bendy', u'rig_hip_l_twist', u'cubey_leg_GimbleCntrl_l', u'cubey_leg_IKleg_Cntrl_l', u'cubey_leg_PV_Cntrl_l'] rightLegSetObjects = [u'rig_ball_r_FK', u'rig_ankle_r_SW', u'rig_hip_r_Bendy', u'rig_knee_r_FK', u'rig_ankle_r_FK', u'rig_hip_r_FK', u'rig_knee_r_Bendy', u'rig_hip_r_twist', u'cubey_leg_GimbleCntrl_r', u'cubey_leg_IKleg_Cntrl_r', u'cubey_leg_PV_Cntrl_r'] lArmSet = SetFactory.SetFactory('armLeft','animation',True) for o in leftArmSetObjects: lArmSet.store(o) #color curves.setCurveColorByName(o,'blueBright') rArmSet = SetFactory.SetFactory('armRight','animation',True) for o in rightArmSetObjects: rArmSet.store(o) #color curves.setCurveColorByName(o,'redBright') torsoSet = SetFactory.SetFactory('torso','animation',True) for o in centerSetObjects: torsoSet.store(o) curves.setCurveColorByName(o,'yellow') lLegSet = SetFactory.SetFactory('legLeft','animation',True) for o in leftLegSetObjects: lLegSet.store(o) curves.setCurveColorByName(o,'blueBright') rLegSet = SetFactory.SetFactory('legRight','animation',True) for o in rightLegSetObjects: rLegSet.store(o) curves.setCurveColorByName(o,'redBright') bindJoints = search.returnAllChildrenObjects('root') bindJoints.append('root') skinJointsSet = SetFactory.SetFactory('skinJoints','td',True) for o in bindJoints: if mc.ls(o,type='joint'): skinJointsSet.store(o) #Set of all sets allSet = SetFactory.SetFactory('all','animation',True) allSet.store(rLegSet.nameLong) allSet.store(lLegSet.nameLong) allSet.store(torsoSet.nameLong) allSet.store(lArmSet.nameLong) allSet.store(rArmSet.nameLong) #Skin! skinIt()
def addOrientationHelpers(self): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Adds orientation helpers to a template chain ARGUMENTS: objects(list) root(string) - root control of the limb chain moduleType(string) RETURNS: returnList(list) = [rootHelper(string),helperObjects(list),helperObjectGroups(list)] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ moduleColors = modules.returnModuleColors(self.ModuleNull.nameLong) helperObjects = [] helperObjectGroups = [] returnBuffer = [] root = self.msgTemplateRoot.getMessage() visAttr = "%s.visOrientHelpers" % self.infoNulls['visibilityOptions'].get() objects = self.templatePosObjectsBuffer.bufferList #>>> Direction and size Stuff """ Directional data derived from joints """ generalDirection = logic.returnHorizontalOrVertical(objects) if generalDirection == 'vertical' and 'leg' not in self.afModuleType.get(): worldUpVector = [0, 0, -1] elif generalDirection == 'vertical' and 'leg' in self.afModuleType.get(): worldUpVector = [0, 0, 1] else: worldUpVector = [0, 1, 0] #Get Size size = (distance.returnBoundingBoxSizeToAverage(objects[0]) * 2) #>>> Master Orient helper createBuffer = curves.createControlCurve('circleArrow1', (size * 2), 'z+') # make the curve curves.setCurveColorByName(createBuffer, moduleColors[0]) attributes.storeInfo(createBuffer, 'cgmType', 'templateOrientRoot') #copy the name attr mainOrientHelperObj = NameFactory.doNameObject(createBuffer) attributes.storeObjectToMessage( mainOrientHelperObj, self.msgTemplateRoot.get(), 'orientHelper') #store the object to it's respective object returnBuffer.append(mainOrientHelperObj) # Snapping position.movePointSnap(mainOrientHelperObj, root) constBuffer = mc.aimConstraint(objects[1], mainOrientHelperObj, maintainOffset=False, weight=1, aimVector=[1, 0, 0], upVector=[0, 1, 0], worldUpVector=worldUpVector, worldUpType='vector') mc.delete(constBuffer[0]) # Follow Groups mainOrientHelperGroupBuffer = rigging.groupMeObject(mainOrientHelperObj) mainOrientHelperGroupBuffer = NameFactory.doNameObject( mainOrientHelperGroupBuffer) mainOrientHelperGroup = rigging.doParentReturnName( mainOrientHelperGroupBuffer, root) mc.pointConstraint(objects[0], mainOrientHelperGroupBuffer, maintainOffset=False) helperObjectGroups.append(mainOrientHelperGroup) # set up constraints mc.aimConstraint(objects[-1], mainOrientHelperGroup, maintainOffset=True, weight=1, aimVector=[1, 0, 0], upVector=[0, 1, 0], worldUpObject=root, worldUpType='objectRotation') # lock and hide stuff attributes.doSetLockHideKeyableAttr( mainOrientHelperObj, True, False, False, ['tx', 'ty', 'tz', 'rz', 'ry', 'sx', 'sy', 'sz', 'v']) #>>> The sub helpers """ make our pair lists """ pairList = lists.parseListToPairs(objects) """ make our controls """ helperObjects = [] for pair in pairList: """ Get Size """ size = (distance.returnBoundingBoxSizeToAverage(pair[0]) * 2) """ make the curve""" createBuffer = curves.createControlCurve('circleArrow2Axis', size, 'y-') curves.setCurveColorByName(createBuffer, moduleColors[1]) """ copy the name attr""" attributes.copyUserAttrs(pair[0], createBuffer, ['cgmName']) attributes.storeInfo(createBuffer, 'cgmType', 'templateOrientObject') helperObj = NameFactory.doNameObject(createBuffer) """ store the object to it's respective object and to an object list """ attributes.storeObjectToMessage(helperObj, pair[0], 'orientHelper') helperObjects.append(helperObj) """ initial snapping """ position.movePointSnap(helperObj, pair[0]) constBuffer = mc.aimConstraint(pair[1], helperObj, maintainOffset=False, weight=1, aimVector=[1, 0, 0], upVector=[0, 1, 0], worldUpVector=worldUpVector, worldUpType='vector') mc.delete(constBuffer[0]) """ follow groups """ helperGroupBuffer = rigging.groupMeObject(helperObj) helperGroup = NameFactory.doNameObject(helperGroupBuffer) helperGroup = rigging.doParentReturnName(helperGroup, pair[0]) helperObjectGroups.append(helperGroup) """ set up constraints """ mc.aimConstraint(pair[1], helperGroup, maintainOffset=False, weight=1, aimVector=[1, 0, 0], upVector=[0, 1, 0], worldUpVector=[0, 1, 0], worldUpObject=mainOrientHelperObj, worldUpType='objectrotation') """ lock and hide stuff """ helperObj = attributes.returnMessageObject(pair[0], 'orientHelper') mc.connectAttr((visAttr), (helperObj + '.v')) attributes.doSetLockHideKeyableAttr( helperObj, True, False, False, ['tx', 'ty', 'tz', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']) #>>> For the last object in the chain for obj in objects[-1:]: """ Get Size """ size = (distance.returnBoundingBoxSizeToAverage(obj) * 2) """ make the curve""" createBuffer = curves.createControlCurve('circleArrow2Axis', size, 'y-') curves.setCurveColorByName(createBuffer, moduleColors[1]) """ copy the name attr""" attributes.copyUserAttrs(obj, createBuffer, ['cgmName']) attributes.storeInfo(createBuffer, 'cgmType', 'templateOrientObject') helperObj = NameFactory.doNameObject(createBuffer) """ store the object to it's respective object """ attributes.storeObjectToMessage(helperObj, obj, 'orientHelper') """ initial snapping """ position.movePointSnap(helperObj, obj) constBuffer = mc.aimConstraint(objects[-2], helperObj, maintainOffset=False, weight=1, aimVector=[1, 0, 0], upVector=[0, 1, 0], worldUpVector=worldUpVector, worldUpType='vector') mc.delete(constBuffer[0]) """ follow groups """ helperGroupBuffer = rigging.groupMeObject(helperObj) helperGroup = NameFactory.doNameObject(helperGroupBuffer) helperGroup = rigging.doParentReturnName(helperGroup, obj) helperObjectGroups.append(helperGroup) """ set up constraints """ secondToLastHelperObject = attributes.returnMessageObject( objects[-2], 'orientHelper') mc.orientConstraint(secondToLastHelperObject, helperGroup, maintainOffset=False, weight=1) """ lock and hide stuff """ helperObj = attributes.returnMessageObject(obj, 'orientHelper') mc.connectAttr((visAttr), (helperObj + '.v')) attributes.doSetLockHideKeyableAttr( helperObj, True, False, False, ['tx', 'ty', 'tz', 'sx', 'sy', 'sz', 'v']) helperObjects.append(helperObj) returnBuffer.append(helperObjects) returnBuffer.append(helperObjectGroups) return returnBuffer