示例#1
0
文件: rig.py 项目: jonntd/japeto
    def preBuild(self):
        """
        sets up the hierachry
        """
        # if there is no puppet node in the scene, we will run the setup first
        if not cmds.ls(type="puppet"):
            self.setup()

        if common.isValid(self.rigGrp):
            return True
        # create hierachy
        cmds.createNode("rig", n=self.rigGrp)
        cmds.createNode("transform", n=self.noXformGrp)
        cmds.createNode("transform", n=self.jointsGrp)
        cmds.createNode("transform", n=self.controlsGrp)

        # create shot and trs controls
        control.create(self._shotCtrl.replace("_%s" % common.CONTROL, ""), parent=self.controlsGrp, color=common.WHITE)
        control.create(self._trsCtrl.replace("_%s" % common.CONTROL, ""), parent=self._shotCtrl, color=common.WHITE)
        # get the parents of the controls
        shotZero = common.getParent(self._shotCtrl)
        trsZero = common.getParent(self._trsCtrl)
        cmds.parent(self._shotCtrl, self.controlsGrp)
        cmds.parent(self._trsCtrl, self._shotCtrl)
        control.scaleShape(self._shotCtrl, [2, 2, 2])
        cmds.delete([shotZero, trsZero])
        # cmds.createNode('transform', n = self.modelGroup)

        cmds.parent([self.noXformGrp, self.jointsGrp, self.controlsGrp], self.rigGrp)

        # turn off inherit transforms on the noXformGrp
        cmds.setAttr("%s.inheritsTransform" % self.noXformGrp, 0)

        self.controls.extend([self._shotCtrl, self._trsCtrl])
示例#2
0
文件: leg.py 项目: jonntd/japeto
    def rig(self):
        if super(Leg,self).rig():
            return True

        #create pelvis control
        pelvisCtrl = \
            control.create(name = self.pelvisJoint.replace('_%s' % common.JOINT, ''),
                    type = 'cube',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR[self._getSide()])
        #end loop

        common.setColor(pelvisCtrl, color = common.SIDE_COLOR[self._getSide()])
        pelvisCtrlZero = common.getParent(pelvisCtrl)
        transform.matchXform(self.pelvisJoint, pelvisCtrlZero, type = 'pose')
        cmds.parentConstraint(pelvisCtrl, self.pelvisJoint, mo = True)

        #parent fkCtrls under the pelvis control
        cmds.parent(common.getParent(self.controls['fk'][0]), pelvisCtrl)

        #parent constraint ik/fk joints to the pelvis control
        cmds.parentConstraint(self.pelvisJoint,self.joints['ik'][0], mo = True)
        cmds.parentConstraint(self.pelvisJoint, self.joints['target'][0], mo = True)

        #add joints to the joints dictionary
        self.joints['fk'].insert(0, self.pelvisJoint)

        #add controls to the control dictionary
        self.controls['fk'].insert(0,pelvisCtrl)


        self.hookRoot.pop(0)
        self.hookRoot.insert(0, pelvisCtrlZero)
示例#3
0
文件: arm.py 项目: jonntd/japeto
	def rig(self):
		if super(Arm,self).rig():
			return True
		'''
		if common.isValid(self.clavicleJoint.replace('_%s' % common.JOINT,common.CONTROL)):
			return True
		'''
		#create pelvis control
		clavicleCtrl = control.create(
							name = self.clavicleJoint.replace('_%s' % common.JOINT,''),
							type = 'cube',
							parent = self.controlsGrp,
							color = common.SIDE_COLOR[self._getSide()])
		
		common.setColor(clavicleCtrl, color = common.SIDE_COLOR[self._getSide()])
		clavicleCtrlZero = common.getParent(clavicleCtrl)
		transform.matchXform(self.clavicleJoint, clavicleCtrlZero, type = 'pose')
		cmds.parentConstraint(clavicleCtrl, self.clavicleJoint, mo = True)
		
		#parent fkCtrls under the pelvis control
		cmds.parent(common.getParent(self.controls['fk'][0]), clavicleCtrl)
		
		#parent constraint ik/fk joints to the pelvis control
		cmds.parentConstraint(self.clavicleJoint,self.joints['ik'][0], mo = True)
		cmds.parentConstraint(self.clavicleJoint, self.joints['target'][0], mo = True)
		
		#add joints to the joints dictionary
		self.joints['fk'].insert(0, self.clavicleJoint)
		
		#add controls to the control dictionary
		self.controls['fk'].insert(0,clavicleCtrl)
		
		
		self.hookRoot.pop(0)
		self.hookRoot.insert(0, clavicleCtrlZero)
示例#4
0
文件: arm.py 项目: jonntd/japeto
	def setupRig(self):
		if super(Arm,self).setupRig():
			return True
		
		self.skinClusterJnts.remove(self.endJoint)
		self.skinClusterJnts.insert(0,self.clavicleJoint)
		
		#delete end joint and end guide
		endJntGuide = self.endJoint.replace(common.JOINT, common.GUIDES)
		if common.isValid(self.endJoint):
			cmds.delete(self.endJoint)
		if common.isValid(endJntGuide):
			cmds.delete(endJntGuide)
			

		if self._getSide() == common.LEFT:
			positions = (
				[self.position[0] + .5, self.position[1], self.position[2] + 1],
				[self.position[0] + 2, self.position[1], self.position[2]],
				[self.position[0] + 5, self.position[1], self.position[2] - 1],
				[self.position[0] + 8, self.position[1], self.position[2]]
				)
		elif self._getSide() == common.RIGHT:
			positions = (
				[self.position[0] + -.5, self.position[1], self.position[2] + 1],
				[self.position[0] - 2, self.position[1], self.position[2]],
				[self.position[0] - 5, self.position[1], self.position[2] - 1],
				[self.position[0] - 8, self.position[1], self.position[2]]
				)
		else:
			positions = (
				[self.position[0] + .5, self.position[1], self.position[2] + 1],
				[self.position[0] + 2, self.position[1], self.position[2]],
				[self.position[0] + 5, self.position[1], self.position[2] - 1],
				[self.position[0] + 8, self.position[1], self.position[2]]
				)


		#create pelvis joint and parent leg under pelvis
		if not common.isValid(self.clavicleJoint):
			joint.create(name = self.clavicleJoint, parent = self.skeletonGrp, position = positions[0])
		
		cmds.parent(self.startJoint, self.clavicleJoint)
		
		#declare guides
		clavicleJointGuide = self.setupCtrl(self.clavicleJoint.replace('_%s' % common.JOINT, ''),self.clavicleJoint)
		startJointGuide  = self.startJoint.replace(common.JOINT, common.GUIDES)
		midJointGuide    = self.midJoint.replace(common.JOINT, common.GUIDES)
		tipJointGuide    = self.tipJoint.replace(common.JOINT, common.GUIDES)
		
		#move master guide to clavicle position
		for i, guide in enumerate([clavicleJointGuide,startJointGuide,midJointGuide, tipJointGuide]):
			zeroGroup = common.getParent(guide)
			if i == 0:
				cmds.xform(common.getParent(self.masterGuide), ws = True, t = positions[i])
			cmds.xform(zeroGroup, ws = True, t = positions[i])
示例#5
0
文件: finger.py 项目: jonntd/japeto
    def setupRig(self):
        if super(Finger, self).setupRig():
            return True

        if self._getSide() == common.LEFT:
            cmds.xform(common.getParent(self.endJoint.replace(common.JOINT, common.GUIDES)), r = True, t = [-4.0, 0, 0])
        elif self._getSide() == common.RIGHT:
            cmds.xform(common.getParent(self.endJoint.replace(common.JOINT, common.GUIDES)), r = True, t = [4.0, 0, 0])
        else:
            cmds.xform(common.getParent(self.endJoint.replace(common.JOINT, common.GUIDES)), r = True, t = [0.0, 4.0, 0])
示例#6
0
 def setupRig(self):
     if common.isValid(self.name()):
         return True
     
     self.setupConstraints = []
     #makes component a puppet node
     self.puppetNode = puppet.create(self.name())
     
     #Create master guide control and 
     control.createSetup('{0}_master'.format(self.name()), type = 'square')
     common.setColor(self.masterGuide, 'darkred')
     
     #create hierarchy
     cmds.createNode('transform', n = self.setupRigGrp)
     cmds.createNode('transform', n = self.skeletonGrp)
     cmds.createNode('transform', n = self.guidesGrp)
     
     cmds.parent(self.skeletonGrp, self.setupRigGrp)
     cmds.parent(self.guidesGrp, self.setupRigGrp)
     cmds.parent(common.getParent(self.masterGuide),self.guidesGrp)
     
     #add attributes to groups
     attribute.addAttr(self.setupRigGrp, 'tag_guides', attrType = 'message')
     masterGuideAttr = attribute.addAttr(self.setupRigGrp, 'master_guide', attrType = 'message')
     attribute.connect(masterGuideAttr, '%s.tag_controls' % self.masterGuide)
示例#7
0
文件: spine.py 项目: jonntd/japeto
 def postRig(self):
     if super(Spine, self).postRig():
         return True
     
     cmds.setAttr('%s.ikfk' % self.ikFkGroup, 0)
     
     cmds.setAttr('%s.v' % self.curve.fullPathName,0)
     cmds.setAttr('%s.v' % self.__spineIkFk.ikHandle,0)
     
     #add roots and point hooks
     self.hookRoot.pop(0)
     self.hookRoot.insert(0,common.getParent(self.controls['ik']))
     
     for jnt in self.__spineIkFk.splineJoints:
         cmds.setAttr('%s.v' % jnt, 0)
     
     for jnt in self.__spineIkFk.driverJoints:
         cmds.setAttr('%s.v' % common.getParent(jnt), 0)
示例#8
0
文件: neck.py 项目: jonntd/japeto
 def setupRig(self):
     '''
     ..todo: still need to flesh out setup for neck
     '''
     if super(Neck, self).setupRig():
         return True
     
     endJointGuide   = self.endJoint.replace(common.JOINT, common.GUIDES)
     if not cmds.objExists(endJointGuide):
         return
     
     cmds.xform(common.getParent(endJointGuide), ws = True, r = True, t = [0,-5, 0])
示例#9
0
文件: joint.py 项目: jonntd/japeto
def save( node, filepath=None ):
    '''Save the following attributes from the joint: translate, rotate, scale, rotateAxis, rotateOrder, jointOrient, radius, drawStyle, parent


    .. python ::
        save( 'joint1' )
        # Result: "/var/tmp/joints.pyson"

        save( cmds.ls( type='joint'), '/var/tmp/bipedSkeleton.joints' )
        # Result: "/var/tmp/bipedSkeleton.joints"
    
    :param node: Node(s) you want to export
    :type node: **str** or **list**
    :param filepath: Filepath to save the file. If None will use the OS temporary directory.
    :type filepath: **str** or **list**
    '''

    # Get filepath
    if filepath == None:
        filepath = os.path.join( tempfile.gettempdir(), 'joints.pyson' )
    
    # Get nodes
    data  = ordereddict.OrderedDict()
    nodes = common.toList( node )

    # Loop through nodes
    for node in nodes:
        
        # Check object
        if not cmds.objectType( node ) == 'joint':
            continue
        
        # Node entries
        data[node] = ordereddict.OrderedDict()
        data[node]['parameters']  = ordereddict.OrderedDict()

        # Store transformation
        for attr in ['translate', 'rotate', 'scale', 'rotateAxis', 'jointOrient', 'rotateOrder', 'radius', 'drawStyle']:
            if attribute.isCompound(attr, node ):
                data[node]['parameters'][attr] = attribute.getValue( attr, node )[0]
            else:
                data[node]['parameters'][attr] = attribute.getValue( attr, node )
        
        # Store parent
        data[node]['parent'] = common.getParent( node )

        # World Position
        data[node]['worldPosition'] = cmds.xform( node, q=True, ws=True, rp=True )
        
    # Save data
    pyon.save( data, filepath )
    return filepath
示例#10
0
文件: spine.py 项目: jonntd/japeto
 def _ikControlSetup(self, drivers):
     '''
     Takes driver joints that drive the IK spine and create controls for them
     
     @param drivers: list of drivers you want to put controls on
     @type drivers: *list* or *tuple* or *str* 
     
     @return: IK controls which were created to drive the driver joints passed in
     @rtype: *list*
     '''
     #create an empty list to store ik controls in so we can return them
     ikControls = list()
     
     drivers = common.toList(drivers)
     
     for i,driver in enumerate(drivers):
         nameDescription = common.getDescription(driver)
         ctrlName = '%s_%s_%s' % (self._getSide(),nameDescription,common.IK)
         ctrl = control.create(ctrlName, type = 'cube',
                               parent = self.controlsGrp,
                               color = common.SIDE_COLOR[self._getSide()])
         ctrlZero = common.getParent(ctrl)
         #driverParent = common.getParent(driver)
         #move control in to position of driver jnt
         transform.matchXform(driver, ctrlZero, 'pose')
         #cmds.parent(ctrlZero, driverParent)
         #cmds.parent(driver, ctrl)
         cmds.parentConstraint(ctrl, driver,mo = True)
         
         
         #connect ik/fk attr from group to  visibility of shapes
         reverse = cmds.createNode('reverse', n = '%s_%s_%s' % (self.name(),
                                                             common.IK,
                                                             common.REVERSE
                                                             ))
         attribute.connect('%s.ikfk' % self.ikFkGroup,'%s.inputX' % reverse)
         for shape in common.getShapes(ctrl):
             if self.ikFkGroup:
                 attribute.connect('%s.outputX' % reverse,
                                   '%s.v' % shape)
             #end if
         #end loop
         
         ikControls.append(ctrl)
         
         
         
     #end loop
         
     return ikControls
     
示例#11
0
文件: chain.py 项目: jonntd/japeto
    def postRig(self):
        if super(Chain, self).postRig():
            return True
        
        #parent ikfk group to the rig grp
        cmds.parent(self.ikFkGroup, self.jointsGrp)
        
        cmds.setAttr('%s.ikfk' % self.ikFkGroup, 1) #<--- might change to IK
        
        #turn off visibility of joints
        for jnt in [self.fkJoints[0], self.ikJoints[0],self.blendJoints[0]]:
            cmds.setAttr('%s.v' % jnt, 0)

        #assign hooks
        self.hookRoot.extend([self.ikJoints[0],common.getParent(self.controls['fk'][0])])
        self.hookPoint.extend([self.blendJoints[-1]])
示例#12
0
文件: spine.py 项目: jonntd/japeto
 def rig(self):
     if component.Component.rig(self):
         return True
     
     self.__spineIkFk = ikfk.SplineIk(self.startJoint,
         self.endJoint,
         name = self.name())
     
     if self.numControls == 2:
         self.__spineIkFk.create([0, -1])
     elif self.numControls == 3:
         self.__spineIkFk.create([0, 2, -1])
         #torsoDriverJnt = self.__spineIkFk.driverJoints[1] 
     
     self.ikFkGroup    = self.__spineIkFk.group
     self.curve        = self.__spineIkFk.curve
     #ikHipJnt          = self.__spineIkFk.ikJoints[0]
     #ikChest           = self.__spineIkFk.ikJoints[-1]
     self.ikJoints     = self.__spineIkFk.ikJoints
     self.fkJoints     = self.__spineIkFk.fkJoints
     self.blendJoints  = self.__spineIkFk.blendJoints
     self.driverJoints = self.__spineIkFk.driverJoints
     #upAxis            = self.__spineIkFk.upAxis
     aimAxis           = self.__spineIkFk.aimAxis
     #hipDriverJnt      = self.__spineIkFk.driverJoints[0]
     #chestDriverJnt    = self.__spineIkFk.driverJoints[-1]
     
     #FK Control Setup
     self.controls['fk'] = self._fkControlSetup(self.__spineIkFk.fkJoints)    
     
     #IK Controls setup
     self.controls['ik'] = self._ikControlSetup(self.driverJoints)
     
     if len(self.controls['ik']) == 3:
         cmds.pointConstraint(self.controls['ik'][0],
                              self.controls['ik'][-1],
                              common.getParent(self.controls['ik'][1]),
                              mo = True)
     #end if
     
     #stretch spine
     ikfk.IkFkSpline.addParametricStretch(crv= self.curve.name,
                                          scaleCompensate= False,
                                          scaleAxis= aimAxis,uniform= False,
                                          useTranslationStretch= False)
示例#13
0
 def setupCtrl(self, name, obj, color = None):
     '''
     :param name: The name of control created
     :type name: *str*	
     
     :param obj: object to be controled
     :type obj: str
     
     :param color: object to be controled
     :type color: str
     
     :return: Guide control
     :rtype: str	
     '''
     #create hierarchy
     guideZero = cmds.createNode('transform', n = '%s_%s' % (name, common.ZERO))
     guideShape = cmds.createNode('implicitSphere',n = '%s_%sShape' % (name,common.GUIDES))
     guide = common.getParent(guideShape)
     guide = cmds.rename(guide, name + '_' + common.GUIDES)
     
     #set color
     if color:
         common.setColor(guideShape, color)
     else:
         common.setColor(guideShape, common.SIDE_COLOR[self._getSide()])
     
     #parent guide to zero group
     cmds.parent(guide, guideZero)
     
     cmds.delete(cmds.parentConstraint(obj, guideZero, mo = False))
     
     constraint = cmds.pointConstraint(guide, obj)
     
     cmds.parent([guideZero, constraint[0]],self.masterGuide)
     
     #lock and hide attributes
     attribute.lockAndHide(['r','s', 'v'], guide)
     
     #tag the guide control with a tag_guides attribute
     tagAttr = attribute.addAttr(guide, 'tag_guides', attrType = 'message')
     
     #connect attribute to the setupRigGrp
     attribute.connect('%s.tag_guides' % self.setupRigGrp, tagAttr)
     
     return guide
示例#14
0
文件: chain.py 项目: jonntd/japeto
    def _fkControlSetup(self, joints):
        '''
        Creates FK control setup on the input joints
        
        Example:
            ...python:
                    self._fkControlSetup(["jnt1", "jnt2", "jnt3"])
                    #Return: ["ctrl1", "ctrl2", "ctrl3"]
                    
        :param joints: Joints to have controls drive
        :type joints: *list* or *tupple* or *str*
        
        
        '''
        joints = common.toList(joints)
        
        if not isinstance(joints, list) and not isinstance(joints, tuple):
            raise RuntimeError('%s must be a *list* or *tuple*' % joints)
        
        fkCtrls = list()
        parent = self.controlsGrp

        for jnt in joints:            
            ctrl = control.create(name= jnt.split('_%s' % common.JOINT)[0],
                    type = 'circle',
                    parent = parent,
                    color = common.SIDE_COLOR[self._getSide()])

            ctrlParent = common.getParent(ctrl)
            transform.matchXform(jnt, ctrlParent, type = 'pose')
            cmds.parentConstraint(ctrl, jnt, mo = True) #----> might change this to connect rotations and not use translation
            
            #connect visibility of shapes to foot control
            for shape in common.getShapes(ctrl):
                if self.ikFkGroup:
                    attribute.connect('%s.ikfk' % self.ikFkGroup,
                                      '%s.v' % shape)
                #end if
            #end loop

            parent = ctrl
            fkCtrls.append(ctrl)
        #end loop
            
        return fkCtrls
示例#15
0
文件: hand.py 项目: jonntd/japeto
    def postRig(self):
        if super(Hand, self).postRig():
            return True

        #TODO: Place build code for fingers here
        for obj in self.fingers:
            self.__fingers[obj].postRig()
            self.skinClusterJnts.extend(self.__fingers[obj].skinClusterJnts)
            #assign hooks
            self.hookRoot.extend(self.__fingers[obj].hookRoot)

        cmds.delete(self.handJoint)

        self.hookRoot.append(common.getParent(self.__handCtrl))
        attribute.lockAndHide(['t', 'r', 's', 'v'], self.__handCtrl)

        
        
        
示例#16
0
文件: hand.py 项目: jonntd/japeto
 def rig(self):
     if not self._puppetNode:
         self.runSetupRig()
     #TODO: Place build code for fingers here
     for obj in self.fingers:
         self.__fingers[obj].rig()
     
     if super(Hand, self).rig():
         return True
     
     #TODO: Put build code here
     control.create(self.handCtrl.replace('_%s' % common.CONTROL, ''),
                    type = 'implicitSphere',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR[self._getSide()])
     
     for i in range(len(common.getShapes(self.handCtrl))):
         control.scaleShape (self.handCtrl,scale = [.3,.3,.3],index = i)
     #end loop
     handCtrlZero = common.getParent(self.handCtrl)
     transform.matchXform(self.handJoint,handCtrlZero, 'pose')
     #cmds.xform(handCtrlZero, ws = True, t = self.handPosition)
     cmds.xform(handCtrlZero, ws = True, r = True, t = [0,1,0])
示例#17
0
文件: hand.py 项目: jonntd/japeto
    def setupRig(self):
        if super(Hand, self).setupRig():
            return True
        

        if self._getSide() == common.LEFT:
        #move master  guide into position
            cmds.xform(common.getParent(self.masterGuide), ws = True,
                       t = self.handPosition)

            for i,obj in enumerate(self.fingers):
                self.__fingers[obj] = finger.Finger('%s_%s' % (self._getPrefix(),
                                                               obj))
                self.__fingers[obj].initialize(numJoints = self.numJoints,
                                               position=[self.position[0] + 10,
                                                 self.position[1],
                                                 (self.position[2] + 2 )- i],
                                               parent = self.parent)
                self.__fingers[obj].setupRig()

                cmds.parentConstraint(self.masterGuide,
                            common.getParent(self.__fingers[obj].masterGuide),
                            mo = True)
                for guide in self.__fingers[obj].getGuides():
                    #tag the guide control with a tag_guides attribute
                    tagAttr = attribute.addAttr(guide, 'hand_guides',
                                                attrType = 'message')
                    attribute.connect('%s.tag_guides' % self.setupRigGrp,
                                      tagAttr)
                #end loop
            #end loop
        #end if

        elif self._getSide() == common.RIGHT:
        #move master  guide into position
            cmds.xform(common.getParent(self.masterGuide), ws = True, t = self.handPosition)

            for i,obj in enumerate(self.fingers):
                self.__fingers[obj] = finger.Finger('%s_%s' % (self._getPrefix(), obj))
                self.__fingers[obj].initialize(numJoints = self.numJoints, position = [self.position[0] - 10, self.position[1], (self.position[2] + 2 ) - i], parent = self.parent)
                self.__fingers[obj].setupRig()
            
                cmds.parentConstraint(self.masterGuide, common.getParent(self.__fingers[obj].masterGuide), mo = True)
        
                for guide in self.__fingers[obj].getGuides():
                    #tag the guide control with a tag_guides attribute
                    tagAttr = attribute.addAttr(guide, 'hand_guides', attrType = 'message')
                    attribute.connect('%s.tag_guides' % self.setupRigGrp, tagAttr)
                #end loop
            #end loop
        #end elif
        else:
        #move master  guide into position
            cmds.xform(common.getParent(self.masterGuide), ws = True, t = self.handPosition)

            for i,obj in enumerate(self.fingers):
                self.__fingers[obj] = finger.Finger('%s_%s' % (self._getPrefix(), obj))
                self.__fingers[obj].initialize(numJoints = self.numJoints, position = [self.position[0] - 10, self.position[1], (self.position[2] + 2 ) - i], parent = self.parent)
                self.__fingers[obj].setupRig()
            
                cmds.parentConstraint(self.masterGuide, common.getParent(self.__fingers[obj].masterGuide), mo = True)
        
                for guide in self.__fingers[obj].getGuides():
                    #tag the guide control with a tag_guides attribute
                    tagAttr = attribute.addAttr(guide, 'hand_guides', attrType = 'message')
                    attribute.connect('%s.tag_guides' % self.setupRigGrp, tagAttr)
                #end loop
            #end loop
        #end elif
        
        
        #create joint and guide
        if not common.isValid(self.handJoint):
            joint.create(self.handJoint, self.skeletonGrp, self.handPosition)
        if not common.isValid(self.handJoint.replace(common.JOINT,common.CONTROL)):
            self.setupCtrl(self.handGuide,self.handJoint, common.SIDE_COLOR[self._getSide()])
示例#18
0
文件: foot.py 项目: jonntd/japeto
    def rig(self):
        if not self._puppetNode:
            self.runSetupRig()
        
        if common.isValid('%s_%s%s' % (self.name(), common.IK, common.FK)):
            return True
        
        cmds.parent([self.__bankInPivot,
                self.__bankOutPivot,
                self.__heelPivot],
                w = True)

        if super(Foot,self).rig():
            return True

        #create foot ik/fk chain and parent group to joints group
        self.__footIkFk = \
                ikfk.IkFkFoot(self.ankleJoint,
                        self.toeJoint,
                        name = self.name())

        #list the groups for the foot ik setup
        self.__footRollGroups.insert(0, 'anklePivot')
        footRollGrpList = self.__footRollGroups

        #create foot setup
        self.__footIkFk.create(searchReplace = '%s' % common.SKINCLUSTER,
                footRollGrpList = footRollGrpList)

        #parent to joints group
        cmds.parent(self.__footIkFk.group, self.jointsGrp)

        #get position of joints
        anklePosition    = \
            cmds.xform(self.ankleJoint, q = True, ws = True, rp = True)

        ballPosition     = \
            cmds.xform(self.ballJoint, q = True, ws = True, rp = True)

        toePosition      = \
            cmds.xform(self.toeJoint, q = True, ws = True, rp = True)

        bankInPosition   = \
            cmds.xform(self.__bankInPivot, q = True, ws = True, rp = True)

        bankOutPosition  = \
            cmds.xform(self.__bankOutPivot, q = True, ws = True, rp = True)

        heelPosition     = \
            cmds.xform(self.__heelPivot, q = True, ws = True, rp = True)

        #delete pivot joints
        for jnt in (self.__heelPivot,self.__bankOutPivot, self.__bankInPivot):
            cmds.delete(jnt)
        #end loop

        #get foot roll groups
        footRollGroups = self.__footIkFk.getFootRolls()
        handles = self.__footIkFk.getIkHandles()

        #position foot roll groups
        for grp in footRollGroups:
            if grp in ['ballRoll', 'toeBend']:
                cmds.xform(footRollGroups[grp], ws = True, rp = ballPosition)
            elif grp in ['heelRoll', 'heelPivot']:
                if grp == self.__heelPivotName:
                    cmds.setAttr('%s.rotateOrder' % footRollGroups[grp], 2)
                cmds.xform(footRollGroups[grp], ws = True, rp = heelPosition)
            elif grp in ['toeRoll', 'toePivot']: 
                cmds.xform(footRollGroups[grp], ws = True, rp = toePosition)
            elif grp in ['bankIn', self.__bankInZero]: 
                cmds.xform(footRollGroups[grp], ws = True, rp = bankInPosition)
            elif grp in ['bankOut', self.__bankOutZero]: 
                cmds.xform(footRollGroups[grp], ws = True, rp = bankOutPosition)
                cmds.setAttr('%s.rotateOrder' % footRollGroups[grp], 2)
            elif grp in ['anklePivot']: 
                cmds.xform(footRollGroups[grp], ws = True, rp = anklePosition)
        #end loop


        #create controls
        self.__footCtrl      = \
            control.create(name= self.name(),
                    type = 'implicitSphere',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR[self._getSide()])

        self.__bankInCtrl    = \
            control.create(name= footRollGroups[self.__bankIn] ,
                    type = 'implicitSphere',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR_SECONDARY[self._getSide()])

        self.__bankOutCtrl   = \
            control.create(name= footRollGroups[self.__bankOut] ,
                    type = 'implicitSphere',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR_SECONDARY[self._getSide()])

        self.__heelPivotCtrl = \
            control.create(name= footRollGroups[self.__heelPivotName] ,
                    type = 'implicitSphere',
                    parent = self.controlsGrp,
                    color = common.SIDE_COLOR_SECONDARY[self._getSide()])

        #parent of controls
        parentBankOutCtrl   = common.getParent(self.__bankOutCtrl)
        parentBankInCtrl    = common.getParent(self.__bankInCtrl)
        parentHeelPivotCtrl = common.getParent(self.__heelPivotCtrl)

        #scale controls
        for ctrl in [self.__footCtrl,self.__bankOutCtrl, self.__bankInCtrl, self.__heelPivotCtrl]:
            for i in range(len(common.getShapes(ctrl))):
                control.scaleShape (ctrl, scale = [.3, .3, .3], index = i)


        #place controls in correct positions
        transform.matchXform(self.ankleJoint,
                common.getParent(self.__footCtrl),
                type = 'pose')

        cmds.xform(common.getParent(self.__footCtrl),
                ws = True,
                r = True,
                t = [0,0,-2])

        cmds.delete(cmds.parentConstraint(footRollGroups['bankIn'],
                parentBankInCtrl))

        cmds.delete(cmds.parentConstraint(footRollGroups['bankOut'],
                parentBankOutCtrl))

        cmds.delete(cmds.parentConstraint(footRollGroups['heelPivot'],
                parentHeelPivotCtrl))

        #Decompose matrix nodes for pivots and connect the controls to them
        for ctrl, grp in zip([self.__bankInCtrl, self.__bankOutCtrl, self.__heelPivotCtrl] , [footRollGroups['bankIn'], footRollGroups['bankOut'], footRollGroups[self.__heelRoll]]):
            grpZero = common.getChildren(grp)[0]

            dcm = cmds.createNode('decomposeMatrix',
                    n = '%s_%s' % (grp, common.DECOMPOSEMATRIX))

            mdn = cmds.createNode('multiplyDivide',
                    n = '%s_%s' % (grp, common.MULTIPLYDIVIDE))

            attribute.connect('%s.worldMatrix[0]' % ctrl, '%s.inputMatrix' % dcm)

            #connect controls to pivots
            attribute.connect('%s.outputTranslate' % dcm, '%s.rotatePivot' % grp)
            attribute.connect('%s.outputTranslate' % dcm, '%s.rotatePivot' % grpZero)
            #Change attributes on Multiply divide node and make connections
            cmds.setAttr('%s.input2Y' % mdn, -1)
            attribute.connect('%s.ry' % ctrl, '%s.input1Y' % mdn)
            attribute.connect('%s.outputY' % mdn, '%s.ry' % grpZero)
            attribute.connect('%s.ry' % ctrl, '%s.ry' % grp)


        #parent constrain the foot control to the ankle joint
        for node in [self.__footCtrl,parentBankOutCtrl,  parentBankInCtrl, parentHeelPivotCtrl]:
            cmds.parentConstraint(footRollGroups['anklePivot'], node, mo = True)


        #add attributes to the foot control and connect them to the pivots
        ikfkAttr      = \
            attribute.addAttr(self.__footCtrl,
                    'ikfk' ,
                    attrType = 'enum',
                    defValue = ['off', 'on'],
                    value = 0)

        bankAttr      = \
            attribute.addAttr(self.__footCtrl,
                    'bank' ,
                    attrType = 'double',
                    defValue = 0,
                    min = -10,
                    max = 10)

        ballRollAttr  = \
            attribute.addAttr(self.__footCtrl,
                    self.__ballRoll ,
                    attrType = 'double',
                    defValue = 0,
                    min = 0,
                    max = 10)

        toeRollAttr   = \
            attribute.addAttr(self.__footCtrl,
                    self.__toeRoll ,
                    attrType = 'double',
                    defValue = 0,
                    min = 0,
                    max = 10)

        toePivotAttr  = \
            attribute.addAttr(self.__footCtrl,
                    self.__toePivot ,
                    attrType = 'double',
                    defValue = 0,
                    min = -10,
                    max = 10)

        toeBendAttr   = \
            attribute.addAttr(self.__footCtrl,
                    self.__toeBend ,
                    attrType = 'double',
                    defValue = 0,
                    min = -10,
                    max = 10)

        heelRollAttr  = \
            attribute.addAttr(self.__footCtrl,
                    self.__heelRoll ,
                    attrType = 'double',
                    defValue = 0,
                    min = -10,
                    max = 0)

        heelPivotAttr = \
            attribute.addAttr(self.__footCtrl,
                    self.__heelPivotName ,
                    attrType = 'double',
                    defValue = 0,
                    min = -10,
                    max = 10)

        self.__footRollAttrs.extend([ikfkAttr,
                bankAttr,
                ballRollAttr,
                toeRollAttr ,
                toePivotAttr,
                toeBendAttr,
                heelRollAttr,
                heelPivotAttr])

        #create remap dictionary to place remap nodes in based on foot roll group names
        ramapNodes = dict()

        #create remap nodes and connect them to foot roll groups
        for attr in [bankAttr,toePivotAttr,toeBendAttr,heelPivotAttr]:
            node, attrName = attr.split('.')
            ramapNodes[attrName] = \
                cmds.createNode('remapValue',
                        n = '%s_%s_%s' % (node, attrName, common.REMAP))

            attribute.connect(attr, '%s.inputValue' % ramapNodes[attrName])
            cmds.setAttr('%s.outputMax' % ramapNodes[attrName], 100)
            cmds.setAttr('%s.outputMin' % ramapNodes[attrName], -100)
            cmds.setAttr('%s.inputMax' % ramapNodes[attrName], 10)
            cmds.setAttr('%s.inputMin' % ramapNodes[attrName], -10)
        #end loop

        for attr in [ballRollAttr,toeRollAttr, heelRollAttr]:
            node, attrName = attr.split('.')
            ramapNodes[attrName] = \
                cmds.createNode('remapValue',
                        n = '%s_%s_%s' % (node, attrName, common.REMAP))
            attribute.connect(attr, '%s.inputValue' % ramapNodes[attrName])
            cmds.setAttr('%s.outputMax' % ramapNodes[attrName], 100)
            cmds.setAttr('%s.outputMin' % ramapNodes[attrName], 0)
            cmds.setAttr('%s.inputMax' % ramapNodes[attrName], 10)
            cmds.setAttr('%s.inputMin' % ramapNodes[attrName], 0)

            if attr == heelRollAttr:
                cmds.setAttr('%s.outputMax' % ramapNodes[attrName], 0)
                cmds.setAttr('%s.outputMin' % ramapNodes[attrName], -100)
                cmds.setAttr('%s.inputMax' % ramapNodes[attrName], 0)
                cmds.setAttr('%s.inputMin' % ramapNodes[attrName], -10)
            #end if
        #end loop

        #connect remap nodes to roll groups    
        #---Bank In/Out---
        if self._getSide() == common.LEFT:
            attribute.connect('%s.outValue' % ramapNodes['bank'],
                              '%s.rz' % footRollGroups[self.__bankIn])

            attribute.connect('%s.outValue' % ramapNodes['bank'],
                              '%s.rz' % footRollGroups[self.__bankOut])

            cmds.transformLimits(footRollGroups[self.__bankIn],
                    rz =[0, 100],
                    erz = [1, 1])

            cmds.transformLimits(footRollGroups[self.__bankOut],
                    rz =[-100, 0],
                    erz = [1, 1])
        elif self._getSide() == common.RIGHT:
            invertMDN = \
                cmds.createNode('multiplyDivide',
                        n = '%s_bankInvert_%s' % (self._getSide(),
                        common.MULTIPLYDIVIDE))

            cmds.setAttr('%s.input2X' % invertMDN, -1)
            attribute.connect('%s.outValue' % ramapNodes['bank'],
                    '%s.input1X' % invertMDN)

            attribute.connect('%s.outputX' % invertMDN,
                    '%s.rz' % footRollGroups[self.__bankIn])

            attribute.connect('%s.outputX' % invertMDN,
                    '%s.rz' % footRollGroups[self.__bankOut])

            cmds.transformLimits(footRollGroups[self.__bankIn],
                    rz =[-100, 0],
                    erz = [1, 1])

            cmds.transformLimits(footRollGroups[self.__bankOut],
                    rz =[0, 100],
                    erz = [1, 1])

        #---Ball Roll---
        attribute.connect('%s.outValue' % ramapNodes[self.__ballRoll],
                '%s.rx' % footRollGroups[self.__ballRoll])
        #---Toe Roll---
        attribute.connect('%s.outValue' % ramapNodes[self.__toeRoll],
                '%s.rx' % footRollGroups[self.__toeRoll])
        #---Toe Pivot---
        attribute.connect('%s.outValue' % ramapNodes[self.__toePivot],
                '%s.ry' % footRollGroups[self.__toePivot])
        #---Heel Roll---
        attribute.connect('%s.outValue' % ramapNodes[self.__heelRoll],
                '%s.rx' % footRollGroups[self.__heelRoll])
        #---Heel Pivot---
        attribute.connect('%s.outValue' % ramapNodes[self.__heelPivotName],
                '%s.ry' % footRollGroups[self.__heelPivotName])
        #---IK/FK---
        attribute.connect(ikfkAttr,
                '%s.ikfk' % self.__footIkFk.group)
        #---Ball Roll---
        attribute.connect('%s.outValue' % ramapNodes[self.__toeBend],
                '%s.rx' % footRollGroups[self.__toeBend])

        #connect fk joints to the ankle pivot
        #cmds.parentConstraint(footRollGroups['anklePivot'], self.__footIkFk.fkJoints[0], mo = True)

        #connecting visibility of control shapes to the controls
        ikfkReverse = \
            cmds.createNode('reverse', n = '%s_%s' % (self.name(),common.REVERSE))

        attribute.connect(ikfkAttr, '%s.inputX' % ikfkReverse)

        for ikCtrl in [self.__bankInCtrl,self.__bankOutCtrl,self.__heelPivotCtrl]:
            cmds.setAttr('%s.rotateOrder' % ikCtrl, 2)
            for shape in common.getShapes(ikCtrl):
                if shape:
                    attribute.connect('%s.outputX' % ikfkReverse, '%s.v' % shape)

        #----FK Setup---
        fkCtrls = list()
        parent = self.controlsGrp
        for jnt in self.__footIkFk.fkJoints:
            if jnt == self.__footIkFk.fkJoints[-1]:
                continue
            #end if

            ctrl = \
                control.create(name= jnt.split('_%s' % common.JOINT)[0],
                        type = 'circle',
                        parent = parent,
                        color = common.SIDE_COLOR[self._getSide()])

            ctrlParent = common.getParent(ctrl)
            transform.matchXform(jnt, ctrlParent, type = 'pose')
            cmds.parentConstraint(ctrl, jnt, mo = True) #----> might change this to connect rotations and not use translation
            if jnt == self.__footIkFk.fkJoints[0]:
                cmds.parentConstraint(footRollGroups['anklePivot'],
                    ctrlParent,
                    mo = True)
            #end if

            #connect visibility of shapes to foot control
            for shape in common.getShapes(ctrl):
                attribute.connect(ikfkAttr, '%s.v' % shape)
            #end for    
            parent = ctrl
            fkCtrls.append(ctrl)

        #assign hooks
        self.hookRoot.extend([footRollGroups['anklePivot'], common.getParent(fkCtrls[0])])
        self.hookPoint.extend([footRollGroups['ballRoll']])
示例#19
0
文件: chain.py 项目: jonntd/japeto
    def setupRig(self):
        if super(Chain, self).setupRig():
            return True
        
        self.skinClusterJnts = [self.startJoint, self.endJoint]
                
        if self._getSide() == common.LEFT:
            positions = (
            [self.position[0] + 2, self.position[1], self.position[2]],
            [self.position[0] + 9, self.position[1], self.position[2]]
            )
            
            aimCtrlPosition = [positions[0][0],
                    positions[0][1] + 5,
                    positions[0][2]]
        #end if    
        elif self._getSide() == common.RIGHT:
            positions = (
            [self.position[0] - 2, self.position[1], self.position[2]],
            [self.position[0] - 9, self.position[1], self.position[2]]
            )
            
            aimCtrlPosition = [positions[0][0],
                    positions[0][1] + 5,
                    positions[0][2]]
        #end elif    
            
        else:
            positions = (
            [self.position[0], self.position[1], self.position[2]],
            [self.position[0], self.position[1] + 9, self.position[2]]
            )
            
            aimCtrlPosition = [positions[0][0],
                    positions[0][1],
                    positions[0][2] + 5]
        #end elif
        for i,jnt in enumerate(self.skinClusterJnts):
            if not common.isValid(jnt):
                cmds.joint(n = jnt,position = positions[i])
            
            if i == 0:
                cmds.parent(jnt, self.skeletonGrp)
                #place Master Guide control in the same position
                #  as the first joint
                transform.matchXform(jnt,
                        common.getParent(self.masterGuide),
                        type = 'position')
            else:
                cmds.parent(jnt, self.skinClusterJnts[i - 1])
            #end if/else
                
            ctrl = self.setupCtrl(jnt.replace('_%s' % common.JOINT, ''),jnt)
            #create template control
            #control.createTemplate(ctrl)
            cmds.select(cl = True)
        #end loop
        

        # ----------------------------------------------------------------------
        # CREATE GUIDES
        startJointGuide = self.startJoint.replace(common.JOINT, common.GUIDES)
        endJointGuide   = self.endJoint.replace(common.JOINT, common.GUIDES)



        # ----------------------------------------------------------------------
        # ORIENTATION 
        #
        if self._getSide() == common.RIGHT:
            aimVectorAttr = attribute.switch ('aimVector',
                    node= self.masterGuide,
                    value=4,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])
            upVectorAttr  = attribute.switch ('upVector',
                    node=self.masterGuide,
                    value=3,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])
        else:
            aimVectorAttr = attribute.switch ('aimVector',
                    node=self.masterGuide,
                    value=1,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])

            upVectorAttr  = attribute.switch ('upVector',
                    node=self.masterGuide,
                    value=3,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])
        
        #create in-between joints and guides and make connections 
        step   = 1.0 / (self.numJoints - 1)
        parent = self.startJoint
        for i in range( 1, self.numJoints - 1 ):
            j = '%s_%s_%s_%s_%s' % (self._getPrefix(),
                    common.getDescription(self.name()),
                    common.padNumber(i,3),
                    common.SKINCLUSTER,
                    common.JOINT)
            if not common.isValid(j):
                joint.create( name= j)

            transform.matchXform( self.startJoint,j, type='rotate' )
            ctrl = self.setupCtrl(j.replace('_%s' % common.JOINT, ''),j)
            ctrlParent = common.getParent(ctrl)
            #create point constraint and figure out percentage for position
            constraint = cmds.pointConstraint( self.startJoint,
                    endJointGuide, ctrlParent )[0]

            weightAliasList = cmds.pointConstraint( constraint,
                    q=True,
                    weightAliasList=True)

            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[0]), 1-(step*i) )
            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[1]),  step*i )

            #adding the joint to skincluster joints list
            self.skinClusterJnts.insert(-1, j)
            relatives = cmds.listRelatives(j, p = True)
            if not relatives:
                cmds.parent(j, parent)
            parent = j

            if i == self.numJoints - 2:
                cmds.parent(self.endJoint, j)
                constraint = cmds.orientConstraint(j, self.endJoint)[0]
                #add constraints to setup constraint list
                self._addSetupConstraints(constraint)


        #create aim control
        aimLocator = self._createAimLocator(aimCtrlPosition,
                color = common.SIDE_COLOR_SECONDARY[self._getSide()])
        
        #create aim constraints
        for i, jnt in enumerate(self.skinClusterJnts):
            if jnt == self.endJoint:
                break
            constraint = cmds.aimConstraint(
                    self.skinClusterJnts[i+1].replace('_%s' % common.JOINT, '_%s' % common.GUIDES),
                    jnt,
                    worldUpType = "object",
                    worldUpObject = aimLocator)[0]

            attribute.connect(aimVectorAttr, '%s.aimVector' % constraint)
            attribute.connect(upVectorAttr, '%s.upVector' % constraint)
            #add constraints to setup constraint list
            self._addSetupConstraints(constraint)
示例#20
0
文件: foot.py 项目: jonntd/japeto
    def setupRig(self):
        if super(Foot, self).setupRig():
            return True

        self.skinClusterJnts = [ self.ankleJoint,
                                 self.ballJoint,
                                 self.toeJoint ]

        if self._getSide() == common.LEFT:
            positions = (
            [self.position[0] + 2, self.position[1] + 2, self.position[2]],
            [self.position[0] + 2, self.position[1], self.position[2] + 2],
            [self.position[0] + 2, self.position[1], self.position[2] + 4]
            )

            #create offset position depending on which side it's on
            bankInOffset = -1
            bankOutOffset = 1
        elif self._getSide() == common.RIGHT:
            positions = (
            [self.position[0] - 2, self.position[1] + 2, self.position[2]],
            [self.position[0] - 2, self.position[1], self.position[2] + 2],
            [self.position[0] - 2, self.position[1], self.position[2] + 4]
            )

            #create offset position depending on which side it's on
            bankInOffset = 1
            bankOutOffset = -1
        else:
            positions = (
            [self.position[0], self.position[1] + 2, self.position[2]],
            [self.position[0], self.position[1], self.position[2] + 2],
            [self.position[0], self.position[1], self.position[2] + 4]
            )

            #create offset position depending on which side it's on
            bankInOffset = -1
            bankOutOffset = 1
        #end elif

        for i,jnt in enumerate(self.skinClusterJnts):
            cmds.joint(n = jnt,position = positions[i])

            if i == 0:
                cmds.parent(jnt, self.skeletonGrp)
                #place Master Guide control in the same position as the first joint
                transform.matchXform(jnt,
                    common.getParent(self.masterGuide),
                    type = 'position')
            else:
                cmds.parent(jnt, self.skinClusterJnts[i - 1])
            #end else

            ctrl = self.setupCtrl(jnt.replace('_%s' % common.JOINT, ''),jnt)
            #create template control
            #control.createTemplate(ctrl)
            cmds.select(cl = True)
        #end loop

        #create pivots for setup
        self.__bankInPivot = cmds.createNode('joint',
                n = '%s_bankIn_%s' % (self._getPrefix(),
                common.PIVOT))

        self.__bankOutPivot = cmds.createNode('joint',
                n = '%s_bankOut_%s' % (self._getPrefix(),
                common.PIVOT))

        self.__heelPivot = cmds.createNode('joint',
                n = '%s_heel_%s' % (self._getPrefix(),
                common.PIVOT))

        #move pivots into position
        x,y,z = positions[1]
        cmds.xform(self.__bankInPivot, ws = True, t = [x + bankInOffset, y, z])
        cmds.xform(self.__bankOutPivot, ws = True, t = [x + bankOutOffset, y, z])
        cmds.xform(self.__heelPivot, ws = True, t = [x, y, z  - 4])

        #parent pivots
        for pivot in [self.__bankInPivot, self.__bankOutPivot, self.__heelPivot]:
            cmds.parent(pivot, self.skeletonGrp)
        #end loop


        # ----------------------------------------------------------------------
        # CREATE GUIDES
        ankleJointGuide = self.ankleJoint.replace(common.JOINT, common.GUIDES)
        ballointGuide   = self.ballJoint.replace(common.JOINT, common.GUIDES)
        toeJointGuide   = self.toeJoint.replace(common.JOINT, common.GUIDES)
        bankInPivotGuide   = \
                self.setupCtrl(self.__bankInPivot.replace('_%s' % common.JOINT, ''),
                self.__bankInPivot,
                color = common.SIDE_COLOR_SECONDARY[self._getSide()])

        bankOutPivotGuide   = \
                self.setupCtrl(self.__bankOutPivot.replace('_%s' % common.JOINT,''),
                self.__bankOutPivot,
                color = common.SIDE_COLOR_SECONDARY[self._getSide()])

        heelPivotGuide   = \
                self.setupCtrl(self.__heelPivot.replace('_%s' % common.JOINT, ''),
                self.__heelPivot,
                color = common.SIDE_COLOR_SECONDARY[self._getSide()])


        cmds.pointConstraint(self.ballJoint,
                common.getParent(bankOutPivotGuide), mo = True)

        cmds.pointConstraint(self.ballJoint,
                common.getParent(bankInPivotGuide), mo = True)

        #resize pivot controls
        for ctrl in [heelPivotGuide, bankOutPivotGuide, bankInPivotGuide]:
            cmds.setAttr('%s.radius' % common.getShapes(ctrl)[0],
                    self.controlScale * .5)
示例#21
0
文件: limb.py 项目: jonntd/japeto
    def setupRig(self):
        if super(Limb,self).setupRig():
            return True

        self.skinClusterJnts = [ self.startJoint,
                                 self.midJoint,
                                 self.tipJoint,
                                 self.endJoint ]

        if self._getSide() == common.LEFT:
            positions = (
            [self.position[0] + 2, self.position[1], self.position[2]],
            [self.position[0] + 5, self.position[1], self.position[2] - 1],
            [self.position[0] + 8, self.position[1], self.position[2]],
                [self.position[0] + 9, self.position[1], self.position[2]]
            )
        elif self._getSide() == common.RIGHT:
            positions = (
            [self.position[0] - 2, self.position[1], self.position[2]],
            [self.position[0] - 5, self.position[1], self.position[2] - 1],
            [self.position[0] - 8, self.position[1], self.position[2]],
            [self.position[0] - 9, self.position[1], self.position[2]]
            )
        else:
            positions = (
            [self.position[0] - 2, self.position[1], self.position[2]],
            [self.position[0] - 5, self.position[1], self.position[2] - 1],
            [self.position[0] - 8, self.position[1], self.position[2]],
            [self.position[0] - 9, self.position[1], self.position[2]]
            )

        for i,jnt in enumerate(self.skinClusterJnts):
            if not common.isValid(jnt):
                cmds.joint(n = jnt,position = positions[i])

            if i == 0:
                cmds.parent(jnt, self.skeletonGrp)
                #place Master Guide control in the same position as the first joint
                transform.matchXform(jnt, common.getParent(self.masterGuide), type = 'position')
            else:
                cmds.parent(jnt, self.skinClusterJnts[i - 1])

            ctrl = self.setupCtrl(jnt.replace('_%s' % common.JOINT, ''),jnt)
            #create template control
            #control.createTemplate(ctrl)
            cmds.select(cl = True)


        # ----------------------------------------------------------------------
        # CREATE GUIDES
        startJointGuide = self.startJoint.replace(common.JOINT, common.GUIDES)
        midJointGuide   = self.midJoint.replace(common.JOINT, common.GUIDES)
        tipJointGuide   = self.tipJoint.replace(common.JOINT, common.GUIDES)
        endJointGuide   = self.endJoint.replace(common.JOINT, common.GUIDES)

        #templateNullGroup = cmds.createNode('transform', n = endJointGuide.replace(common.GUIDES, common.GROUP))
        #transform.matchXform(locator, endJointGuide, type = 'position')
        #cmds.pointConstraint(tipJointGuide, templateNullGroup)
        #cmds.parent(templateNullGroup, self.guidesGrp)
        #control.createTemplate(templateNullGroup, defaultType = 'implicitSphere')


        # ----------------------------------------------------------------------
        # ORIENTATION 
        #
        if self._getSide() == common.RIGHT:
            aimVectorAttr = \
                attribute.switch ('aimVector',
                    node= self.masterGuide,
                    value=4,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])

            upVectorAttr  = \
                attribute.switch ('upVector',
                    node=self.masterGuide,
                    value=3,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])
        else:
            aimVectorAttr = \
                attribute.switch ('aimVector',
                    node=self.masterGuide,
                    value=1,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])

            upVectorAttr  = \
                attribute.switch ('upVector',
                    node=self.masterGuide,
                    value=3,
                    choices=['x','y','z','-x','-y','-z'],
                    outputs=[(1,0,0),(0,1,0),(0,0,1),(-1,0,0),(0,-1,0),(0,0,-1)])

        #Get Vectors for the cross product
        #Decompose matrix nodes 
        startJointDcm = \
            cmds.createNode('decomposeMatrix',
                name = self.startJoint.replace('%s_%s' % (common.SKINCLUSTER, common.JOINT), common.DECOMPOSEMATRIX ))

        attribute.connect('%s.worldMatrix' % startJointGuide,'%s.inputMatrix' % startJointDcm)

        midJointDcm = \
            cmds.createNode('decomposeMatrix', name = self.midJoint.replace('%s_%s' % (common.SKINCLUSTER, common.JOINT), common.DECOMPOSEMATRIX ))

        attribute.connect('%s.worldMatrix' % midJointGuide, '%s.inputMatrix' % midJointDcm)

        tipJointDcm = \
            cmds.createNode('decomposeMatrix', name = self.tipJoint.replace('%s_%s' % (common.SKINCLUSTER, common.JOINT), common.DECOMPOSEMATRIX ))
        attribute.connect('%s.worldMatrix' % tipJointGuide, '%s.inputMatrix' % tipJointDcm)

        #plus minus average nodes
        v1Node = cmds.createNode('plusMinusAverage')
        v2Node = cmds.createNode('plusMinusAverage')
        cmds.setAttr('%s.operation' % v1Node, 2)
        cmds.setAttr('%s.operation' % v2Node, 2)

        #connect Decompose Matrix and Plus Minus Average nodes
        attribute.connect('%s.outputTranslate' % tipJointDcm, '%s.input3D[0]' % v1Node)
        attribute.connect('%s.outputTranslate' % startJointDcm, '%s.input3D[1]' % v1Node)
        attribute.connect('%s.outputTranslate' % midJointDcm, '%s.input3D[0]' % v2Node)
        attribute.connect('%s.outputTranslate' % startJointDcm, '%s.input3D[1]' % v2Node)

        #Get the cross product
        crossNode = cmds.createNode('vectorProduct')
        cmds.setAttr( '%s.%s' % (crossNode,'operation') , 2 )
        attribute.connect( '%s.%s' % (v1Node,'output3D'), '%s.%s' % (crossNode,'input1') )
        attribute.connect( '%s.%s' % (v2Node,'output3D'), '%s.%s' % (crossNode,'input2') )
        crossVectorAttr = '%s.%s' % (crossNode,'output')

        #Aim start joint to the middle joint
        constraint = \
            cmds.aimConstraint(midJointGuide,
                    self.startJoint,
                    aimVector = (1,0,0),
                    upVector = (0,1,0),
                    worldUpType = 'vector',
                    worldUpVector = (0,1,0))[0]

        attribute.connect(aimVectorAttr, '%s.aimVector' % constraint)
        attribute.connect(upVectorAttr, '%s.upVector' % constraint)
        attribute.connect(crossVectorAttr, '%s.worldUpVector' % constraint)
        self.setupConstraints.append(constraint)

        #Aim middle joint to the tip joint
        constraint = \
            cmds.aimConstraint(tipJointGuide,
                    self.midJoint,
                    aimVector = (1,0,0),
                    upVector = (0,1,0),
                    worldUpType = 'vector',
                    worldUpVector = (0,1,0))[0]

        attribute.connect(aimVectorAttr, '%s.aimVector' % constraint)
        attribute.connect(upVectorAttr, '%s.upVector' % constraint)
        attribute.connect(crossVectorAttr, '%s.worldUpVector' % constraint)
        self.setupConstraints.append(constraint)

        constraint = cmds.orientConstraint(self.midJoint, self.tipJoint)[0]
        self.setupConstraints.append(constraint)

        cmds.setAttr('%s.normalizeOutput' % crossNode, True)

        self.upTwistJnts = list()
        step   = 1.0 / (self.numSegments + 1)
        parent = self.startJoint
        for i in range( 1, self.numSegments + 1 ):
            j = joint.create( name='%s' % (self.startJoint.replace('_%s' % common.SKINCLUSTER, 'Twist_%s_%s' % (common.padNumber(i,3), common.SKINCLUSTER))), parent=parent )
            transform.matchXform( self.startJoint,j, type='rotate' )
            constraint = cmds.pointConstraint( self.startJoint, self.midJoint, j )[0]
            weightAliasList = cmds.pointConstraint( constraint, q=True, weightAliasList=True )
            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[0]), 1-(step*i) )
            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[1]),  step*i )
            self.upTwistJnts.append(j)
            self.skinClusterJnts.append(j) #adding the joint to skincluster joints list

        # Create MiddleJoint Segments
        self.loTwistJnts = list()
        parent = self.midJoint
        for i in range( 1, self.numSegments + 1):
            j = joint.create( name='%s' % (self.midJoint.replace('_%s' % common.SKINCLUSTER, 'Twist_%s_%s' % (common.padNumber(i,3), common.SKINCLUSTER))), parent=parent )
            transform.matchXform( self.midJoint,j, type='rotate' )
            constraint = cmds.pointConstraint( self.midJoint, self.tipJoint, j )[0]
            weightAliasList = cmds.pointConstraint( constraint, q=True, weightAliasList=True )
            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[0]), 1-(step*i) )
            cmds.setAttr( '%s.%s' % (constraint, weightAliasList[1]),  step*i )
            self.loTwistJnts.append(j)
            self.skinClusterJnts.append(j) #adding the joint to skincluster joints list
示例#22
0
文件: limb.py 项目: jonntd/japeto
    def rig(self):
        if not self._puppetNode:
            self.runSetupRig()
        if cmds.objExists('%s.master_guide' % self.setupRigGrp):
            self.masterGuide = attribute.getConnections('master_guide', self.setupRigGrp)[0].split('.')[0]
        if common.isValid(self.masterGuide):
            #get orientations for controls
            fkOrient  = self.__fkOrient()
            ikOrient  = self.__ikOrient()
            upVector  = self.upVector
            aimVector = self.aimVector

        #call parent class rig function
        if super(Limb, self).rig():
            return True
        
        #create ik fk switch
        ikfkDict = ikfk.create(jointChain = [self.startJoint, self.midJoint, self.tipJoint], stretch = self.stretch)
        ikfkDict['group'] = cmds.rename(ikfkDict['group'], '%s_%s' % (self.name(),ikfkDict['group']))

        #set the visibility on the ik/fk/blend joints to off
        cmds.setAttr('%s.v' % ikfkDict['fkJoints'][0], 0)
        cmds.setAttr('%s.v' % ikfkDict['ikJoints'][0], 0)
        cmds.setAttr('%s.v' % ikfkDict['blendJoints'][0], 0)

        ikfkAttr = attribute.addAttr(self.rigGrp, attr = 'ikfk', attrType = 'enum', defValue = ['off','on'],value = 0)

        cmds.connectAttr(ikfkAttr, '%s.ikfk' % ikfkDict['group'], l = True, f = True)

        #parent ikfk group under joints group
        cmds.parent(ikfkDict['group'], self.jointsGrp)

        #rename all ik and blend joints
        for i,jnt in enumerate(ikfkDict['ikJoints']):
            jnt = cmds.rename(jnt, jnt.replace('%s_%s_%s' % (common.SKINCLUSTER,common.JOINT, common.IK), '%s_%s' % (common.IK, common.JOINT)))
            ikfkDict['ikJoints'][i] = jnt

        for i,jnt in enumerate(ikfkDict['blendJoints']):
            jnt = cmds.rename(jnt, jnt.replace('%s_%s_%s' % (common.SKINCLUSTER,common.JOINT, common.BLEND), '%s_%s' % (common.BLEND, common.JOINT)))
            ikfkDict['blendJoints'][i] = jnt

        #create ik setup
        ikCtrl = control.create(name = ikfkDict['ikJoints'][2].replace('_%s' % common.JOINT, ''),type = 'cube', parent = self.controlsGrp, color = common.SIDE_COLOR[self._getSide()])
        ikCtrlZero = common.getParent(ikCtrl)
        attribute.copy('stretch', ikfkDict['group'], destination = ikCtrl, connect = True,reverseConnect = False)
        attribute.copy('stretchTop', ikfkDict['group'], destination = ikCtrl, connect = True,reverseConnect = False)
        attribute.copy('stretchBottom', ikfkDict['group'], destination = ikCtrl, connect = True,reverseConnect = False)

        if ikOrient == 'Local':
            transform.matchXform(ikfkDict['ikJoints'][2], ikCtrlZero, type = 'pose')
        else:
            transform.matchXform(ikfkDict['ikJoints'][2], ikCtrlZero, type = 'position')
            cmds.orientConstraint(ikCtrl, ikfkDict['ikJoints'][2], mo = True)
            common.setColor(ikCtrl, common.SIDE_COLOR[self._getSide()])

            #setup poleVector
            pvCtrl = control.create(name = ikfkDict['ikJoints'][2].replace('_%s' % common.JOINT, '_%s' % common.POLEVECTOR),type = 'cube', parent = self.controlsGrp, color = common.SIDE_COLOR[self._getSide()])
            #size polevector control

        for i in range(len(common.getShapes(pvCtrl))):
            control.scaleShape(pvCtrl, scale = [self.controlScale * .5, self.controlScale * .5, self.controlScale * .5], index = i)

        pvCtrlZero = common.getParent(pvCtrl)
        pvDisplayLineAttr = attribute.addAttr(pvCtrl, attr = 'pvLine', attrType = 'enum', defValue = 'off:on', value = 1)
        transform.matchXform(ikfkDict['ikJoints'][1], pvCtrlZero, type = 'position')
        #cmds.parent(ikfkDict['ikHandle'], w = True)
        pvPos = ikfk.getPoleVectorPosition(ikfkDict['ikJoints'][1], ikfkDict['ikHandle'])
        cmds.xform(pvCtrlZero, ws = True, t = pvPos)
        common.setColor(pvCtrlZero, common.SIDE_COLOR[self._getSide()])

        #create polevector constraint and parent under control
        cmds.poleVectorConstraint(pvCtrl, ikfkDict['ikHandle'])
        targetConstraint = cmds.pointConstraint(ikCtrl, ikfkDict['targetJnts'][1], mo = True) #ikhandle is under target joint
        pvDisplayLine = control.displayLine(ikfkDict['ikJoints'][0], pvCtrl, name = pvCtrl.replace(common.CONTROL, common.DISPLAYLINE), parent = self.controlsGrp)


        cmds.orientConstraint(ikCtrl,ikfkDict['ikJoints'][0], mo = True)

        #adding attribute to ik ctrl
        ikTwistAttr = attribute.addAttr(ikCtrl, attr = 'twist')
        cmds.connectAttr(ikTwistAttr, '%s.twist' % ikfkDict['ikHandle'], f = True)

        #connecting to shapes
        ikfkReverse = cmds.createNode('reverse', n = ikCtrl.replace('%s_%s' % (common.IK, common.CONTROL), '%s_%s' % (common.REVERSE, common.UTILITY)))
        attribute.connect('%s.ikfk' % ikfkDict['group'], '%s.inputX' % ikfkReverse)
        for shape in common.getShapes(ikCtrl):
            attribute.connect('%s.outputX' % ikfkReverse,'%s.v' % shape)

        for shape in common.getShapes(pvCtrl):
            attribute.connect('%s.outputX' % ikfkReverse,'%s.v' % shape)

        #connect pvDisplayLineAttr in pvDisplayLine visibility
        displayLineMultiply = cmds.createNode('multiplyDivide', n = pvDisplayLine.replace(common.DISPLAYLINE, common.MULTIPLYDIVIDE))
        attribute.connect(pvDisplayLineAttr, '%s.input1X' % displayLineMultiply)
        attribute.connect('%s.outputX' % ikfkReverse, '%s.input2X' % displayLineMultiply)
        attribute.connect('%s.outputX' % displayLineMultiply, '%s.v' % common.getChildren(pvDisplayLine)[0])

        #create fk setup
        fkCtrls = list()
        parent = self.controlsGrp
        for i,jnt in enumerate(ikfkDict['fkJoints']):
            cmds.select(cl = True)
            #rename fk joint
            jnt = cmds.rename(jnt,jnt.replace('%s_%s_%s' % (common.SKINCLUSTER,common.JOINT,common.FK), '%s_%s' % (common.FK,common.JOINT)))
            ikfkDict['fkJoints'][i] = jnt #re-assign fk joint intop ikfkDict
            #create controls, set color, and make connections
            fkCtrl = control.create(name = jnt.replace('_%s' % common.JOINT, ''),type = 'circle', parent = parent, color = common.SIDE_COLOR[self._getSide()])
            fkCtrlZero = common.getParent(fkCtrl)
            
            if fkOrient == 'Local':
                transform.matchXform(jnt, fkCtrlZero, type = 'pose')
            #end if
            else:
                transform.matchXform(jnt, fkCtrlZero, type = 'position')
            #end else
            
            cmds.connectAttr('%s.ikfk' % ikfkDict['group'], '%s.v' % common.getShapes(fkCtrl)[0], f = True)
            cmds.parentConstraint(fkCtrl, jnt, mo = True)
            attribute.lockAndHide('t', fkCtrl)
            attribute.lockAndHide('s', fkCtrl)
            attribute.lockAndHide('v', fkCtrl)
            #get joint rotate order and apply to control and parent group
            rotateOrder = attribute.getValue('rotateOrder', jnt)
            for node in [fkCtrl, fkCtrlZero]:
                cmds.setAttr('%s.rotateOrder' % node, rotateOrder)
    
                fkCtrls.append(fkCtrl)
                parent = fkCtrl
            #end loop
        #end loop

        aimAxis = transform.getAimAxis(ikfkDict['blendJoints'][0], allowNegative = False)    
        #Up Twist Joint Setup
        if self.upTwistJnts:
            noTwistJnt = common.duplicate(self.startJoint, name = self.startJoint.replace('%s' % common.SKINCLUSTER, 'NoTwist_%s' % common.SKINCLUSTER), parent = self.startJoint)

            inverseMultNode = cmds.createNode('multiplyDivide', n = noTwistJnt.replace('%s_%s' % (common.SKINCLUSTER,common.JOINT), '%s_%s' % (common.UTILITY, common.MULTIPLYDIVIDE)))
            cmds.connectAttr('%s.r%s' % (ikfkDict['blendJoints'][0], aimAxis), '%s.input1X' % inverseMultNode, f = True)
            cmds.setAttr('%s.input2X' % inverseMultNode, -1)
            cmds.connectAttr('%s.outputX' % inverseMultNode, '%s.r%s' % (noTwistJnt, aimAxis), f = True)


            step   = 1.0 / (len(self.upTwistJnts) +1)
            for i in range( 1, (len(self.upTwistJnts)+1) ):
                twsitMultNode = cmds.createNode('multiplyDivide', n = self.upTwistJnts[i - 1].replace('%s_%s' % (common.SKINCLUSTER,common.JOINT), '%s_%s' % (common.UTILITY, common.MULTIPLYDIVIDE)))
                cmds.connectAttr('%s.r%s' % (ikfkDict['blendJoints'][0], aimAxis), '%s.input1X' % twsitMultNode, f = True)
                cmds.setAttr('%s.input2X' % twsitMultNode, -(1-(step*i))  )
                cmds.connectAttr('%s.outputX' % twsitMultNode, '%s.r%s' % (self.upTwistJnts[i -1], aimAxis),f = True)
            #end loop

            self.upTwistJnts.insert(0, noTwistJnt)
        #end if

        if self.loTwistJnts:
            twistJnt = common.duplicate(self.midJoint,name = self.midJoint.replace('%s' % common.SKINCLUSTER, 'loTwist_%s' % common.SKINCLUSTER), parent = self.midJoint)
            constraint = cmds.aimConstraint(ikfkDict['blendJoints'][2],twistJnt,aimVector =  aimVector, upVector  = upVector,  worldUpType ="objectrotation", worldUpVector = upVector, worldUpObject = self.tipJoint)
            cmds.setAttr('%s.v' % twistJnt, 0)
        #end if

        step   = 1.0 / (len(self.loTwistJnts) +1)
        for i in range( 1, (len(self.loTwistJnts)+1) ):
            twsitMultNode = cmds.createNode('multiplyDivide', n = self.loTwistJnts[i - 1].replace('%s_%s' % (common.SKINCLUSTER,common.JOINT), '%s_%s' % (common.UTILITY, common.MULTIPLYDIVIDE)))
            cmds.connectAttr('%s.r%s' % (ikfkDict['blendJoints'][2], aimAxis), '%s.input1X' % twsitMultNode, f = True)
            cmds.setAttr('%s.input2X' % twsitMultNode, 1-(step*i) )
            cmds.connectAttr('%s.outputX' % twsitMultNode, '%s.r%s' % (self.loTwistJnts[i -1], aimAxis),f = True)
        #end loop

        #------------------------
        #Add to class variables
        #------------------------
        #assign joints to the joints list
        self.joints = {'ik' : ikfkDict['ikJoints'], 'fk' : ikfkDict['fkJoints'], 'blend' : ikfkDict['blendJoints'], 'target' : ikfkDict['targetJnts']}
        #assign controls to the controls list
        #assign fkCtrls into the controls dictionary 
        self.controls = {'ik' : [ikCtrl, pvCtrl],'fk' : fkCtrls }
        self.ikfkGroup = ikfkDict['group']
        #assign hooks
        self.hookRoot = [ikfkDict['ikJoints'][0], common.getParent(fkCtrls[0]), ikCtrl, ikfkDict['targetJnts'][-1]]
        self.hookPoint = [ikfkDict['blendJoints'][-1]]
        #add no twist joint to the skincluster list
        self.skinClusterJnts.append(noTwistJnt)
示例#23
0
文件: joint.py 项目: jonntd/japeto
def load( filepath, world=False ):
    '''Import joints exported with the *save* function. **python format**
    If the joint already exists it will set the transformation, if it doesn't it will create it.
    
    .. python ::

        # This command will only import the exported values into persp node, if any.
        load( '/var/tmp/attributes.pyson', 'persp' )

    :param filepath: File exported with the save function.
    :type filepath: **str**
    :param world: Import world position
    :type world: **bool**
    '''

    if not fileIO.isFile(filepath):
        raise RuntimeError, 'No valid filepath "%s"' % filepath

    # Get Data
    data = pyon.load( filepath )
    
    # Create Joints
    for joint in data.keys():
        
        parameters    = data[joint]['parameters']
        parent        = data[joint]['parent']
        
        # Create Joint
        if not common.isValid( joint ):
            joint = create( name=joint )

        # Create Parent Node
        if not common.isValid( parent ) and parent in data.keys():
            parent = create( name=parent )

        # Parent joint
        if common.isValid( parent ) and common.getParent( joint ) != parent:
            cmds.parent( joint, parent )

        # Set values
        for attr in parameters.keys():
            
            # Check if valid
            if not common.isValid('%s.%s' % (joint, attr)):
                continue

            # ------------------------------------------------------------------
            # Check if connected or locked
            locked = False
            if attribute.isConnected( attr, joint, incoming=True, outgoing=False ) or attribute.isLocked( attr, joint ):
                locked = True
            if attribute.isCompound( attr, joint ):
                attrChildren = cmds.attributeQuery( attr, node = joint, listChildren = True)
                for attrChild in attrChildren:
                    if attribute.isConnected( attrChild, joint, incoming=True, outgoing=False ) or attribute.isLocked( attrChild, joint ):
                        locked = True
            if locked:
                continue
            
            # ------------------------------------------------------------------
            # Set values
            value = parameters[attr]
            attribute.setValue( attr, joint, value )
    
    # Set world position
    if world:
        for joint in data.keys():
            worldPosition = data[joint]['worldPosition']
            cmds.move( worldPosition[0], worldPosition[1], worldPosition[2], joint, worldSpace=True, a=True, pcp=True )
    
    #logger.info( 'Joints loaded from: "%s"' % filepath)
示例#24
0
    def postSetupRig(self):
        '''
        clean up section for the setup rig
        '''
        if common.isValid('%s.displayAxis' % self.masterGuide) or common.isValid(self.masterGuide) != True:
            return True
        #create attributes and lock/hide attrs on top nodes as well as masterGuide control
        displayAttr = attribute.addAttr(self.masterGuide, 'displayAxis', attrType = 'enum', defValue = 'off:on')
        attribute.lockAndHide(['r','t','s','v'], [self.setupRigGrp, self.skeletonGrp,self.guidesGrp, common.getParent(self.masterGuide)])
        attribute.lockAndHide('v', self.masterGuide)
        
        #resize guide controls
        for guide in self.getGuides():
            cmds.setAttr('%s.radius' % common.getShapes(guide, 0), self.controlScale * .5)
        
        #resize masterGuide control
        control.scaleShape(self.masterGuide, scale = [self.controlScale * 2, self.controlScale * 2, self.controlScale * 2])
        
        #declaring skeleton joints
        skeletonJnts = self.getSkeletonJnts()
        
        #connect joints to the attributes on the masterGuide control
        for jnt in skeletonJnts:
            if cmds.objExists(jnt):
                attribute.connect(displayAttr , '%s.displayLocalAxis' % jnt)
                common.setDisplayType(jnt, 'reference')

        #parent all constraints to guides group
        if self.setupConstraints:
            cmds.parent(self.setupConstraints, self.guidesGrp)

        #Put the build attributes onto setup rigs
        '''
        cmds.addAttr(self.setupRigGrp, ln = 'kwargs', dt = "string")
        cmds.setAttr('%s.kwargs' % self.setupRigGrp, str(self._buildAttrs), type = "string")
        '''
        attribute.copy('displayAxis', self.masterGuide, self.name(), reverseConnect = True)
        
        #parent setup under puppet node
        self._puppetNode.addChild(self.setupRigGrp)
        
        if self.parentHook:
            if cmds.objExists(self.parentHook):
                displayLine = control.displayLine(self.masterGuide, self.parentHook, name = self.masterGuide.replace('_%s' % common.GUIDES, '_%s' % common.CURVE))
                cmds.parent(displayLine, self.guidesGrp)

        #set build args on puppet node
        attrs = dict()
        for attr in self.attributes():
            attrs[attr.name()] = attr.value()
        self.puppetNode.storeArgs(**attrs)