def ObjectFacesToFolicles():
    try:
        import parentConstraintToSurface
    except:
        "Can't find parentConstraintToSurface"

    selection = mc.ls(sl=True) or []
    if not selection:
        return "Nothing selected"

    #If we're going, create a return set
    returnSet = SetFactory.SetFactory('folicledLocs', 'td', True)

    # Make some groups
    mLocGroup = mc.group(em=True, name='locators_grp')

    number = len(selection)
    returnList = []
    for i, o in enumerate(selection):
        guiFactory.report("On %s. %s of %s" % (o, i, number))
        faceBuffer = "%s.f[4]" % o
        if not mc.objExists(faceBuffer):
            print "'%s' has no face!" % o

        loc = locators.locMeObject(faceBuffer)
        returnSet.store(loc)
        mc.select(cl=True)
        mc.select(loc, o)
        parentConstraintToSurface.parentConstraintToSurface()

        rigging.doParentReturnName(loc, mLocGroup)

    follicles = mc.ls(type='follicle')
    mc.select(follicles)
    mc.group(name='folicles_grp')
Example #2
0
    def doParent(self,p = False):
        """
        Function for parenting a maya instanced object while maintaining a correct object instance.

        Keyword arguments:
        p(string) -- Whether to run a full scene dictionary check or the faster just objExists check

        """ 
        assert self.transform,"'%s' has no transform"%obj	
        
        if p: #if we have a target parent
            try:
                #If we have an Object Factory instance, link it
                p.nameShort
                p = p.nameShort
            except:
                #If it fails, check that the object name exists and if so, initialize a new Object Factory instance
                assert mc.objExists(p) is True, "'%s' - parent object doesn't exist" %p     

            buffer = rigging.doParentReturnName(self.nameLong,p)
            
        else:#If not, do so to world
            buffer = rigging.doParentToWorld(self.nameLong)
            
        self.update(buffer)
Example #3
0
    def addGeo(self):
        """ 
        Add geo to a puppet
        """
        assert self.msgGeoGroup.get() is not False, "No geo group found!"

        selection = mc.ls(sl=True, flatten=True, long=True) or []

        if not selection:
            guiFactory.warning("No selection found to add to '%s'" %
                               self.nameBase)

        returnList = []
        for o in selection:
            if search.returnObjectType(o) in geoTypes:
                if self.msgGeoGroup.get() not in search.returnAllParents(
                        o, True):
                    o = rigging.doParentReturnName(o, self.msgGeoGroup.get())
                    self.geo.append(o)
                else:
                    guiFactory.warning("'%s' already a part of '%s'" %
                                       (o, self.nameBase))
            else:
                guiFactory.warning(
                    "'%s' doesn't seem to be geo. Not added to '%s'" %
                    (o, self.nameBase))
Example #4
0
    def addModule(self, module, *a, **kw):
        """
        Adds a module to a puppet
        
        module(string)
        """
        if module in self.ModulesBuffer.bufferList:
            return guiFactory.warning("'%s' already connnected to '%s'" %
                                      (module, self.nameBase))

        elif mc.objExists(module):
            # If it exists, check type to initialize and add
            modType = search.returnTagInfo(module, 'moduleType') or False
            if modType in moduleTypeToFunctionDict.keys():
                self.ModulesBuffer.store(module)
                moduleNullBuffer = rigging.doParentReturnName(
                    module, self.msgModulesGroup.get())
                self.Module[self.ModulesBuffer.bufferList.index(
                    module)] = moduleTypeToFunctionDict[modType](
                        moduleNullBuffer)

            else:
                guiFactory.warning(
                    "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize"
                )

        else:
            guiFactory.warning(
                "'%s' is not a module type found in the moduleTypeToFunctionDict. Cannot initialize"
                % module)
    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')
            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')
            #joints.orientJoint(j,'xyz','yup')
            joints.orientJoint(j, 'zyx', '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
Example #6
0
    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')
	    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') 
	    #joints.orientJoint(j,'xyz','yup')
	    joints.orientJoint(j,'zyx','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
Example #7
0
 def _fncStep_parenting_(self):
     """
     """
     _mi_headMasterAnim = self.md_objs['headMasterAnim']
     _mi_bodyMasterAnim = self.md_objs['BodyPuppet'].masterControl
     _mi_bodyPuppet = self.md_objs['BodyPuppet']
     _mi_headPuppet = self.md_objs['headPuppet']
     
     try:#Geo --------------------------------------------------------------------
         for mObj in _mi_headPuppet.masterNull.geoGroup.getChildren(asMeta = True):
             mObj.parent = _mi_bodyPuppet.masterNull.geoGroup
     except Exception,error:raise Exception,"Geo | error: {0}".format(error)    
     
     try:#Face Rig/gui --------------------------------------------------------------------
         for k in ['faceGui','faceCam']:
             rigging.doParentReturnName(self.md_objs[k].mNode, _mi_bodyPuppet.masterNull.noTransformGroup.mNode)
     except Exception,error:raise Exception,"Face Rig/GUI | error: {0}".format(error)              
     
     try:#to Master control --------------------------------------------------------------------
         for k in ['world_eyeLook','world_leftEye','world_rightEye','SDKface','SDKcustomize']:
             rigging.doParentReturnName(self.md_objs[k].mNode, _mi_bodyMasterAnim.mNode)
     except Exception,error:raise Exception,"...to master Control | error: {0}".format(error)         
     
     try:#Skeleton --------------------------------------------------------------------
         rigging.doParentReturnName(self.md_objs['joint_faceRigHead'].mNode, self.md_objs['joint_bodyHead'].mNode)
     except Exception,error:raise Exception,"...to master Control | error: {0}".format(error)  
     
     try:#Object Sets --------------------------------------------------------------------
         _mi_bodyPuppet = self.md_objs['BodyPuppet']
         
         for k in ['l_eyeModule','r_eyeModule','headModule']:
             _mi_bodyPuppet.puppetSet.addObj(self.md_objs[k].rigNull.moduleSet.mNode)
         
     except Exception,error:raise Exception,"...to master Control | error: {0}".format(error)   
Example #8
0
def skeletonizeCharacter(masterNull):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Skeletonizes a character
    
    ARGUMENTS:
    masterNull(string)
    
    RETURNS:
    nothin
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    modules = modules.returnModules(masterNull)
    orderedModules = modules.returnOrderedModules(modules)
    #>>> Do the spine first
    stateCheck = modules.moduleStateCheck(orderedModules[0], ['template'])
    if stateCheck == 1:
        spineJoints = skeletonize(orderedModules[0])
    else:
        print('%s%s' %
              (module, ' has already been skeletonized. Moving on...'))

    #>>> Do the rest
    for module in orderedModules[1:]:
        stateCheck = modules.moduleStateCheck(module, ['template'])
        if stateCheck == 1:
            templateNull = modules.returnTemplateNull(module)
            root = modules.returnInfoNullObjects(module,
                                                 'templatePosObjects',
                                                 types='templateRoot')

            #>>> See if our item has a non default anchor
            anchored = storeTemplateRootParent(module)
            if anchored == True:
                anchor = attributes.returnMessageObject(
                    root[0], 'skeletonParent')
                closestJoint = distance.returnClosestObject(
                    anchor, spineJoints)
            else:
                closestJoint = distance.returnClosestObject(
                    root[0], spineJoints)

            limbJoints = skeletonize(module)
            rootName = rigging.doParentReturnName(limbJoints[0], closestJoint)
            print rootName
        else:
            print('%s%s' %
                  (module, ' has already been skeletonized. Moving on...'))
Example #9
0
def ObjectFacesToFolicles():
    try:
	import parentConstraintToSurface
    except:
	"Can't find parentConstraintToSurface"
	
    selection = mc.ls(sl=True) or []
    if not selection:
	return "Nothing selected"
    
    #If we're going, create a return set
    returnSet = SetFactory.SetFactory('folicledLocs','td',True)
    
    # Make some groups
    mLocGroup = mc.group(em=True,name = 'locators_grp')   
    
    number = len(selection)
    returnList = []
    for i,o in enumerate(selection):
	guiFactory.report("On %s. %s of %s"%(o,i,number))
	faceBuffer = "%s.f[4]"%o
	if not mc.objExists(faceBuffer):
	    print "'%s' has no face!"%o
	    
	loc = locators.locMeObject(faceBuffer)
	returnSet.store(loc)	
	mc.select(cl=True)
	mc.select(loc,o)
	parentConstraintToSurface.parentConstraintToSurface()
	
	rigging.doParentReturnName(loc,mLocGroup)
	
    
    follicles = mc.ls(type='follicle')
    mc.select(follicles)
    mc.group(name = 'folicles_grp')
Example #10
0
def returnAbsoluteSizeCurve(curve):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass an curve into it and it returns absolute distance scale

    ARGUMENTS:
    curve(string) - curve

    RETURNS:
    distances(list) - [xLength,yLength,zLength]
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    def duplicateShape(shape):
        parentObj = mc.listRelatives(shape, p=True, fullPath=True)
        shapes = mc.listRelatives(parentObj, shapes=True, fullPath=True)
        matchObjName = mc.ls(shape, long=True)
        matchIndex = shapes.index(matchObjName[0])

        dupBuffer = mc.duplicate(parentObj)
        children = mc.listRelatives(dupBuffer[0], children = True, fullPath =True)
        if len(children) > 0:
            for c in children:
                if search.returnObjectType(c) != 'shape':
                    mc.delete(c)

        dupShapes = mc.listRelatives(dupBuffer[0], shapes=True, fullPath=True)
        for shape in dupShapes:
            if dupShapes.index(shape) != matchIndex:
                mc.delete(shape)
                return dupBuffer[0]


    boundingBoxSize = returnBoundingBoxSize(curve)
    if mayaVersion <=2010:
        return boundingBoxSize
    else:
        distanceToMove = max(boundingBoxSize)
        positions = []
        isShape = False
        if search.returnObjectType(curve) == 'shape':
            dupCurve = duplicateShape(curve)
            curve = dupCurve
            isShape = True

        loc = rigging.locMeObjectStandAlone(curve)
        locGroup = rigging.groupMeObject(loc,False)
        loc = rigging.doParentReturnName(loc,locGroup)
        directions = ['x','y','z']
        for direction in directions:
            positionsBuffer = []
            mc.setAttr((loc+'.t'+direction),distanceToMove)
            positionsBuffer.append(returnClosestUPosition(loc,curve))
            mc.setAttr((loc+'.t'+direction),-distanceToMove)
            positionsBuffer.append(returnClosestUPosition(loc,curve))
            mc.setAttr((loc+'.t'+direction),0)
            positions.append(positionsBuffer)

        distances = []
        for set in positions:
            distances.append(returnDistanceBetweenPoints(set[0],set[1]))

        if isShape == True:
            mc.delete(dupCurve)

        mc.delete(locGroup)
        return distances
Example #11
0
def bakeBlendShapeNode(sourceObject, blendShapeNode, baseNameToUse = False, stripPrefix = False, ignoreInbetweens = False, ignoreTargets = False):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Function for exporting an object's blendshapes

    ARGUMENTS:
    targetObject(string)
    sourceObject(string)
    blendShapeNode(string) the node to bake from
    baseName(bool/string) - if it's False, it uses the target Object name, else, it uses what is supplied
    stripPrefix(bool) - whether to strip the first '_' segment
    ignoreInbetweens(bool)
    ignoreTargets(list) - targets to ignore in the processing

    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Prep
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ declare variables """
    returnList = []
    blendShapeNamesBaked = []
    blendShapeConnections = []
    currentConnections = []

    """ base name """
    if baseNameToUse == False:
        baseName = ''
    else:
        baseName = baseNameToUse + '_'


    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Meat of it
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    targetDict = returnBlendShapeTargetsAndWeights(sourceObject,blendShapeNode)
    targetSets = []
    blendShapeNodeChannels = []

    for key in targetDict.keys():
        targetSetBuffer = targetDict.get(key)
        targetSets.append(targetSetBuffer)

        baseSet = targetSetBuffer[-1]
        blendShapeNodeChannels.append(baseSet[0])

    blendShapeShortNames = []

    """ first loop gets connections, breaks them and sets everything to 0 """
    for shape in blendShapeNodeChannels:
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        """ get the connection """
        blendShapeConnections.append(attributes.returnDriverAttribute(blendShapeBuffer))
        print blendShapeConnections
        """break it """
        attributes.doBreakConnection(blendShapeBuffer)
        attributes.doSetAttr(blendShapeBuffer,0)


    # Bake it
    bakedGeo = bakeBlendShapes(sourceObject, sourceObject, blendShapeNode, baseNameToUse, stripPrefix, ignoreInbetweens, ignoreTargets)


    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Finish out
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ restore connections """
    for shape in blendShapeNodeChannels:
        currentIndex = blendShapeNodeChannels.index(shape)
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        """ Restore the connection """
        if blendShapeConnections[currentIndex] != False:
            attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer)

    """ group for geo """
    meshGroup = mc.group( em=True)
    if baseNameToUse != False:
        attributes.storeInfo(meshGroup,'cgmName', baseNameToUse)
    attributes.storeInfo(meshGroup,'cgmTypeModifier', 'blendShapeGeo')
    meshGroup = NameFactory.doNameObject(meshGroup)

    for geo in bakedGeo:
        rigging.doParentReturnName(geo,meshGroup)

    returnList.append(meshGroup)
    returnList.append(bakedGeo)

    return returnList
Example #12
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
Example #13
0
        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	
Example #14
0
 def doCreateStartingPositionLoc(self, modeType='child', workingObject=None, aimingObject=None, cvIndex = None ):
     """ 
     >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     DESCRIPTION:
     Adds a locator setup to duplicate to get our initial position locators. All should be zeroed out.
     The top node of the return group has the loctor and move group connected is message nodes if needed.
     
     ARGUMENTS:
     modeType(string)
         child - basic child locator to the workingObject
         innerChild - aims locator from the working to the aiming curves
         cvBack - works off working curves cvIndex. Places it and aiming
                     it back on z. Mainly used for tails
         radialOut - Works off working curve cv for position and radial 
                     orientation. It's transform group is oriented to 
                     the aiming curves equivalent cv. Good for arms
         radialDown - same as radial out but locator orientation is y down zup for legs.
                     transform orientation is the same as radial out
         footBase - looking for it's module Parent's last loc to start from
         parentDuplicate - looking for it's module Parent's last loc to start from
         
     workingObject(string) - usually the sizing objects start curve (can be a locator for parentchild loc)
     aimingObject(string) - usually the sizing objects end curve
     cvIndex(int) - cv to work off of
     
     RETURNS:
     returnList(list) = [rootHelper(string),helperObjects(list),helperObjectGroups(list)]
     >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     """
     
     if modeType == 'child':
         """ make initial loc and orient it """
         returnLoc = []
         curveShapes = mc.listRelatives(workingObject, shapes = True)
         startLoc = locators.locMeObject(workingObject)
         aimLoc = locators.locMeObject(workingObject)
         upLoc = locators.locMeCvFromCvIndex(curveShapes[0],0)
         
         startLoc = mc.rename(startLoc,(self.ModuleNull.nameBase+'child_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         sizeObjectLength = distance.returnDistanceBetweenObjects(workingObject,aimingObject)
         mc.xform(aimLoc,t=[0,0,sizeObjectLength],r=True,os=True)
         aimConstraintBuffer = mc.aimConstraint(aimLoc,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )
         mc.delete(aimConstraintBuffer[0])
         mc.delete(upLoc)
         mc.delete(aimLoc)
         
         zeroGroup = StartLoc.doGroup()
         returnLoc.append(StartLoc.nameLong)
         
         attributes.storeInfo(zeroGroup,'locator',startLoc)
         returnLoc.append(zeroGroup)
         
         return returnLoc
         
     elif modeType == 'innerChild':       
         """ make initial lock and orient it """
         returnLoc = []
         curveShapes = mc.listRelatives(workingObject, shapes = True)
         startLoc = locators.locMeObject(workingObject)
         aimLoc = locators.locMeObject(aimingObject)
         upLoc = locators.locMeCvFromCvIndex(curveShapes[0],0)
         startLoc = mc.rename(startLoc, (self.ModuleNull.nameBase+'_innerChild_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         aimConstraintBuffer = mc.aimConstraint(aimLoc,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )
         mc.delete(aimConstraintBuffer[0])
         mc.delete(upLoc)
         mc.delete(aimLoc)
         
         zeroGroup = StartLoc.doGroup()  
         returnLoc.append(StartLoc.nameLong)
         
         #zeroGroup = rigging.zeroTransformMeObject(startLoc)
         #attributes.storeInfo(zeroGroup,'locator',startLoc)
         returnLoc.append(zeroGroup)
         
         return returnLoc
         
     elif  modeType == 'cvBack':
         returnLoc = []
         curveShapes = mc.listRelatives(workingObject, shapes = True)
         startLoc = locators.locMeCvFromCvIndex(curveShapes[0],cvIndex)
         upLoc = locators.locMeObject(workingObject)
         
         initialAimLoc = locators.locMeObject(aimingObject)
         aimConstraintBuffer = mc.aimConstraint(initialAimLoc,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,-1,0],  worldUpObject = upLoc, worldUpType = 'object', skip = ['x','z'])
         mc.delete(aimConstraintBuffer[0])
         mc.delete(initialAimLoc)
 
         aimLoc = locators.locMeCvFromCvIndex(curveShapes[0],cvIndex)
         startLoc = mc.rename(startLoc, (self.ModuleNull.nameBase+'_radialBackl_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         sizeObjectLength = distance.returnDistanceBetweenObjects(workingObject,aimingObject)
         mc.xform(aimLoc,t=[0,0,-sizeObjectLength],r=True,ws=True)
         aimConstraintBuffer = mc.aimConstraint(aimLoc,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpType = 'vector' )
         mc.delete(aimConstraintBuffer[0])
         mc.delete(aimLoc)
         mc.delete(upLoc)
         returnLoc.append(startLoc)
         zeroGroup = StartLoc.doGroup()  
         returnLoc.append(StartLoc.nameLong)
         
         return returnLoc
         
     elif  modeType == 'radialOut':
         sizeObjectLength = distance.returnDistanceBetweenObjects(workingObject,aimingObject)
         
         returnLoc = []
         
         workingObjectShapes = mc.listRelatives(workingObject, shapes = True)
         aimingObjectShapes = mc.listRelatives(aimingObject, shapes = True)
         
         """initial loc creation and orientation"""
         startLoc = locators.locMeCvFromCvIndex(workingObjectShapes[0],cvIndex)
         startLocAim = locators.locMeObject(workingObject)
         startLocUp = locators.locMeCvFromCvIndex(workingObjectShapes[0],cvIndex)
         startLoc = mc.rename(startLoc, (self.ModuleNull.nameBase+'_radialOut_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         
         """ move the up loc up """
         mc.xform(startLocUp,t=[0,sizeObjectLength,0],r=True,ws=True)
 
         """ aim it """
         aimConstraintBuffer = mc.aimConstraint(startLocAim,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpType = 'vector' )
         mc.delete(aimConstraintBuffer[0])
         mc.delete(startLocUp)
         
         """ setup the transform group"""
         transformGroup = rigging.groupMeObject(startLoc,False)
         transformGroup = mc.rename(transformGroup,('%s%s' %(startLoc,'_moveGroup')))
         groupUp = startLocAim
         groupAim = locators.locMeCvFromCvIndex(aimingObjectShapes[0],cvIndex)
         
         """aim it"""
         aimConstraintBuffer = mc.aimConstraint(groupAim,transformGroup,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,-1,0],  worldUpObject = groupUp, worldUpType = 'object')
         mc.delete(aimConstraintBuffer[0])
         mc.delete(groupUp)
         mc.delete(groupAim)
         
         startLoc = rigging.doParentReturnName(startLoc,transformGroup)
         rigging.zeroTransformMeObject(startLoc)
         returnLoc.append(startLoc)
         returnLoc.append(transformGroup)
         zeroGroup = rigging.groupMeObject(transformGroup)
         attributes.storeInfo(zeroGroup,'move',transformGroup)
         returnLoc.append(zeroGroup)
         
         return returnLoc
         
     elif  modeType == 'radialDown':
         sizeObjectLength = distance.returnDistanceBetweenObjects(workingObject,aimingObject)
         returnLoc = []
         
         workingObjectShapes = mc.listRelatives(workingObject, shapes = True)
         aimingObjectShapes = mc.listRelatives(aimingObject, shapes = True)
         
         """initial loc creation and orientation"""
         startLoc = locators.locMeCvFromCvIndex(workingObjectShapes[0],cvIndex)
         startLocAim = locators.locMeCvFromCvIndex(workingObjectShapes[0],cvIndex)
         startLoc = mc.rename(startLoc, (self.ModuleNull.nameBase+'_radialDown_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         """ move the up loc up """
         mc.xform(startLocAim,t=[0,-sizeObjectLength,0],r=True, ws=True)
         
         """ aim it """
         aimConstraintBuffer = mc.aimConstraint(startLocAim,startLoc,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,0,1], worldUpType = 'vector' )
         mc.delete(aimConstraintBuffer[0])
         
         
         """ setup the transform group"""
         transformGroup = rigging.groupMeObject(startLoc,False)
         transformGroup = mc.rename(transformGroup,('%s%s' %(startLoc,'_moveGroup')))
         groupUp = startLocAim
         groupAim = locators.locMeCvFromCvIndex(aimingObjectShapes[0],cvIndex)
         
         """aim it"""
         aimConstraintBuffer = mc.aimConstraint(groupAim,transformGroup,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,-1,0],  worldUpObject = groupUp, worldUpType = 'object')
         mc.delete(aimConstraintBuffer[0])
         mc.delete(groupUp)
         mc.delete(groupAim)
         
         startLoc = rigging.doParentReturnName(startLoc,transformGroup)
         rigging.zeroTransformMeObject(startLoc)
         returnLoc.append(startLoc)
         returnLoc.append(transformGroup)
         zeroGroup = rigging.groupMeObject(transformGroup)
         attributes.storeInfo(zeroGroup,'move',transformGroup)
         returnLoc.append(zeroGroup)
         
         return returnLoc
         
     elif modeType == 'footBase':
         returnLoc = []
         startLoc = locators.locMeObject(workingObject)
         startLoc = mc.rename(startLoc,(self.ModuleNull.nameBase+'_footcgmase_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         masterGroup = rigging.groupMeObject(startLoc)
         
         mc.setAttr((startLoc+'.rx'),-90)
         returnLoc.append(startLoc)
         zeroGroup = rigging.zeroTransformMeObject(startLoc)
         
         currentPos = mc.xform(zeroGroup,q=True, t=True,ws=True)
         mc.xform(zeroGroup,t=[currentPos[0],0,currentPos[2]], ws = True)
         
         attributes.storeInfo(zeroGroup,'locator',startLoc)
         returnLoc.append(zeroGroup)
         returnLoc.append(masterGroup)
         
         return returnLoc
         
     elif modeType == 'parentDuplicate':
         returnLoc = []
         startLoc = locators.locMeObject(workingObject)
         startLoc = mc.rename(startLoc,(self.ModuleNull.nameBase+'_parentDup_startLoc'))
         StartLoc = ObjectFactory(startLoc)
         
         masterGroup = rigging.groupMeObject(startLoc)
         returnLoc.append(startLoc)
         returnLoc.append(masterGroup)
         
         return returnLoc
     else:
         return False
Example #15
0
    def verifyModule(self,forceNew = False):
        """
        Verifies the integrity of the base module class null. Repairing and restoring broken connections or deleted items.
        """
        for k in defaultSettings.keys():
            try:
                self.__dict__[k]
            except:
                self.__dict__[k] = defaultSettings[k]       
                
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Nulls creation
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
        #need a check to see if it exists from specfic name call
        if not self.ModuleNull or forceNew:
            #See if one exists from the name dict
            buffer = NameFactory.returnCombinedNameFromDict(self.generateNameDict())
            if mc.objExists(buffer):
                if forceNew:
                    cnt = NameFactory.returnIterateNumber(buffer)
                    self.ModuleNull = ObjectFactory(mc.group(empty=True))
                    self.ModuleNull.store('cgmIterator',cnt)
                else:
                    self.ModuleNull = ObjectFactory(buffer)
                
        #if we still don't have one, make it
        if not self.ModuleNull:
            self.ModuleNull = ObjectFactory(mc.group(empty=True))
            
        #Initialize the module parent attr
        self.msgModuleParent = AttrFactory(self.ModuleNull,'moduleParent','message',self.moduleParent)

        #Naming stuff           
        self.ModuleNull.store('cgmName',self.nameBase,True)   
        self.ModuleNull.store('cgmType','module')
        self.afModuleType = AttrFactory(self.ModuleNull,'moduleType',initialValue='None')
        
        #Store any naming tags from the init call
        for k in self.callTags.keys():
            if self.callTags.get(k):
                self.ModuleNull.store(k,self.callTags.get(k),True)
            elif k in self.parentTagDict.keys():
                self.ModuleNull.store(k,'%s.%s'%(self.msgModuleParent.value,k))                    
            
        self.ModuleNull.doName(True)
        mc.xform (self.ModuleNull.nameShort, os=True, piv= (0,0,0)) 
        
        for flag in moduleStates:
            self.__dict__["af%sState"%flag.capitalize()] = AttrFactory(self.ModuleNull,'%sState'%flag,'bool',initialValue=0,lock=True)

        attributes.doSetLockHideKeyableAttr(self.ModuleNull.nameShort,channels=['tx','ty','tz','rx','ry','rz','sx','sy','sz'])
    
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Main Nulls
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>         
        self.msgRigNull = AttrFactory(self.ModuleNull,'rigNull','message')
        self.msgTemplateNull = AttrFactory(self.ModuleNull,'templateNull','message')
        self.msgInfoNull = AttrFactory(self.ModuleNull,'info','message')
        
        nullAttributes = [self.msgRigNull, self.msgTemplateNull, self.msgInfoNull]
        nullInstances = ['RigNull', 'TemplateNull', 'InfoNull']
        
        for i,null in enumerate(nullAttributes):
            created = False
            if not null.get():
                #If there's nothing connected to our message, we're gonna make our null
                guiFactory.report("'%s' not found. Creating"%null.attr)
                self.__dict__[ nullInstances[i] ] = ObjectFactory(mc.group(empty=True))
                created = True
            else:
                self.__dict__[ nullInstances[i] ] = ObjectFactory(null.value)
                
            if null.attr == 'info':
                #Special case stuff for the master info null
                self.__dict__[ nullInstances[i] ].store('cgmName','master',True)  
                self.__dict__[ nullInstances[i] ].store('cgmType','infoNull')
                
            else:
                self.__dict__[ nullInstances[i] ].store('cgmType',null.attr)
                
            mc.xform (self.__dict__[ nullInstances[i] ].nameShort, os=True, piv= (0,0,0)) 
            self.__dict__[ nullInstances[i] ].doParent(self.ModuleNull.nameShort)
            
            if created and self.__dict__[ nullInstances[i] ].nameLong != null.value:
                null.doStore(self.__dict__[ nullInstances[i] ].nameLong)
                
            attributes.doSetLockHideKeyableAttr(self.__dict__[ nullInstances[i] ].nameShort)
            self.__dict__[ nullInstances[i] ].doName(True)
            null.updateData()
            
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        # Info Nulls
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
        for k in InfoNullsNames:
            self.infoNulls[k] = AttrFactory(self.InfoNull,k,'message')
            
            if not self.infoNulls[k].value:
                guiFactory.report("'%s' not found. Creating"%k)                
                createBuffer = modules.createInfoNull(k)
                self.infoNulls[k].doStore(createBuffer)
                
            if self.infoNulls[k].value:  
                attributes.doSetLockHideKeyableAttr(self.infoNulls[k].value)                
                if rigging.doParentReturnName( self.infoNulls[k].value,self.msgInfoNull.value):
                    buffer = NameFactory.doNameObject(self.infoNulls[k].value)
                    if buffer != self.infoNulls[k].value:
                        self.infoNulls[k].doStore(buffer)
                    else:
                        self.infoNulls[k].updateData()
                        
            else:
                guiFactory.warning("'%s' has failed to initialize"%k)
       
        if self.infoNulls['setupOptions']:
            self.SetupOptionsNull = ObjectFactory( self.infoNulls['setupOptions'].get() )            
            self.optionHandles = AttrFactory(self.SetupOptionsNull,'handles','int',initialValue=self.handles)
        
        if self.infoNulls['settings']:
            self.optionAimAxis = AttrFactory(self.infoNulls['settings'].get(),'axisAim','enum',enum = 'x+:y+:z+:x-:y-:z-',initialValue=2) 
            self.optionUpAxis = AttrFactory(self.infoNulls['settings'].get(),'axisUp','enum',enum = 'x+:y+:z+:x-:y-:z-',initialValue=1) 
            self.optionOutAxis = AttrFactory(self.infoNulls['settings'].get(),'axisOut','enum',enum = 'x+:y+:z+:x-:y-:z-',initialValue=0)                       
        return True
Example #16
0
def parentObjectToNameObject(object):
    object = NameFactory(object)
    if mc.objExists(object.cgm['cgmName']):
        obj = rigging.doParentReturnName(object.nameLong,object.cgm['cgmName'])
Example #17
0
def attachAimedObjectToSurface (obj, surface, aimObject, parent = True):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    
    """ Make a transform group """
    surfaceLoc = locators.locMeClosestUVOnSurface(obj,surface)
    surfaceFollowGroup = rigging.groupMeObject(surfaceLoc,False)
    transformGroup = rigging.groupMeObject(obj,False)
    
    surfaceFollowGroup = mc.rename(surfaceFollowGroup,(obj+'_surfaceFollowGroup'))
    attributes.storeInfo(surfaceFollowGroup,'object',obj)  
    
    transformGroup = mc.rename(transformGroup,(obj+'_surfaceFollowTransformGroup'))
    attributes.storeInfo(transformGroup,'object',obj) 
    
    
    controlSurface = mc.listRelatives(surface,shapes=True)
    
    """ make the node """
    closestPointNode = mc.createNode ('closestPointOnSurface',name= (obj+'_closestPointInfoNode'))
    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((surfaceLoc+'.translate'),(closestPointNode+'.inPosition'))
    attributes.doConnectAttr((controlSurface[0]+'.worldSpace'),(closestPointNode+'.inputSurface'))
    
    pointOnSurfaceNode = mc.createNode ('pointOnSurfaceInfo',name= (obj+'_posInfoNode'))
    """ Connect the info node to the surface """                  
    attributes.doConnectAttr  ((controlSurface[0]+'.worldSpace'),(pointOnSurfaceNode+'.inputSurface'))
    """ Contect the pos group to the info node"""
    attributes.doConnectAttr ((pointOnSurfaceNode+'.position'),(surfaceFollowGroup+'.translate'))
    attributes.doConnectAttr ((closestPointNode+'.parameterU'),(pointOnSurfaceNode+'.parameterU'))
    attributes.doConnectAttr  ((closestPointNode+'.parameterV'),(pointOnSurfaceNode+'.parameterV'))

    """ if we wanna aim """
    if aimObject != False: 
        """ make some locs """
        upLoc = locators.locMeObject(surface)
        aimLoc = locators.locMeObject(aimObject)
        attributes.storeInfo(upLoc,'cgmName',obj)
        attributes.storeInfo(upLoc,'cgmTypeModifier','up')
        upLoc = NameFactoryOld.doNameObject(upLoc)
        
        attributes.storeInfo(aimLoc,'cgmName',aimObject)
        attributes.storeInfo(aimLoc,'cgmTypeModifier','aim')
        aimLoc = NameFactoryOld.doNameObject(aimLoc)

        attributes.storeInfo(surfaceFollowGroup,'locatorUp',upLoc)
        attributes.storeInfo(surfaceFollowGroup,'aimLoc',aimLoc)
        #mc.parent(upLoc,aimObject)
        
        boundingBoxSize = distance.returnBoundingBoxSize(surface)
        distance = max(boundingBoxSize)*2
        
        mc.xform(upLoc,t = [0,distance,0],ws=True,r=True)
        
        attributes.doConnectAttr((aimLoc+'.translate'),(closestPointNode+'.inPosition'))

        """ constrain the aim loc to the aim object """
        pointConstraintBuffer = mc.pointConstraint(aimObject,aimLoc,maintainOffset = True, weight = 1)
        
        """ aim it """
        aimConstraintBuffer = mc.aimConstraint(aimLoc,surfaceFollowGroup,maintainOffset = True, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )

        """ aim the controller back at the obj"""
        aimConstraintBuffer = mc.aimConstraint(obj,aimLoc,maintainOffset = True, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpObject = upLoc, worldUpType = 'object' )
        
        mc.parent(upLoc,aimObject)
    else:
        mc.delete(closestPointNode)
    
    transformGroup = rigging.doParentReturnName(transformGroup,surfaceFollowGroup)
    """finally parent it"""    
    if parent == True:
        mc.parent(obj,transformGroup)
        
    if parent == 'constrain':
        mc.parentConstraint(transformGroup,obj,maintainOffset = True)
    
    mc.delete(surfaceLoc)
    return [transformGroup,surfaceFollowGroup]
Example #18
0
def parentObjectToNameObject(object):
    object = NameFactory(object)
    if mc.objExists(object.cgm['cgmName']):
        obj = rigging.doParentReturnName(object.nameLong,object.cgm['cgmName'])
Example #19
0
def createMasterNull(characterName='nothingNothing'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a masterNull for a character/asset
    
    ARGUMENTS:
    characterName(string)
    
    RETURNS:
    masterNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if characterName == 'nothingNothing':
        randomOptions = ['David', 'Josh', 'NameMe', 'Homer', 'Georgie']
        characterName = random.choice(randomOptions)

    #Create main null
    masterNullBuffer = mc.group(empty=True)
    attributes.storeInfo(masterNullBuffer, 'cgmName', characterName)
    attributes.storeInfo(masterNullBuffer, 'cgmType', 'ignore')
    attributes.storeInfo(masterNullBuffer, 'cgmModuleType', 'master')
    masterNull = NameFactory.doNameObject(masterNullBuffer)

    #Create modules container null
    modulesGroupBuffer = mc.group(empty=True)
    attributes.storeInfo(modulesGroupBuffer, 'cgmName', 'modules')
    attributes.storeInfo(modulesGroupBuffer, 'cgmType', 'group')
    modulesGroup = NameFactory.doNameObject(modulesGroupBuffer)
    modulesGroup = rigging.doParentReturnName(modulesGroup, masterNull)
    attributes.storeObjectToMessage(modulesGroup, masterNull, 'modulesGroup')

    #Create modules container null
    meshGroupBuffer = mc.group(empty=True)
    attributes.storeInfo(meshGroupBuffer, 'cgmName', 'geo')
    attributes.storeInfo(modulesGroupBuffer, 'cgmType', 'group')
    meshGroup = NameFactory.doNameObject(modulesGroupBuffer)
    meshGroup = rigging.doParentReturnName(meshGroup, masterNull)
    attributes.storeObjectToMessage(meshGroup, masterNull, 'geoGroup')

    #Create master info null
    masterInfoNull = createInfoNull('master')
    attributes.storeObjectToMessage(masterInfoNull, masterNull, 'info')
    masterInfoNull = rigging.doParentReturnName(masterInfoNull, masterNull)

    #Create modules info null
    modulesInfoNull = createInfoNull('modules')
    attributes.storeObjectToMessage(modulesInfoNull, masterInfoNull, 'modules')
    modulesInfoNull = rigging.doParentReturnName(modulesInfoNull,
                                                 masterInfoNull)

    #Create mesh info null
    meshInfoNull = createInfoNull('geo')
    attributes.storeObjectToMessage(meshInfoNull, masterInfoNull, 'geo')
    modulesInfoNull = rigging.doParentReturnName(meshInfoNull, masterInfoNull)

    #Create global settings info null
    settingsInfoNull = createInfoNull('settings')
    attributes.storeObjectToMessage(settingsInfoNull, masterInfoNull,
                                    'settings')
    settingsInfoNull = rigging.doParentReturnName(settingsInfoNull,
                                                  masterInfoNull)
    defaultFont = returnSettingsData('defaultTextFont')
    attributes.storeInfo(settingsInfoNull, 'font', defaultFont)

    return masterNull
Example #20
0
def createMasterNull(characterName='nothingNothing'):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Creates a masterNull for a character/asset
    
    ARGUMENTS:
    characterName(string)
    
    RETURNS:
    masterNull(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if characterName == 'nothingNothing':
        randomOptions = ['David','Josh','NameMe','Homer','Georgie']
        characterName = random.choice(randomOptions)
    
    #Create main null
    masterNullBuffer = mc.group (empty=True)
    attributes.storeInfo(masterNullBuffer,'cgmName',characterName)   
    attributes.storeInfo(masterNullBuffer,'cgmType','ignore')
    attributes.storeInfo(masterNullBuffer,'cgmModuleType','master')
    masterNull = NameFactory.doNameObject(masterNullBuffer)
    
    #Create modules container null
    modulesGroupBuffer = mc.group (empty=True)
    attributes.storeInfo(modulesGroupBuffer,'cgmName','modules')   
    attributes.storeInfo(modulesGroupBuffer,'cgmType','group')
    modulesGroup = NameFactory.doNameObject(modulesGroupBuffer)
    modulesGroup = rigging.doParentReturnName(modulesGroup,masterNull)
    attributes.storeObjectToMessage (modulesGroup, masterNull, 'modulesGroup')
    
    #Create modules container null
    meshGroupBuffer = mc.group (empty=True)
    attributes.storeInfo(meshGroupBuffer,'cgmName','geo')   
    attributes.storeInfo(modulesGroupBuffer,'cgmType','group')
    meshGroup = NameFactory.doNameObject(modulesGroupBuffer)
    meshGroup = rigging.doParentReturnName(meshGroup,masterNull)
    attributes.storeObjectToMessage (meshGroup, masterNull, 'geoGroup')
    
    #Create master info null
    masterInfoNull = createInfoNull('master')
    attributes.storeObjectToMessage (masterInfoNull, masterNull, 'info')
    masterInfoNull = rigging.doParentReturnName(masterInfoNull,masterNull)
    
    #Create modules info null
    modulesInfoNull = createInfoNull('modules')
    attributes.storeObjectToMessage (modulesInfoNull, masterInfoNull, 'modules')
    modulesInfoNull = rigging.doParentReturnName(modulesInfoNull,masterInfoNull)
    
    #Create mesh info null
    meshInfoNull = createInfoNull('geo')
    attributes.storeObjectToMessage (meshInfoNull, masterInfoNull, 'geo')
    modulesInfoNull = rigging.doParentReturnName(meshInfoNull,masterInfoNull)
    
    #Create global settings info null
    settingsInfoNull = createInfoNull('settings')
    attributes.storeObjectToMessage (settingsInfoNull, masterInfoNull, 'settings')
    settingsInfoNull = rigging.doParentReturnName(settingsInfoNull,masterInfoNull)
    defaultFont = returnSettingsData('defaultTextFont')
    attributes.storeInfo(settingsInfoNull,'font',defaultFont)

    return masterNull
Example #21
0
def bakeBlendShapeNodeToTargetObject(targetObject,sourceObject, blendShapeNode, baseNameToUse = False, stripPrefix = False,ignoreInbetweens = False, ignoreTargets = False, transferConnections = True):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Function for baking a series of blendshapes from one object to another

    ARGUMENTS:
    targetObject(string)
    sourceObject(string)
    blendShapeNode(string) the node to bake from
    baseNameToUse(bool/string) - if it's False, it uses the target Object name, else, it uses what is supplied
    stripPrefix(bool)
    ignoreInbetweens(bool)
    ignoreTargets(list) - list of targets to ignore
    transferConnections(bool) - if True, builds a new blendshape node and transfers the connections from our base objects

    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Prep
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ declare variables """
    returnList = []
    blendShapeNamesBaked = []
    blendShapeConnections = []
    currentConnections = []
    bakedGeo = []

    """ size """
    sizeBuffer = distance.returnBoundingBoxSize(targetObject)
    sizeX = sizeBuffer[0]
    sizeY = sizeBuffer[1]

    """ base name """
    if baseNameToUse == False:
        baseName = ''
    else:
        baseName = baseNameToUse + '_'

    """ wrap deform object """
    wrapBuffer = wrapDeformObject(targetObject,sourceObject,True)
    targetObjectBaked = wrapBuffer[1]

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Meat of it
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    blendShapeNodeChannels = returnBlendShapeAttributes(blendShapeNode)

    blendShapeShortNames = []
    """ first loop stores and sets everything to 0 """

    for shape in blendShapeNodeChannels:
        keepGoing = True
        if ignoreTargets != False:
            if shape in ignoreTargets:
                keepGoing = False
            else:
                keepGoing = True

        blendShapeBuffer = (blendShapeNode + '.' + shape)
        """ get the connection """
        blendShapeConnections.append(attributes.returnDriverAttribute(blendShapeBuffer))

        if keepGoing == True:
            print ('breaking....' + blendShapeBuffer)
            """break it """
            attributes.doBreakConnection(blendShapeBuffer)
            attributes.doSetAttr(blendShapeNode,shape,0)

    # Bake it
    bakedGeo = bakeBlendShapes(sourceObject, targetObjectBaked, blendShapeNode, baseNameToUse, stripPrefix, ignoreInbetweens, ignoreTargets)


    """ restore connections """
    for shape in blendShapeNodeChannels:
        keepGoing = True
        if ignoreTargets != False:
            if shape in ignoreTargets:
                keepGoing = False
            else:
                keepGoing = True

        currentIndex = blendShapeNodeChannels.index(shape)
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        """ Restore the connection """
        if keepGoing == True:
            print ('connecting....' + blendShapeBuffer)
            print blendShapeConnections[currentIndex]
            if blendShapeConnections[currentIndex] != False:
                attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer)


    # Need to build a new blendshape node?
    if transferConnections == True:
        # Build it
        newBlendShapeNode = buildBlendShapeNode(targetObject, bakedGeo, baseNameToUse)

        newBlendShapeChannels = returnBlendShapeAttributes(newBlendShapeNode)

        for shape in newBlendShapeChannels:
            blendShapeBuffer = (newBlendShapeNode+'.'+shape)
            currentIndex = newBlendShapeChannels.index(shape)
            if blendShapeConnections[currentIndex] != False:
                attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer)

    """delete the wrap"""
    mc.delete(wrapBuffer[0])

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Finish out
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ group for geo """
    meshGroup = mc.group( em=True)
    if baseNameToUse != False:
        attributes.storeInfo(meshGroup,'cgmName', baseNameToUse)
    attributes.storeInfo(meshGroup,'cgmTypeModifier', 'blendShapeGeo')
    meshGroup = NameFactory.doNameObject(meshGroup)

    for geo in bakedGeo:
        rigging.doParentReturnName(geo,meshGroup)

    returnList.append(meshGroup)
    returnList.append(bakedGeo)

    mc.delete(targetObjectBaked)
    return returnList
Example #22
0
def bakeCombinedBlendShapeNodeToTargetObject(targetObject,sourceObject, blendShapeNode, baseName = False, directions=['left','right']):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Function for baking a series of blendshapes from one object to another when you have a left/right variant

    ARGUMENTS:
    targetObject(string)
    sourceObject(string)
    blendShapeNode(string) the node to bake from
    baseName(bool/string) - if it's False, it uses the target Object name, else, it uses what is supplied
    directions[list] = (['left','right'])

    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Prep
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ declare variables """
    returnList = []
    blendShapeNamesBaked = []
    blendShapeConnections = []
    currentConnections = []
    bakedGeo = []

    """ size """
    sizeBuffer = distance.returnBoundingBoxSize(targetObject)
    sizeX = sizeBuffer[0]
    sizeY = sizeBuffer[1]

    """ base name """
    if baseName == False:
        baseName = ''
    else:
        baseName = baseName + '_'

    """reference check """
    refPrefix = search.returnReferencePrefix(sourceObject)
    if refPrefix != False:
        referencePrefix = (search.returnReferencePrefix(sourceObject) + ':')
    else:
        referencePrefix = ''

    """ wrap deform object """
    wrapBuffer = wrapDeformObject(targetObject,sourceObject,True)
    targetObjectBaked = wrapBuffer[1]

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Meat of it
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    #setAttr ($wrapDeformer[0] + ".autoWeightThreshold") 1;
    """ cause maya is stupid and doesn't have a python equivalent"""
    mc.select(targetObjectBaked,r=True)
    mc.select(sourceObject,tgl=True)
    mel.eval('AddWrapInfluence')
    mc.select(cl=True)

    """
    may need to add this in later
    //reorders deformation order for proper baking of skinned mesh
    //reorderDeformers "tweak1" "face_skinCluster" $deformerGeo;
    """

    blendShapeNodeChannels = search.returnBlendShapeAttributes(blendShapeNode)
    blendShapeShortNames = []

    """ first loop stores and sets everything to 0 """
    for shape in blendShapeNodeChannels:
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        blendShapeConnections.append(attributes.returnDriverAttribute(blendShapeBuffer))
        """break it """
        attributes.doBreakConnection(blendShapeBuffer)
        attributes.doSetAttr(blendShapeNode,shape,0)

    """ Find pairs """
    blendshapePairs = lists.returnMatchedStrippedEndList(blendShapeNodeChannels,directions)

    """ first loop stores and sets everything to 0 """
    for pair in blendshapePairs:
        blendShapeBuffer = (blendShapeNode+'.'+pair[0])
        splitBuffer = pair[0].split('_')
        nameBuffer = splitBuffer[:-1]
        pairBaseName = '_'.join(nameBuffer)

        if '_' in list(pairBaseName):
            newSplitBuffer = pair[0].split('_')
            newNameBuffer = newSplitBuffer[1:]
            blendShapeShortNames.append('_'.join(newNameBuffer))
        else:
            blendShapeShortNames.append(pairBaseName)

    t=1
    pair = 0
    for i in range (len(blendshapePairs)):
        row = i//5
        if t>5:
            t=1
        """ start extracting """
        blendShapeNodeChannelsBuffer = blendshapePairs[pair]
        shape1 = blendShapeNodeChannelsBuffer[0]
        shape2 = blendShapeNodeChannelsBuffer[1]
        attributes.doSetAttr(blendShapeNode,shape1,1)
        attributes.doSetAttr(blendShapeNode,shape2,1)
        dupBuffer = mc.duplicate(targetObjectBaked)
        splitBuffer = blendShapeShortNames[pair].split('_')
        nameBuffer = splitBuffer[:-1]
        shortName = '_'.join(nameBuffer)

        dupBuffer = mc.rename (dupBuffer,(baseName+shortName))
        mc.xform(dupBuffer,r=True,t=[((sizeX*(t+1.2))*1.5),(sizeY*row*-1.5),0])
        bakedGeo.append(dupBuffer)

        attributes.doSetAttr(blendShapeNode,shape1,0)
        attributes.doSetAttr(blendShapeNode,shape2,0)
        pair +=1
        t+=1

    """ restore connections """
    for shape in blendShapeNodeChannels:
        currentIndex = blendShapeNodeChannels.index(shape)
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        """ Restore the connection """
        if blendShapeConnections[currentIndex] != False:
            attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer)

    """delete the wrap"""
    mc.delete(wrapBuffer[0])

    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Finish out
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ group for geo """
    meshGroup = mc.group( em=True)
    attributes.storeInfo(meshGroup,'cgmName', baseName)
    attributes.storeInfo(meshGroup,'cgmTypeModifier', 'blendShapeGeo')
    meshGroup = NameFactory.doNameObject(meshGroup)

    for geo in bakedGeo:
        rigging.doParentReturnName(geo,meshGroup)

    returnList.append(meshGroup)
    returnList.append(bakedGeo)

    mc.delete(targetObjectBaked)
    return returnList
Example #23
0
def attachAimedObjectToSurface(obj, surface, aimObject, parent=True):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Script to rename a joint chain list
    
    ARGUMENTS:
    jointList(list) - list of joints in order
    startJointName(string) - what you want the root named
    interiorJointRootName(string) - what you want the iterative name to be
    
    RETURNS:
    newJoints(list)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    """ Make a transform group """
    surfaceLoc = locators.locMeClosestUVOnSurface(obj, surface)
    surfaceFollowGroup = rigging.groupMeObject(surfaceLoc, False)
    transformGroup = rigging.groupMeObject(obj, False)

    surfaceFollowGroup = mc.rename(surfaceFollowGroup,
                                   (obj + '_surfaceFollowGroup'))
    attributes.storeInfo(surfaceFollowGroup, 'object', obj)

    transformGroup = mc.rename(transformGroup,
                               (obj + '_surfaceFollowTransformGroup'))
    attributes.storeInfo(transformGroup, 'object', obj)

    controlSurface = mc.listRelatives(surface, shapes=True)
    """ make the node """
    closestPointNode = mc.createNode('closestPointOnSurface',
                                     name=(obj + '_closestPointInfoNode'))
    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((surfaceLoc + '.translate'),
                             (closestPointNode + '.inPosition'))
    attributes.doConnectAttr((controlSurface[0] + '.worldSpace'),
                             (closestPointNode + '.inputSurface'))

    pointOnSurfaceNode = mc.createNode('pointOnSurfaceInfo',
                                       name=(obj + '_posInfoNode'))
    """ Connect the info node to the surface """
    attributes.doConnectAttr((controlSurface[0] + '.worldSpace'),
                             (pointOnSurfaceNode + '.inputSurface'))
    """ Contect the pos group to the info node"""
    attributes.doConnectAttr((pointOnSurfaceNode + '.position'),
                             (surfaceFollowGroup + '.translate'))
    attributes.doConnectAttr((closestPointNode + '.parameterU'),
                             (pointOnSurfaceNode + '.parameterU'))
    attributes.doConnectAttr((closestPointNode + '.parameterV'),
                             (pointOnSurfaceNode + '.parameterV'))
    """ if we wanna aim """
    if aimObject != False:
        """ make some locs """
        upLoc = locators.locMeObject(surface)
        aimLoc = locators.locMeObject(aimObject)
        attributes.storeInfo(upLoc, 'cgmName', obj)
        attributes.storeInfo(upLoc, 'cgmTypeModifier', 'up')
        upLoc = NameFactory.doNameObject(upLoc)

        attributes.storeInfo(aimLoc, 'cgmName', aimObject)
        attributes.storeInfo(aimLoc, 'cgmTypeModifier', 'aim')
        aimLoc = NameFactory.doNameObject(aimLoc)

        attributes.storeInfo(surfaceFollowGroup, 'locatorUp', upLoc)
        attributes.storeInfo(surfaceFollowGroup, 'aimLoc', aimLoc)
        #mc.parent(upLoc,aimObject)

        boundingBoxSize = distance.returnBoundingBoxSize(surface)
        distance = max(boundingBoxSize) * 2

        mc.xform(upLoc, t=[0, distance, 0], ws=True, r=True)

        attributes.doConnectAttr((aimLoc + '.translate'),
                                 (closestPointNode + '.inPosition'))
        """ constrain the aim loc to the aim object """
        pointConstraintBuffer = mc.pointConstraint(aimObject,
                                                   aimLoc,
                                                   maintainOffset=True,
                                                   weight=1)
        """ aim it """
        aimConstraintBuffer = mc.aimConstraint(aimLoc,
                                               surfaceFollowGroup,
                                               maintainOffset=True,
                                               weight=1,
                                               aimVector=[0, 0, 1],
                                               upVector=[0, 1, 0],
                                               worldUpObject=upLoc,
                                               worldUpType='object')
        """ aim the controller back at the obj"""
        aimConstraintBuffer = mc.aimConstraint(obj,
                                               aimLoc,
                                               maintainOffset=True,
                                               weight=1,
                                               aimVector=[0, 0, -1],
                                               upVector=[0, 1, 0],
                                               worldUpObject=upLoc,
                                               worldUpType='object')

        mc.parent(upLoc, aimObject)
    else:
        mc.delete(closestPointNode)

    transformGroup = rigging.doParentReturnName(transformGroup,
                                                surfaceFollowGroup)
    """finally parent it"""
    if parent == True:
        mc.parent(obj, transformGroup)

    if parent == 'constrain':
        mc.parentConstraint(transformGroup, obj, maintainOffset=True)

    mc.delete(surfaceLoc)
    return [transformGroup, surfaceFollowGroup]
Example #24
0
def bakeCombinedBlendShapeNode(sourceObject, blendShapeNode, baseNameToUse = False, directions=['left','right']):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Function for baking a series of blendshapes out from one object that have a split type

    ARGUMENTS:
    sourceObject(string)
    sourceObject(string)
    blendShapeNode(string) the node to bake from
    baseName(bool/string) - if it's False, it uses the target Object name, else, it uses what is supplied
    directions[list] = (['left','right'])

    RETURNS:
    Success(bool)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Prep
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ declare variables """
    returnList = []
    blendShapeNamesBaked = []
    blendShapeConnections = []
    currentConnections = []
    bakedGeo = []

    """ size """
    sizeBuffer = distance.returnBoundingBoxSize(sourceObject)
    sizeX = sizeBuffer[0]
    sizeY = sizeBuffer[1]

    """ base name """
    if baseNameToUse == False:
        baseName = ''
    else:
        baseName = baseNameToUse + '_'


    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Meat of it
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    blendShapeNodeChannels = search.returnBlendShapeAttributes(blendShapeNode)
    blendShapeShortNames = []

    """ first loop stores and sets everything to 0 """
    for shape in blendShapeNodeChannels:
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        blendShapeConnections.append(attributes.returnDriverAttribute(blendShapeBuffer))
        """break it """
        attributes.doBreakConnection(blendShapeBuffer)
        attributes.doSetAttr(blendShapeBuffer,0)

    """ Find pairs """
    blendshapePairs = lists.returnMatchedStrippedEndList(blendShapeNodeChannels,directions)

    """ first loop stores and sets everything to 0 """
    for pair in blendshapePairs:
        blendShapeBuffer = (blendShapeNode+'.'+pair[0])
        splitBuffer = pair[0].split('_')
        nameBuffer = splitBuffer[:-1]
        pairBaseName = '_'.join(nameBuffer)

        if '_' in list(pairBaseName):
            newSplitBuffer = pair[0].split('_')
            newNameBuffer = newSplitBuffer[1:]
            blendShapeShortNames.append('_'.join(newNameBuffer))
        else:
            blendShapeShortNames.append(pairBaseName)

    t=1
    pair = 0
    for i in range (len(blendshapePairs)):
        row = i//5
        if t>5:
            t=1
        """ start extracting """
        blendShapeNodeChannelsBuffer = blendshapePairs[pair]
        shape1 = blendShapeNodeChannelsBuffer[0]
        shape2 = blendShapeNodeChannelsBuffer[1]
        blendShape1Buffer = (blendShapeNode+'.'+shape1)
        blendShape2Buffer = (blendShapeNode+'.'+shape2)
        attributes.doSetAttr(blendShape1Buffer,1)
        attributes.doSetAttr(blendShape2Buffer,1)
        dupBuffer = mc.duplicate(sourceObject)


        splitBuffer = blendShapeShortNames[pair].split('_')
        if len(splitBuffer)>1:
            nameBuffer = splitBuffer[:-1]
        else:
            nameBuffer = splitBuffer
        shortName = '_'.join(nameBuffer)

        dupBuffer = mc.rename (dupBuffer,(baseName+shortName))
        """ Unlock it """
        attributes.doSetLockHideKeyableAttr(dupBuffer,False,True,True)

        mc.xform(dupBuffer,r=True,t=[((sizeX*(t+1.2))*1.5),(sizeY*row*-1.5),0])
        bakedGeo.append(dupBuffer)

        attributes.doSetAttr(blendShape1Buffer,0)
        attributes.doSetAttr(blendShape2Buffer,0)
        pair +=1
        t+=1

    """ restore connections """
    for shape in blendShapeNodeChannels:
        currentIndex = blendShapeNodeChannels.index(shape)
        blendShapeBuffer = (blendShapeNode+'.'+shape)
        """ Restore the connection """
        if blendShapeConnections[currentIndex] != False:
            attributes.doConnectAttr(blendShapeConnections[currentIndex],blendShapeBuffer)


    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Finish out
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ group for geo """
    meshGroup = mc.group( em=True)
    attributes.storeInfo(meshGroup,'cgmName', baseNameToUse)
    attributes.storeInfo(meshGroup,'cgmTypeModifier', 'blendShapeGeo')
    meshGroup = NameFactory.doNameObject(meshGroup)

    for geo in bakedGeo:
        rigging.doParentReturnName(geo,meshGroup)

    returnList.append(meshGroup)
    returnList.append(bakedGeo)

    return returnList
Example #25
0
def returnAbsoluteSizeCurve(curve):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass an curve into it and it returns absolute distance scale

    ARGUMENTS:
    curve(string) - curve

    RETURNS:
    distances(list) - [xLength,yLength,zLength]
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    def duplicateShape(shape):
        parentObj = mc.listRelatives(shape, p=True, fullPath=True)
        shapes = mc.listRelatives(parentObj, shapes=True, fullPath=True)
        matchObjName = mc.ls(shape, long=True)
        matchIndex = shapes.index(matchObjName[0])

        dupBuffer = mc.duplicate(parentObj)
        children = mc.listRelatives(dupBuffer[0], children = True, fullPath =True)
        if len(children) > 0:
            for c in children:
                if search.returnObjectType(c) != 'shape':
                    mc.delete(c)

        dupShapes = mc.listRelatives(dupBuffer[0], shapes=True, fullPath=True)
        for shape in dupShapes:
            if dupShapes.index(shape) != matchIndex:
                mc.delete(shape)
                return dupBuffer[0]


    boundingBoxSize = returnBoundingBoxSize(curve)
    if mayaVersion <=2010:
        return boundingBoxSize
    else:
        distanceToMove = max(boundingBoxSize)
        positions = []
        isShape = False
        if search.returnObjectType(curve) == 'shape':
            dupCurve = duplicateShape(curve)
            curve = dupCurve
            isShape = True

        loc = rigging.locMeObjectStandAlone(curve)
        locGroup = rigging.groupMeObject(loc,False)
        loc = rigging.doParentReturnName(loc,locGroup)
        directions = ['x','y','z']
        for direction in directions:
            positionsBuffer = []
            mc.setAttr((loc+'.t'+direction),distanceToMove)
            positionsBuffer.append(returnClosestUPosition(loc,curve))
            mc.setAttr((loc+'.t'+direction),-distanceToMove)
            positionsBuffer.append(returnClosestUPosition(loc,curve))
            mc.setAttr((loc+'.t'+direction),0)
            positions.append(positionsBuffer)

        distances = []
        for set in positions:
            distances.append(returnDistanceBetweenPoints(set[0],set[1]))

        if isShape == True:
            mc.delete(dupCurve)

        mc.delete(locGroup)
        return distances
Example #26
0
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