Ejemplo n.º 1
0
 def rigBlendControl(self, _parent):
     # Move and parent blend control
     rc.orientControl(self.m_blendControl, _parent)
     group = rg.addGroup(self.m_blendControl, "%s_0" %(self.m_blendControl))
     moveValue = -2
     if self.m_isMirrored:
         moveValue *= -1
     cmds.setAttr("%s.t%s" %(self.m_blendControl, self.m_twistAxis), moveValue)
     cmds.parentConstraint(_parent, group, mo=1)
     rc.lockAttrs(
         self.m_blendControl, 
         [
             "tx", 
             "ty",
             "tz", 
             "rx", 
             "ry", 
             "rz", 
             "sx", 
             "sy", 
             "sz", 
             "visibility"
         ],
         True,
         True
         )
Ejemplo n.º 2
0
    def generate(self):
        self.m_fingers = []
        names = ["indexFing", "middleFing", "ringFing", "pinkyFing", "thumb"]
        for i in range(len(names)):
            thumb = False
            if i == (len(names) - 1):
                thumb = True
            newFinger = fing.FingerRig(
                "%s_%s" %(self.m_name, names[i]),
                self.m_handJoints.getFinger(i),
                thumb
                )
            newFinger.generate()
            cmds.parent(newFinger.getGroup(), self.m_group)
            self.m_fingers.append(newFinger)

        #create control
        self.m_control = cmds.spaceLocator(n="%s_CTRL" %(self.m_name))[0]


        rc.orientControl(self.m_control, self.m_fingers[3].getKnuckle())
        group = rg.addGroup(self.m_control, "%s_0" %(self.m_control))
        rc.lockAttrs(self.m_control, ["tx", "rotate", "scale"], True, False)
        cmds.parent(group, self.m_group)
        cmds.expression(n="%s_EXP" %(self.m_name), s=self.createExp())
Ejemplo n.º 3
0
 def __init__(
         self, 
         _sceneData,
         _name,
         _baseName,
         _topJoint,
         _toePivot,
         _heelPivot,
         _insidePivot,
         _outsidePivot,
         _footMain,
         _ankleIK,
         _parentFK,
         _parentBIND,
         _parentTwist,
         _blendControl = False,
         _blendAttr = "IK_FK_Blend"
         ):
     self.m_sceneData = _sceneData
     self.m_name = _name
     self.m_baseName = _baseName
     self.m_group = cmds.group(n="%s_GRP" %(self.m_name), em=True)
     self.m_topJoint = _topJoint
     self.m_footToePivot = _toePivot
     self.m_footHeelPivot = _heelPivot
     self.m_footInsidePivot = _insidePivot
     self.m_footOutsidePivot = _outsidePivot
     self.m_footMain = _footMain
     self.m_ankleIK = _ankleIK
     self.m_parentFK = _parentFK
     self.m_parentBIND = _parentBIND
     self.m_parentTwist = _parentTwist
     self.m_blendAttr = _blendAttr
     self.m_allControls = {}
     if _blendControl:
         self.m_blendControl = _blendControl
     else:
         self.m_blendControl = cmds.circle(
             n="%s_blend_CTRL" %(self.m_name),
             )[0]
         rc.addToControlDict(
             self.m_allControls,
             "%s_IKFKBlend" %(self.m_blendControl),
             self.m_blendControl
             )
         cmds.parent(self.m_blendControl, self.m_group)
     if not cmds.objExists(
             "%s.%s" %(self.m_blendControl, self.m_blendAttr
             )):
         cmds.addAttr(
             self.m_blendControl,
             ln=self.m_blendAttr,
             at="float",
             min = 0,
             max = 1,
             dv = 0,
             k=1
             )
Ejemplo n.º 4
0
    def generate(self):
        # Generate Leg
        self.m_legRig = arm.ArmRig(
            self.m_sceneData,
            self.m_legJoints, 
            self.m_name,
            self.m_baseName,
            self.m_twistAxis,
            False
            )
        self.m_legRig.setUpperStretchChain(
            self.m_numUpperControls,
            self.m_upperStretchJoints,
            self.m_numUpperJoints
            )
        self.m_legRig.setLowerStretchChain(
            self.m_numLowerControls,
            self.m_lowerStretchJoints,
            self.m_numLowerJoints
            )
        self.m_legRig.generate()
        rc.addDictToControlDict(self.m_allControls, self.m_legRig.getAllControls())

        # Generate Foot
        self.m_footRig = fr.FootRig(
            self.m_sceneData,
            "%s_foot" %(self.m_name),
            self.m_baseName,
            self.m_footJoints[0],
            self.m_toePivot,
            self.m_heelPivot,
            self.m_insidePivot,
            self.m_outsidePivot,
            self.m_footMain,
            self.m_legRig.getIKControl(),
            self.m_legRig.getFKParent(),
            self.m_legRig.getBINDParent(),
            self.m_legRig.getAnkleTwist(),
            self.m_legRig.getBlendControl()
            )
        self.m_footRig.generate()
        rc.addDictToControlDict(self.m_allControls, self.m_footRig.getAllControls())
        cmds.parent(self.m_footRig.getGroup(), self.m_group)

        #Rig blend control
        self.m_legRig.rigBlendControl(self.m_footRig.getAnkleJoint())

        # Connect up visibility
        ikVis, fkVis = self.m_legRig.getVisibilityAttrs()
        cmds.connectAttr(
            ikVis,
            "%s.visibility" %(self.m_footRig.m_ikFoot.getGroup())
            )
        cmds.connectAttr(
            fkVis,
            "%s.visibility" %(self.m_footRig.m_fkFoot.getGroup())
            )
Ejemplo n.º 5
0
 def duplicateJoints(self, _joints, _postFix):
     newJoints = cmds.duplicate(_joints.m_shoulder, rc=1)
     if cmds.listRelatives(newJoints[0], p=True):
         cmds.parent(newJoints[0], w=True)
     for i in range(0, len(_joints)):
         jointNameEnd = _joints[i].find("_")
         newName = self.m_name+"_"+_postFix+"_"+\
             _joints[i][:jointNameEnd] + "_JNT"
         newJoints[i] = cmds.rename(newJoints[i], newName)
         rc.stripSets(newJoints[i])
     return aj.ArmJoints(newJoints)
Ejemplo n.º 6
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.º 7
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.º 8
0
 def duplicateJoints(self, _topJoint, _tagName):
      dupJoints = cmds.duplicate(_topJoint, rc=True)
      if cmds.listRelatives(dupJoints[0], p=True):
         cmds.parent(dupJoints[0], w=True)
      i = 0
      for name in [
              "%s_%s_ankle_JNT" %(self.m_name, _tagName),
              "%s_%s_ball_JNT" %(self.m_name, _tagName),
              "%s_%s_toeEND_JNT"%(self.m_name, _tagName)
              ]:
          cmds.rename(dupJoints[i], name)
          dupJoints[i] = name
          rc.stripSets(dupJoints[i])
          i+=1
      return dupJoints
Ejemplo n.º 9
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.º 10
0
 def connectBind(self):
     #Create opposite node to blend
     blendOpposite = rc.create1MinusNode(
         "%s.%s" %(self.m_blendControl, self.m_blendAttr),
         "%s_IKFKBlendOpp_CTRL" %(self.m_name)
         )
     for i in range(len(self.m_bindJoints)):
         const1 = cmds.parentConstraint(
             self.m_ikJoints[i],
             self.m_bindJoints[i],
             st = ["x", "y", "z"]
             )[0]
         const2 = cmds.parentConstraint(
             self.m_fkJoints[i],
             self.m_bindJoints[i],
             st = ["x", "y", "z"]
             )[0]
         cmds.connectAttr(
             blendOpposite,
             "%s.blendParent2" %(self.m_bindJoints[i])
             )
         # Change to quarternion
         pairBlend = cmds.listConnections(
             "%s.constraintRotateX" %(const1),
             d=1
             )[0]
         cmds.setAttr("%s.rotInterpolation" %(pairBlend), 1)
Ejemplo n.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
0
def generateAutoClav(_name, _shoulderSDK, _wristIK):
	print "doing something"
	error.assertString(_name)
	error.assertMayaObject(_shoulderSDK)
	error.assertMayaObject(_wristIK)
	cmds.select(clear=True)

	# Create joints
	joint1 = cmds.joint(n="%s_IK_JNT" %(_name))
	rc.copyTranslation(joint1, _shoulderSDK)
	joint2 = cmds.joint(n="%s_IKEND_JNT" %(_name))
	rc.copyTranslation(joint2, _wristIK)
	#cmds.parent(joint2, joint1)

	# Create IK
	ikControl = cmds.ikHandle(
		n="%s_IK" %(_name),
		sol="ikRPsolver",
		sj= joint1,
		ee=joint2
		)[0]
	# deselect so we don't get warnings
	cmds.select(d=1)

	# Create pole vec
	locator = cmds.spaceLocator(n="%s_up_LOC" %(_name))[0]
	rc.orientControl(locator, _wristIK)
	locGroup = rg.addGroup(locator, "%s_0" %(locator))
	cmds.setAttr("%s.ty" %(locator), 2)

	cmds.poleVectorConstraint(locator, ikControl)

	# Connect up to rig
	cmds.pointConstraint(_wristIK, locGroup, mo=1)
	cmds.pointConstraint(_wristIK, ikControl, mo=1)

	cmds.orientConstraint(joint1, _shoulderSDK, mo=1)
Ejemplo n.º 18
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.º 19
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.º 20
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.º 21
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.º 22
0
    def connectIKFK(self):
        blendAttrName = "IK_FK_Blend"
        self.m_blendAttr = self.m_blendControl + "." + blendAttrName
        try:
            cmds.setAttr(self.m_blendAttr, 0)
            print "WARNING, IK_FK_Blend attribute already exsits"
        except:
            cmds.addAttr(
                self.m_blendControl, 
                ln=blendAttrName, 
                min = 0, 
                max = 1, 
                k = 1
                )
        self.m_blendAttr = self.m_blendControl + "." + blendAttrName
        self.m_blendOppAttr = rc.create1MinusNode(
            self.m_blendAttr, 
            self.m_name+"_IKFKBlendOpp_CTRL"
            )
        # Attach each joint to BIND
        bindJoints = self.m_bindRig.m_joints
        ikJoints = self.m_ikRig.m_joints
        fkJoints = self.m_fkRig.m_joints
        for i in range(0, len(bindJoints) - 1):
            #Orientation
            const1 = cmds.parentConstraint(
                ikJoints[i], 
                bindJoints[i],
                st = ["x", "y", "z"]
                )
            const1 = const1[0]
            const2 = cmds.parentConstraint(
                fkJoints[i], 
                bindJoints[i],
                st = ["x", "y", "z"]
                )
            const2 = const2[0]
            cmds.connectAttr(
                self.m_blendOppAttr, 
                "%s.blendParent2" %(bindJoints[i])
                )
            # Set rotation method to quarternion
            #   get pair blend node
            pairBlend = cmds.listConnections(
                "%s.constraintRotateX" %(const1), 
                d=True
                )
            pairBlend = pairBlend[0]
            cmds.setAttr("%s.rotInterpolation" %(pairBlend), 1)

        for i in range(1, len(bindJoints)):
            # Connect up blended lengths
            blendedAttr = self.createBlendAttr(
                rg.stripMiddle(ikJoints[i], 0, 1), 
                ikJoints[i] + ".translateX", 
                fkJoints[i] + ".translateX", 
                self.m_blendAttr, self.m_blendOppAttr
                )
            cmds.connectAttr(blendedAttr, bindJoints[i] + ".translateX")

        # Fix wrist rotations
        self.m_bindRig.aimWrist(self.m_ikRig.getIKControl(), [self.m_blendAttr, self.m_blendOppAttr])
Ejemplo n.º 23
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.º 24
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.º 25
0
    def generate(self):
        if self.m_isThumb:
            names = ["metacarpal", "knuckle", "tip", "tipEND"]
        else:
            names = ["metacarpal", "knuckle", "mid", "tip", "tipEND"]
        i = 0
        parentControl = False
        self.m_controls = []
        self.m_stretchControls = []
            
        for joint in self.m_joints:
            # Create control
            newStretch = False
            if joint != self.m_joints[0]:
                #Create stretch control
                stretchName = "%s_%s_stretch_CTRL" %(self.m_name, names[i])
                newStretch = cmds.spaceLocator(n=stretchName)[0]
                rc.setMultiAttrs(
                    newStretch,
                    ["localScaleX", "localScaleY", "localScaleZ"],
                    0.15
                    )
                rc.orientControl(newStretch, cmds.listRelatives(joint, p=1)[0])
                rc.copyTranslation(newStretch, joint)
                if parentControl:
                    cmds.parent(newStretch, parentControl)
                else:
                    cmds.parent(newStretch, self.m_group)
                rg.add3Groups(
                    newStretch, 
                    ["_SDK", "_CONST", "_0"]
                    )
                # lock unused attrs
                rc.lockAttrs(
                    newStretch,
                    ["ty", "tz", "rotate", "scale"],
                    True,
                    False
                    )
                parentControl = newStretch
            
            if joint != self.m_joints[-1]:
                controlName = "%s_%s_CTRL" %(self.m_name, names[i])
                newControl = cmds.circle(
                    n=controlName,
                    nr=(1, 0, 0),
                    r=0.1
                    )[0]
                rc.orientControl(newControl, joint)
                if parentControl:
                    cmds.parent(newControl, parentControl)
                else:
                    cmds.parent(newControl, self.m_group)
                self.m_controls.append(newControl)

                groups = rg.add3Groups(newControl, ["_SDK", "_CONST", "_0"])
                if newStretch:
                    # Attach to stretch
                    cmds.parentConstraint(newStretch, groups[1], mo=1)
                # Attach to joint
                cmds.parentConstraint(newControl, joint, mo=1)
                rc.lockAttrs(
                    newControl,
                    ["translate", "scale"],
                    True,
                    False
                    )
                parentControl = newControl
                i += 1
            else:
                cmds.parentConstraint(newStretch, joint, mo=1)

        # Rig metacarpals
        if not self.m_isThumb:
            pass

        self.m_isGenerated = True
Ejemplo n.º 26
0
 def getUpperLength(self):
     assert self.m_isGenerated, "Rig not generated"
     return rc.getDistBetween(self.m_controls[0], self.m_controls[1])
Ejemplo n.º 27
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)
Ejemplo n.º 28
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.º 29
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.º 30
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