示例#1
0
 def returnOverrideColors(self):
     """ 
     Generate core names for a module and return them
     
     RETURNS:
     generatedNames(list)
     """
     direction = False
     if self.ModuleNull.cgm['cgmDirection']:
         direction = dictionary.validateStringDirection(self.ModuleNull.cgm['cgmDirection'])
     
     if not direction:
         return modules.returnSettingsData('colorCenter',True)
     else:
         return modules.returnSettingsData(('color'+direction.capitalize()),True)    
示例#2
0
	def build(self):#================================================================================   	
		    
	    try:#>>>Get data
		orientation = self._go._jointOrientation or modules.returnSettingsData('jointOrientation')
		mi_moduleParent = False
		if self._go._mi_module.getMessage('moduleParent'):
		    mi_moduleParent = self._go._mi_module.moduleParent
		    
		mi_controlIK = self._go._i_rigNull.controlIK
		ml_controlsFK =  self._go._i_rigNull.msgList_get('controlsFK')    
		ml_rigJoints = self._go._i_rigNull.msgList_get('rigJoints')
		ml_blendJoints = self._go._i_rigNull.msgList_get('blendJoints')
		mi_settings = self._go._i_rigNull.settings
		
		log.info("mi_controlIK: %s"%mi_controlIK.getShortName())
		log.info("ml_controlsFK: %s"%[o.getShortName() for o in ml_controlsFK])
		log.info("mi_settings: %s"%mi_settings.getShortName())
		
		log.info("ml_rigJoints: %s"%[o.getShortName() for o in ml_rigJoints])
		log.info("ml_blendJoints: %s"%[o.getShortName() for o in ml_blendJoints])
		
		ml_segmentHandleChains = self._go._get_segmentHandleChains()
		ml_segmentChains = self._go._get_segmentChains()
		ml_influenceChains = self._go._get_influenceChains()	
		
		aimVector = dictionary.stringToVectorDict.get("%s+"%self._go._jointOrientation[0])
		upVector = dictionary.stringToVectorDict.get("%s+"%self._go._jointOrientation[1]) 
		
		#Build our contrain to pool
		l_constrainTargetJoints = []
		"""
		for ml_chain in ml_segmentChains:
		    l_constrainTargetJoints.extend([i_jnt.mNode for i_jnt in ml_chain[:-1]])
		l_constrainTargetJoints.extend([i_jnt.mNode for i_jnt in ml_blendJoints[-2:]])
		"""
		if not l_constrainTargetJoints:
		    l_constrainTargetJoints = [i_jnt.mNode for i_jnt in ml_blendJoints]
		    
		for i_jnt in ml_blendJoints:
		    attributes.doSetLockHideKeyableAttr(i_jnt.mNode,lock=True, visible=True, keyable=False)
		    i_jnt.radius = 0#This is how we can hide joints without hiding them since we have children we want to ride along
		    i_jnt.drawStyle = 2
		    
		for i_jnt in ml_controlsFK:
		    i_jnt.radius = 0#This is how we can hide joints without hiding them since we have children we want to ride along
		    i_jnt.drawStyle = 2		    
		    
		#Set group lockks
		for mCtrl in self._go._i_rigNull.msgList_get('controlsAll'):
		    try:mCtrl._setControlGroupLocks()	
		    except Exception,error:log.error("%s _setControlGroupLocks failed on object: %s"%(self._str_reportStart,mCtrl.p_nameShort))
	    	    
	    except Exception,error:
		log.error("finger.build_rig>> Gather data fail!")
		raise Exception,error
示例#3
0
    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
示例#4
0
    def verify(self):
        """ 
        Verifies the various components a masterNull for a character/asset. If a piece is missing it replaces it.
        
        RETURNS:
        success(bool)
        """
        #Puppet null
        try:
            if not mc.objExists(self.nameBase):
                buffer = mc.group(empty=True)
                self.PuppetNull = ObjectFactory(buffer)
            else:
                self.PuppetNull = ObjectFactory(self.nameBase)

            self.PuppetNull.store('cgmName', self.nameBase, True)
            self.PuppetNull.store('cgmType', 'ignore')
            self.PuppetNull.store('cgmModuleType', 'master')

            if self.PuppetNull.nameShort != self.nameBase:
                self.PuppetNull.doName(False)

            attributes.doSetLockHideKeyableAttr(self.PuppetNull.nameShort,
                                                channels=[
                                                    'tx', 'ty', 'tz', 'rx',
                                                    'ry', 'rz', 'sx', 'sy',
                                                    'sz'
                                                ])
        except:
            guiFactory.warning("Puppet null failed!")

        #Checks our modules container null
        created = False
        #Initialize message attr
        self.msgModulesGroup = AttrFactory(self.PuppetNull, 'modulesGroup',
                                           'message')
        if not self.msgModulesGroup.get():
            self.ModulesGroup = ObjectFactory(mc.group(empty=True))
            self.msgModulesGroup.doStore(self.ModulesGroup.nameShort)
            created = True
        else:
            self.ModulesGroup = ObjectFactory(self.msgModulesGroup.get())

        self.ModulesGroup.store('cgmName', 'modules')
        self.ModulesGroup.store('cgmType', 'group')

        self.ModulesGroup.doParent(self.PuppetNull.nameShort)

        if created:
            self.ModulesGroup.doName(False)

        self.msgModulesGroup.updateData()

        attributes.doSetLockHideKeyableAttr(self.ModulesGroup.nameShort)

        #Checks our noTransform container null
        created = False
        self.msgNoTransformGroup = AttrFactory(self.PuppetNull,
                                               'noTransformGroup', 'message')
        if not self.msgNoTransformGroup.get():
            self.NoTransformGroup = ObjectFactory(mc.group(empty=True))
            self.msgNoTransformGroup.doStore(self.NoTransformGroup.nameShort)
            created = True
        else:
            self.NoTransformGroup = ObjectFactory(
                self.msgNoTransformGroup.get())

        self.NoTransformGroup.store('cgmName', 'noTransform')
        self.NoTransformGroup.store('cgmType', 'group')

        self.NoTransformGroup.doParent(self.PuppetNull.nameShort)

        if created:
            self.NoTransformGroup.doName(False)

        self.msgNoTransformGroup.updateData()

        attributes.doSetLockHideKeyableAttr(self.NoTransformGroup.nameShort)

        #Checks our geo container null
        created = False
        self.msgGeoGroup = AttrFactory(self.PuppetNull, 'geoGroup', 'message')
        if not self.msgGeoGroup.get():
            self.GeoGroup = ObjectFactory(mc.group(empty=True))
            self.msgGeoGroup.doStore(self.GeoGroup.nameShort)
            created = True
        else:
            self.GeoGroup = ObjectFactory(self.msgGeoGroup.get())

        self.GeoGroup.store('cgmName', 'geo')
        self.GeoGroup.store('cgmType', 'group')

        self.GeoGroup.doParent(self.msgNoTransformGroup.get())

        if created:
            self.GeoGroup.doName(False)

        self.msgGeoGroup.updateData()

        attributes.doSetLockHideKeyableAttr(self.GeoGroup.nameShort)

        #Checks master info null
        created = False
        self.msgPuppetInfo = AttrFactory(self.PuppetNull, 'info', 'message')
        if not self.msgPuppetInfo.get():
            self.PuppetInfoNull = ObjectFactory(mc.group(empty=True))
            self.msgPuppetInfo.doStore(self.PuppetInfoNull.nameShort)
            created = True
        else:
            self.PuppetInfoNull = ObjectFactory(self.msgPuppetInfo.get())

        self.PuppetInfoNull.store('cgmName', 'master')
        self.PuppetInfoNull.store('cgmType', 'info')

        self.PuppetInfoNull.doParent(self.PuppetNull.nameShort)

        if created:
            self.PuppetInfoNull.doName(False)

        self.msgPuppetInfo.updateData()

        attributes.doSetLockHideKeyableAttr(self.PuppetInfoNull.nameShort)

        #Checks modules info null
        created = False
        self.msgModuleInfo = AttrFactory(self.msgPuppetInfo.get(), 'modules',
                                         'message')
        if not self.msgModuleInfo.get():
            self.ModuleInfoNull = ObjectFactory(mc.group(empty=True))
            self.msgModuleInfo.doStore(self.ModuleInfoNull.nameShort)
            created = True
        else:
            self.ModuleInfoNull = ObjectFactory(self.msgModuleInfo.get())

        self.ModuleInfoNull.store('cgmName', 'modules')
        self.ModuleInfoNull.store('cgmType', 'info')

        self.ModuleInfoNull.doParent(self.PuppetInfoNull.nameShort)

        if created:
            self.ModuleInfoNull.doName(False)

        self.msgModuleInfo.updateData()

        attributes.doSetLockHideKeyableAttr(self.ModuleInfoNull.nameShort)

        #Initialize our modules null as a buffer
        self.ModulesBuffer = BufferFactory(self.ModuleInfoNull.nameShort)

        #Checks geo info null
        created = False
        self.msgGeoInfo = AttrFactory(self.msgPuppetInfo.get(), 'geo',
                                      'message')
        if not self.msgGeoInfo.get():
            self.GeoInfoNull = ObjectFactory(mc.group(empty=True))
            self.msgGeoInfo.doStore(self.GeoInfoNull.nameShort)
            created = True
        else:
            self.GeoInfoNull = ObjectFactory(self.msgGeoInfo.get())

        self.GeoInfoNull.store('cgmName', 'geo')
        self.GeoInfoNull.store('cgmType', 'info')

        self.GeoInfoNull.doParent(self.msgPuppetInfo.get())

        if created:
            self.GeoInfoNull.doName(False)

        self.msgGeoInfo.updateData()

        attributes.doSetLockHideKeyableAttr(self.GeoInfoNull.nameShort)

        #Checks settings info null
        created = False
        self.msgSettingsInfo = AttrFactory(self.msgPuppetInfo.get(),
                                           'settings', 'message')
        if not self.msgSettingsInfo.get():
            self.SettingsInfoNull = ObjectFactory(mc.group(empty=True))
            self.msgSettingsInfo.doStore(self.SettingsInfoNull.nameShort)
            created = True
        else:
            self.SettingsInfoNull = ObjectFactory(self.msgSettingsInfo.get())

        self.SettingsInfoNull.store('cgmName', 'settings')
        self.SettingsInfoNull.store('cgmType', 'info')
        defaultFont = modules.returnSettingsData('defaultTextFont')
        self.SettingsInfoNull.store('font', defaultFont)

        self.SettingsInfoNull.doParent(self.msgPuppetInfo.get())

        if created:
            self.SettingsInfoNull.doName(False)

        self.msgSettingsInfo.updateData()

        self.optionPuppetMode = AttrFactory(self.SettingsInfoNull,
                                            'optionPuppetTemplateMode',
                                            'int',
                                            initialValue=0)

        self.optionAimAxis = AttrFactory(self.SettingsInfoNull,
                                         'axisAim',
                                         'enum',
                                         enum='x+:y+:z+:x-:y-:z-',
                                         initialValue=2)
        self.optionUpAxis = AttrFactory(self.SettingsInfoNull,
                                        'axisUp',
                                        'enum',
                                        enum='x+:y+:z+:x-:y-:z-',
                                        initialValue=1)
        self.optionOutAxis = AttrFactory(self.SettingsInfoNull,
                                         'axisOut',
                                         'enum',
                                         enum='x+:y+:z+:x-:y-:z-',
                                         initialValue=0)

        attributes.doSetLockHideKeyableAttr(self.SettingsInfoNull.nameShort)

        return True
示例#5
0
def rigSpine(moduleNull):
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>>Get our info
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    partName = NameFactory.returnUniqueGeneratedName(moduleNull,
                                                     ignore='cgmType')
    """ template null """
    templateNull = modules.returnTemplateNull(moduleNull)
    templateNullData = attributes.returnUserAttrsToDict(templateNull)
    jointOrientation = modules.returnSettingsData('jointOrientation')
    templateRoot = modules.returnInfoNullObjects(moduleNull,
                                                 'templatePosObjects',
                                                 types='templateRoot')
    """ AutonameStuff """
    divider = NameFactory.returnCGMDivider()
    """ control helper objects """
    controlTemplateObjects = modules.returnInfoNullObjects(
        moduleNull, 'templateControlObjects', types='all')
    controlTemplateObjects = distance.returnDistanceSortedList(
        templateRoot, controlTemplateObjects)

    print 'controlTemplateObjects...'
    print controlTemplateObjects
    """size list of template control objects """
    controlTemplateObjectsSizes = []
    for obj in controlTemplateObjects:
        controlTemplateObjectsSizes.append(
            distance.returnAbsoluteSizeCurve(obj))
    print 'sizes...'
    print controlTemplateObjectsSizes
    """ Skin Joints """
    skinJoints = modules.returnInfoNullObjects(moduleNull,
                                               'skinJoints',
                                               types='all')
    skinJoints = distance.returnDistanceSortedList(templateRoot, skinJoints)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Make Controls
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ control options """
    fk = templateNullData.get('fk')
    ik = templateNullData.get('ik')
    stretch = templateNullData.get('stretch')
    bend = templateNullData.get('bend')
    """controls to make """
    controlsToMake = []
    controlsToMake.append('cog')

    if fk == True:
        controlsToMake.append('segmentControls')
        controlsToMake.append('hips')

    if ik == True:
        controlsToMake.append('vectorHandles')
        controlsToMake.append('spineIKHandle')

    controlsDict = modules.limbControlMaker(moduleNull, controlsToMake)

    print controlsDict
    #>>> Organize em
    segmentControls = controlsDict.get('segmentControls')
    spineIKHandle = controlsDict.get('spineIKHandle')
    cog = controlsDict.get('cog')
    hips = controlsDict.get('hips')
    vectorHandles = controlsDict.get('vectorHandles')

    for handle in vectorHandles[-1:]:
        mc.delete(handle)
        vectorHandles.remove(handle)

    #>>> Parent em
    rigging.parentListToHeirarchy(segmentControls)
    mc.parent(spineIKHandle, segmentControls[-1])
    mc.parent(segmentControls[0], cog)
    mc.parent(hips, cog)

    for obj in segmentControls:
        rigging.zeroTransformMeObject(obj)
        mc.makeIdentity(obj, apply=True, translate=True)

    for obj in vectorHandles:
        mc.makeIdentity(obj, apply=True, translate=True)
    """ hips anchor locator """
    locBuffer = locators.locMeObject(hips)
    attributes.storeInfo(locBuffer, 'cgmName', hips)
    attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor')
    hipsAnchor = NameFactory.doNameObject(locBuffer)

    mc.setAttr((hipsAnchor + '.rotateOrder'), 5)

    pointConstraintBuffer = mc.pointConstraint(hips,
                                               hipsAnchor,
                                               maintainOffset=False,
                                               weight=1)
    orientConstraintBuffer = mc.orientConstraint(hips,
                                                 hipsAnchor,
                                                 maintainOffset=False,
                                                 skip=['x', 'y'],
                                                 weight=1)
    """ hips anchor group constraint """
    groupBuffer = rigging.groupMeObject(hipsAnchor)
    attributes.storeInfo(groupBuffer, 'cgmName', hipsAnchor)
    attributes.storeInfo(groupBuffer, 'cgmTypeModifier', 'orient')
    hipsAnchorOrGroup = NameFactory.doNameObject(groupBuffer)
    orientConstraintBuffer = mc.orientConstraint(segmentControls[0],
                                                 hipsAnchorOrGroup,
                                                 maintainOffset=False,
                                                 weight=1)
    """ end anchor locator """
    locBuffer = locators.locMeObject(segmentControls[-1])
    attributes.storeInfo(locBuffer, 'cgmName', segmentControls[-1])
    attributes.storeInfo(locBuffer, 'cgmTypeModifier', 'anchor')
    endAnchor = NameFactory.doNameObject(locBuffer)

    mc.setAttr((endAnchor + '.rotateOrder'), 5)

    mc.parent(endAnchor, spineIKHandle)

    #>>> set up follow chains
    constraintChain = []
    constraintChain.append(hipsAnchor)
    constraintChain = constraintChain + vectorHandles
    constraintChain.append(endAnchor)

    constraintChainReturn = constraints.doSegmentAimPointConstraint(
        constraintChain)
    print constraintChainReturn
    vectorHandlesZeroGroups = []
    for obj in vectorHandles:
        vectorHandlesZeroGroups.append(rigging.zeroTransformMeObject(obj))
    """ parent the last group to our IK handle """
    #mc.parent(vectorHandlesZeroGroups[-1],spineIKHandle)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Joint Chains
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ surface chain """
    dupJointsBuffer = mc.duplicate(skinJoints[:-1], po=True, rc=True)
    surfaceJoints = []
    for joint in dupJointsBuffer:
        attributes.storeInfo(joint, 'cgmType', 'surfaceJoint')
        surfaceJoints.append(NameFactory.doNameObject(joint))
    """ firm start """
    startJointsBuffer = mc.duplicate(skinJoints[0], po=True, rc=True)
    startJoints = []
    for joint in startJointsBuffer:
        attributes.storeInfo(joint, 'cgmType', 'deformationJoint')
        startJoints.append(NameFactory.doNameObject(joint))
    """ firm end """
    endJointsBuffer = mc.duplicate(skinJoints[-2:], po=True, rc=True)
    endJoints = []
    for joint in endJointsBuffer:
        attributes.storeInfo(joint, 'cgmType', 'deformationJoint')
        endJoints.append(NameFactory.doNameObject(joint))
    mc.parent(endJoints[0], world=True)

    #>>> Influence chain
    """
    get the root joints from our main chain searching by "cgmName" tags...maybe not the best way
    Maybe should change to search to closest joints
    """
    influenceJointsBuffer = []
    for obj in surfaceJoints:
        if (search.returnTagInfo(obj, 'cgmName')) != False:
            influenceJointsBuffer.append(obj)
    """ make our influence joints """
    influenceJoints = []
    for joint in influenceJointsBuffer:
        buffer = mc.duplicate(joint, po=True)
        closestObject = distance.returnClosestObject(buffer[0], surfaceJoints)
        attributes.storeInfo(buffer[0], 'cgmName', closestObject)
        attributes.storeInfo(buffer[0], 'cgmType', 'influenceJoint')
        rigging.doParentToWorld(buffer[0])
        influenceJoints.append(NameFactory.doNameObject(buffer[0]))

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Put our deformation joints in the rig
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    ############### need better way of doing this for iterative
    mc.parent(endJoints[0], spineIKHandle)
    mc.parent(startJoints[0], hips)
    mc.parent(influenceJoints[0], hipsAnchor)
    mc.parent(influenceJoints[1], vectorHandles[0])
    mc.parent(influenceJoints[2], spineIKHandle)
    #mc.parent(influenceJoints[3],spineIKHandle)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Control Surface
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ create """
    orientationBuffer = list(jointOrientation)
    outChannel = orientationBuffer[2]
    upChannel = (orientationBuffer[1] + 'up')
    print upChannel

    surfaceBuffer = joints.loftSurfaceFromJointList(surfaceJoints, outChannel)
    controlSurface = surfaceBuffer[0]
    attributes.copyUserAttrs(moduleNull,
                             controlSurface,
                             attrsToCopy=['cgmName'])
    attributes.storeInfo(controlSurface, 'cgmType', 'controlSurface', True)
    controlSurface = NameFactory.doNameObject(controlSurface)
    """ connect joints to surface"""
    surfaceConnectReturn = joints.attachJointChainToSurface(
        surfaceJoints, controlSurface, jointOrientation, upChannel, 'animCrv')
    print surfaceConnectReturn
    """ surface influence joints skinning"""
    surfaceSkinCluster = mc.skinCluster(influenceJoints,
                                        controlSurface,
                                        tsb=True,
                                        n=(controlSurface + '_skinCluster'),
                                        maximumInfluences=3,
                                        normalizeWeights=1,
                                        dropoffRate=1)
    #surfaceSkinCluster = mc.skinCluster (influenceJoints,controlSurface,tsb=True, n=(controlSurface+'_skinCluster'),maximumInfluences = 3, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1)
    controlSurfaceSkinCluster = surfaceSkinCluster[0]
    """ smooth skin weights """
    skinning.simpleControlSurfaceSmoothWeights(controlSurface)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Connect skin joints to surface joints
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    deformationJoints = []
    deformationJoints.append(startJoints[0])
    deformationJoints = deformationJoints + surfaceJoints[1:-2]
    deformationJoints = deformationJoints + endJoints
    for joint in skinJoints:
        attachJoint = distance.returnClosestObject(joint, deformationJoints)
        pntConstBuffer = mc.pointConstraint(attachJoint,
                                            joint,
                                            maintainOffset=False,
                                            weight=1)
        orConstBuffer = mc.orientConstraint(attachJoint,
                                            joint,
                                            maintainOffset=False,
                                            weight=1)
        #mc.connectAttr((attachJoint+'.t'),(joint+'.t'))
        #mc.connectAttr((attachJoint+'.r'),(joint+'.r'))
        mc.connectAttr((attachJoint + '.s'), (joint + '.s'))
        pntConstBuffer = mc.pointConstraint(attachJoint,
                                            joint,
                                            maintainOffset=False,
                                            weight=1)
        orConstBuffer = mc.orientConstraint(attachJoint,
                                            joint,
                                            maintainOffset=False,
                                            weight=1)
示例#6
0
def skeletonize(moduleNull, stiffIndex=0):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Basic limb skeletonizer
    
    ARGUMENTS:
    moduleNull(string)
    stiffIndex(int) - the index of the template objects you want to not have roll joints
                      For example, a value of -1 will let the chest portion of a spine 
                      segment be solid instead of having a roll segment. Default is '0'
                      which will put roll joints in every segment
    
    RETURNS:
    limbJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>>Get our info
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    partName = NameFactory.returnUniqueGeneratedName(moduleNull,
                                                     ignore='cgmType')
    """ template null """
    templateNull = modules.returnTemplateNull(moduleNull)
    templateNullData = attributes.returnUserAttrsToDict(templateNull)
    """ template object nulls """
    templatePosObjectsInfoNull = modules.returnInfoTypeNull(
        moduleNull, 'templatePosObjects')
    templateControlObjectsNull = modules.returnInfoTypeNull(
        moduleNull, 'templateControlObjects')
    templatePosObjectsInfoData = attributes.returnUserAttrsToDict(
        templatePosObjectsInfoNull)
    templateControlObjectsData = attributes.returnUserAttrsToDict(
        templateControlObjectsNull)

    jointOrientation = modules.returnSettingsData('jointOrientation')
    moduleRootBuffer = modules.returnInfoNullObjects(moduleNull,
                                                     'templatePosObjects',
                                                     types='templateRoot')
    moduleRoot = moduleRootBuffer[0]
    stiffIndex = templateNullData.get('stiffIndex')
    rollJoints = templateNullData.get('rollJoints')
    """ AutonameStuff """
    divider = NameFactory.returnCGMDivider()
    skinJointsNull = modules.returnInfoTypeNull(moduleNull, 'skinJoints')

    templateObjects = []
    coreNamesArray = []

    #>>>TemplateInfo
    for key in templatePosObjectsInfoData.keys():
        if (mc.attributeQuery(key, node=templatePosObjectsInfoNull,
                              msg=True)) == True:
            templateObjects.append(templatePosObjectsInfoData[key])
        coreNamesArray.append(key)

    posTemplateObjects = []
    """ Get the positional template objects"""
    for obj in templateObjects:
        bufferList = obj.split(divider)
        if (typesDictionary.get('templateObject')) in bufferList:
            posTemplateObjects.append(obj + divider +
                                      typesDictionary.get('locator'))
    """put objects in order of closeness to root"""
    posTemplateObjects = distance.returnDistanceSortedList(
        moduleRoot, posTemplateObjects)
    curve = (templatePosObjectsInfoData['curve'])

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Actually making the skeleton with consideration for roll joints and the stiffIndex!
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    if stiffIndex == 0:
        """ If no roll joints """
        limbJoints = joints.createJointsFromCurve(curve, partName, rollJoints)
    else:
        rolledJoints = joints.createJointsFromCurve(curve, partName,
                                                    rollJoints)
        if rollJoints == 0:
            limbJoints = rolledJoints
        else:
            if stiffIndex < 0:
                """ Get our to delete number in a rolledJoints[-4:] format"""
                #searchIndex = (int('%s%s' %('-',(rollJoints+1)))*abs(stiffIndex)-1)
                searchIndex = (int('%s%s' % ('-', (rollJoints + 1))) *
                               abs(stiffIndex))
                toDelete = rolledJoints[searchIndex:]
                """ delete out the roll joints we don't want"""
                mc.delete(toDelete[0])
                for name in toDelete:
                    rolledJoints.remove(name)
                """ make our stiff joints """
                jointPositions = []
                if abs(stiffIndex) == 1:
                    jointPositions.append(
                        distance.returnClosestUPosition(
                            posTemplateObjects[stiffIndex], curve))
                else:
                    for obj in posTemplateObjects[stiffIndex:]:
                        jointPositions.append(
                            distance.returnClosestUPosition(obj, curve))

                stiffJoints = joints.createJointsFromPosListName(
                    jointPositions, 'partName')
                """ connect em up """
                mc.parent(stiffJoints[0], rolledJoints[-1])
                limbJoints = []
                for joint in rolledJoints:
                    limbJoints.append(joint)
                for joint in stiffJoints:
                    limbJoints.append(joint)

            else:
                """ if it's not negative, it's positive...."""
                searchIndex = ((rollJoints + 1) * abs(stiffIndex))
                toDelete = rolledJoints[:searchIndex]
                toKeep = rolledJoints[searchIndex:]
                """ delete out the roll joints we don't want"""
                mc.parent(toKeep[0], world=True)
                mc.delete(toDelete[0])
                for name in toDelete:
                    rolledJoints.remove(name)
                """ make our stiff joints """
                jointPositions = []
                if abs(stiffIndex) == 1:
                    jointPositions.append(
                        distance.returnClosestUPosition(
                            posTemplateObjects[stiffIndex - 1], curve))
                else:
                    for obj in posTemplateObjects[:stiffIndex]:
                        jointPositions.append(
                            distance.returnClosestUPosition(obj, curve))

                stiffJoints = joints.createJointsFromPosListName(
                    jointPositions, 'partName')
                """ connect em up """
                mc.parent(rolledJoints[0], stiffJoints[-1])
                limbJoints = []
                for joint in stiffJoints:
                    limbJoints.append(joint)
                for joint in rolledJoints:
                    limbJoints.append(joint)

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Naming
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ 
    Copy naming information from template objects to the joints closest to them
    copy over a cgmNameModifier tag from the module first
    """
    attributes.copyUserAttrs(moduleNull,
                             limbJoints[0],
                             attrsToCopy=['cgmNameModifier'])
    """
    First we need to find our matches
    """
    for obj in posTemplateObjects:
        closestJoint = distance.returnClosestObject(obj, limbJoints)
        transferObj = attributes.returnMessageObject(obj, 'cgmName')
        """Then we copy it"""
        attributes.copyUserAttrs(
            transferObj,
            closestJoint,
            attrsToCopy=['cgmNameModifier', 'cgmDirection', 'cgmName'])

    limbJointsBuffer = NameFactory.doRenameHeir(limbJoints[0])
    limbJoints = []
    limbJoints.append(limbJointsBuffer[0])
    for joint in limbJointsBuffer[1]:
        limbJoints.append(joint)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Orientation
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    limbJoints = orientSegment(limbJoints, posTemplateObjects,
                               jointOrientation)

    #>>> Set its radius and toggle axis visbility on
    #averageDistance = distance.returnAverageDistanceBetweenObjects (limbJoints)
    jointSize = (
        distance.returnDistanceBetweenObjects(limbJoints[0], limbJoints[-1]) /
        6)
    for jnt in limbJoints:
        mc.setAttr((jnt + '.radi'), jointSize * .2)
        #>>>>>>> TEMP
        joints.toggleJntLocalAxisDisplay(jnt)

    print 'to orientation'
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    #>>> Storing data
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    skinJointsNull = modules.returnInfoTypeNull(moduleNull, 'skinJoints')
    skinJointsNullData = attributes.returnUserAttrsToList(skinJointsNull)
    existingSkinJoints = lists.removeMatchedIndexEntries(
        skinJointsNullData, 'cgm')
    print existingSkinJoints
    if len(existingSkinJoints) > 0:
        for entry in existingSkinJoints:
            attrBuffer = (skinJointsNull + '.' + entry[0])
            print attrBuffer
            attributes.doDeleteAttr(skinJointsNull, entry[0])

    for i in range(len(limbJoints)):
        buffer = ('%s%s' % ('joint_', i))
        attributes.storeInfo(skinJointsNull, buffer, limbJoints[i])

    return limbJoints
示例#7
0
def getSettingsColors(arg=None):
    try:
        return modules.returnSettingsData(('color' + arg.capitalize()), True)
    except:
        return modules.returnSettingsData('colorCenter', True)
示例#8
0
def getSettingsColors(arg=None):
    try:
        return modules.returnSettingsData(("color" + arg.capitalize()), True)
    except:
        return modules.returnSettingsData("colorCenter", True)