예제 #1
0
	def placeCtrl(self, jnt=None, type=None):
		"""
		snaps the control to the given joint with the same orientation
		:return string - ctrl name
		"""

		# create different control based on the type IK/FK
		if type == 'fk':
			ctrlCrv = rigUtils.createRigControl('sphere')
			ctrlCrv = pm.rename(ctrlCrv, self.side + '_' + self.limbPart + '_' + ctrlCrv)
			rigUtils.setControlColor(ctrlCrv)

			pm.delete(pm.orientConstraint(jnt, ctrlCrv))

			pm.scale(0.12, 0.12, 0.12)
			pm.makeIdentity(a=True, s=True)

			pm.parent(ctrlCrv, jnt)

			# resets the transforms for the controller
			for trans in ['.tx', '.ty', '.tz', '.rx', '.ry', '.rz']:
				pm.setAttr(ctrlCrv + trans, 0)

			# unparent the control and parent the shape from the control to the joint, so we are adding a shape node to
			# the joint interact with the animator
			pm.parent(world=True)
			ctrlCrvShape = pm.listRelatives(ctrlCrv)
			pm.select(ctrlCrvShape)
			pm.select(jnt, add=True)
			pm.parent(r=True, s=True)
			pm.delete(ctrlCrv)

		elif type == 'ik':
			ctrlCrv = rigUtils.createRigControl('cross')

			pm.delete(pm.orientConstraint(jnt, ctrlCrv))
			pm.scale(ctrlCrv, (0.08, 0.08, 0.08))

			pm.makeIdentity(s=True, t=True, r=True, a=True)

			ctrlCrv = pm.rename(ctrlCrv, self.side + '_' + self.limbPart + '_ik_ctrl')
			pm.delete(pm.pointConstraint(self.endJoint, ctrlCrv))
			pm.makeIdentity(a=True, t=True)

			if self.limbPart == 'arm':
				pm.rotate(ctrlCrv, (0,0,90))
				pm.makeIdentity(a=True, r=True)

		return ctrlCrv
예제 #2
0
def createRigStructure():

	pm.promptDialog (m='Enter character name:', title='Autorig')
	characterName = pm.promptDialog(query=True, text=True)

	# create group structre for the rig
	mainGrp = pm.group(name=characterName, em=True)
	pm.group(name='mesh_grp', em=True, p=mainGrp)
	rigGrp = pm.group(name='rig_grp', em=True, p=mainGrp)

	# create main ctrl for the rig
	mainCtrlGrp = rigUtils.createRigControl('cross')
	mainCtrlGrp = pm.rename(mainCtrlGrp, 'main_ctrl')
	rigUtils.setControlColor(mainCtrlGrp)
	"""
	pm.group(name='m_head_grp', em=True, p=mainCtrlGrp)
	pm.group(name='m_spine_grp', em=True, p=mainCtrlGrp)
	pm.group(name='l_leg_grp', em=True, p=mainCtrlGrp)
	pm.group(name='l_leg_grp', em=True, p=mainCtrlGrp)
	pm.group(name='l_arm_grp', em=True, p=mainCtrlGrp)
	pm.group(name='r_arm_grp', em=True, p=mainCtrlGrp)
	pm.group(name='l_foot_grp', em=True, p=mainCtrlGrp)
	pm.group(name='r_foot_grp', em=True, p=mainCtrlGrp)
	"""
	pm.parent(mainCtrlGrp, rigGrp)
예제 #3
0
def build_head():
    headJnts = pm.ls('*_head*_jnt')
    ctrl = rigUtils.createRigControl('circle')[0]
    pm.rotate(90, 0, 0)
    pm.makeIdentity(ctrl, a=True, t=True, r=True)

    pm.rename(ctrl, 'head_ctrl')
    rigUtils.setControlColor(ctrl)

    pm.delete(pm.pointConstraint(headJnts[0], ctrl))
    orientConst = pm.orientConstraint(headJnts[0], ctrl, mo=False)

    pm.delete(orientConst)
    pm.makeIdentity(ctrl, a=True, t=True, r=True)

    pm.parent(headJnts[0], ctrl)

    headGrp = pm.group(n='head_grp', em=True)
    pm.parent(ctrl, headGrp)

    spineJntList = pm.ls('M_spine*_jnt')
    pm.parent(headGrp, 'neck_ctrl')
    rigUtils.hideAttributes(ctrl=ctrl,
                            trans=True,
                            rot=False,
                            scale=True,
                            vis=True,
                            radius=False)

    pm.delete(ctrl, ch=1)
예제 #4
0
    def createNeckCtrl(self):

        headCtrl = rigUtils.createRigControl('circle')
        headCtrl = pm.rename(headCtrl[0], 'M_head_ctrl')
        rigUtils.setControlColor(headCtrl)

        pm.move(
            headCtrl,
            (self.headRootPos[0], self.headRootPos[1], self.headRootPos[2]))
        pm.rotate(headCtrl, (0, 0, 90))
        pm.scale(headCtrl, (1.5, 1.5, 1.5))
        pm.makeIdentity(a=True, r=True, t=True, s=True)
예제 #5
0
    def createCOGCtrl(self):
        """
		create and place COG control in the COG joint
		"""

        cogCtrl = rigUtils.createRigControl('COG')
        pm.delete(pm.pointConstraint(self.starJoint, cogCtrl))
        pm.makeIdentity(cogCtrl, a=True, t=True)
        rigUtils.setControlColor(cogCtrl)
        cogCtrl = pm.rename(cogCtrl, 'COG_ctrl')

        pm.parent(self.starJoint, cogCtrl)
예제 #6
0
	def placePoleVectorCtrl(self, jntList):
		"""
		place pole vector controller in the middle joint and offsets the position
		:param jntList: string list- list of 3 limb joints
		"""
		armlimbLenght = self.getLimbLength(self.side + '_arm1_rigHelper', self.side + '_arm3_rigHelper')
		leglimbLenght = self.getLimbLength(self.side + '_leg_0_rigHelper', self.side + '_leg_2_rigHelper')
		
		start = pm.xform(jntList[0], q=1, ws=1, t=1)
		mid = pm.xform(jntList[1], q=1, ws=1, t=1)
		end = pm.xform(jntList[2], q=1, ws=1, t=1)

		startV = OpenMaya.MVector(start[0], start[1], start[2])
		midV = OpenMaya.MVector(mid[0], mid[1], mid[2])
		endV = OpenMaya.MVector(end[0], end[1], end[2])

		startEnd = endV - startV
		startMid = midV - startV

		dotP = startMid * startEnd

		proj = float(dotP) / float(startEnd.length())
		startEndN = startEnd.normal()
		projV = startEndN * proj

		arrowV = startMid - projV
		arrowV *= 8.0
		finalV = arrowV + midV

		# create poleVector controller
		self.poleVectCtrl = rigUtils.createRigControl('poleVector')
		self.poleVectCtrl = pm.rename(self.poleVectCtrl, self.side + '_' + self.limbPart + '_' + self.poleVectCtrl)

		pm.select(self.poleVectCtrl)

		pm.xform(ws=1, t=(finalV.x, finalV.y, finalV.z))
		pm.makeIdentity(self.poleVectCtrl, a=True, t=True)

		rigUtils.setControlColor(self.poleVectCtrl)
예제 #7
0
    def createFootCtrl(self):
        """
		Create foot nurbs curve and place in the feel of the character.
		The control will have the size from the heel helper to the end foot helper
		"""

        footCtrl = rigUtils.createRigControl('foot')
        pm.rename(footCtrl, self.side + footCtrl)
        footCtrl = self.side + footCtrl

        # mirror ctrl if we are doing the right side
        if self.side == 'R':
            pm.scale(footCtrl, (-1, 1, 1))
            pm.makeIdentity(footCtrl, a=True, s=True)

        # place the foot ctrl in the 3rd rig helper (heel)
        pm.delete(pm.pointConstraint(self.side + '_leg_3_rigHelper', footCtrl))
        pm.makeIdentity(footCtrl, a=True, t=True)

        endFootHelper = pm.PyNode(self.side + '_leg_5_rigHelper')
        endFootCtrl = pm.PyNode(self.side + '_foot_ctrl')

        # gets the heel helper world position and the bounding box of the foot controller
        endFootHelperPos = endFootHelper.getTranslation('world')
        bbox = pm.exactWorldBoundingBox(footCtrl)

        # gets the correct scale to feet the helpers
        scaleFactor = (endFootHelperPos[2] - bbox[5]) + 1
        pm.scale(footCtrl, scaleFactor, scaleFactor, scaleFactor)

        pm.makeIdentity(footCtrl, a=True, s=True)

        # parent the control to the new created foot chain
        rigUtils.setControlColor(footCtrl)
        pm.parent(self.footJnt, self.side + '_foot_ctrl')

        return footCtrl