示例#1
0
def updatePhosphorFaceJointSDKs (jOhJoints):
    for o in jOhJoints:
        #Find our match
        buffer = o.strip('jOH_')
        print buffer
        if mc.objExists(buffer):
            print True
            print ("'%s' matches '%s'"%(o,buffer))
            position.movePointSnap(o,buffer)
            sdk.updateSDKWithCurrentObjectInfo (o, 'rest_txtCrv.rest')
示例#2
0
def updatePhosphorFaceJointSDKs (jOhJoints):
    for o in jOhJoints:
        #Find our match
        buffer = o.strip('jOH_')
        print buffer
        if mc.objExists(buffer):
            print True
            print ("'%s' matches '%s'"%(o,buffer))
            position.movePointSnap(o,buffer)
            sdk.updateSDKWithCurrentObjectInfo (o, 'rest_txtCrv.rest')
示例#3
0
def locMeClosestUVOnSurface(obj, surface, pivotOnSurfaceOnly=False):
    """
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Places locators on the cv's of a surface

	ARGUMENTS:
	curve(string)

	RETURNS:
	locList(list)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
    locBuffer = locMeObject(obj)
    pivotLoc = locMeObject(obj)

    controlSurface = mc.listRelatives(surface, shapes=True)
    """ make the closest point node """
    closestPointNode = mc.createNode('closestPointOnSurface')
    """ to account for target objects in heirarchies """
    attributes.doConnectAttr((locBuffer + '.translate'),
                             (closestPointNode + '.inPosition'))
    attributes.doConnectAttr((controlSurface[0] + '.worldSpace'),
                             (closestPointNode + '.inputSurface'))
    """ make the pointOnSurfaceNode """
    pointOnSurfaceNode = mc.createNode('pointOnSurfaceInfo')
    """ 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'),
                             (pivotLoc + '.translate'))
    attributes.doConnectAttr((closestPointNode + '.parameterU'),
                             (pointOnSurfaceNode + '.parameterU'))
    attributes.doConnectAttr((closestPointNode + '.parameterV'),
                             (pointOnSurfaceNode + '.parameterV'))

    if pivotOnSurfaceOnly != True:
        position.movePointSnap(locBuffer, pivotLoc)
    else:
        rigging.copyPivot(locBuffer, pivotLoc)

    mc.delete(closestPointNode)
    mc.delete(pointOnSurfaceNode)
    mc.delete(pivotLoc)

    #Rotate
    constBuffer = mc.normalConstraint(surface, locBuffer)
    mc.delete(constBuffer[0])

    return locBuffer
示例#4
0
def locMeClosestUVOnSurface(obj, surface, pivotOnSurfaceOnly = False):
	"""
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	DESCRIPTION:
	Places locators on the cv's of a surface

	ARGUMENTS:
	curve(string)

	RETURNS:
	locList(list)
	>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	"""
	locBuffer = locMeObject(obj)
	pivotLoc = locMeObject(obj)

	controlSurface = mc.listRelatives(surface,shapes=True)

	""" make the closest point node """
	closestPointNode = mc.createNode ('closestPointOnSurface')
	""" to account for target objects in heirarchies """
	attributes.doConnectAttr((locBuffer+'.translate'),(closestPointNode+'.inPosition'))
	attributes.doConnectAttr((controlSurface[0]+'.worldSpace'),(closestPointNode+'.inputSurface'))

	""" make the pointOnSurfaceNode """
	pointOnSurfaceNode = mc.createNode ('pointOnSurfaceInfo')
	""" 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'),(pivotLoc+'.translate'))
	attributes.doConnectAttr ((closestPointNode+'.parameterU'),(pointOnSurfaceNode+'.parameterU'))
	attributes.doConnectAttr  ((closestPointNode+'.parameterV'),(pointOnSurfaceNode+'.parameterV'))

	if pivotOnSurfaceOnly != True:
		position.movePointSnap(locBuffer,pivotLoc)
	else:
		rigging.copyPivot(locBuffer,pivotLoc)


	mc.delete(closestPointNode)
	mc.delete(pointOnSurfaceNode)
	mc.delete(pivotLoc)

	#Rotate
	constBuffer = mc.normalConstraint(surface,locBuffer)
	mc.delete(constBuffer[0])

	return locBuffer
示例#5
0
def basicEyeJointSurfaceSetup(jointList, jointRoot, surface):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    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)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    baseDistance = distance.returnAverageDistanceBetweenObjectsAndRoot(
        jointList, jointRoot)
    controls = []
    groups = []

    for joint in jointList:
        """ make the control """
        jointControl = curves.createControlCurve('circle', 1)
        scaleFactor = baseDistance * .25
        mc.setAttr((jointControl + '.sx'), scaleFactor)
        mc.setAttr((jointControl + '.sy'), scaleFactor)
        mc.setAttr((jointControl + '.sz'), scaleFactor)
        position.movePointSnap(jointControl, joint)
        position.aimSnap(jointControl, jointRoot, [0, 0, -1])
        mc.xform(jointControl, t=[0, 0, baseDistance * .4], os=True, r=True)
        mc.makeIdentity(jointControl, apply=True, s=True)
        """ naming it """
        attributes.storeInfo(jointControl, 'cgmName', joint, True)
        attributes.storeInfo(jointControl, 'cgmType', 'controlAnim')
        jointControl = NameFactory.doNameObject(jointControl)
        controls.append(jointControl)

        groups.append(rigging.zeroTransformMeObject(jointControl))

    for control in controls:
        indexCount = controls.index(control)
        attachAimedObjectToSurface(jointList[indexCount], surface, control,
                                   'constrain')
示例#6
0
def basicEyeJointSurfaceSetup(jointList, jointRoot, surface):
    """ 
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    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)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    baseDistance = distance.returnAverageDistanceBetweenObjectsAndRoot (jointList,jointRoot)
    controls = []
    groups = []
    
    for joint in jointList:
        """ make the control """        
        jointControl = curves.createControlCurve('circle',1)
        scaleFactor = baseDistance*.25
        mc.setAttr((jointControl+'.sx'),scaleFactor)
        mc.setAttr((jointControl+'.sy'),scaleFactor)
        mc.setAttr((jointControl+'.sz'),scaleFactor)
        position.movePointSnap(jointControl,joint)
        position.aimSnap(jointControl,jointRoot,[0,0,-1])
        mc.xform(jointControl,t=[0,0,baseDistance*.4],os=True, r=True)
        mc.makeIdentity(jointControl, apply = True, s=True)
        
        
        """ naming it """
        attributes.storeInfo(jointControl,'cgmName',joint,True)
        attributes.storeInfo(jointControl,'cgmType','controlAnim')
        jointControl = NameFactoryOld.doNameObject(jointControl)
        controls.append(jointControl)
        
        groups.append( rigging.zeroTransformMeObject(jointControl) )
        
    for control in controls:
        indexCount = controls.index(control)
        attachAimedObjectToSurface (jointList[indexCount], surface, control, 'constrain')
示例#7
0
    def doMove(self,**kws):
	if kws:log.debug("Snap.doMove>>> kws: %s"%kws)
	if len(self.l_targets) == 1:
	    #>>> Check our target	    
	    i_target = cgmMeta.cgmNode( self.l_targets[0] )
	    log.debug("i_target: %s"%i_target)
	    targetType = i_target.getMayaType()	    

	    if self.b_snapComponents:
		components = self.i_obj.getComponents()
		if not components:raise StandardError,"This objects has no components to snap: '%s'"%self.i_obj.getShortName()
		#>>>Progress bar
		mayaMainProgressBar = gui.doStartMayaProgressBar(len(components))		
		for c in components:
		    if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) :
			break
		    mc.progressBar(mayaMainProgressBar, edit=True, status = ("Wrapping '%s'"%c), step=1)
		    
		    if targetType in ['mesh','nurbsSurface','nurbsCurve']:
			pos = distance.returnWorldSpacePosition(c)
			targetLoc = mc.spaceLocator()
			mc.move (pos[0],pos[1],pos[2], targetLoc[0])

			closestLoc = locators.locClosest([targetLoc[0]],i_target.mNode)
			if self._posOffset:
			    self.doOrientObjToSurface(i_target.mNode,closestLoc)
			    mc.move (self._posOffset[0],self._posOffset[1],self._posOffset[2], [closestLoc], r=True, rpr = True, os = True, wd = True)								
			position.movePointSnap(c,closestLoc)
			mc.delete([targetLoc[0],closestLoc])
			
		gui.doEndMayaProgressBar(mayaMainProgressBar)#Close out this progress bar    
		
	    else:
		pos = False
		if self.b_snaptoSurface:#>>> If our target is surface we can use
		    if targetType in ['mesh','nurbsCurve','nurbsSurface']:
			i_locObj = self.i_obj.doLoc()#Get our position loc
			i_locTarget = cgmMeta.cgmObject( locators.locClosest([i_locObj.mNode],i_target.mNode) )#Loc closest
			#i_locObj.rename('objLoc')
			#i_locTarget.rename('targetLoc')
			if self._posOffset:
			    try:
				self.doOrientObjToSurface(i_target.mNode,i_locTarget.mNode)
				mc.move (self._posOffset[0],self._posOffset[1],self._posOffset[2], [i_locTarget.mNode], r=True, rpr = True, os = True, wd = True)								
			    except StandardError,error:
				log.warn("self._posOffset failure!")
				log.error(error)
			
			pos = i_locTarget.getPosition(True)
			i_locObj.delete()
			i_locTarget.delete()
		elif self.b_midSurfacePos:
		    log.debug("Snap.move>>> midSurfacePos mode!")
		    if targetType not in ['mesh','nurbsCurve','nurbsSurface']:
			log.warning("Can't do midSurfacPos on targetType: '%s'"%targetType)
			return False
		    #Get the axis info
		    axisToCheck = kws.pop('axisToCheck',False)
		    if not axisToCheck:
			axisToCheck = []		    
			up = dictionary.returnVectorToString(self._upVector) or False
			if not up:
			    raise StandardError,"SnapFactory>>> must have up vector for midSurfaceSnap: %s"%self._upVector
			for a in ['x','y','z']:
			    if a != up[0]:
				axisToCheck.append(a)
			if not axisToCheck:
			    raise StandardError,"SnapFactory>>> couldn't find any axis to do"
		    #i_locObj = self.i_obj.doLoc()#Get our position loc		
		    #log.debug(axisToCheck)
		    pos = RayCast.findMeshMidPointFromObject(i_target.mNode, self.i_obj.mNode, axisToCheck=axisToCheck,**kws)
		    #i_locObj.delete()
		    
		else:
		    pos = i_target.getPosition(True)	    
		if pos:
		    if self.i_obj.isComponent():
			if self.b_softSelection:#Only need to do this if soft select is on
			    mc.softSelect(softSelectEnabled = True)
			    mc.select(self.i_obj.getComponent())
			    mc.move (pos[0],pos[1],pos[2],rpr=True)
			    mc.select(cl=True)
			else:
			    mc.move (pos[0],pos[1],pos[2], self.i_obj.getComponent())	    		    
		    else:
			mc.move (pos[0],pos[1],pos[2], self.i_obj.mNode, rpr=True)	    
示例#8
0
    def doMove(self, **kws):
        if kws: log.debug("Snap.doMove>>> kws: %s" % kws)
        if len(self.l_targets) == 1:
            #>>> Check our target
            i_target = cgmMeta.cgmNode(self.l_targets[0])
            log.debug("i_target: %s" % i_target)
            targetType = i_target.getMayaType()

            if self.b_snapComponents:
                components = self.i_obj.getComponents()
                if not components:
                    raise StandardError, "This objects has no components to snap: '%s'" % self.i_obj.getShortName(
                    )
                #>>>Progress bar
                mayaMainProgressBar = gui.doStartMayaProgressBar(
                    len(components))
                for c in components:
                    if mc.progressBar(mayaMainProgressBar,
                                      query=True,
                                      isCancelled=True):
                        break
                    mc.progressBar(mayaMainProgressBar,
                                   edit=True,
                                   status=("Wrapping '%s'" % c),
                                   step=1)

                    if targetType in ['mesh', 'nurbsSurface', 'nurbsCurve']:
                        pos = distance.returnWorldSpacePosition(c)
                        targetLoc = mc.spaceLocator()
                        mc.move(pos[0], pos[1], pos[2], targetLoc[0])

                        closestLoc = locators.locClosest([targetLoc[0]],
                                                         i_target.mNode)
                        if self._posOffset:
                            self.doOrientObjToSurface(i_target.mNode,
                                                      closestLoc)
                            mc.move(self._posOffset[0],
                                    self._posOffset[1],
                                    self._posOffset[2], [closestLoc],
                                    r=True,
                                    rpr=True,
                                    os=True,
                                    wd=True)
                        position.movePointSnap(c, closestLoc)
                        mc.delete([targetLoc[0], closestLoc])

                gui.doEndMayaProgressBar(
                    mayaMainProgressBar)  #Close out this progress bar

            else:
                pos = False
                if self.b_snaptoSurface:  #>>> If our target is surface we can use
                    if targetType in ['mesh', 'nurbsCurve', 'nurbsSurface']:
                        i_locObj = self.i_obj.doLoc()  #Get our position loc
                        i_locTarget = cgmMeta.cgmObject(
                            locators.locClosest([i_locObj.mNode],
                                                i_target.mNode))  #Loc closest
                        #i_locObj.rename('objLoc')
                        #i_locTarget.rename('targetLoc')
                        if self._posOffset:
                            try:
                                self.doOrientObjToSurface(
                                    i_target.mNode, i_locTarget.mNode)
                                mc.move(self._posOffset[0],
                                        self._posOffset[1],
                                        self._posOffset[2],
                                        [i_locTarget.mNode],
                                        r=True,
                                        rpr=True,
                                        os=True,
                                        wd=True)
                            except StandardError, error:
                                log.warn("self._posOffset failure!")
                                log.error(error)

                        pos = i_locTarget.getPosition(True)
                        i_locObj.delete()
                        i_locTarget.delete()
                elif self.b_midSurfacePos:
                    log.debug("Snap.move>>> midSurfacePos mode!")
                    if targetType not in [
                            'mesh', 'nurbsCurve', 'nurbsSurface'
                    ]:
                        log.warning(
                            "Can't do midSurfacPos on targetType: '%s'" %
                            targetType)
                        return False
                    #Get the axis info
                    axisToCheck = kws.pop('axisToCheck', False)
                    if not axisToCheck:
                        axisToCheck = []
                        up = dictionary.returnVectorToString(
                            self._upVector) or False
                        if not up:
                            raise StandardError, "SnapFactory>>> must have up vector for midSurfaceSnap: %s" % self._upVector
                        for a in ['x', 'y', 'z']:
                            if a != up[0]:
                                axisToCheck.append(a)
                        if not axisToCheck:
                            raise StandardError, "SnapFactory>>> couldn't find any axis to do"
                    #i_locObj = self.i_obj.doLoc()#Get our position loc
                    #log.debug(axisToCheck)
                    pos = RayCast.findMeshMidPointFromObject(
                        i_target.mNode,
                        self.i_obj.mNode,
                        axisToCheck=axisToCheck,
                        **kws)
                    #i_locObj.delete()

                else:
                    pos = i_target.getPosition(True)
                if pos:
                    if self.i_obj.isComponent():
                        if self.b_softSelection:  #Only need to do this if soft select is on
                            mc.softSelect(softSelectEnabled=True)
                            mc.select(self.i_obj.getComponent())
                            mc.move(pos[0], pos[1], pos[2], rpr=True)
                            mc.select(cl=True)
                        else:
                            mc.move(pos[0], pos[1], pos[2],
                                    self.i_obj.getComponent())
                    else:
                        mc.move(pos[0],
                                pos[1],
                                pos[2],
                                self.i_obj.mNode,
                                rpr=True)
示例#9
0
def rigSpine (crvName,tailCntrlJoints,waveControlObject,splitJoints):
    """ Rebuild curve - with actual curve in it!"""
    """ first have to make our reg spine""" 
    mc.rebuildCurve (crvName, ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(splitJoints), d=1, tol=5)
    """ Make joint chains"""
    spineJoints = joints.createJointsFromCurve (crvName,'spine')
    """ set joint radius """
    joints.setGoodJointRadius (spineJoints,1)
    """ Orienting the joint chain """
    joints.orientJointChain (spineJoints, 'xyz', 'zup')
    
    """ Renaming the joint chain """
    spineJointsBuffer = names.renameJointChainList (spineJoints, 'tailStart', 'tail')
    spineJoints = spineJointsBuffer
    """ removing initial bind from the spine curve """
    mc.delete ('bindPose1')
    mc.delete ('skinCluster1')
    """ Makes our control surface """
    controlSurface = makeJointControlSurfaceFish(spineJoints[0],tailCntrlJoints,'y','tail')
    """ parenting the tail joints """
    rigging.parentListToHeirarchy (tailCntrlJoints)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>auto swim stuff
    """ Creating our deformation surface """
    deformMeshBuffer = mc.duplicate (controlSurface)
    deformMesh = mc.rename (deformMeshBuffer[0],(controlSurface[0]+'_defmesh'))
    """ Creates  our wave deformer """
    deformerBuffer = mc.nonLinear (deformMesh, type = 'wave', name = 'swimWave')
    waveDeformer = mc.rename (deformerBuffer[0], 'waveDeformer')
    waveDeformerHandle = mc.rename (deformerBuffer[1], 'waveDeformerHandle')
    """ move the handle """
    position.movePointSnap (waveDeformerHandle,spineJoints[0])
    mc.setAttr ((waveDeformerHandle+'.rx'),90)
    mc.setAttr ((waveDeformerHandle+'.ry'),90)
    """ set some variables """
    mc.setAttr ((waveDeformer+'.dropoff'),1)
    mc.setAttr ((waveDeformer+'.dropoffPosition'),1)
    mc.setAttr ((waveDeformer+'.maxRadius'),2)
    """ make our blendshape node and reorder things"""
    blendshapeNode = mc.blendShape (deformMesh, controlSurface[0], name = 'swim_bsNode' )
    mc.reorderDeformers ("tweak2", blendshapeNode[0],controlSurface[0])
    """ add some attrs to our wave control object """
    attributes.addSectionBreakAttrToObj (waveControlObject, 'swim')
    attributes.addFloatAttributeToObject (waveControlObject, 'auto', min = 0, max = 1, dv =0)
    attributes.addFloatAttributeToObject (waveControlObject, 'speed', -100, 100, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'wavelength', 0, 10, 5)
    attributes.addFloatAttributeToObject (waveControlObject, 'amplitude', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoff', 0, 1, 1)
    attributes.addFloatAttributeToObject (waveControlObject, 'dropoffPosition', 0, 1, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'minRadius', 0, 10, 0)
    attributes.addFloatAttributeToObject (waveControlObject, 'maxRadius', 0, 10, 10)
    """ connect a few attrs """
    mc.connectAttr ((waveControlObject+'.auto'),(blendshapeNode[0]+'.'+deformMesh))
    mc.connectAttr ((waveControlObject+'.wavelength'),(waveDeformer+'.wavelength'))
    mc.connectAttr ((waveControlObject+'.amplitude'),(waveDeformer+'.amplitude'))
    mc.connectAttr ((waveControlObject+'.dropoff'),(waveDeformer+'.dropoff'))
    mc.connectAttr ((waveControlObject+'.dropoffPosition'),(waveDeformer+'.dropoffPosition'))
    mc.connectAttr ((waveControlObject+'.minRadius'),(waveDeformer+'.minRadius'))
    mc.connectAttr ((waveControlObject+'.maxRadius'),(waveDeformer+'.maxRadius'))
    """ set some good base values """
    mc.setAttr ((waveControlObject+'.speed'),1)
    mc.setAttr ((waveControlObject+'.wavelength'),4)
    mc.setAttr ((waveControlObject+'.amplitude'),.3)
    mc.setAttr ((waveControlObject+'.dropoff'),1)
    mc.setAttr ((waveControlObject+'.dropoffPosition'),1)
    mc.setAttr ((waveControlObject+'.maxRadius'),2)
    """ sets up swim speed """
    nodes.offsetCycleSpeedControlNodeSetup (waveDeformer,(waveControlObject+'.speed'),90,-10)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Head control and joint
    headJointBuffer = mc.duplicate ('head_anim')
    headJoint = mc.rename (headJointBuffer, 'head_jnt')
    headCtrlGrp = rigging.groupMeObject ('head_anim',True)
    #mc.parent (headJoint, spineJoints[0])
    mc.parent (headJoint, 'move_anim')
    contsBuffer = mc.parentConstraint (spineJoints[0], headCtrlGrp, maintainOffset = True)
    mc.rename (contsBuffer,(headCtrlGrp+'_prntConst'))
    contsBuffer = mc.parentConstraint ('head_anim', headJoint, maintainOffset = True)
    mc.rename (contsBuffer,(headJoint+'_prntConst'))
    mc.parent (headCtrlGrp,'move_anim')
    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Clean stuff
    """ deform group """
    deformGrp = mc.group (n= 'swimDeform_grp', w=True, empty=True)
    mc.parent (waveDeformerHandle,deformGrp)
    mc.parent (deformMesh,deformGrp)
    mc.setAttr ((deformGrp+'.v'), 0)
    mc.setAttr ((controlSurface[0]+'.v'),0)
    """ delete placement stuff """
    mc.delete ('curvePlacementStuff')
    mc.parent (tailCntrlJoints[0],waveControlObject)
    mc.parent (deformGrp, 'rigStuff_grp')

    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Ctrl Joints to Ctrls
    ctrlSize = (distance.returnAverageDistanceBetweenObjects (tailCntrlJoints))
    curves.parentShape ('head_anim', 'sampleCtrlZ')
    for ctrl in tailCntrlJoints:
        rigging.makeObjCtrl (ctrl,ctrlSize)
 
    #>>>>>>>>>>>>>>>>>>>>>Store skin joint data
    """ check for master skin info group """
    name = 'spine'
    if mc.objExists ('master_skinJntList_grp'):
        masterSkinJointList = ('master_skinJntList_grp')
    else:
        masterSkinJointList = mc.group (n= ('master_skinJntList_grp'), w=True, empty=True)
        mc.parent(masterSkinJointList,'rigStuff_grp')
    """ check for segment skin info group """
    if mc.objExists (name+'_skinJntList_grp'):
        skinJointList = (name+'_skinJntList_grp')
    else:
        skinJointList = mc.group (n= (name+'_skinJntList_grp'), w=True, empty=True)
    mc.parent (skinJointList,masterSkinJointList)
    attributes.storeObjNameToMessage (skinJointList,masterSkinJointList)
    """ store the skin joint data """
    for jnt in spineJoints:
        attributes.storeObjNameToMessage (jnt,skinJointList)
    attributes.storeObjNameToMessage (headJoint,skinJointList)
示例#10
0
def surfRigger(objectNull,anchor,worldScale,mirror,mode,jointsPerChain,deformChains,ctrlChains):
    """ Get variables"""
    nullBase = names.stripSuffixObj (objectNull)
    templateNull = (nullBase + '_templateNull')
    moverNull = (nullBase + '_mover')
    templateNullMessageData = []
    templateNullMessageData = attributes.returnMessageAttrs (templateNull)
    templateObjects = []
    coreNamesList = []
    spineJointNumber = int(mc.getAttr (objectNull+'.rollJoints'))
    #spineChainList = search.returnChildrenJoints (spineChain)
    spineChainList = []
    spineChainList.append (anchor)
    jointChains = []
    for set in templateNullMessageData:
        templateObjects.append (set[1])
        coreNamesList.append (set[0])
    #>>>>>>>>>>>>>>>>>>>>>Store skin joint data
    """ check for master skin info group """
    if mc.objExists ('master_skinJntList_grp'):
        masterSkinJointList = ('master_skinJntList_grp')
    else:
        masterSkinJointList = mc.group (n= ('master_skinJntList_grp'), w=True, empty=True)
        mc.parent(masterSkinJointList,'rigStuff_grp')
    """ check for segment skin info group """
    if mc.objExists (nullBase+'_skinJntList_grp'):
        skinJointListGrp = (nullBase+'_skinJntList_grp')
    else:
        skinJointListGrp = mc.group (n= (nullBase+'_skinJntList_grp'), w=True, empty=True)
    attributes.storeObjNameToMessage (skinJointListGrp,masterSkinJointList)
    mc.parent (skinJointListGrp,masterSkinJointList)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """ Rebuild curve - with actual curve in it!"""
    mc.rebuildCurve ((templateObjects[3]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5)
    mc.rebuildCurve ((templateObjects[7]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5)
    mc.rebuildCurve ((templateObjects[11]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=jointsPerChain, d=1, tol=5)
    """ Reverse the curve """
    mc.reverseCurve ((templateObjects[3]),ch=False,rpo=True)
    mc.reverseCurve ((templateObjects[7]),ch=False,rpo=True)
    mc.reverseCurve ((templateObjects[11]),ch=False,rpo=True)
    """ loft our surface to figure out joint positions, then delete it"""
    controlSurface = mc.loft ([templateObjects[3],templateObjects[7],templateObjects[11]],name=(nullBase+'_surf'),ss=(ctrlChains-mode),ch=1,u=1,c=0,ar=1,d=3,rn=0,po=0,rsn=True)
    mc.select (cl=True)
    jointChains = joints.createJointChainsFromLoftSurface (nullBase,controlSurface[0],2,False)
    frontChain = jointChains[0]
    backChain = jointChains[-1]
    """ Chain - orienting, sizing """
    for chain in jointChains:
        joints.orientJointChain (chain, 'xyz', 'zup')
        joints.setGoodJointRadius(chain,.5)
    #IF we have mode 0, gotta make a main ctrl
    if mode == 0:
        midChain = []
        if (len(jointChains)) > 3:
            midChain = jointChains[int(len(jointChains)/2)]
        else:
            midChain = jointChains[1]
            jointChains.remove(midChain)
        if ctrlChains > 2:
            masterCtrlBuffer = mc.duplicate (midChain[0],parentOnly=True)
        else:
            masterCtrlBuffer = midChain[0]
            mc.delete (midChain[1])
        masterCtrl = mc.rename (masterCtrlBuffer,(nullBase+'_master_anim'))
        position.movePointSnap(masterCtrl,moverNull)
        """ temp parenting the master control for mirroring purposes """
        spineHookJoint = distance.returnClosestObject (masterCtrl, spineChainList)
        mc.parent (masterCtrl,spineHookJoint)
    mc.delete (controlSurface[0])
    #>>>>>>>>>>>>Parent time
    """ Get closest joint """
    if mode == 0:
        for chain in jointChains:
            mc.parent (chain[0],masterCtrl)
    else:
        for chain in jointChains:
            tailHookJoint = distance.returnClosestObject (chain[0], spineChainList)
            mc.parent (chain[0],tailHookJoint)
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>> Ctrl Joints to Ctrls
    cnt = 0
    for chain in jointChains:
        ctrlSize = (distance.returnAverageDistanceBetweenObjects (chain)/2)
        for jnt in chain[0:-1]:
            rigging.makeObjCtrl (jnt,ctrlSize)
        """ adds our Anim tag """
        chainBuffer = []
        chainBuffer = names.addSuffixList ('anim', chain)
        jointChains[cnt]= chainBuffer
        cnt +=1
    #>>>>>>>>>>>>>>>>>>>Mirroring while getting chain info
    """ If mirroring ...."""
    if mirror == True:
        # if we have a main control
        leftSkinChains = []
        rightSkinChains = []
        masterCtrls = []
        if mode == 0:
            leftChain = []
            rightChain = []
            finHeirarchy = []
            finHeirarchy.append (masterCtrl)
            children = search.returnChildrenJoints (masterCtrl)
            finHeirarchy += children
            leftChain = names.addPrefixList ('left',finHeirarchy)
            masterCtrl = leftChain [0]
            rightChainBuffer = mc.mirrorJoint (masterCtrl,mirrorYZ=True,mirrorBehavior=True, searchReplace =['left','right'])
            rightChainJointBuffer = mc.ls (rightChainBuffer,type='joint')
            rightChain = rightChainJointBuffer
            leftSkinChains.append(leftChain)
            rightSkinChains.append(rightChain)
            masterCtrls.append(leftChain[0])
            masterCtrls.append(rightChain[0])
        else:
            for chain in jointChains:
                leftChain =[]
                leftChain = names.addPrefixList ('left',chain)
                rightChainBuffer = (mc.mirrorJoint (leftChain[0],mirrorYZ=True,mirrorBehavior=True, searchReplace =['left','right']))
                rightChainJointBuffer = mc.ls (rightChainBuffer,type='joint')
                rightChain = rightChainJointBuffer
                rightSkinChains.append (rightChainJointBuffer)
                leftSkinChains.append (leftChain)
        """ complile our chains to lists of skin joints """
        leftSkinJointList=[]
        rightSkinJointList=[]
        for chain in leftSkinChains:
            for jnt in chain:
                leftSkinJointList.append (jnt)
        for chain in rightSkinChains:
            for jnt in chain:
                rightSkinJointList.append (jnt)
        """if we're not mirroring, let's return our skin joints for the deformation surface"""
    else:
        skinJointList = []
        skinChains = []
        for chain in jointChains:
            skinChains.append (chain)
            for jnt in chain:
                skinJointList.append (jnt)
                
    #>>>>>>>>>>>>>>>>>>>>>>>>>>Time to make the deformation surface stuff
    """ Rebuild curve - with actual curve in it!"""
    #mc.rebuildCurve ((templateObjects[3]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(3), d=1, tol=5)
    #mc.rebuildCurve ((templateObjects[7]), ch=0, rpo=1, rt=0, end=0, kr=0, kcp=0, kep=1, kt=0, s=(3), d=1, tol=5)
    """ loft our surface to figure out joint positions, then delete it"""
    deformSurface = mc.loft ([templateObjects[3],templateObjects[7],templateObjects[11]],name=(nullBase+'_surf'),ss=(deformChains-1),ch=0,u=1,c=0,ar=1,d=3,rn=0,po=0,rsn=True)
    if mirror == True:
        deformSurfaceNameBuffer = deformSurface[0]
        """we have a surface to mirror..."""
        surfaceMirrorBuffer = mc.duplicate (deformSurface[0])
        mc.setAttr ((surfaceMirrorBuffer[0]+'.sx'),-1)
        leftBuffer = mc.rename (deformSurface[0],('left_'+deformSurfaceNameBuffer))
        rightBuffer = mc.rename (surfaceMirrorBuffer[0],('right_'+deformSurfaceNameBuffer))
        deformSurface[0]=leftBuffer
        deformSurface.append(rightBuffer)
        leftDeformJointChains = joints.createJointChainsFromLoftSurface (('left_'+nullBase),deformSurface[0],2,False)
        rightDeformJointChains = joints.createJointChainsFromLoftSurface (('right_'+nullBase),deformSurface[1],2,False)
        """ Connecting to surface """
        for chain in leftDeformJointChains:
            attachSurfaceReturn = joints.attachJointChainToSurface (chain,deformSurface[0],'xyz','zup')
            tailHookJoint = distance.returnClosestObject (chain[0], spineChainList)
            """ break the connection so we can parent it"""
            """first return the original thing to follow"""
            parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate'))
            attributes.doBreakConnection (chain[0]+'.translate')
            #mc.parent (chain[0],tailHookJoint)
            """ reconstrain it to the driver"""
            constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True)
            mc.rename (constraintBuffer[0],(chain[0]+'_pointConst'))
            """ store the skin joint data """
            for jnt in chain:
                attributes.storeObjNameToMessage (jnt,skinJointListGrp)

        for chain in rightDeformJointChains:
            attachSurfaceMirrorReturn = joints.attachJointChainToSurface (chain,deformSurface[1],'xyz','zup')
            tailHookJoint = distance.returnClosestObject (chain[0], spineChainList)
            """ break the connection s we can parent it"""
            """first return the original thing to follow"""
            parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate'))
            attributes.doBreakConnection (chain[0]+'.translate')
            #mc.parent (chain[0],tailHookJoint)
            """ reconstrain it to the driver"""
            constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True)
            mc.rename (constraintBuffer[0],(chain[0]+'_pointConst'))
            """ store the skin joint data """
            for jnt in chain:
                attributes.storeObjNameToMessage (jnt,skinJointListGrp)

        """ parent the scale stuff to rig stuff grp"""
        mc.select (cl=True)
        for item in attachSurfaceReturn[0]:
            mc.parent(item,'rigStuff_grp')
        for item in attachSurfaceMirrorReturn[0]:
            mc.parent(item,'rigStuff_grp')
        """ hook up world scale """
        mc.connectAttr (worldScale,attachSurfaceReturn[1])
        mc.connectAttr (worldScale,attachSurfaceMirrorReturn[1])
        #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Skin in the control joints
        """ Time to set skin our surface to our control joints """
        mc.skinCluster (leftSkinJointList,deformSurface[0],tsb=True, n=(deformSurface[0]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1)
        mc.skinCluster (rightSkinJointList,deformSurface[1],tsb=True, n=(deformSurface[1]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1)
    #>>>>>If we,re not mirrored, let's make our deform setup
    else:
        deformJointChains = []
        deformJointChains = joints.createJointChainsFromLoftSurface (nullBase,deformSurface[0],2,False)
        """ Connecting to surface """
        for chain in deformJointChains:
            attachSurfaceReturn = joints.attachJointChainToSurface (chain,deformSurface[0],'xyz','zup')
            tailHookJoint = distance.returnClosestObject (chain[0], spineChainList)
            """ break the connection so we can parent it"""
            """first return the original thing to follow"""
            parentBuffer = attributes.returnDriverObject ((chain[0]+'.translate'))
            attributes.doBreakConnection (chain[0]+'.translate')
            #mc.parent (chain[0],tailHookJoint)
            """ reconstrain it to the driver"""
            constraintBuffer = mc.pointConstraint (parentBuffer,chain[0], maintainOffset = True)
            mc.rename (constraintBuffer[0],(chain[0]+'_pointConst'))
            """ store the skin joint data """
            for jnt in chain:
                attributes.storeObjNameToMessage (jnt,skinJointListGrp)
        """ hook up world scale  """
        partScaleBuffer = attachSurfaceReturn[1]
        mc.connectAttr (worldScale, partScaleBuffer)
        """ parent the scale stuff to rig stuff grp"""
        mc.select (cl=True)
        for item in attachSurfaceReturn[0]:
            mc.parent(item,'rigStuff_grp')
        """ Time to set skin our surface to our control joints """
        mc.skinCluster (skinJointList,deformSurface[0],tsb=True, n=(deformSurface[0]+'_skinCluster'),maximumInfluences = 8, normalizeWeights = 1, dropoffRate=1,smoothWeights=.5,obeyMaxInfluences=True, weight = 1)
        
        
    """ Setting up the joint starts"""
    if mode == 0:
        if mirror == True:
            for ctrl in masterCtrls:
                rigging.makeObjCtrl (ctrl,(ctrlSize*4))
                masterCtrlGrp = rigging.groupMeObject (ctrl,True)
                """ Get closest joint and connect the Cntrl """
                spineHookJoint = distance.returnClosestObject (masterCtrlGrp, spineChainList)
                mc.parent(masterCtrlGrp,spineHookJoint)
        else:
            rigging.makeObjCtrl (masterCtrl,(ctrlSize*4))
            masterCtrlGrp = rigging.groupMeObject (masterCtrl,True)
            """ Get closest joint and connect the Cntrl """
            spineHookJoint = distance.returnClosestObject (masterCtrlGrp, spineChainList)
            mc.parent(masterCtrlGrp,spineHookJoint)
    #else we need to connect the individual chains to the spine
    else:
        if mirror == True:
            for chain in leftSkinChains:
                chainCtrlGrp = rigging.groupMeObject (chain[0],True)
                spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList)
                mc.parent(chainCtrlGrp,spineHookJoint)
            for chain in rightSkinChains:
                chainCtrlGrp = rigging.groupMeObject (chain[0],True)
                spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList)
                mc.parent(chainCtrlGrp,spineHookJoint)
        else:
            for chain in skinChains:
                chainCtrlGrp = rigging.groupMeObject (chain[0],True)
                spineHookJoint = distance.returnClosestObject (chainCtrlGrp, spineChainList)
                mc.parent(chainCtrlGrp,spineHookJoint)
示例#11
0
def doCreateOrientationHelpers(self):
    """ 
    """
    log.debug(">>> addOrientationHelpers")
    assert self.cls == 'TemplateFactory.go',"Not a TemlateFactory.go instance!"
    assert mc.objExists(self.m.mNode),"module no longer exists"
    #Gather limb specific data and check
    #===================================
    #'orientHelpers':'messageSimple',#Orientation helper controls
    #'orientRootHelper':'messageSimple',#Root orienation helper

    helperObjects = []
    helperObjectGroups = []
    returnBuffer = []
    root = self.i_templateNull.getMessage('root')[0]
    objects =  self.i_templateNull.getMessage('controlObjects')
    log.debug(root)
    log.debug(objects)
    log.debug(self.foundDirections)
    
    #>> Create orient root control
    #=============================     
    orientRootSize = (distance.returnBoundingBoxSizeToAverage(root,True)*2.5)    
    i_orientRootControl = cgmMeta.cgmObject( curves.createControlCurve('circleArrow1',orientRootSize) )
    i_orientRootControl.addAttr('mClass','cgmObject',lock=True)
    
    curves.setCurveColorByName(i_orientRootControl.mNode,self.moduleColors[0])
    i_orientRootControl.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug    
    i_orientRootControl.addAttr('cgmType',value = 'templateOrientRoot', attrType = 'string', lock=True)
    i_orientRootControl.doName()
    
    #>>> Store it
    i_orientRootControl.connectParent(self.templateNull,'orientRootHelper','owner')#Connect it to it's object      
    
    #>>> Position and set up follow groups
    position.moveParentSnap(i_orientRootControl.mNode,root)    
    i_orientRootControl.parent = root #parent it to the root
    i_orientRootControl.doGroup(maintain = True)#group while maintainting position
    
    mc.pointConstraint(objects[0],i_orientRootControl.parent,maintainOffset = False)#Point contraint orient control to the first helper object
    mc.aimConstraint(objects[-1],i_orientRootControl.parent,maintainOffset = True, weight = 1, aimVector = [1,0,0], upVector = [0,1,0], worldUpObject = root, worldUpType = 'objectRotation' )
    attributes.doSetLockHideKeyableAttr(i_orientRootControl.mNode,True,False,False,['tx','ty','tz','rx','ry','sx','sy','sz','v'])
    
    self.i_orientHelpers = []#we're gonna store the instances so we can get them all after parenting and what not
    #>> Sub controls
    #============================= 
    if len(objects) == 1:#If a single handle module
        i_obj = cgmMeta.cgmObject(objects[0])
        position.moveOrientSnap(objects[0],root)
    else:
        for i,obj in enumerate(objects):
            log.debug("on %s"%(mc.ls(obj,shortNames=True)[0]))
            #>>> Create and color      
            size = (distance.returnBoundingBoxSizeToAverage(obj,True)*2) # Get size
            i_obj = cgmMeta.cgmObject(curves.createControlCurve('circleArrow2Axis',size))#make the curve
            i_obj.addAttr('mClass','cgmObject',lock=True)
            curves.setCurveColorByName(i_obj.mNode,self.moduleColors[1])
            #>>> Tag and name
            i_obj.doCopyNameTagsFromObject(obj)
            i_obj.doStore('cgmType','templateOrientHelper',True)        
            i_obj.doName()
            
            #>>> Link it to it's object and append list for full store
            i_obj.connectParent(obj,'helper','owner')#Connect it to it's object      
            self.i_orientHelpers.append(i_obj)
            log.debug(i_obj.owner)
            #>>> initial snapping """
            position.movePointSnap(i_obj.mNode,obj)
            
            if i < len(objects)-1:#If we have a pair for it, aim at that pairs aim, otherwise, aim at the second to last object
                constBuffer = mc.aimConstraint(objects[i+1],i_obj.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = self.foundDirections[1], worldUpType = 'vector' )
            else:
                constBuffer = mc.aimConstraint(objects[-2],i_obj.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpVector = self.foundDirections[1], worldUpType = 'vector' )
    
            if constBuffer:mc.delete(constBuffer)
        
            #>>> follow groups
            i_obj.parent = obj
            i_obj.doGroup(maintain = True)
            
            if i < len(objects)-1:#If we have a pair for it, aim at that pairs aim, otherwise, aim at the second to last object
                mc.aimConstraint(objects[i+1],i_obj.parent,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = [0,1,0], worldUpObject = i_orientRootControl.mNode, worldUpType = 'objectrotation' )
            else:
                constBuffer = mc.aimConstraint(objects[-2],i_obj.parent,maintainOffset = False, weight = 1, aimVector = [0,0,-1], upVector = [0,1,0], worldUpObject = i_orientRootControl.mNode, worldUpType = 'objectrotation' )
    
            #>>> ConnectVis, lock and hide
            #mc.connectAttr((visAttr),(helperObj+'.v'))
            if obj == objects[-1]:
                attributes.doSetLockHideKeyableAttr(i_obj.mNode,True,False,False,['tx','ty','tz','ry','sx','sy','sz','v'])            
            else:
                attributes.doSetLockHideKeyableAttr(i_obj.mNode,True,False,False,['tx','ty','tz','rx','ry','sx','sy','sz','v'])
    #>>> Get data ready to go forward
    bufferList = []
    for o in self.i_orientHelpers:
        bufferList.append(o.mNode)
    self.i_templateNull.orientHelpers = bufferList
    self.i_orientRootHelper = i_orientRootControl
    log.debug("orientRootHelper: [%s]"%self.i_templateNull.orientRootHelper.getShortName())   
    log.debug("orientHelpers: %s"%self.i_templateNull.getMessage('orientHelpers'))

    return True
示例#12
0
def doMakeLimbTemplate(self):  
    """
    Self should be a TemplateFactory.go
    """
    """
    returnList = []
    templObjNameList = []
    templHandleList = []
    """
    log.debug(">>> doMakeLimbTemplate")
    assert self.cls == 'TemplateFactory.go',"Not a TemlateFactory.go instance!"
    
    #Gather limb specific data and check
    #==============
    doCurveDegree = getGoodCurveDegree(self)
    if not doCurveDegree:raise ValueError,"Curve degree didn't query"
    
    #>>>Scale stuff
    size = returnModuleBaseSize(self.m)
    
    lastCountSizeMatch = len(self.corePosList) -1
    
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    # Making the template objects
    #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    templHandleList = []
    self.i_controlObjects = []
    self.i_locs = []
    for i,pos in enumerate(self.corePosList):# Don't like this sizing method but it is what it is for now
        #>> Make each of our base handles
        #=============================        
        if i == 0:
            sizeMultiplier = 1
        elif i == lastCountSizeMatch:
            sizeMultiplier = .8
        else:
            sizeMultiplier = .75
        
        #>>> Create and set attributes on the object
        i_obj = cgmMeta.cgmObject( curves.createControlCurve('sphere',(size * sizeMultiplier)) )
        i_obj.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later
        
        curves.setCurveColorByName(i_obj.mNode,self.moduleColors[0])
        
        i_obj.addAttr('cgmName',value = str(self.l_coreNames[i]), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug
        if self.direction != None:
            i_obj.addAttr('cgmDirection',value = self.direction,attrType = 'string',lock=True)  
        i_obj.addAttr('cgmType',value = 'templateObject', attrType = 'string',lock=True) 
        i_obj.doName()#Name it
        
        mc.move (pos[0], pos[1], pos[2], [i_obj.mNode], a=True)
        i_obj.parent = self.templateNull
        
        #>>> Loc it and store the loc
        #i_loc = cgmMeta.cgmObject( i_obj.doLoc() )
        i_loc =  i_obj.doLoc()
        i_loc.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later
        i_loc.addAttr('cgmName',value = self.m.getShortName(), attrType = 'string', lock=True) #Add name tag
        i_loc.addAttr('cgmType',value = 'templateCurveLoc', attrType = 'string', lock=True) #Add Type
        i_loc.v = False # Turn off visibility
        i_loc.doName()
        
        self.i_locs.append(i_loc)
        i_obj.connectChildNode(i_loc.mNode,'curveLoc','owner')
        i_loc.parent = self.templateNull#parent to the templateNull
        
        mc.pointConstraint(i_obj.mNode,i_loc.mNode,maintainOffset = False)#Point contraint loc to the object
                    
        templHandleList.append (i_obj.mNode)
        self.i_controlObjects.append(i_obj)
        
    #>> Make the curve
    #=============================     
    i_crv = cgmMeta.cgmObject( mc.curve (d=doCurveDegree, p = self.corePosList , os=True) )
    i_crv.addAttr('mClass','cgmObject',lock=True)#tag it so it can initialize later
    
    i_crv.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug
    if self.direction != None:
        i_crv.addAttr('cgmDirection',value = self.direction, attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug

    i_crv.addAttr('cgmType',value = 'templateCurve', attrType = 'string', lock=True)
    curves.setCurveColorByName(i_crv.mNode,self.moduleColors[0])
    i_crv.parent = self.templateNull    
    i_crv.doName()
    i_crv.setDrawingOverrideSettings({'overrideEnabled':1,'overrideDisplayType':2},True)
        
    for i,i_obj in enumerate(self.i_controlObjects):#Connect each of our handles ot the cv's of the curve we just made
        mc.connectAttr ( (i_obj.curveLoc.mNode+'.translate') , ('%s%s%i%s' % (i_crv.mNode, '.controlPoints[', i, ']')), f=True )
        
    
    self.foundDirections = returnGeneralDirections(self,templHandleList)
    log.debug("directions: %s"%self.foundDirections )
    
    #>> Create root control
    #=============================  
    rootSize = (distance.returnBoundingBoxSizeToAverage(templHandleList[0],True)*1.25)    
    i_rootControl = cgmMeta.cgmObject( curves.createControlCurve('cube',rootSize) )
    i_rootControl.addAttr('mClass','cgmObject',lock=True)
    
    curves.setCurveColorByName(i_rootControl.mNode,self.moduleColors[0])
    i_rootControl.addAttr('cgmName',value = str(self.m.getShortName()), attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug    
    i_rootControl.addAttr('cgmType',value = 'templateRoot', attrType = 'string', lock=True)
    if self.direction != None:
        i_rootControl.addAttr('cgmDirection',value = self.direction, attrType = 'string', lock=True)#<<<<<<<<<<<FIX THIS str(call) when Mark fixes bug
    i_rootControl.doName()

    #>>> Position it
    if self.m.moduleType in ['clavicle']:
        position.movePointSnap(i_rootControl.mNode,templHandleList[0])
    else:
        position.movePointSnap(i_rootControl.mNode,templHandleList[0])
    
    #See if there's a better way to do this
    log.debug("templHandleList: %s"%templHandleList)
    if self.m.moduleType not in ['foot']:
        if len(templHandleList)>1:
            log.info("setting up constraints...")        
            constBuffer = mc.aimConstraint(templHandleList[-1],i_rootControl.mNode,maintainOffset = False, weight = 1, aimVector = [0,0,1], upVector = [0,1,0], worldUpVector = self.worldUpVector, worldUpType = 'vector' )
            mc.delete (constBuffer[0])    
        elif self.m.getMessage('moduleParent'):
            #parentTemplateObjects =  self.m.moduleParent.templateNull.getMessage('controlObjects')
            helper = self.m.moduleParent.templateNull.controlObjects[-1].helper.mNode
            if helper:
                log.info("helper: %s"%helper)
                constBuffer = mc.orientConstraint( helper,i_rootControl.mNode,maintainOffset = False)
                mc.delete (constBuffer[0])    
    
    i_rootControl.parent = self.templateNull
    i_rootControl.doGroup(maintain=True)
    
    
    #>> Store objects
    #=============================      
    self.i_templateNull.curve = i_crv.mNode
    self.i_templateNull.root = i_rootControl.mNode
    self.i_templateNull.controlObjects = templHandleList
    
    self.i_rootControl = i_rootControl#link to carry

    #>> Orientation helpers
    #=============================      
    """ Make our Orientation Helpers """
    doCreateOrientationHelpers(self)
    doParentControlObjects(self.m)

    #if self.m.getMessage('moduleParent'):#If we have a moduleParent, constrain it
        #constrainToParentModule(self.m)
    return True
示例#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	
示例#14
0
    def getPartBaseDistance(self,PuppetInstance,locator):
        """ 
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        DESCRIPTION:
        Pass  a generated locator (z is forward) from this system and it measures the distance
        to the bounding box edge
        
        ARGUMENTS:
        locator(string)
        meshGroup(string)
        
        RETURNS:
        distance(float)
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        """
        vectorToStringDict = {'x':[1,0,0],'-x':[1,0,0],'y':[0,1,0],'-y':[0,1,0],'z':[0,0,1],'-z':[0,0,1]}

        """ size distance for pivot """
        boundingBoxSize = distance.returnBoundingBoxSize( PuppetInstance.GeoGroup.nameLong )
        boundingBoxSize = cgmMath.multiplyLists([[.5,.5,.5],boundingBoxSize])
        
        """ make our bounding box pivot """
        cgmLoc = locators.centerPivotLocMeObject( PuppetInstance.GeoGroup.nameLong )
        
        """makeour measure loc and snap it to the the cgmLoc"""
        measureLocBuffer = mc.duplicate(locator)
        measureLoc = measureLocBuffer[0]
        position.movePointSnap(measureLoc,cgmLoc)
        
        """ Get it up on the axis with the cgmLoc back to where it was """
        distanceToPivot = mc.xform(measureLoc,q=True, t=True,os=True)
        mc.xform(measureLoc, t= [0,0,distanceToPivot[2]],os=True)
        
        """ figure out our relationship between our locators, which is in front"""
        measureLocPos = mc.xform(measureLoc,q=True, t=True,os=True)
        mainLocPos = mc.xform(locator,q=True, t=True,os=True)
        
        if measureLocPos[2] < mainLocPos[2]:
            distanceCombineMode = 'subtract'
            locOrder = [measureLoc,locator]
        else:
            distanceCombineMode = 'add'
            locOrder = [locator,measureLoc]
            
            """ determine our aim direction """
        aimDirection = logic.returnLinearDirection(locOrder[0],locOrder[1])
        aimVector = vectorToStringDict.get(aimDirection)
        maxIndexMatch =  max(aimVector)
        maxIndex = aimVector.index(maxIndexMatch)
        fullDistance = boundingBoxSize[maxIndex]
        
        """ get some measurements """
        distanceToSubtract = distance.returnDistanceBetweenObjects(locOrder[0],locOrder[1])
        if distanceCombineMode == 'subtract':
            returnDistance = fullDistance - distanceToSubtract
        else:
            returnDistance = fullDistance + distanceToSubtract
        
        mc.delete(measureLoc)
        mc.delete(cgmLoc)
        
        return returnDistance
示例#15
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