Ejemplo n.º 1
0
 def setupIK(self):
     #Create shoulder 
     self.m_shoulderCtrl = cmds.spaceLocator(
         n=self.m_joints.m_shoulder.replace("_JNT", "_LOC")
         )[0]
     # Add to controls
     rc.addToControlDict(self.m_allControls, "%s_IKShoulder" %(self.m_baseName), self.m_shoulderCtrl)
     rc.addToLayer(self.m_sceneData, "hidden", self.m_shoulderCtrl)
     rc.orientControl(self.m_shoulderCtrl, self.m_joints.m_shoulder)
     rg.add3Groups(self.m_shoulderCtrl, ["_SDK", "_CONST", "_0"])
     cmds.parent(self.m_shoulderCtrl+"_0", self.m_group, r=1)
     cmds.pointConstraint(
         self.m_shoulderCtrl, 
         self.m_joints.m_shoulder, 
         mo=1
         )
     desiredName = self.m_wristCtrl.replace("_CTRL", "_IK")
     self.m_ikHandle = cmds.ikHandle(
         n = desiredName, 
         sj = self.m_joints.m_shoulder, 
         ee = self.m_joints.m_wrist, 
         sol = "ikRPsolver", 
         see = True
         )[0]
     # deselect so we don't get errors
     cmds.select(d=1)
     rc.addToLayer(self.m_sceneData, "hidden", [self.m_ikHandle])
     cmds.parent(self.m_ikHandle, self.m_wristCtrl)
     self.setupPoleVec()
Ejemplo n.º 2
0
 def rigWrist(self):
     self.m_wristCtrl = rg.stripMiddle(self.m_joints.m_wrist, 0, 1)+"_CTRL"
     self.m_wristCtrl = cmds.spaceLocator(n = self.m_wristCtrl)[0]
     rc.orientControl(self.m_wristCtrl, self.m_joints.m_wrist)
     rg.add3Groups(self.m_wristCtrl, ["_SDK", "_CONST", "_0"])
     cmds.parent(self.m_wristCtrl+"_0", self.m_group, r=1)
     # Add to controls
     rc.addToControlDict(self.m_allControls, "%s_IKWrist" %(self.m_baseName), self.m_wristCtrl)
     rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_wristCtrl)
Ejemplo n.º 3
0
    def rigElbow(self):
       #Check that shoulder has been done
       if not self.m_isShoulder:
           self.rigShoulder()
       
       #Rig for stretch
       self.m_stretchCtrl = rc.changeExt(
            self.m_joints.m_elbow1, 
            "_stretch_CTRL"
            )
       self.m_stretchCtrl = cmds.spaceLocator(
            n = self.m_stretchCtrl
            )[0]
       rc.orientControl(self.m_stretchCtrl, self.m_joints.m_shoulder)
       elbowDisplace = cmds.getAttr("%s.tx" %(self.m_joints.m_elbow1))
       groups = rg.add3Groups(self.m_stretchCtrl, ["_SDK", "_CONST", "_0"])
       cmds.parent(groups[2], self.m_shoulderGBLCtrl)
       cmds.setAttr("%s.tx" %(groups[2]), elbowDisplace)
       cmds.pointConstraint(self.m_stretchCtrl, self.m_joints.m_elbow1)

       # --- Elbow --- #
       self.m_elbowCtrl = rc.makeCTRL(
            self.m_joints.m_elbow1, 
            False, 
            True,
            ["_SDK", "_CONST", "_0"]
            )
       cmds.parent(self.m_elbowCtrl+"_0", self.m_stretchCtrl)
       #Connect up double rotations
       try:
           cmds.connectAttr(
                self.m_joints.m_elbow1+".rotate",
                self.m_joints.m_elbow2+".rotate", 
                f=1
                )
       except:
           print "Warning, double joint rotations seem to already be connected"
       
       #- lock and hide unused attributes -#
       rc.lockAttrs(
            self.m_stretchCtrl, 
            ["ty", "tz", "rx", "ry", "rz", "sx",  "sy",  "sz"]
            )

       rc.lockAttrs(
            self.m_elbowCtrl, 
            ["tx", "ty", "tz",  "sx",  "sy",  "sz"]
            )
       rc.addToLayer(self.m_sceneData, "mainCtrl", [self.m_stretchCtrl, self.m_elbowCtrl])
       #Add to controls
       rc.addToControlDict(self.m_allControls, "%s_FKElbowStretch" %(self.m_baseName), self.m_stretchCtrl)
       rc.addToControlDict(self.m_allControls, "%s_FKElbow" %(self.m_baseName), self.m_elbowCtrl)
       self.m_isElbow = True
Ejemplo n.º 4
0
    def aimWrist(self, _fkWrist, _blendControlAttrs):
        error.assertType(_fkWrist, ["", u''])
        error.assertList(_blendControlAttrs, ["", u''])
        assert len(_blendControlAttrs) == 2, "_blendControls must contain two elements"
        

        # Make sure wrist is aimed right

        # create fix control that always aims as fk should.
        # this is used to help blend between ik and fk
        if (self.m_rigWrist):
            group = cmds.group(n="%s_wrist_blendFix_GRP" %(self.m_name), em=True)
            cmds.parent(group, self.m_group)
            rc.orientControl(group, self.m_wristCtrl)
            cmds.pointConstraint(self.m_joints.m_wrist, group, mo=1)
            # Create up locator
            wristAimFix = cmds.spaceLocator(n="%s_wristAimFix_LOC" %(self.m_name))[0]
            rc.addToLayer(self.m_sceneData, "hidden", wristAimFix)
            cmds.parent(wristAimFix, self.m_joints.m_elbow2, r=1)
            aimOffset = 1
            if self.m_isMirrored:
                aimOffset *= -1
            cmds.setAttr("%s.t%s" %(wristAimFix, self.m_twistAxis), aimOffset)
            aim = cmds.aimConstraint(
                self.m_joints.m_elbow2,
                group,
                worldUpType = "object",
                worldUpObject = wristAimFix,
                mo = True
                )[0]

            orient = cmds.orientConstraint(
                _fkWrist,
                "%s_SDK" %(self.m_wristCtrl),
                mo= True
                )[0]
            orient = cmds.orientConstraint(
                group,
                "%s_SDK" %(self.m_wristCtrl),
                mo= True
                )[0]
            cmds.setAttr("%s.interpType" %(orient), 2)
            cmds.connectAttr(
                _blendControlAttrs[0],
                "%s.%sW0" %(orient, _fkWrist)
                )
            cmds.connectAttr(
                _blendControlAttrs[1],
                "%s.%sW1" %(orient, group)
                )
Ejemplo n.º 5
0
 def clusterPoint(self, _point, _control, _name, _constraint = cmds.parentConstraint, _aim = False):
     #pos = cmds.xform(_control, t=1, q=1, ws=1)
     #cmds.xform(_point, t=pos, ws=1)
     clusterResult = cmds.cluster(_point, n=_name)
     #cmds.setAttr(clusterResult[1]+".visibility", 0)
     rc.addToLayer(self.m_sceneData, "hidden", [clusterResult[1]])
     cmds.parent(clusterResult[1], self.m_group)
     _constraint(_control, clusterResult[1], mo=1)
     if _aim:
         cmds.aimConstraint(
             _aim,
             clusterResult[1],
             mo=True
             )
     return clusterResult[1]
Ejemplo n.º 6
0
    def setupPoleVec(self):
        middleName = rg.stripMiddle(self.m_joints.m_shoulder, 0, 3)
        desiredName = self.m_name+"PoleVec_LOC"
        self.m_poleVec = cmds.spaceLocator(n = desiredName)[0]
        # Add to controls
        rc.addToControlDict(self.m_allControls, "%s_IKPoleVec" %(self.m_baseName), self.m_poleVec)
        rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_poleVec)
        cmds.addAttr(
            self.m_poleVec, 
            ln=self.m_poleVecPinAttr, 
            min=0, 
            max=1, 
            k=True, 
            dv=0
            )
        cmds.addAttr(
            self.m_poleVec, 
            ln=self.m_maxStretchAttr, 
            at = "float", 
            min=0, 
            dv=10, 
            k=1
            )
        self.m_maxStretch = "%s.%s" %(self.m_poleVec, self.m_maxStretchAttr)
        rc.orientControl(self.m_poleVec, self.m_joints.m_elbow1)
        groups = rg.add3Groups(self.m_poleVec, ["_SDK", "_CONST", "_0"])
        cmds.poleVectorConstraint(self.m_poleVec, self.m_ikHandle)
        cmds.parent(groups[-1], self.m_group, r=1)
        # Lock unused attributes
        rc.lockAttrs(
            self.m_poleVec,
            ["scale", "rotate"],
            True,
            False
            )


        axis , offset = self.getPoleVecAxis(2)
        if axis != "":
            cmds.setAttr("%s.t%s" %(groups[1], axis), offset) 

        #Create line
        midGroup = cmds.group(em=1, n=self.m_name+"PoleVec_GRP")
        cmds.parent(midGroup, self.m_group)
        cmds.pointConstraint(self.m_joints.m_elbow1, midGroup)
        cmds.pointConstraint(self.m_joints.m_elbow2, midGroup)
        lineNodes = rc.createLine([self.m_poleVec, midGroup], self.m_sceneData, "mainCtrl")
        cmds.parent(lineNodes[0], self.m_group)
Ejemplo n.º 7
0
 def rigShoulder(self):
    try:
        # --- Shoulder --- #
        #Create shoulder controls
        gimbalCtrls = rc.makeGimbalCTRL(
             self.m_joints.m_shoulder, 
             False, 
             True
             )
        self.m_shoulderGBLCtrl = gimbalCtrls[0]
        self.m_shoulderCtrl = gimbalCtrls[1]    
        # Add to controls
        rc.addToControlDict(self.m_allControls, "%s_FKShoulder" %(self.m_baseName), self.m_shoulderCtrl)
        rc.addToControlDict(
           self.m_allControls,
           "%s_FKShoulderGBL" %(self.m_baseName),
           self.m_shoulderGBLCtrl
           )
        rc.addToLayer(self.m_sceneData, "mainCtrl", gimbalCtrls)      
        self.m_isShoulder = True
        cmds.parent(self.m_shoulderCtrl+"_0", self.m_group, r=1)
        cmds.pointConstraint(
             self.m_shoulderGBLCtrl, 
             self.m_joints.m_shoulder
             )
        #Sort out scaling
        cmds.scaleConstraint(
             self.m_shoulderGBLCtrl, 
             self.m_joints.m_shoulder
             )
         
        #Lock unused attributes
        rc.lockAttrs(
             self.m_shoulderCtrl,
             ["translate", "scale"],
             True,
             False
             )
        rc.lockAttrs(
             self.m_shoulderGBLCtrl,
             ["translate", "scale"],
             True,
             False
             )
    except:
        print "WARNING: FK Shoulder setup was unsuccessful!"
        self.m_isShoulder = False
Ejemplo n.º 8
0
    def createToe(self):
        if not self.m_ankleGenerated:
            self.createAnkle()
        self.m_toeCtrl = cmds.circle(
            n="%s_toe_CTRL" %(self.m_name),
            nr=(1, 0, 0)
            )[0]
        rc.addToControlDict(self.m_allControls, "%s_FKToe" %(self.m_baseName), self.m_toeCtrl)
        rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_toeCtrl)
        rc.orientControl(self.m_toeCtrl, self.m_joints[1])
        groups = rg.add3Groups(self.m_toeCtrl, ["_SDK", "_CONST", "_0"])
        cmds.parentConstraint(self.m_toeCtrl, self.m_joints[1])
        cmds.parent(groups[-1], self.m_ankleCtrl)

        self.m_toeGenerated = True
        #Lock unused attributes
        rc.lockAttrs(self.m_toeCtrl, ["translate", "scale"], True, False)
Ejemplo n.º 9
0
    def __init__(
            self,
            _sceneData,
            _joints,
            _name,
            _baseName,
            _twistAxis="y",
            _rigWrist=True,
            _blendControl=False
            ):
        self.m_sceneData = _sceneData
        self.m_startJoints = aj.ArmJoints(_joints)
        # Make sure to strip blendParent2 attribute otherwise ik fk blending
        # can break. This sometimes happens if joints are taken from a previous
        # version of the rig and used to generate a new one.
        for joint in self.m_startJoints.getJointList():
            rc.stripAttr(joint, "blendParent2")

        self.m_name = _name
        self.m_baseName = _baseName
        self.m_group = "%s_GRP" %(self.m_name)
        if not cmds.objExists(self.m_group):
            self.m_group = cmds.group(n=self.m_group, em=True)

        self.m_twistAxis = _twistAxis
        self.m_rigWrist = _rigWrist
        self.m_blendControl = _blendControl
        self.m_isMirrored = self.checkMirroring()
        self.m_allControls = {}
        if not self.m_blendControl:
            self.m_blendControl = cmds.circle(n=self.m_name+"_IKFKBlend_CTRL")[0]
            cmds.parent(self.m_blendControl, self.m_group)
            rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_blendControl)	
            rc.addToControlDict(self.m_allControls, "%s_IKFKBlend" %(self.m_baseName), self.m_blendControl)
        self.m_isGenerated = False
        
        # stretch chain parameters
        self.m_numUpperControls = 2
        self.m_numLowerControls = 2
        self.m_numUpperJoints = 5
        self.m_numLowerJoints = 5
        self.m_upperStretchJoints = False
        self.m_lowerStretchJoints = False
Ejemplo n.º 10
0
    def setupElbowTwist(self):
        # Create joints
        cmds.select(d=1)
        joint1 = cmds.joint(n="%s_midTwist_JNT" %(self.m_name))#, s=[0.1, 0.1, 0.1])
        cmds.setAttr("%s.radius" %(joint1), 0.15)
        rc.orientControl(joint1, self.m_joints.m_elbow1)
        joint2 = cmds.joint(n="%s_midTwistEnd_JNT" %(self.m_name))#, s=[0.1, 0.1, 0.1])
        cmds.setAttr("%s.radius" %(joint2), 0.15)
        rc.orientControl(joint2, self.m_joints.m_elbow2)
        cmds.parent(joint1, self.m_group)
        self.m_elbowTwistJoints = [joint1, joint2]
        rc.addToLayer(self.m_sceneData, "ref", self.m_elbowTwistJoints)
        rc.addToSet(self.m_sceneData, "bind", self.m_elbowTwistJoints[0])
        # sort out joint orientations
        tmpLocator = cmds.spaceLocator()[0]
        cmds.parent(tmpLocator, self.m_joints.m_elbow1, r=1)
        cmds.setAttr("%s.t%s" %(tmpLocator, self.m_twistAxis), 1)
        rc.reorientJoints(self.m_elbowTwistJoints, tmpLocator)
        cmds.delete(tmpLocator)
        

        # Create control
        self.m_elbowTwist = cmds.spaceLocator(n="%s_midTwist_CTRL" %(self.m_name))[0]
        rc.orientControl(self.m_elbowTwist, self.m_elbowTwistJoints[0])
        cmds.parent(self.m_elbowTwist, self.m_group)
        groups = rg.add3Groups(self.m_elbowTwist, ["_SDK", "_CONST", "_0"])
        # Create aim locator
        self.m_elbowTwistAimLoc = cmds.spaceLocator(n="%s_midTwistAim_LOC" %(self.m_name))[0]
        cmds.parent(self.m_elbowTwistAimLoc, self.m_elbowTwist, r=1)
        aimOffset = 1
        if(self.m_isMirrored):
            aimOffset *=1

        cmds.setAttr("%s.tx" %(self.m_elbowTwistAimLoc), aimOffset)
        rc.addToLayer(self.m_sceneData, "hidden", self.m_elbowTwistAimLoc)
        # Connect up joint
        cmds.pointConstraint(self.m_elbowTwist, self.m_elbowTwistJoints[0])
        cmds.parentConstraint(self.m_joints.m_elbow1, groups[1])
        self.m_twistAimConstraint = cmds.aimConstraint(
            self.m_elbowTwistAimLoc,
            self.m_elbowTwistJoints[0],
            mo=1
            )
Ejemplo n.º 11
0
 def rigWrist(self):
     gimbalCtrls = rc.makeGimbalCTRL(self.m_joints.m_wrist, False, False)
     self.m_wristCtrl = gimbalCtrls[1]
     self.m_wristGBLCtrl = gimbalCtrls[0]
     rc.addToControlDict(self.m_allControls, "%s_bindWrist" %(self.m_baseName), self.m_wristCtrl)
     rc.addToControlDict(self.m_allControls, "%s_bindWristGBL" %(self.m_baseName), self.m_wristGBLCtrl)
     rc.addToLayer(self.m_sceneData, "mainCtrl", gimbalCtrls)
     #Lock controls
     for control in [self.m_wristCtrl, self.m_wristGBLCtrl]:
         cmds.setAttr(control+".translate", l=1)
         cmds.setAttr(control+".scale", l=1)
     
     cmds.parent(self.m_wristCtrl+"_0", self.m_group)
     cmds.pointConstraint(self.m_joints.m_wrist, self.m_wristCtrl+"_CONST")
     cmds.orientConstraint(
         self.m_wristGBLCtrl, 
         self.m_joints.m_wrist, 
         mo=True
         )
Ejemplo n.º 12
0
 def createJoints(self):
     if not self.m_userJoints:
         self.m_bindJoints = []
         startPos = cmds.xform(self.m_parent1, q=1, t=1, ws=1)
         endPos = cmds.xform(self.m_parent2, q=1, t=1, ws=1)
         stepVec = vec.divide(
             vec.subtract(endPos, startPos), 
             self.m_numJoints - 1
             )
         currentPos = startPos
         for i in range(self.m_numJoints):
             newJoint = self.m_name+"_"+str(i)+"_BIND_JNT"
             newJoint = cmds.joint(n=newJoint, p=currentPos)
             cmds.setAttr("%s.radius" %(newJoint), 0.1)
             self.m_bindJoints.append(newJoint)
             currentPos = vec.add(currentPos, stepVec)
         #fix orientations
         cmds.joint(
             self.m_bindJoints[0], 
             e=1, 
             oj="xyz", 
             sao = "yup", 
             ch=1, 
             zso=1
             )
     else:
         # Duplicate joints and rename
         newJoints = cmds.duplicate(self.m_userJoints[0], rc=1)
         for i in range(len(newJoints)):
             newJoint = "%s_%d_BIND_JNT" %(self.m_name, i)
             newJoints[i] = cmds.rename(newJoints[i], newJoint)
         self.m_bindJoints = newJoints
     #Put it in the right group
     cmds.parent(self.m_bindJoints[0], self.m_group)
     rc.addToLayer(self.m_sceneData, "ref", self.m_bindJoints[0])
     #Strip sets
     for joint in self.m_bindJoints:
         rc.stripSets(joint)
     #Add all except first and last to bind set
     for joint in self.m_bindJoints[:-1]:
         rc.addToSet(self.m_sceneData, "bind", joint)
Ejemplo n.º 13
0
 def rigWrist(self):
    #Check that shoulder has been done
    if not self.m_isElbow:
        self.rigElbow()
    # --- Wrist --- #
    self.m_wristCtrl = rc.makeCTRL(
         self.m_joints.m_wrist, 
         False,
         False,
         ["_SDK", "_CONST", "_0"]
         )
    # Sort orientation
    rc.orientControl(self.m_wristCtrl+"_0", self.m_joints.m_elbow2)
    rc.copyTranslation(self.m_wristCtrl+"_0", self.m_joints.m_wrist)
    #Parent for neatness
    cmds.parent(self.m_wristCtrl+"_0", self.m_elbowCtrl)
    #Connect up to previous joint
    cmds.parentConstraint(
         self.m_joints.m_elbow2,
         self.m_wristCtrl+"_CONST",
         mo=1
         )
    cmds.pointConstraint(
         self.m_wristCtrl,
         self.m_joints.m_wrist,
         skip=["y", "z"]
         )
    rc.lockAttrs(
         self.m_wristCtrl,
         ["ty", "tz", "rotate", "scale"],
         True,
         False
         )
    # Add to controls
    rc.addToControlDict(self.m_allControls, "%s_FKWrist" %(self.m_baseName), self.m_wristCtrl)
    rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_wristCtrl)
    self.m_isWrist = True
Ejemplo n.º 14
0
    def generate(self):
        cmds.cycleCheck(e=False)
        # -- Duplicate joints and rename for IK-FK switch --- #
        self.m_bindJoints = self.duplicateJoints(self.m_startJoints, "BIND")
        rc.addToLayer(self.m_sceneData, "ref", self.m_bindJoints[0])
        self.m_ikJoints = self.duplicateJoints(self.m_startJoints, "IK")
        rc.addToLayer(self.m_sceneData, "ref", self.m_ikJoints[0])
        self.m_fkJoints = self.duplicateJoints(self.m_startJoints, "FK")
        rc.addToLayer(self.m_sceneData, "ref", self.m_fkJoints[0])

        # -- Create shoulder locator -- #
        self.m_shoulderLocator = self.m_name+"_shoulder_CTRL"
        self.m_shoulderLocator = cmds.spaceLocator(n=self.m_shoulderLocator)[0]
        rc.addToLayer(self.m_sceneData, "detailCtrl", self.m_shoulderLocator)
        rc.orientControl(self.m_shoulderLocator, self.m_startJoints.m_shoulder)
        shoulderGRPs = rg.add3Groups(
            self.m_shoulderLocator, 
            ["_SDK", "_CONST", "_0"]
            )
        cmds.parent(shoulderGRPs[-1], self.m_group)
        # -- Setup FK rig -- #
        tmpList = self.m_fkJoints.getJointList()
        self.m_fkRig = fk.FKArmRig(self.m_sceneData, tmpList, self.m_name+"_FK", self.m_baseName)
        self.m_fkRig.generate()
        cmds.parent(self.m_fkRig.m_group, self.m_group)
        cmds.parentConstraint(
            self.m_shoulderLocator, 
            self.m_fkRig.getMainTransform(),
            mo=True
            )
        # -- Setup IK rig -- #
        tmpList = self.m_ikJoints.getJointList()
        self.m_ikRig = ik.IKArmRig(
            self.m_sceneData,
            tmpList, 
            self.m_name+"_IK",
            self.m_baseName,
            self.m_isMirrored,
            self.m_twistAxis
            )
        self.m_ikRig.generate()
        cmds.parent(self.m_ikRig.m_group, self.m_group)
        cmds.pointConstraint(
            self.m_shoulderLocator,
            self.m_ikRig.getMainTransform(),
            mo=True
            )
        # -- Setup BIND rig -- #
        tmpList = self.m_bindJoints.getJointList()
        self.m_bindRig = bind.BINDArmRig(
            self.m_sceneData,
            tmpList, 
            self.m_name+"_BIND",
            self.m_baseName,
            self.m_blendControl,
            self.m_numUpperControls,
            self.m_numLowerControls,
            self.m_numUpperJoints,
            self.m_numLowerJoints,
            self.m_upperStretchJoints,
            self.m_lowerStretchJoints,
            self.m_isMirrored,
            self.m_twistAxis,
            self.m_rigWrist
            )    
        self.m_bindRig.generate()
        cmds.parent(self.m_bindRig.m_group, self.m_group) 
        cmds.pointConstraint(
            self.m_shoulderLocator,
            self.m_bindRig.getMainTransform(),
            mo=True
            )
        # rig the blend control for aestethics
        if self.m_rigWrist:
            self.rigBlendControl(self.m_bindRig.getWristCtrl())


        # -- Connect up rigs -- #
        try:
            tmp = self.m_blendControl
        except:
            self.m_blendControl = self.createBlendControl()
        self.connectIKFK()
        # -- Setup visibility -- #
        self.setupVisibility()
         
        cmds.cycleCheck(e=True)
        
        # Add all controls
        rc.addToControlDict(
            self.m_allControls,
            "%s_shoulderLocator" %(self.m_baseName),
            self.m_shoulderLocator
            )
        rc.addDictToControlDict(self.m_allControls, self.m_fkRig.getAllControls())
        rc.addDictToControlDict(self.m_allControls, self.m_ikRig.getAllControls())
        rc.addDictToControlDict(self.m_allControls, self.m_bindRig.getAllControls())

        self.m_isGenerated = True
Ejemplo n.º 15
0
    def generate(self):
        # Generate controls
        self.m_heelRoll = cmds.spaceLocator(
            n="%s_heelRoll_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_heelRoll" %(self.m_baseName),
            self.m_heelRoll
            )
        self.m_insideRoll = cmds.spaceLocator(
            n="%s_insideRoll_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_insideRoll" %(self.m_baseName),
            self.m_insideRoll
            )
        self.m_outsideRoll = cmds.spaceLocator(
            n="%s_outsideRoll_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_outsideRoll" %(self.m_baseName),
            self.m_outsideRoll
            )
        self.m_toeRoll = cmds.spaceLocator(
            n="%s_toeRoll_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_toeRoll" %(self.m_baseName),
            self.m_toeRoll
            )
        self.m_ballRoll = cmds.spaceLocator(
            n="%s_ballRoll_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_ballRoll" %(self.m_baseName),
            self.m_ballRoll
            )
        self.m_toeFlap = cmds.spaceLocator(
            n="%s_toeFlap_CTRL" %(self.m_name)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_toeFlap" %(self.m_baseName),
            self.m_toeFlap
            )
        rc.addToLayer(
            self.m_sceneData,
            "detailCtrl",
            [
                self.m_heelRoll,
                self.m_insideRoll,
                self.m_outsideRoll,
                self.m_toeRoll,
                self.m_ballRoll,
                self.m_toeFlap
            ]
            )
        self.m_mainCtrl = cmds.circle(
            n="%s_main_CTRL" %(self.m_name),
            nr=(1, 0, 0)
            )[0]
        rc.addToControlDict(
            self.m_allControls,
            "%s_mainCtrl" %(self.m_baseName),
            self.m_mainCtrl
            )
        rc.addToLayer(self.m_sceneData, "mainCtrl", self.m_mainCtrl)
        rc.orientControl(self.m_mainCtrl, self.m_footMainLoc)
        cmds.parent(self.m_mainCtrl, self.m_group)
        mainCtrlGroups = rg.add3Groups(
            self.m_mainCtrl, 
            ["_SDK", "_CONST", "_0"]
            )
        # Move everything into the right places
        rc.orientControl(self.m_heelRoll, self.m_heelPivotLoc)
        rc.orientControl(self.m_insideRoll, self.m_insidePivotLoc)
        rc.orientControl(self.m_outsideRoll, self.m_outsidePivotLoc)
        rc.orientControl(self.m_toeRoll, self.m_toePivotLoc)
        rc.orientControl(self.m_ballRoll, self.m_joints[1])
        rc.orientControl(self.m_toeFlap, self.m_joints[1])



        # Parent everything
        cmds.parent(self.m_heelRoll, self.m_mainCtrl)
        cmds.parent(self.m_insideRoll, self.m_heelRoll)
        cmds.parent(self.m_outsideRoll, self.m_insideRoll)
        cmds.parent(self.m_toeRoll, self.m_outsideRoll)
        cmds.parent(self.m_ballRoll, self.m_toeRoll)
        cmds.parent(self.m_toeFlap, self.m_toeRoll)

        # Create Groups above
        defaultExt = ["_SDK", "_CONST", "_0"]
        rg.add3Groups(self.m_heelRoll, defaultExt)
        rg.add3Groups(self.m_insideRoll, defaultExt)
        rg.add3Groups(self.m_outsideRoll, defaultExt)
        rg.add3Groups(self.m_toeRoll, defaultExt)
        rg.add3Groups(self.m_ballRoll, defaultExt)
        rg.add3Groups(self.m_toeFlap, defaultExt)

        # Create IKs
        self.m_footIK = cmds.ikHandle(
            sj=self.m_joints[0],
            ee=self.m_joints[1],
            sol="ikRPsolver"
            )[0]
        # deselect so we don't get warnings
        cmds.select(d=1)
        cmds.parent(self.m_footIK, self.m_ballRoll)
        self.m_toeIK = cmds.ikHandle(
            sj=self.m_joints[1],
            ee=self.m_joints[2],
            sol="ikRPsolver"
            )[0]
        # deselect so we don't get warnings
        cmds.select(d=1)
        cmds.parent(self.m_toeIK, self.m_toeFlap)

        rc.addToLayer(self.m_sceneData, "hidden", [self.m_footIK, self.m_toeIK])

        # Sort ankle
        cmds.parentConstraint(self.m_ballRoll, self.m_ankleIK, mo=True)
        cmds.parentConstraint(self.m_ankleIK, self.m_joints[0], mo=True)
Ejemplo n.º 16
0
    def createControls(self):
        #If no blend control is speified add one
        if not self.m_blendControl:
            self.m_blendControl = cmds.circle(n=self.m_name+"Blend_CTRL")[0]
            cmds.parent(self.m_blendControl, self.m_group)
            self.m_allControls.append(self.m_blendControl)
            rc.addToControlDict(
                self.m_allControls,
                "%s_StretchChainCtrl" %(self.m_baseName),
                self.m_blendControl
                )

        cmds.addAttr(
            self.m_blendControl,
            ln=self.m_attrHeading,
            k=True,
            at = "enum",
            en = "---------:"
            )

        if self.m_isAutoBend:
            cmds.addAttr(
                self.m_blendControl, 
                ln=self.m_blendAttrName, 
                k=1, min=0, max=1, dv=0
                )
            blendNodeAttr = self.m_blendControl+"."+self.m_blendAttrName
            oppBlendNodeAttr = rc.create1MinusNode(
                blendNodeAttr, 
                self.m_name+"OppBlend_CTRL" 
                )
        
        self.m_controls = []
        self.m_parentCtrls = []
        self.m_pointCtrls = []
        startPos = cmds.xform(self.m_parent1, q=1, t=1, ws=1)
        endPos = cmds.xform(self.m_parent2, q=1, t=1, ws=1)
        stepVec = vec.divide(
            vec.subtract(endPos, startPos), 
            self.m_numCtrls + 1
            )
        currentPos = vec.add(startPos, stepVec)
        for i in range(self.m_numCtrls):
            newCtrl = self.m_name+"_"+str(i)+"_CTRL"
            parentCtrl = self.m_name+"_"+str(i)+"_parent_CTRL"
            pointCtrl = self.m_name+"_"+str(i)+"_point_CTRL"
            
            newCtrl = cmds.spaceLocator(n=newCtrl)[0]
            self.m_controls.append(newCtrl)
            cmds.parent(newCtrl, self.m_group)
            cmds.xform(newCtrl, t=currentPos, ws=1)
            newCtrlGroups = rg.add3Groups(newCtrl, ["_SDK", "_CONST", "_0"])
            
            if self.m_isAutoBend:
                parentCtrl = cmds.duplicate(newCtrl, n=parentCtrl)[0]
                cmds.parent(parentCtrl, newCtrlGroups[2])
                #cmds.setAttr(parentCtrl+".visibility", 0)
                pointCtrl = cmds.duplicate(newCtrl, n=pointCtrl)[0]
                cmds.parent(pointCtrl, newCtrlGroups[2])
                #cmds.setAttr(pointCtrl+".visibility", 0)

                rc.addToLayer(self.m_sceneData, "hidden", [parentCtrl, pointCtrl])

                #Create blend between parent and point setups
                blendConst = cmds.pointConstraint(parentCtrl, newCtrlGroups[1])
                cmds.connectAttr(blendNodeAttr, blendConst[0]+"."+parentCtrl+"W0")
                blendConst = cmds.pointConstraint(pointCtrl, newCtrlGroups[1])
                cmds.connectAttr(oppBlendNodeAttr, blendConst[0]+"."+pointCtrl+"W1")
                
                
                self.m_parentCtrls.append(parentCtrl)
                self.m_pointCtrls.append(pointCtrl)
                
                grandParent = cmds.listRelatives(self.m_parent1, p=1)
                if grandParent == None or not self.m_isParentBend:
                    grandParent = self.m_parent1
                
                parentConst = rc.applyWeightedConstraint(
                    grandParent, 
                    parentCtrl, 
                    self.m_parent2, 
                    cmds.parentConstraint
                    )
                pointConst = rc.applyWeightedConstraint(
                    self.m_parent1, 
                    pointCtrl, 
                    self.m_parent2, 
                    cmds.pointConstraint
                    )
            cmds.aimConstraint(
                    self.m_parent2,
                    newCtrlGroups[1]
                    )
            currentPos = vec.add(currentPos, stepVec)
            #lock attrs
            cmds.setAttr(newCtrl+".rotate", l=1)
            cmds.setAttr(newCtrl+".scale", l=1)
        rc.addToLayer(self.m_sceneData, "detailCtrl", self.m_controls)
        # Add controls
        i=0
        for control in self.m_controls:
            rc.addToControlDict(self.m_allControls, "%s_%d_detail" %(self.m_baseName, i), control)
            i+=1
Ejemplo n.º 17
0
 def createIK(self):
     numCVs = self.m_numCtrls - 1
     if self.m_numCtrls == 1:
         numCVs = 4
     ikResult = cmds.ikHandle(
        sol = "ikSplineSolver",
        sj=self.m_bindJoints[0], 
        ee=self.m_bindJoints[-1],
        ns=numCVs, 
        n = self.m_name + "_IK"
        )
     # deselect so we don't get warnings
     cmds.select(d=1)
     self.m_ikCurve = ikResult[2]
     rc.addToLayer(self.m_sceneData, "hidden", self.m_ikCurve)
     newCurveName = self.m_name+"_IK_CURVE"
     self.m_ikCurve = cmds.rename(self.m_ikCurve, newCurveName)
     self.m_ikHandle = ikResult[0]
     cmds.parent(self.m_ikHandle, self.m_group)
     #cmds.setAttr(self.m_ikHandle+".visibility", 0)
     rc.addToLayer(self.m_sceneData, "hidden", [self.m_ikHandle])
     #Make sure curve does not get double transformed
     cmds.setAttr(self.m_ikCurve+".inheritsTransform", 0)
     self.m_clusters = []
     
     #Create clusters
     if len(self.m_controls) == 1:
         name = self.m_parent1[:self.m_parent1.rfind("_")]+"_stretch_CLUSTER"
         self.m_clusters.append(self.clusterPoint(
             [
                 self.m_ikCurve+".cv[0]",
                 self.m_ikCurve+".cv[1]"
             ],
             self.m_parent1,
             name,
             cmds.pointConstraint,
             self.m_parent2
             ))
         name = self.m_controls[0][:self.m_controls[0].rfind("_")]+\
             "_stretch_CLUSTER"
         self.m_clusters.append(self.clusterPoint(
             [
                 self.m_ikCurve+".cv["+str(2)+"]",
                 self.m_ikCurve+".cv["+str(3)+"]",
                 self.m_ikCurve+".cv["+str(4)+"]"
             ], 
             self.m_controls[0],
             name
             ))
         name = self.m_parent2[:self.m_parent2.rfind("_")]+"_stretch_CLUSTER"
         self.m_clusters.append(self.clusterPoint(
             [
                 self.m_ikCurve+".cv["+str(5)+"]", 
                 self.m_ikCurve+".cv["+str(6)+"]" 
             ],
             self.m_parent2, 
             name,
             cmds.pointConstraint,
             self.m_parent1
             ))
     else:
         name = self.m_parent1[:self.m_parent1.rfind("_")]+"_stretch_CLUSTER"
         self.m_clusters.append(self.clusterPoint(self.m_ikCurve+".cv[0]", self.m_parent1, name))
         for i in range(0, len(self.m_controls)):
             name = self.m_controls[i][:self.m_controls[i].rfind("_")]+\
                 "_stretch_CLUSTER"
             self.m_clusters.append(self.clusterPoint(
                 self.m_ikCurve+".cv["+str(i+1)+"]", 
                 self.m_controls[i],
                 name
                 ))
         name = self.m_parent2[:self.m_parent2.rfind("_")]+"_stretch_CLUSTER"
         self.m_clusters.append(self.clusterPoint(
             self.m_ikCurve+".cv["+str(self.m_numCtrls+2)+"]", 
             self.m_parent2, 
             name
             ))
     
     
     
     #Do stretch
     self.m_curveInfo = cmds.createNode(
         "curveInfo", 
         n=self.m_name+"_CURVEINFO"
         )
     cmds.connectAttr(
         self.m_ikCurve+".worldSpace", 
         self.m_curveInfo+".inputCurve"
         )
     scaleComp = cmds.createNode(
         "multiplyDivide",
         n=self.m_name+"_IK_scaleComp_MULT"
         )
     cmds.setAttr(scaleComp+".operation", 2)
     cmds.connectAttr(
         self.m_curveInfo+".arcLength", 
         scaleComp+".input1X"
         )
     cmds.connectAttr(self.m_scaleNull+".sx", scaleComp+".input2X")
     normaliseNode = cmds.createNode(
         "multiplyDivide", 
         n=self.m_name+"_normalise_MULT"
         )
     cmds.connectAttr(scaleComp+".outputX", normaliseNode+".input1X")
     cmds.setAttr(normaliseNode+".input2X", self.m_numJoints-1)
     cmds.setAttr(normaliseNode+".operation", 2)
     # VOLUME RETENTION #
     #Create overall stretch node
     stretchAmount = cmds.createNode(
         "multiplyDivide", 
         n=self.m_name+"_IK_sretchValue_MULT"
         )
     # #---set to division
     cmds.setAttr(stretchAmount+".operation", 2)
     cmds.connectAttr(
         self.m_curveInfo+".arcLength", 
         stretchAmount+".input1X"
         )
     currentLen = cmds.getAttr(self.m_curveInfo+".arcLength")
     cmds.setAttr(stretchAmount+".input2X", currentLen)
     
     # Add squetch control
     cmds.addAttr(
         self.m_blendControl, 
         ln=self.m_squetchAttrName, 
         min=0, 
         dv=1, 
         k=1
         )
     cmds.addAttr(
         self.m_blendControl, 
         ln=self.m_squetchBoolAttrName, 
         k=1, 
         dv=1, 
         at="bool"
         )
     stretchExp =  self.makeStretchExpression(
         self.m_blendControl+"."+self.m_squetchAttrName,
         stretchAmount+".outputX",
         self.m_blendControl+"."+self.m_squetchBoolAttrName
         )
     cmds.expression(n=self.m_name+"_IK_stretch_EXP", s=stretchExp)
Ejemplo n.º 18
0
    def createTwist(self):
        numJoints = len(self.m_bindJoints)
        if numJoints == 0:
            raise Exception, "No joints, cannot create twist setup"
        
        #Create twist controls
        # Twist 1
        self.m_twistControl1 = cmds.spaceLocator(
            n="%s_upperTwist_CTRL" %(self.m_name)
            )[0]
        #cmds.parent(self.m_twistControl1, self.m_parent1, r=1)
        
        # Twist 2
        self.m_twistControl2 = cmds.spaceLocator(
            n="%s_lowerTwist_CTRL" %(self.m_name)
            )[0]
        #cmds.parent(self.m_twistControl2, self.m_parent2, r=1)

        for control, parent in map(
                                    None, 
                                    [self.m_twistControl1, self.m_twistControl2],
                                    [self.m_parent1, self.m_parent2]
                                    ): 
            rc.orientControl(control, parent)
            groups = rg.add3Groups(control, ["_SDK", "_CONST", "_0"])
            if self.m_isMirrored:
                cmds.setAttr(
                    "%s.t%s" %(groups[0], self.m_twistAxis),
                    1
                    )
            else:
                cmds.setAttr(
                    "%s.t%s" %(groups[0], self.m_twistAxis),
                    -1
                    )
            if self.m_isParentTwist:
                cmds.parentConstraint(parent, groups[1], mo=1)
            cmds.parent(groups[2], self.m_group)
            rc.lockAttrs(
                control,
                ["rotate", "scale", "visibility"],
                True,
                False
                )

        cmds.setAttr("%s.dTwistControlEnable" %(self.m_ikHandle), 1)
        cmds.setAttr("%s.dWorldUpType" %(self.m_ikHandle), 2)
        cmds.setAttr("%s.dTwistValueType" %(self.m_ikHandle), 1)

        if self.m_twistAxis == "y":
            if self.m_isMirrored:
                cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 0)
            else:
                cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 1)
        else:
            if self.m_isMirrored:
                cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 3)
            else:
                cmds.setAttr("%s.dWorldUpAxis" %(self.m_ikHandle), 4)
        
        cmds.connectAttr(
            "%s.worldMatrix[0]" %(self.m_twistControl1),
            "%s.dWorldUpMatrix" %(self.m_ikHandle),
            f = True
            )
        cmds.connectAttr(
            "%s.worldMatrix[0]" %(self.m_twistControl2),
            "%s.dWorldUpMatrixEnd" %(self.m_ikHandle),
            f = True
            )
        rc.addToLayer(self.m_sceneData, "detailCtrl", [self.m_twistControl1, self.m_twistControl2])

        #Add to controls
        rc.addToControlDict(self.m_allControls, "%s_topTwist" %(self.m_baseName), self.m_twistControl1)
        rc.addToControlDict(self.m_allControls, "%s_lowTwist" %(self.m_baseName), self.m_twistControl2)
Ejemplo n.º 19
0
    def setupStretch(self):
       #Create the bendy bits 
        self.m_upperStretch = chain.StretchChain(
            self.m_sceneData,
            self.m_joints.m_shoulder, 
            self.m_elbowTwistJoints[0], #self.m_joints.m_elbow1,#
            self.m_name+"_upperStretch", 
            "%s_upperStretch" %(self.m_baseName),
            self.m_numLowerControls, 
            self.m_numUpperJoints
            )
        self.m_upperStretch.setMirroring(self.m_isMirrored)
        self.m_upperStretch.setBendFromParent(False)
        self.m_upperStretch.setBlendControl(self.m_controlObject)
        self.m_upperStretch.setBlendAttrName("upperBend") 
        self.m_upperStretch.setSquetchAttrName("upperSquetchiness")
        self.m_upperStretch.setSquetchBoolAttrName("upperSquetchOnOff")
        self.m_upperStretch.setAttrHeading("UPPER")
        self.m_upperStretch.setTwistAxis(self.m_twistAxis)
        self.m_upperStretch.setBindJoints(self.m_upperStretchJoints)
        self.m_upperStretch.setIsParentTwist(False)
        self.m_upperArmGRP = self.m_upperStretch.generate()
        cmds.parent(self.m_upperArmGRP, self.m_group)
 
        self.m_lowerStretch = chain.StretchChain(
            self.m_sceneData,
            self.m_elbowTwistJoints[1], #self.m_joints.m_elbow1,#
            self.m_joints.m_wrist, 
            self.m_name+"_lowerStretch",
            "%s_lowerStretch" %(self.m_baseName),
            self.m_numLowerControls, 
            self.m_numLowerJoints
            )
        self.m_lowerStretch.setMirroring(self.m_isMirrored)
        self.m_lowerStretch.setBlendControl(self.m_controlObject)
        self.m_lowerStretch.setBlendAttrName("lowerBend")
        self.m_lowerStretch.setSquetchAttrName("lowerSquetchiness")
        self.m_lowerStretch.setSquetchBoolAttrName("lowerSquetchOnOff")
        self.m_lowerStretch.setAttrHeading("LOWER")
        self.m_lowerStretch.setTwistAxis(self.m_twistAxis)
        self.m_lowerStretch.setBindJoints(self.m_lowerStretchJoints)
        self.m_lowerStretch.setIsParentTwist(False)
        self.m_lowerArmGRP = self.m_lowerStretch.generate()
        cmds.parent(self.m_lowerArmGRP, self.m_group)
        # Sort out twist controls (parenting)
        lowerTwistControls = self.m_lowerStretch.getTwistControls()
        upperTwistControls = self.m_upperStretch.getTwistControls()
        # --- connect up elbow twists
        cmds.parentConstraint(upperTwistControls[1], "%s_CONST" %(lowerTwistControls[0]))
        # --- parent elbow twist to bind joint
        cmds.parentConstraint(self.m_joints.m_elbow1, "%s_CONST" %(upperTwistControls[1]), mo=1)
        # --- parent wrist twist to bind joint
        cmds.parentConstraint(self.m_joints.m_wrist, "%s_CONST" %(lowerTwistControls[1]), mo=1)
        
        # fix elbow twist
        cmds.aimConstraint(self.m_twistAimConstraint, e=1, wut="object", wuo=upperTwistControls[1])
        
        rc.addDictToControlDict(self.m_allControls, self.m_upperStretch.getAllControls())
        rc.addDictToControlDict(self.m_allControls, self.m_lowerStretch.getAllControls())
        # Hide unused twist controls
        rc.addToLayer(self.m_sceneData, "detailCtrl", [lowerTwistControls[1]] + upperTwistControls)
        rc.addToLayer(self.m_sceneData, "hidden", lowerTwistControls[0])
Ejemplo n.º 20
0
    def generate(self):
        # Create IK
        self.m_ikJoints = self.duplicateJoints(self.m_topJoint, "IK")
        rc.addToLayer(self.m_sceneData, "ref", self.m_ikJoints[0])
        self.m_ikFoot = IKFoot.IKFootRig(
            self.m_sceneData,
            "%s_IK" %(self.m_name),
            self.m_baseName,
            self.m_ikJoints,
            self.m_footToePivot,
            self.m_footHeelPivot,
            self.m_footInsidePivot,
            self.m_footOutsidePivot,
            self.m_footMain,
            self.m_ankleIK
            )
        self.m_ikFoot.generate()
        cmds.parent(self.m_ikFoot.getGroup(), self.m_group)

        # Create FK
        self.m_fkJoints = self.duplicateJoints(self.m_topJoint, "FK")
        rc.addToLayer(self.m_sceneData, "ref", self.m_fkJoints[0])
        self.m_fkFoot = FKFoot.FKFootRig(
            self.m_sceneData,
            "%s_FK" %(self.m_name),
            self.m_baseName,
            self.m_fkJoints,
            self.m_footMain,
            self.m_parentFK
            )
        self.m_fkFoot.generate()
        cmds.parent(self.m_fkFoot.getGroup(), self.m_group)

        # Create BIND
        self.m_bindJoints = self.duplicateJoints(
            self.m_topJoint,
            "BIND"
            )
        rc.addToLayer(self.m_sceneData, "ref", self.m_bindJoints[0])
        bindGroups = rg.add3Groups(
            self.m_bindJoints[0],
            ["_SDK", "_CONST", "_0"]
            )
        cmds.parent(bindGroups[-1], self.m_group)
        self.connectBind()
        # connect to parent
        cmds.parentConstraint(self.m_parentBIND, bindGroups[-1], mo=1)
        # connect to parent twist
        # Strip constraint
        targetList = cmds.parentConstraint(self.m_parentTwist, q=1, tl=1)
        try:
            cmds.parentConstraint(targetList, self.m_parentTwist, e=True, rm=True)
        except:
            print "Warning couldn't remove constraint when creating foot attachment"
        # Add new constraint
        cmds.parentConstraint(self.m_bindJoints[0], self.m_parentTwist, mo=1)
        # Add to sets
        rc.addToSet(self.m_sceneData, "bind", self.m_bindJoints)
        # Add to controls
        rc.addDictToControlDict(self.m_allControls, self.m_ikFoot.getAllControls())
        rc.addDictToControlDict(self.m_allControls, self.m_fkFoot.getAllControls())
Ejemplo n.º 21
0
    def setupStretch(self):
        # Create nodes to get locator positions
        topDecomp = cmds.createNode(
            "decomposeMatrix", 
            n=self.m_name+"_posMatTop_NODE"
            )
        bottomDecomp = cmds.createNode(
            "decomposeMatrix", 
            n=self.m_name+"_posMatBottom_NODE"
            )
        middleDecomp = cmds.createNode(
            "decomposeMatrix",
            n="%s_posMatMid_NODE" %(self.m_name)
            )
        cmds.connectAttr(
            self.m_shoulderCtrl+".worldMatrix", 
            topDecomp+".inputMatrix"
            )
        cmds.connectAttr(
            self.m_wristCtrl+".worldMatrix", 
            bottomDecomp+".inputMatrix"
            )
        cmds.connectAttr(
            self.m_poleVec+".worldMatrix", 
            middleDecomp+".inputMatrix"
            )
        #Create distance nodes
        distTotal = cmds.createNode(
            "distanceDimShape", 
            n=self.m_name+"_StretchMain_DIST"
            )

        distTop = cmds.createNode(
            "distanceDimShape", 
            n=self.m_name+"_StretchTop_DIST"
            )
        distBottom = cmds.createNode(
            "distanceDimShape", 
            n=self.m_name+"_StretchBottom_DIST"
            )
        # Connect distance nodes to locator positions
        #   main
        cmds.connectAttr(topDecomp+".outputTranslate", distTotal+".startPoint")
        cmds.connectAttr(bottomDecomp+".outputTranslate", distTotal+".endPoint")
        #   top
        cmds.connectAttr(
            "%s.outputTranslate" %(topDecomp),
            "%s.startPoint" %(distTop)
            )
        cmds.connectAttr(
            "%s.outputTranslate" %(middleDecomp),
            "%s.endPoint" %(distTop)
            )
        #   bottom
        cmds.connectAttr(
            "%s.outputTranslate" %(middleDecomp),
            "%s.startPoint" %(distBottom)
            )
        cmds.connectAttr(
            "%s.outputTranslate" %(bottomDecomp),
            "%s.endPoint" %(distBottom)
            )

        #Neaten up dist nodes
        distNodes = [distTotal, distTop, distBottom]
        for node in distNodes:
            distParent = cmds.listRelatives(node, p=1)
            distParent = distParent[0]
            cmds.parent(distParent, self.m_group) 
        rc.addToLayer(self.m_sceneData, "hidden", distNodes)

        #Create angle nodes
        angleAttr = self.createAngleNode(
            cmds.listRelatives(self.m_shoulderCtrl, s=1)[0], 
            cmds.listRelatives(self.m_poleVec, s=1)[0], 
            cmds.listRelatives(self.m_wristCtrl, s=1)[0]
            )
        exp = self.createStretchExp(distTotal, distTop, distBottom, angleAttr)
        cmds.expression(n="%s_stretch_EXP" %(self.m_name), s=exp)