コード例 #1
0
ファイル: lib_deformer.py プロジェクト: creuter23/tools
def wrap_createScalableWrap(driver, tgts, scale_obj, parent=None):
	'''Only used on skinned driver meshes, creates a wrap that scales
	Args:
		driver (pm.nt.Transform): wrap driver
		tgts ([pm.nt.Transform]): list of objects to wrap
		scale_obj (pm.nt.Transform): The object that it gets its scaling from
		parent (pm.nt.Transform): If not set, uses scaleParent as parent, otherwise
								  That's the new parent
	Returns ([pm.nt.wrap]): list of wrap deformers that were created
	Usage: 
		wrap_createScalableWrap(pm.ls(sl=True)[0],[pm.ls(sl=True)[1]], pm.PyNode('global_CTRL'))
	'''
	wrap = createWrap(driver, tgts, 0, 50, 2, True, True, 0)
	#Create the wrap scale group
	scaleGrp = 'wrapScale_GRP'
	if pm.objExists(scaleGrp):
		scaleGrp = pm.PyNode(scaleGrp)
	else:
		scaleGrp = pm.group(em=True, n=scaleGrp)
	#Create a scale joint for the base object
	scaleJnt = pm.joint(n=driver+'_WRAPSCALE_JNT')
	scaleJnt.setParent(scaleGrp)
	#skin it
	pm.skinCluster(scaleJnt, wrap['driver'][1], tsb=True, n=driver.name()+'wrap_SKINCLSTR')
	#parent the joint under the scale parent
	if parent:
		scaleGrp.setParent( parent )
	else:
		scaleGrp.setParent( scale_obj )
	#scale the transform of the targets
	for tgt in tgts:
		pm.scaleConstraint(scale_obj, tgt, mo=True)
	return wrap
コード例 #2
0
ファイル: location.py プロジェクト: Mikfr83/crab
    def create_rig(self, parent):

        # -- We're given the skeleton component instance, so we can
        # -- utilise the find method to find the joint we need to build
        # -- a control against
        root_joint = self.find_first('RootJoint')

        # -- Create a transform to use as a control
        root_control = crab.create.control(
            description='Rig%s' % self.options.description,
            side=self.options.side,
            parent=parent,
            match_to=root_joint,
            shape='cog',
            lock_list=self.options.lock,
            hide_list=self.options.hide,
        )

        location_control = crab.create.control(
            description='%s' % self.options.description,
            side=self.options.side,
            parent=root_control,
            match_to=root_control,
            shape='arrow_x',
            lock_list=self.options.lock,
            hide_list=self.options.hide,
        )
        print('---')
        if pm.upAxis(q=True, axis=True).upper() == 'Y':
            crab.utils.shapes.spin(location_control, y=-90)

        # -- All joints should have a binding. The binding allows crab
        # -- to know what control parent to utilise when building skeletal
        # -- components.
        # -- The act of binding also constrains the skeleton joint to the
        # -- control
        self.bind(
            root_joint,
            root_control,
            constrain=False,
        )

        # -- Constrain the joint to the location
        pm.parentConstraint(
            location_control,
            root_joint,
            mo=False,
        )

        # -- Constrain the joint to the location
        pm.scaleConstraint(
            location_control,
            root_joint,
            mo=False,
        )

        # -- Select our tip joint
        pm.select(root_control)

        return True
コード例 #3
0
    def bind(self, skeletal_joint, control, constrain=True, scale=True, **kwargs):
        """
        Creates a constraint binding between the skeletal joint and the control
        such that the skeletal joint will be driven by the control and this
        control will act as the parent for any child components below this
        skeletal joint.
        """
        if constrain:
            pm.parentConstraint(
                control,
                skeletal_joint,
                **kwargs
            )

            pm.scaleConstraint(
                control,
                skeletal_joint,
                **kwargs
            )

        # -- Add a binding link between the skeletal joint and
        # -- the control
        if not skeletal_joint.hasAttr(config.BOUND):
            skeletal_joint.addAttr(
                config.BOUND,
                at='message',
            )
        control.message.connect(skeletal_joint.attr(config.BOUND))
コード例 #4
0
def connectCns(cnxDict, nsRig=None, nsSkin=None):
    """Connect the joints using constraints

    Args:
        cnxDict (dict): Description of the deconections to remove
        nsRig (string, optional): rig namespace
        nsSkin (None, optional): model namespace
    """
    for i, jnt in enumerate(cnxDict["joints"]):
        if nsSkin:
            oJnt = pm.PyNode(nsSkin + ":" + jnt)
        else:
            oJnt = pm.PyNode(jnt)

        if cnxDict["attrs"][i][0]:
            if nsRig:
                oAttr = pm.PyNode(nsRig + ":" + cnxDict["attrs"][i][0])
            else:
                oAttr = pm.PyNode(cnxDict["attrs"][i][0])

            oNode = oAttr.node()
            oTrans = pm.listConnections(
                pm.listConnections(oNode.inputMatrix)[0].matrixIn[0])
            pm.parentConstraint(oTrans, oJnt, mo=True)
            pm.scaleConstraint(oTrans, oJnt, mo=True)
コード例 #5
0
def create_bind_joint(jnt):
    name= jnt.name().replace('joint', "bindJoint")
    bind_joint = pm.duplicate(jnt, name=name, po=True)[0]
    pm.parentConstraint(jnt, bind_joint, mo=False)
    pm.scaleConstraint(jnt, bind_joint, mo=False)
    
    pm.parent(bind_joint, 'bind_joint')
コード例 #6
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectArms(namespace):
	print 'adasdasdasda'
	sides = {'Left':'L', 'Right':'R'}
	tsmArmChain = ['Arm_joint1','Arm_joint2','Arm_joint3','Arm_joint5','Arm_influence7_intermediate_constrain','Arm_joint6','Arm_joint7','Arm_joint8','Arm_joint7']
	capcomArmChain = ['Shoulder','ArmDir','Arm1','Arm2','Elbow','ARoll3','ARoll4','handRot','handXR'] 

	i=0

	for jnt in tsmArmChain:
		try:
			target = pm.ls(namespace + sides['Left'] + capcomArmChain[i])[0]
		except:
			print ' cant find', capcomArmChain[i]
			
		source = pm.ls(sides.keys()[1] + jnt )[0]
		i+=1

		pm.parentConstraint(source,target,mo=True)
		pm.scaleConstraint(source,target,mo=True)

	i=0

	for jnt in tsmArmChain:
		target = pm.ls(namespace + sides['Right'] + capcomArmChain[i])[0]
		source = pm.ls(sides.keys()[0] + jnt )[0]
		i+=1

		pm.parentConstraint(source,target,mo=True)        
		pm.scaleConstraint(source,target,mo=True)
コード例 #7
0
def bdConnectFingers(namespace):
    tsmFingers = [
        'LeftThumb_joint1', 'LeftThumb_joint2', 'LeftThumb_joint3',
        'LeftFinger1_joint1', 'LeftFinger1_joint2', 'LeftFinger1_joint3',
        'LeftFinger1_joint4', 'LeftFinger2_joint1', 'LeftFinger2_joint2',
        'LeftFinger2_joint3', 'LeftFinger2_joint4', 'LeftFinger3_joint1',
        'LeftFinger3_joint2', 'LeftFinger3_joint3', 'LeftFinger3_joint4',
        'LeftFinger4_joint1', 'LeftFinger4_joint2', 'LeftFinger4_joint3',
        'LeftFinger4_joint4'
    ]
    capcomFingers = [
        'LThumb1', 'LThumb2', 'LThumb3', 'LRH', 'LIndex1', 'LIndex2',
        'LIndex3', 'LCH', 'LMiddle1', 'LMiddle2', 'LMiddle3', 'LLH', 'LRing1',
        'LRing2', 'LRing3', 'LLH', 'LPinky1', 'LPinky2', 'LPinky3'
    ]
    i = 0

    for jnt in tsmFingers:
        targetLeft = pm.ls(namespace + capcomFingers[i])[0]
        sourceLeft = pm.ls(jnt)[0]
        targetRight = pm.ls(namespace + 'R' + capcomFingers[i][1:])[0]
        sourceRight = pm.ls(jnt.replace('Left', 'Right'))[0]
        i += 1

        pm.parentConstraint(sourceLeft, targetLeft, mo=True)
        pm.scaleConstraint(sourceLeft, targetLeft, mo=True)
        pm.parentConstraint(sourceRight, targetRight, mo=True)
        pm.scaleConstraint(sourceRight, targetRight, mo=True)
コード例 #8
0
def scaleConstrain():
    u"""先选控制器,再选被缩放约束的物体"""
    sel_objs = pm.ls(sl = True)
    sel_con = sel_objs[0]
    sel_children = sel_objs[1:]
    for sel_child in sel_children:
        pm.scaleConstraint(sel_con, sel_child, o = [1, 1, 1], w = 1)
コード例 #9
0
ファイル: rigFaceAvarGrps.py プロジェクト: renaudll/omtk
 def _parent_avar(self, avar, parent):
     try:
         avar_grp_parent = avar._grp_parent
         pymel.parentConstraint(parent, avar_grp_parent, maintainOffset=True)
         pymel.scaleConstraint(parent, avar_grp_parent, maintainOffset=True)
     except Exception, e:
         print(str(e))
コード例 #10
0
def bdConnectLegs(namespace):
    sides = {'Left': 'L', 'Right': 'R'}
    tsmLegChain = [
        'Leg_joint8', 'Leg_joint7', 'Leg_joint4',
        'Leg_influence5_intermediate_constrain_halfNode', 'Leg_joint1',
        'Leg_joint1'
    ]
    capcomLegChain = ['Toe', 'Foot', 'Leg2', 'Knee', 'Leg1', 'LegDir']

    i = 0
    for jnt in tsmLegChain:
        target = pm.ls(namespace + sides['Left'] + capcomLegChain[i])[0]
        source = pm.ls(sides.keys()[1] + jnt)[0]
        i += 1

        pm.parentConstraint(source, target, mo=True)
        pm.scaleConstraint(source, target, mo=True)

    i = 0
    for jnt in tsmLegChain:
        target = pm.ls(namespace + sides['Right'] + capcomLegChain[i])[0]
        source = pm.ls(sides.keys()[0] + jnt)[0]
        i += 1

        pm.parentConstraint(source, target, mo=True)
        pm.scaleConstraint(source, target, mo=True)
コード例 #11
0
def FTV_generateFluidTransformSpaceGrp( name, fluidSourceData):
	''' return a group that is fully constrained by fluidSourceData'''
	fluidSpaceTransform = pm.group( em=True, n=name )
	pm.parentConstraint(fluidSourceData[0], fluidSpaceTransform)
	pm.scaleConstraint(fluidSourceData[0], fluidSpaceTransform)
	FTV_lockAndHide(fluidSpaceTransform, ['v'])
	return fluidSpaceTransform
コード例 #12
0
    def addOperators(self):
        """Create operators and set the relations for the component rig

        Apply operators, constraints, expressions to the hierarchy.
        In order to keep the code clean and easier to debug,
        we shouldn't create any new object in this method.

        """

        upvDir = self.settings["upVectorDirection"]
        if upvDir == 0:
            upvVec = [1, 0, 0]
        elif upvDir == 1:
            upvVec = [0, 1, 0]
        else:
            upvVec = [0, 0, 1]

        applyop.aimCns(self.eye_npo, self.eyeIK_ctl, "zy", 2, upvVec,
                       self.root, False)

        pm.scaleConstraint(self.eyeOver_ctl,
                           self.eye_npo,
                           maintainOffset=False)
        pm.pointConstraint(self.eyeOver_ctl,
                           self.eye_npo,
                           maintainOffset=False)
コード例 #13
0
def ExtraControlForJnt(jnts=None):

    if not jnts:
        jnts = pm.ls(sl=True)
    else:
        jnts = pm.ls(jnts)

    for jnt in jnts:

        # duplicate joint
        pm.select(clear=True)
        newJnt = pm.joint(p=[0, 0, 0], name='%s_extra' % jnt.name())
        pm.delete(pm.pointConstraint(jnt, newJnt))
        pm.delete(pm.orientConstraint(jnt, newJnt))
        pm.parent(newJnt, jnt)
        newJnt.jointOrient.set(jnt.jointOrient.get())

        # create control curve for joint
        ctrl = CubeCrv(name='%s_ctrl' % jnt.name())
        pm.delete(pm.pointConstraint(jnt, ctrl))
        pm.delete(pm.orientConstraint(jnt, ctrl))
        zeroAndOfs = ZeroGrp(ctrl)
        ctrl.translate >> newJnt.translate
        ctrl.rotate >> newJnt.rotate
        ctrl.scale >> newJnt.scale

        # make controls to move with base joints
        pm.parentConstraint(jnt, zeroAndOfs[0])
        pm.scaleConstraint(jnt, zeroAndOfs[0])
コード例 #14
0
ファイル: module_base.py プロジェクト: AtonLerin/littlewitch
	def connectChains(self, *args, **kwargs):
		## pass in the roots to connect
		## arguments to args are expected to be lists or tuples

		chains = []
		for arg in args:
			if isinstance(arg, list) or isinstance(arg, tuple):
				chains.append(utils.makeList(arg))
				root = chains[-1][0].getParent()
				if not root.type() == 'transform' or not root.endswith('_rigRoot'):
					raise ModuleBaseException('connectChains: Passed in chain has no rig root.')
			else:
				raise ModuleBaseException('connectChains: Only lists of joints may be passed in.')

		if len(chains) < 2:
			raise ModuleBaseException('connectChains: need at least two chain roots.')

		targetChain = chains.pop(-1)

		if len(chains) == 1:
			## direct connection
			for source, target in zip(chains[0], targetChain ):
				for attr in 'translate','rotate','scale':
					for axis in 'XYZ':
						source.attr(attr+axis) >> target.attr(attr+axis)

			## because we checked earlier the rigRoots should be present at this point
			sourceRoot = chains[0][0].getParent()
			targetRoot = targetChain[0].getParent()

			pm.parentConstraint(sourceRoot, targetRoot, mo=True)
			pm.scaleConstraint(sourceRoot, targetRoot, mo=True)

		else:
			raise NotImplementedError("Multiple chains aren't finished yet, sorry.")
コード例 #15
0
def rig_transformer_piece(transform):
    """
	Usage:
		rig_transformer_piece( pm.ls(sl=True)[0] )
	"""
    if get_parentConstraintPairs(transform):
        # create a control and store its groups/parts
        ctrl_GRP = create_boundingBoxCtrl(transform)
        ctrl = [ctrl for ctrl in ctrl_GRP.listRelatives(c=True, type="transform") if "CTRL" in ctrl.name()][0]
        ctrlCon_GRP = [
            con_grp for con_grp in ctrl.listRelatives(c=True, type="transform") if "Con_GRP" in con_grp.name()
        ][0]
        # get the parent constraint information and then remove it
        target_weight_pairs = get_parentConstraintPairs(transform)
        pm.delete(target_weight_pairs[1])
        # setup the new space switching based on the old parent constraint
        parents = [target_weight_pairs[0][0][0], "spineJA_JNT", "spineJF_JNT", "globalB_CTRL", "worldSpace_GRP"]
        parent_names = ["normal", "hips", "chest", "global", "world"]
        ctrl_setupSpaceSwitch(ctrl, ctrl_GRP, parents, parent_names)
        # control the object with the new space-switch controller
        pm.parentConstraint(ctrlCon_GRP, transform, mo=True)
        pm.scaleConstraint(ctrlCon_GRP, transform, mo=True)
    else:
        # if it didn't have a parentConstraint do nothing
        return None
コード例 #16
0
def cnsPart(source, target):
    """Constraint target to source with parent and scale constraint

    Args:
        source (dagNode): Source object
        target (dagNode): target object
    """
    if not WIP:
        pm.parentConstraint(source, target, mo=True)
        pm.scaleConstraint(source, target, mo=True)

    if WIP:
        # Is not working with stack offset objects
        offsetLvl = pm.createNode("transform",
                                  n=source.name().split("_")[0] + "_offLvl")
        pm.parent(offsetLvl, source)
        mulmat_node = pm.createNode("multMatrix")
        pm.connectAttr(offsetLvl + ".worldMatrix",
                       mulmat_node + ".matrixIn[0]",
                       f=True)
        pm.connectAttr(target + ".parentInverseMatrix",
                       mulmat_node + ".matrixIn[1]",
                       f=True)

        dm_node = node.createDecomposeMatrixNode(mulmat_node + ".matrixSum")
        pm.connectAttr(dm_node + ".outputTranslate", target + ".t", f=True)
        pm.connectAttr(dm_node + ".outputRotate", target + ".r", f=True)
        pm.connectAttr(dm_node + ".outputScale", target + ".s", f=True)
コード例 #17
0
def ExtraControlForJnt( jnts=None ) :

	if not jnts:
		jnts = pm.ls( sl=True )
	else:
		jnts = pm.ls( jnts )
	
	
	for jnt in jnts:
		
		# duplicate joint
		pm.select( clear=True )
		newJnt = pm.joint( p = [0,0,0], name= '%s_extra'%jnt.name() )
		pm.delete( pm.pointConstraint( jnt, newJnt ) )
		pm.delete( pm.orientConstraint( jnt, newJnt ) )
		pm.parent( newJnt, jnt )
		newJnt.jointOrient.set( jnt.jointOrient.get() )
		
		# create control curve for joint
		ctrl = CubeCrv( name = '%s_ctrl'%jnt.name() )
		pm.delete( pm.pointConstraint( jnt, ctrl ) )
		pm.delete( pm.orientConstraint( jnt, ctrl ) )
		zeroAndOfs = ZeroGrp( ctrl )
		ctrl.translate >> newJnt.translate
		ctrl.rotate >> newJnt.rotate
		ctrl.scale >> newJnt.scale
        
		# make controls to move with base joints
		pm.parentConstraint( jnt, zeroAndOfs[0] )
		pm.scaleConstraint( jnt, zeroAndOfs[0] )
コード例 #18
0
def match_micro(source, flip = 'none'):
    if source.hasAttr('microController'):
        try:
            joint_target = uf.meta_traverse(source = source, relation = 'child', tag = 'jointSkin')[0]
            control_grp = pm.ls(str(source).replace('_CTL','_GRP'))[0]
        except:
            pm.warning('problem finding joint_target or control_grp')
        try:
            pm.delete(control_grp, constraints = 1)
            pm.matchTransform(control_grp, joint_target, pos = True, rot = True, scale = False)
        except:
            pm.warning('failed to matchTransform')
        try:
            tr_constraint = pm.parentConstraint (source,joint_target, mo = 1, weight = 1)
            tr_constraint.setAttr('interpType', 2)
            sc_constraint = pm.scaleConstraint(source,joint_target, mo = 1, weight = 1)
        except:
            pm.warning('failed to constrain')
        if 'x' in flip:
            pm.xform(source, euler = True, rotation = [180,0,0])
        elif 'y' in flip:
            pm.xform(source, euler = True, rotation = [0,180,0])
        elif 'z' in flip:
            pm.xform(source, euler = True, rotation = [0,0,180])
        else:
            pm.warning('controller attr present ')
            pass
    elif source.hasAttr('controller'):
        pm.warning("make sure this doesn't f**k anything!")
        try:
            joint_target = uf.meta_traverse(source = source, relation = 'child', tag = 'jointSkin')[0]
            control_grp = pm.ls(str(source).replace('_CTL','_GRP'))[0]
        except:
            pm.warning('problem finding joint_target or control_grp')
        try:
            pm.delete(control_grp, constraints = 1)
            pm.matchTransform(control_grp, joint_target, pos = True, rot = True, scale = False)
        except:
            pm.warning('failed to matchTransform')
        try:
            tr_constraint = pm.parentConstraint (source,joint_target, mo = 1, weight = 1)
            tr_constraint.setAttr('interpType', 2)
            sc_constraint = pm.scaleConstraint(source,joint_target, mo = 1, weight = 1)
        except:
            pm.warning('failed to constrain')
        if 'x' in flip:
            pm.xform(source, euler = True, rotation = [180,0,0])
        elif 'y' in flip:
            pm.xform(source, euler = True, rotation = [0,180,0])
        elif 'z' in flip:
            pm.xform(source, euler = True, rotation = [0,0,180])
        else:
            pm.warning('controller attr present ')
            pass
        pass
    else:
        pm.warning('no controller or microController attr')
        pass
    pass
コード例 #19
0
 def parent_to(self, parent):
     """
     Parent the system to a specific object.
     # TODO: Implement!
     """
     if self.grp_anm:
         pymel.parentConstraint(parent, self.grp_anm, maintainOffset=True)
         pymel.scaleConstraint(parent, self.grp_anm, maintainOffset=True)
コード例 #20
0
def scaleConstraintRename(sels):
    if len(sels) >= 3 or len(sels) <= 1:
        pm.error('Please select two')

    part = sels[1].split("_")

    renameConstraint = '_'.join(['slc', part[1], part[2], part[3]])
    pm.scaleConstraint(sels[0], sels[1], n=renameConstraint, mo=True, w=1)
コード例 #21
0
    def genereateAnim(self, reopen=True):
        # export_path,_ = self.getFilename()
        Scene = self.preExport()
        FBXAnim = os.path.join(Scene.dirname(), "FBXAnim")
        os.mkdir(FBXAnim) if not os.path.exists(FBXAnim) else None
        export_path = os.path.join(FBXAnim, "%s.FBX" % Scene.namebase)
        export_path = export_path.replace('\\', '/')

        # NOTE 导入所有的 reference
        [ref.importContents(True) for ref in pm.listReferences()]

        mesh_list = pm.ls("MODEL", ni=1, dag=1, type="mesh")
        # # NOTE 删除非变形器历史
        # pm.bakePartialHistory( mesh_list,prePostDeformers=True )
        jnt_list = self.getJntList(mesh_list)

        pm.select(cl=1)
        root = pm.joint(n="root")

        jnt_parent = self.getRelParent(jnt_list, root)

        anim_parent = {}
        for jnt in jnt_list:
            pm.select(cl=1)
            anim_jnt = pm.joint(n="%s_bind" % jnt)
            pm.parentConstraint(jnt, anim_jnt, mo=0)
            pm.scaleConstraint(jnt, anim_jnt, mo=0)
            parent = jnt_parent[jnt]
            anim_parent[
                anim_jnt] = "%s_bind" % parent if parent != root else root

        jnt_transform = {}
        for anim_jnt, parent in anim_parent.items():
            anim_jnt.setParent(parent)
            # NOTE 删除骨骼缩放修正组
            transform = anim_jnt.getParent()
            if transform != parent:
                pm.ungroup(transform)

        # NOTE bake 关键帧
        start_time = pm.playbackOptions(q=1, min=1)
        end_time = pm.playbackOptions(q=1, max=1)
        pm.bakeResults(anim_parent.keys(),
                       simulation=1,
                       t=(start_time, end_time))

        # NOTE 删除 root 骨骼下的所有约束
        pm.delete(pm.ls(root, dag=1, ni=1, type="constraint"))

        pm.select(root)

        # NOTE 导出文件
        mel.eval('FBXExport -f "' + export_path + '" -s')
        os.startfile(os.path.dirname(export_path))

        # NOTE 重新打开当前文件
        if reopen:
            pm.openFile(pm.sceneName(), f=1)
コード例 #22
0
 def _parent_avar(self, avar, parent):
     try:
         avar_grp_parent = avar._grp_parent
         pymel.parentConstraint(parent,
                                avar_grp_parent,
                                maintainOffset=True)
         pymel.scaleConstraint(parent, avar_grp_parent, maintainOffset=True)
     except Exception, e:
         print(str(e))
コード例 #23
0
ファイル: joint.py プロジェクト: kyuhoChoi/mayaTools
def createJointGeo( joints=[], constraint=False, parent=True, color=True ):
    if not joints:
        joints = pm.selected(type='joint')

    GEOs = []
    for jnt in joints:
        jnt   = pm.PyNode(jnt)
        child = jnt.getChildren( type='joint' )

        if not child: continue # 자식 조인트가 없으면 넘어감

        # 지오메트리 생성
        geo = pm.polyCube(ch=False)[0]

        #
        geo.setParent(jnt)

        geo.t.set( child[0].t.get() * 0.5 )
        geo.r.set( 0,0,0 )

        # 스케일 조정
        tr   = child[0].t.get()
        abtr = [ abs(val) for val in tr ]

        radius = jnt.radius.get() * 2
        sx = abtr[0] if abtr[0] > 0.001 else radius
        sy = abtr[1] if abtr[1] > 0.001 else radius
        sz = abtr[2] if abtr[2] > 0.001 else radius
        geo.s.set( sx,sy,sz )

        # 이름 변경
        geo.rename( jnt.name()+'_geo' )

        # 지오메트리 pivot 옮김
        copyPivot( jnt, geo )

        # transform 초기화
        pm.makeIdentity(geo, t=True, r=True, s=True, apply=True)

        if color:
            assignColorAxisShader( geo.f[4], 'x' )
            assignColorAxisShader( geo.f[1], 'y' )
            assignColorAxisShader( geo.f[0], 'z' )

        if not parent:
            geo.setParent(w=True)

        # 구속
        if constraint:
            geo.setParent(w=True)
            pm.parentConstraint(jnt,geo)
            pm.scaleConstraint(jnt,geo)

        GEOs.append(geo)

    return GEOs
コード例 #24
0
ファイル: flexi_plane.py プロジェクト: michaelanieves/Rigging
    def add_squash_n_stretch(self, follicles):
        """ 
        Args:
            None
        Returns (None)
        Usage:
        """
        base_name = '%s_flexiPlane' % self.flexiPlaneNameField.getText()
        wire_name =  '%s_wire_CRV' % base_name
        main_crv_name =  '%s_main_CTRL' % base_name
        
        wire = pm.PyNode(wire_name)
        
        arc_len = pm.arclen(wire, ch = True)
        pm.rename( arc_len, wire_name + 'info' )
        arc_len_val = pm.getAttr( wire_name + 'info.arcLength')
        
        multDiv_length = pm.shadingNode( 'multiplyDivide', asUtility = True )
        pm.rename( multDiv_length, base_name  + '_div_squashStretch_length' )
        pm.setAttr( base_name  + '_div_squashStretch_length.operation', 2 )
        
        pm.connectAttr( wire_name + 'info.arcLength', base_name  + '_div_squashStretch_length.input1X' )
        pm.setAttr( base_name  + '_div_squashStretch_length.input2X', arc_len_val )
        
        multDiv_volume = pm.shadingNode( 'multiplyDivide', asUtility = True )
        pm.rename( multDiv_volume, base_name  + '_div_volume' )
        pm.setAttr( base_name  + '_div_volume.operation', 2 )
        pm.setAttr( base_name  + '_div_volume.input1X', 1 )
        
        pm.connectAttr( base_name  + '_div_squashStretch_length.outputX', base_name  + '_div_volume.input2X', f = True )
        
        conditional_volume = pm.shadingNode( 'condition', asUtility = True )
        pm.rename( conditional_volume, base_name  + '_cond_volume' )
        pm.setAttr( base_name  + '_cond_volume.secondTerm', 1 )
        pm.connectAttr( main_crv_name + '.squashN_stretch', base_name  + '_cond_volume.firstTerm' )

        multDiv_globelScale = pm.shadingNode( 'multiplyDivide', asUtility = True )
        pm.rename( multDiv_globelScale, base_name  + '_mult_globalScale' )
        pm.connectAttr( base_name  + '_div_volume.outputX', base_name  + '_mult_globalScale.input1X' )
        pm.connectAttr( main_crv_name  + '.scaleX', base_name  + '_mult_globalScale.input2X' )
        pm.connectAttr( base_name  + '_mult_globalScale.outputX', base_name  + '_cond_volume.colorIfTrueR' )

        for index,follicle in enumerate(follicles):
            jnt_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
                                                 INDEX = 'flexiPlane_jnt%03d' % (index+1),
                                                 SUFFIX = 'JNT')
            jnt_offset_name = jnt_name.replace('_JNT','Offset_GRP')
            tweek_crv_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
                                                 INDEX = 'flexiPlane_tweak%03d' % (index+1),
                                                 SUFFIX = 'CTRL')
            
            pm.scaleConstraint( tweek_crv_name + 'Con_GRP', jnt_offset_name )
            pm.connectAttr( base_name  + '_cond_volume.outColorR', jnt_name + '.scaleX')
            pm.connectAttr( base_name  + '_cond_volume.outColorR', jnt_name + '.scaleZ')
            
            pm.select( clear = True )
コード例 #25
0
ファイル: _biped.py プロジェクト: wandth/subins_tutorials
def create_puppet(root, inputs):
    '''
        :example
            from crowd.core import biped
            roots = biped.get_root_skeletons()
            input = biped.get_input('biped')
            biped.create_puppet(roots[0][0], input)   
    '''
    if not isinstance(root, str):
        root = str(root)

    skeletons = generic.get_root_children()
    print 'skeletons\t', skeletons
    scene_skeletons = generic.get_skeletons(root, skeletons)
    print 'scene_skeletons\t', scene_skeletons

    suffix = ''

    fk_skeletons = generic.find_fk_skeletons(scene_skeletons, inputs['fk'])

    print 'fk_skeletons', fk_skeletons

    return

    fk_node = create_fk(fk_skeletons, inputs['fk'])
    ik_skeletons = generic.find_ik_skeletons(scene_skeletons, inputs['ik'])
    ik_nodes = create_ik(ik_skeletons, inputs['ik'])
    puppet = core.group(n='puppet', em=True)
    controls = core.group(n='controls', em=True)

    world_ctrl = controls.create_shape('world_ctrl',
                                       shape='cricle',
                                       orientation=[0, 1, 0],
                                       raduis=4.0)
    generic.disable_attributes(world_ctrl, attributs=['v'])
    ik = core.group(n='ik', em=True)
    joint = core.group(n='joints', em=True)
    controls.setParent(puppet)
    world_ctrl.setParent(controls)
    ik.setParent(puppet)
    joint.setParent(puppet)
    ik_nodes[0].setParent(controls)
    ik_nodes[1].setParent(ik)
    fk_node.setParent(controls)
    core.PyNode(root).setParent(joint)

    for each in [ik_nodes[0], fk_node, joint]:
        core.parentConstraint(world_ctrl,
                              each,
                              w=True,
                              n='%s_parent_constraint' % world_ctrl)
        core.scaleConstraint(world_ctrl,
                             each,
                             o=[1, 1, 1],
                             w=True,
                             n='%s_scale_constraint' % world_ctrl)
コード例 #26
0
def rig_crankshaft():
	#cmds.file("/jobs/pennzoilPennzoilNaturalGas_5402237/build/piston/release/work/mayaScene/pistonBuild/vLatest/mayaScene_pistonBuild_vLatest.ma",
	#          i=True, type="mayaAscii", ignoreVersion=True,rpr="mayaScene_pistonBuild_vLatest",options="v=0",pr=True,loadReferenceDepth="all")
	#setup variables for existing nodes
	global_ctrl=pm.PyNode('global_CTRL')
	global_loc=pm.PyNode('global_LOC')
	crankshaft_ctrl = pm.PyNode('crankshaft_CTRL')
	crankshaft_loc = pm.PyNode('crankshaft_LOC')
	display_ctrl = mpc.rig_makeCtrlLabel('display')
	
	#create piston controls
	for piston in range(0,global_loc.numPistons.get()):
		ctrl_offset = mpc.rig_ctrlDuplicate(crankshaft_ctrl, 'piston'+string.uppercase[piston]+'_mover')
		weight_loc = pm.PyNode('weight%s_LOC'%string.uppercase[piston])
		rod_loc = pm.PyNode('rod%s_LOC'%string.uppercase[piston])
		head_loc = pm.PyNode('head%s_LOC'%string.uppercase[piston])
		piston_loc = pm.PyNode('piston%s_LOC'%string.uppercase[piston])
		if ctrl_offset[0]:
			pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[0] ) )
			ctrl_offset[0].rx.set(90)
			pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
		else:
			pm.delete( pm.parentConstraint(weight_loc, ctrl_offset[1] ) )
			pm.parentConstraint(ctrl_offset[2], piston_loc, mo=True)
		mpc.rig_ctrlLock([ctrl_offset[1]], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
		mpc.rig_ctrlColor(ctrl_offset[1], 15)
		
	#setup connections
	pm.delete( pm.parentConstraint(  crankshaft_ctrl.getParent(), crankshaft_loc ) )
	pm.parentConstraint( crankshaft_ctrl, crankshaft_loc,  mo=True )
	
	#parent + create groups + lock down ctrls
	grp_csr = pm.group(em=True,n='crankshaftRig_GRP')
	grp_model = pm.group(em=True,n='model_GRP')
	grp_nodes = pm.group(em=True,n='nodes_GRP')
	grp_model.setParent(grp_csr)
	grp_nodes.setParent(grp_csr)
	global_ctrl.getParent().setParent(grp_csr)
	global_loc.setParent(grp_nodes)
	global_loc.visibility.set(0)
	display_ctrl.getParent().setParent(global_ctrl)
	display_ctrl.getParent().ty.set(pm.xform('headA_LOC', q=True , t=True, ws=True)[1])
	mpc.rig_ctrlLock([crankshaft_ctrl], ['tx','ty','tz','rz','ry','sx','sy','sz','v'], setKeyable=False, lock=True)
	pm.scaleConstraint( global_ctrl, grp_nodes, mo=True )
	display_ctrl.addAttr('displayLocators', at='long', min=0,max=1, k=True)
	display_ctrl.displayLocators.connect(global_loc.v, f=True)
	
	if pm.objExists('pistons_lodA_GRP'):
		pm.PyNode('pistons_lodA_GRP').setParent(grp_model)
	
	#Create Sets
	rp_set = mpc.rig_setsCreateHubSet([grp_csr], 'crankshaft', 'rigPuppet')
	ac_set = mpc.rig_setsCreateHubSet(pm.ls('*CTRL'), 'crankshaft','animCurves')
	gc_set = mpc.rig_setsCreateHubSet(pm.ls('*GEO'), 'crankshaft','geometryCache')
	pm.delete('hubMayaScenePistonBuildSet')
	pm.sets(rp_set, add=(ac_set, gc_set))
コード例 #27
0
ファイル: rigBiaseControl.py プロジェクト: rendermotion/RMPY
    def default_hieararchy(self):
        self.clusters_parent.setParent(self.rig_system.kinematics)
        self.driver_points_parent.setParent(self.rig_system.kinematics)
        self.result_points_parent.setParent(self.rig_system.kinematics)

        self.biased_line.setParent(self.rig_system.display)
        self.frame_line.setParent(self.rig_system.display)

        pm.parentConstraint(self.frame_line, self.result_points_parent)
        pm.scaleConstraint(self.frame_line, self.result_points_parent)
コード例 #28
0
    def run(self):
        # retrieve mid and root joints
        self.midJoint = self.endJoint.getParent()
        self.rootJoint = self.midJoint.getParent()

        # duplicate joints for ik chain
        ikJointNameFmt = '{0}_ik'
        ikjnts = pulse.nodes.duplicateBranch(self.rootJoint,
                                             self.endJoint,
                                             nameFmt=ikJointNameFmt)
        for j in ikjnts:
            # TODO: debug settings for build actions
            j.v.set(True)
        self.rootIkJoint = ikjnts[0]
        self.midIkJoint = ikjnts[1]
        self.endIkJoint = ikjnts[2]

        # parent ik joints to root control
        self.rootIkJoint.setParent(self.rootCtl)

        # create ik and hook up pole object and controls
        handle, effector = pm.ikHandle(n="{0}_ikHandle".format(
            self.endIkJoint),
                                       sj=self.rootIkJoint,
                                       ee=self.endIkJoint,
                                       sol="ikRPsolver")

        # add twist attr to end control
        self.endCtl.addAttr('twist', at='double', k=1)
        self.endCtl.twist >> handle.twist

        # connect mid ik ctl (pole vector)
        pm.poleVectorConstraint(self.midCtlIk, handle)

        # parent ik handle to end control
        handle.setParent(self.endCtl)

        # constraint end joint scale and rotation to end control
        pm.orientConstraint(self.endCtl, self.endIkJoint, mo=True)
        pm.scaleConstraint(self.endCtl, self.endIkJoint, mo=True)

        # constraint the original joint branch to the ik joint branch
        pulse.nodes.fullConstraint(self.rootIkJoint, self.rootJoint)
        pulse.nodes.fullConstraint(self.midIkJoint, self.midJoint)
        pulse.nodes.fullConstraint(self.endIkJoint, self.endJoint)

        # setup ikfk switch
        # ...

        # cleanup
        for jnt in ikjnts:
            # TODO: lock attrs
            jnt.v.set(False)

        handle.v.set(False)
コード例 #29
0
ファイル: sticky_patch.py プロジェクト: Mikfr83/crab
    def create_rig(self, parent):

        # -- Duplicate the guide mesh
        guide_mesh = self.find_first('GuideSurface')
        surface_xfo = pm.duplicate(guide_mesh)[0]
        surface_xfo.setParent(parent, r=False)

        # -- Ensure the parameters are set up for our needs
        surface_xfo.inheritsTransform.set(False)
        surface_xfo.visibility.set(False)

        # -- Pull out the mesh shape
        surface = surface_xfo.getShape()

        # -- Copy the skin weights between the two
        self.copy_weights(from_this=guide_mesh, to_this=surface_xfo)

        # -- Now create the follicle
        follicle = self.create_follicle(
            description='Guide{}'.format(self.options.description),
            side=self.options.side,
            parent=parent,
            surface=surface,
            u=0.5,
            v=0.5,
        )

        # -- Get the transform so we can properly bind
        follicle_xfo = follicle.getParent()
        follicle_xfo.inheritsTransform.set(False)

        # -- Scale constraint the node so that any rig scaling still comes through
        pm.scaleConstraint(
            follicle_xfo.getParent(),
            follicle_xfo,
        )

        # -- Create our offset control
        control = crab.create.control(
            description=self.options.description,
            side=self.options.side,
            shape='cube',
            parent=follicle_xfo,
            match_to=follicle_xfo,
            hide_list='v',
        )

        # -- Finally we bind the joint to the follicle
        self.bind(
            self.find_first('PatchJoint'),
            control,
            mo=False,
        )

        return True
コード例 #30
0
def aaa(target):

    pm.select(target, r =True)
    ctrl = sl.square_prop_shape()
    new_name = pm.rename(ctrl,target)
    adb.AutoSuffix([new_name])
    pm.parentConstraint(ctrl, target, mo=True)
    pm.scaleConstraint(ctrl, target, mo=True)
    pm.select(None)
    
    return ctrl
コード例 #31
0
    def creatorLoc(self, name=None):

        if pm.objExists('Head_M'):

            pos = pm.PyNode('Head_M').getTranslation(space='world')
            loc = pm.spaceLocator(p=pos, n=name + '_loc')
            geo = self.getGeoGroup()[0]
            loc.setParent(geo.getParent())
            pm.parentConstraint('Head_M', loc, mo=True)
            pm.scaleConstraint('Head_M', loc, mo=True)
            return loc
コード例 #32
0
    def constrain_to_rig(self, nothing):
        """Constrain the plebe to the mGear rig using constraints
        """
        # Sanity checking
        if not pm.objExists(self.template.get('root')):
            pm.warning("Unable to find '{character}' in scene! ".format(
                character=self.template.get('root')
            ), "Check that you have the correct template selected")
            return False
        if not pm.objExists('global_C0_ctl'):
            pm.warning("You need to build the rig first!")
            return False
        warnings = False

        for pairs in self.template.get('joints'):
            for source, target in pairs.items():
                if not pm.objExists(target.get('joint')):
                    warnings = True
                    pm.warning("Joint '{joint}' not found, so it won't be "
                               "connected to the rig.".format(
                                   joint=target.get('joint')
                               )
                               )
                    continue
                self.clear_transforms(target.get('joint'))
                if target.get('constrain')[0] == "1" and target.get('constrain')[1] == "1":
                    pm.parentConstraint(
                        source,
                        target.get('joint'),
                        maintainOffset=True,
                        decompRotationToChild=True
                    )
                elif target.get('constrain')[0] == "1":
                    pm.pointConstraint(
                        source,
                        target.get('joint'),
                        maintainOffset=True
                    )
                elif target.get('constrain')[1] == "1":
                    pm.orientConstraint(
                        source,
                        target.get('joint'),
                        maintainOffset=True
                    )
                if target.get('constrain')[2] == "1":
                    pm.scaleConstraint(
                        source,
                        target.get('joint'),
                        maintainOffset=True
                    )
        pm.displayInfo("Done attaching the character to the rig")
        if warnings:
            pm.warning("Some joints failed to attach to the rig. "
                       "See the script editor for details!")
コード例 #33
0
ファイル: utils_autoRig.py プロジェクト: adamfok/afok_toolset
def create_control(node, name='', shape="", axis="", size=1, point=True, orient=True, scale=False, help=False):
    node = pm.PyNode(node)
    
    if not shape:
        shape = "circle"
        
    if not name:
        name = "%s_ctrl" %node.name()

    shapeMELs = {
    "circle"     :  "circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 0.5 -d 3 -ut 0  -s 8 -ch 0",
    "diamond"    :  "circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 0.5 -d 1 -ut 0  -s 4 -ch 0",
    "square"     :  "curve -d 1 -p -0.5 0 0.5 -p -0.5 0 -0.5 -p 0.5 0 -0.5 -p 0.5 0 0.5 -p -0.5 0 0.5 -k 0 -k 1 -k 2 -k 3 -k 4",
    "global"     :  "curve -d 3 -p 0 0 0.75 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.375 0 0.5 -p 0.5 0 0.5 -p 0.5 0 0.375 -p 0.5 0 -0.375 -p 0.5 0 -0.5 -p 0.375 0 -0.5 -p -0.375 0 -0.5 -p -0.5 0 -0.5 -p -0.5 0 -0.375 -p -0.5 0 0.375 -p -0.5 0 0.5 -p -0.375 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p 0 0 0.75 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17",
    "local"      :  "curve -d 3 -p 0 0 0.5 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.25 0 0.375 -p 0.375 0 0.375 -p 0.375 0 0.25 -p 0.375 0 -0.25 -p 0.375 0 -0.375 -p 0.25 0 -0.375 -p -0.25 0 -0.375 -p -0.375 0 -0.375 -p -0.375 0 -0.25 -p -0.375 0 0.25 -p -0.375 0 0.375 -p -0.25 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p 0 0 0.5 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17",
    "root"       :  "curve -d 1 -p 0 0 0.325 -p -0.0634045 0 0.318755 -p -0.124372 0 0.300261 -p -0.180561 0 0.270228 -p -0.22981 0 0.22981 -p -0.270228 0 0.180561 -p -0.300261 0 0.124372 -p -0.318755 0 0.0634045 -p -0.325 0 0 -p -0.318755 0 -0.0634045 -p -0.300261 0 -0.124372 -p -0.270228 0 -0.180561 -p -0.22981 0 -0.22981 -p -0.180561 0 -0.270228 -p -0.124372 0 -0.300261 -p -0.0634045 0 -0.318755 -p 0 0 -0.325 -p 0.0634045 0 -0.318755 -p 0.124372 0 -0.300261 -p 0.180561 0 -0.270228 -p 0.22981 0 -0.22981 -p 0.270228 0 -0.180561 -p 0.300261 0 -0.124372 -p 0.318755 0 -0.0634045 -p 0.325 0 0 -p 0.318755 0 0.0634045 -p 0.300261 0 0.124372 -p 0.270228 0 0.180561 -p 0.22981 0 0.22981 -p 0.180561 0 0.270228 -p 0.124372 0 0.300261 -p 0.0634045 0 0.318755 -p 0 0 0.325 -p 0 0 -0.325 -p 0 0 -0.25 -p -0.0487726 0 -0.245197 -p -0.095671 0 -0.23097 -p -0.138893 0 -0.207868 -p -0.176777 0 -0.176777 -p -0.207868 0 -0.138893 -p -0.23097 0 -0.095671 -p -0.245197 0 -0.0487726 -p -0.25 0 0 -p -0.325 0 0 -p 0.325 0 0 -p -0.25 0 0 -p -0.245197 0 0.0487726 -p -0.23097 0 0.095671 -p -0.207868 0 0.138893 -p -0.176777 0 0.176777 -p -0.138893 0 0.207868 -p -0.095671 0 0.23097 -p -0.0487726 0 0.245197 -p 0 0 0.25 -p 0.0487726 0 0.245197 -p 0.095671 0 0.23097 -p 0.138893 0 0.207868 -p 0.176777 0 0.176777 -p 0.207868 0 0.138893 -p 0.23097 0 0.095671 -p 0.245197 0 0.0487726 -p 0.25 0 0 -p 0.245197 0 -0.0487726 -p 0.23097 0 -0.095671 -p 0.207868 0 -0.138893 -p 0.176777 0 -0.176777 -p 0.138893 0 -0.207868 -p 0.095671 0 -0.23097 -p 0.0487726 0 -0.245197 -p 0 0 -0.25 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 -k 40 -k 41 -k 42 -k 43 -k 44 -k 45 -k 46 -k 47 -k 48 -k 49 -k 50 -k 51 -k 52 -k 53 -k 54 -k 55 -k 56 -k 57 -k 58 -k 59 -k 60 -k 61 -k 62 -k 63 -k 64 -k 65 -k 66 -k 67 -k 68 -k 69",
    }
    
    if help:
        print "################################"
        print "- Available Control Shape List -"
        for key in shapeMELs:
            print key
        print "################################"            
        return 
    
    shapeMEL = "%s -n %s" % (shapeMELs[shape], name)
    
    rotations = {'x'  : [90, 0 , 0],
                 '-x' : [-90, 0 , 0],
                 'y'  : [0, 90, 0],
                 '-y' : [0, -90, 0],
                 'z'  : [0, 0, 90],
                 '-z'  : [0, 0, -90],
                 }
                        
    try:
        pm.mel.eval(shapeMEL)        
        ctrl = pm.PyNode(name)
        ctrl.scale.set(size, size, size)
        if axis: ctrl.rotate.set(rotations[axis])
        pm.makeIdentity(ctrl, apply=True, t=True, r=True, s=True)

        pm.delete(pm.parentConstraint(node, ctrl, mo=False))
                
        if point : pm.pointConstraint(ctrl, node, mo=True, name="%s_tConst"%node.name())
        if orient : pm.orientConstraint(ctrl, node, mo=True, name="%s_rConst"%node.name())
        if scale : pm.scaleConstraint(ctrl, node, mo=True, name="%s_sConst"%node.name())
        
        return ctrl
    
    except Exception as e:
        pm.warning("error while creating control %s" %e)
        
コード例 #34
0
ファイル: lib_mpc.py プロジェクト: AndresMWeber/aw
def rig_makeBlockGeo(geometry, mpcStyle=False):
	'''Uses the MPC block geo script to create automaded block geo out of one selected object which is properly constrained.
	Args:
		geometry (pm.PyNode): poly mesh to be broken apart
		mpcStyle (boolean): replaces the suffix based on JNT and GEO
	Returns (list[pm.PyNode]): List of proxies that were generated
	Example Usage:
		rig_makeBlockGeo()
	'''
	#convert the list to a mel list as a string to pass
	command = 'rig_makeBlockGeo ({{"{MESHES}"}},"");'.format(MESHES=geometry)
	print command
	proxies = mel.eval(command)
	
	if len(proxies):
		#Time to sort them and order them + constrain them
		if not pm.objExists('proxy_GRP'):
			prx_grp = pm.group(em=True, n='proxy_GRP')
		else:
			prx_grp = pm.PyNode('proxy_GRP')
		
	if pm.objExists('model_GRP'):
		prx_grp.setParent('model_GRP')
		if pm.objExists('globalCon_GRP'):
			pm.scaleConstraint('globalCon_GRP', prx_grp, mo=True)
	final={}
	
	proxy_grp = geometry.replace('GEO','PROXY_GRP')
	if not pm.objExists(proxy_grp):
		proxy_grp=pm.group(em=True,n=proxy_grp)
	else:
		proxy_grp=pm.PyNode(proxy_grp)
	proxy_grp.setParent(prx_grp)
	
	for proxy in proxies:
		if mpcStyle:
			proxy=pm.PyNode(proxy)
			pm.polySoftEdge(proxy, a=0, ch=0)
			jnt = proxy.name().replace('_GEO','')
			print proxy.name().replace('_GEO','')
			print proxy.name().replace('GEO','JNT')
			if pm.objExists(proxy.replace('GEO','JNT')):
				jnt = proxy.replace('GEO','JNT')
			pm.parentConstraint(jnt, proxy, mo=True)
			proxy.setParent(proxy_grp)
			proxy.rename(geometry+'_'+proxy.replace('GEO','PROXY'))
			print 'adding joint'
			final[proxy]=jnt
		else:
			proxy=pm.PyNode(proxy)
			pm.polySoftEdge(proxy, a=0, ch=0)
			proxy.rename(proxy.replace('GEO','PROXY'))
			final[proxy]=proxy.replace('_PROXY', '')
	return final
コード例 #35
0
def feetctrl(arg):
	value=pm.textField('cmm',q=True,tx=True)
	ctrsel = ["Ankle_L","ToesEnd_L","Ankle_R","ToesEnd_R"]
	fmsel = []
	fmseladjust = ["footmask_LB","footmask_LF","footmask_RB","footmask_RF"]
	LBcube = pm.polyCube(n="footmask_LB",w=0.13,h=0.03,d=0.2)
	pm.move(0.095,-0.015,0.013)
	fmsel.append(LBcube)
	LFcube = pm.polyCube(n="footmask_LF",w=0.13,h=0.03,d=0.08)
	pm.move(0.095,-0.015,0.143)
	fmsel.append(LFcube)
	RBcube = pm.polyCube(n="footmask_RB",w=0.13,h=0.03,d=0.2)
	pm.move(-0.095,-0.015,0.013)
	fmsel.append(RBcube)
	RFcube = pm.polyCube(n="footmask_RF",w=0.13,h=0.03,d=0.08)
	pm.move(-0.095,-0.015,0.143)
	fmsel.append(RFcube)
	
	fmselNew = [i for i in fmseladjust if i not in fmsel]
	AiUNode = pm.shadingNode("aiUtility",asShader=True)
	SGNode = pm.createNode("shadingEngine")
	pm.setAttr(AiUNode+".hardwareColor",0,1,1)
	pm.setAttr(AiUNode+".shadeMode",2)
	for i in range(0,len(fmselNew)):
	    shapeNode = pm.listRelatives(fmselNew[i],s=True,f=True)
	    pm.defaultNavigation(source=AiUNode,destination =shapeNode[0]+".instObjGroups[0]" ,connectToExisting=True)
	    pm.setAttr(shapeNode[0]+".castsShadows",0)
	    pm.setAttr(shapeNode[0]+".receiveShadows",0)
	    pm.setAttr(shapeNode[0]+".motionBlur",0)
	    pm.setAttr(shapeNode[0]+".primaryVisibility",0)
	    pm.setAttr(shapeNode[0]+".smoothShading",0)
	    pm.setAttr(shapeNode[0]+".visibleInReflections",0)
	    pm.setAttr(shapeNode[0]+".visibleInRefractions",0)
	    pm.setAttr(shapeNode[0]+".doubleSided",0)
	    pm.setAttr(shapeNode[0]+".aiSelfShadows",0)
	    pm.setAttr(shapeNode[0]+".aiOpaque",0)
	    pm.setAttr(shapeNode[0]+".aiVisibleInDiffuse",0)
	    pm.setAttr(shapeNode[0]+".aiVisibleInGlossy",0)
	for i in range(0,len(fmselNew)):
		pm.makeIdentity(fmselNew[i],apply=True,t=1,r=1,s=1,n=0)
	pm.select(fmselNew,r=1)	
	mel.eval('DeleteHistory')
	pm.group(fmselNew,name=value+'_feetMask_g')
	pm.rename(AiUNode,value)
	for i in range(0,len(ctrsel)):
	        if pm.objExists(ctrsel[i]):
	            pm.select(ctrsel[i])
	            pm.parentConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1)
	            pm.scaleConstraint(ctrsel[i],fmselNew[i],mo=True,weight = 1)
	            pm.setAttr(fmselNew[i] + '.primaryVisibility',0)
	            pm.setAttr(fmselNew[i] + '.castsShadows',0)
	            pm.setAttr(fmselNew[i] + '.receiveShadows',0)
	            pm.rename(fmselNew[i],value +"_" + fmselNew[i])  
コード例 #36
0
def bdConnectMouth(namespace):
    zoobeCenter = ['lower_lip_center_speak', 'upper_lip_center_speak']
    capcomCenterDown = [
        'lower_lip_center_speak', 'lower_lip_open_center_speak'
    ]
    capcomCenterUp = ['upper_lip_center_speak', 'upper_lip_open_center_speak']

    zoobeMouth = [
        'upper_lip_left_speak', 'lip_corner_left_speak', 'lower_lip_left_speak'
    ]
    capcomMouth = [
        'upper_lip_left_speak', 'lip_corner_left_speak', 'lower_lip_left_speak'
    ]

    zoobeJaw = 'lower_jaw_speak'
    capcomJaw = 'lower_jaw_speak'

    sourceJaw = pm.ls(zoobeJaw)[0]
    targetJaw = pm.ls(namespace + capcomJaw)[0]

    pm.parentConstraint(sourceJaw, targetJaw, mo=True)
    pm.scaleConstraint(sourceJaw, targetJaw, mo=True)

    sourceUp = pm.ls(zoobeCenter[1])[0]
    sourceDown = pm.ls(zoobeCenter[0])[0]

    for jnt in capcomCenterUp:
        target = pm.ls(namespace + jnt)[0]

        pm.parentConstraint(sourceUp, target, mo=True)
        pm.scaleConstraint(sourceUp, target, mo=True)

    for jnt in capcomCenterDown:
        target = pm.ls(namespace + jnt)[0]

        pm.parentConstraint(sourceDown, target, mo=True)
        pm.scaleConstraint(sourceDown, target, mo=True)

        i = 0

    for jnt in zoobeMouth:
        targetLeft = pm.ls(namespace + capcomMouth[i])[0]
        sourceLeft = pm.ls(jnt)[0]
        targetRight = pm.ls(namespace +
                            capcomMouth[i].replace('_left', '_right'))[0]
        sourceRight = pm.ls(jnt.replace('_left', '_right'))[0]
        i += 1

        pm.parentConstraint(sourceLeft, targetLeft, mo=True)
        pm.scaleConstraint(sourceLeft, targetLeft, mo=True)
        pm.parentConstraint(sourceRight, targetRight, mo=True)
        pm.scaleConstraint(sourceRight, targetRight, mo=True)
コード例 #37
0
ファイル: flexi_plane.py プロジェクト: michaelanieves/Rigging
    def build_tweek_ctrls(self, follicles):
        """ 
        Args:
            None
        Returns (None)
        """
        base_name = '%s_flexiPlane' % self.flexiPlaneNameField.getText()
        follicle_prefix = '%s_flexiPlane_' % self.flexiPlaneNameField.getText()
        mainCTRLGRP = self.flexiPlaneNameField.getText() + '_flexiPlane_main_CTRLCon_GRP'
        main_crv_name =  '%s_main_CTRL' % base_name
        tweekCTRLGRP = pm.group( em = True, name = self.flexiPlaneNameField.getText() + '_flexiPlane_tweakCTRL_GRP' )
        tweekCTRLGRP.setAttr( 'inheritsTransform', 0 )
        pm.parent( tweekCTRLGRP, mainCTRLGRP )
        

        for index,follicle in enumerate(follicles):
            tweek_crv_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
                                                 INDEX = 'flexiPlane_tweak%03d' % (index+1),
                                                 SUFFIX = 'CTRL')
            pm.circle( c = (0, 0, 0 ), nr = ( 0, 1, 0 ), sw = 360, r = 1, d = 3, ut = 0, tol = 0.000129167, s = 8, n = tweek_crv_name, ch = 0 )
            pm.setAttr( tweek_crv_name + '.scaleX', .5 )
            pm.setAttr( tweek_crv_name + '.scaleY', .5 )
            pm.setAttr( tweek_crv_name + '.scaleZ', .5 )
            pm.setAttr( tweek_crv_name + '.overrideEnabled', 1 )
            pm.setAttr( tweek_crv_name + '.overrideColor', 17 )
            pm.makeIdentity( tweek_crv_name, apply=True, translate=True, rotate=True, scale=True )
            pm.setAttr( tweek_crv_name + '.overrideEnabled', 1 )
            pm.setAttr( tweek_crv_name + '.overrideColor', 17 )
            
            pm.duplicate( tweek_crv_name, n= tweek_crv_name + 'A' )
            pm.setAttr( tweek_crv_name + 'A.rotateZ', -90 )
            pm.makeIdentity( tweek_crv_name + 'A', apply=True, translate=True, rotate=True, scale=True )
            
            pm.duplicate( tweek_crv_name, n= tweek_crv_name + 'B' )
            pm.setAttr( tweek_crv_name + 'B.rotateZ', -90 )
            pm.setAttr( tweek_crv_name + 'B.rotateX', -90 )
            pm.makeIdentity( tweek_crv_name + 'B', apply=True, translate=True, rotate=True, scale=True )
            
            pm.parent( tweek_crv_name + 'AShape', tweek_crv_name + 'BShape', tweek_crv_name, add = True, shape = True )
            pm.delete( tweek_crv_name + 'A', tweek_crv_name + 'B')
            
            pm.select(tweek_crv_name, r=True)
            offSetGRP.add_offset_grps()
            conGRP.add_con_grps()
            pm.select(clear = True)
            
            pm.connectAttr( follicle + '.translate', tweek_crv_name + 'Offset_GRP.translate' )
            pm.connectAttr( follicle + '.rotate', tweek_crv_name + 'Offset_GRP.rotate' )
            pm.parent( tweek_crv_name + 'Offset_GRP', tweekCTRLGRP )
            pm.scaleConstraint( main_crv_name, tweek_crv_name + 'Offset_GRP' )
 
            pm.select( clear = True)
コード例 #38
0
ファイル: hacks.py プロジェクト: sayehaye3d/ls-rigging-tools
def connectEyeDeformerToEyeMover(aimJntsGrp, moverBnd):
    '''
    transform eye deformer with eyeMover ctrl
    '''
    masterGrp = aimJntsGrp.getParent()
    consGrp = pm.group(em=True, n=aimJntsGrp+'_PR_SC')
    moverMat = moverBnd.getMatrix(ws=True)
    consGrp.setMatrix(moverMat, ws=True)
    masterGrp | consGrp | aimJntsGrp
    # constraints
    pCtl = pm.PyNode(moverBnd.attached_pri_ctl.get())
    pm.parentConstraint(moverBnd, consGrp)
    pm.scaleConstraint(pCtl, consGrp)
コード例 #39
0
def publishJoints(rig, systems):
    """
    for each system, makes a group under rig.bind_GRP. Makes a copy of each joint in system.joints and constrains it
    to the corresponding system joint.
    """
    for system in systems:
        grp = coreUtils.addChild(rig.bind_grp, 'group',
                                 '%s_bind_GRP' % system.name)
        for joint in system.joints:
            j = coreUtils.addChild(grp, 'joint',
                                   joint.name().replace('JNT', 'BND'))
            pmc.parentConstraint(joint, j, mo=0)
            pmc.scaleConstraint(joint, j, mo=0)
コード例 #40
0
 def socket(self, plug, mode='parentConstraint'):
     """given a transform node, constraint to this objects comp_grp
     
     :param mode: define which constraint type is desired
     :type mode: str
     """
     if mode == 'parentConstraint':
         pm.parentConstraint(plug, self.comp_grp, mo=True)
     elif mode == 'pointConstraint':
         pm.pointConstraint(plug, self.comp_grp, mo=True)
     elif mode == 'orientConstraint':
         pm.orientConstraint(plug, self.comp_grp, mo=True)
     pm.scaleConstraint(plug, self.comp_grp, mo=True)
コード例 #41
0
ファイル: FK_chain.py プロジェクト: nicolasboselli/DEV_pymel
def createOneFKChain(jointList = None, radius = 1, theSuffix = "_FK_ctrl", axis = [1,0,0] ):
    # create controller
    fkCtrlsGrp, fkCtrls = helpers.createCircle(axis=axis, sel = jointList, radius = radius, suffix = theSuffix)
    
    # create controller hierachy 
    for i in range(len(fkCtrls)-1, 0, -1): fkCtrlsGrp[i].setParent(fkCtrls[i-1])

    # constraint joint to controllers
    for i, null in enumerate(fkCtrls):
        pm.parentConstraint(fkCtrls[i], jointList[i])
        pm.scaleConstraint(fkCtrls[i], jointList[i])
    
    return fkCtrlsGrp, fkCtrls
コード例 #42
0
ファイル: addFeatures.py プロジェクト: anang-prabowo/work
def addLockKneeElbow():
    '''
    add lock knee/elbow feature
    '''
    ikCtrls = {'FL':('IK_ARM_FL_CTRL', 'ElbowLock', 'PVC_ARM_FL_CTRL' , 'jIKArmFL', 'jIKClavL02'),
               'FR':('IK_ARM_FR_CTRL', 'ElbowLock', 'PVC_ARM_FR_CTRL' , 'jIKArmFR', 'jIKClavR02'),
               'BL':('IK_LEG_BL_CTRL', 'KneeLock', 'PVC_LEG_BL_CTRL', 'jIKLegBL', 'jIKHipBL02'),
               'BR':('IK_LEG_BR_CTRL', 'KneeLock', 'PVC_LEG_BR_CTRL', 'jIKLegBR', 'jIKHipBR02')}
               

    for side in ikCtrls:
        pm.addAttr(ikCtrls[side][0], sn=ikCtrls[side][1], at='bool')
        lockAttr = pm.PyNode('%s.%s'%(ikCtrls[side][0], ikCtrls[side][1]))
        lockAttr.set(0, keyable=True, lock=False)
        
        pt1 = pm.PyNode(ikCtrls[side][4])
        pt2 = pm.PyNode(ikCtrls[side][2])
        pt3 = pm.PyNode(ikCtrls[side][0])
        
        pt1pos = pm.xform(pt1, q=True, ws=True, rp=True)
        pt2pos = pm.xform(pt2, q=True, ws=True, rp=True)
        pt3pos = pm.xform(pt3, q=True, ws=True, rp=True)
        
        dim1 = pm.distanceDimension(startPoint=pt1pos, endPoint=pt2pos)
        dim1Parent = dim1.listRelatives(parent=True)[0]
        dim1Parent.rename('%s_lockPos_01'%side)
        dim2 = pm.distanceDimension(startPoint=pt3pos, endPoint=pt2pos)
        dim2Parent = dim2.listRelatives(parent=True)[0]
        dim2Parent.rename('%s_lockPos_02'%side)
        
        loc = dim1.endPoint.listConnections()[0]
        loc.rename('loc_%s_%s'%(side,ikCtrls[side][1]))
        
        pm.parentConstraint(ikCtrls[side][2], loc, mo=True)
        pm.scaleConstraint('CONSTRAIN', loc, mo=True)
        pm.parent((dim1, dim2, loc), 'misc')
        
        cond = pm.createNode('condition', name='cond_adjust_%s_%s'%(side,ikCtrls[side][1]))
        jnt01 = pm.PyNode('%s02'%ikCtrls[side][3])
        jnt02 = pm.PyNode('%s03'%ikCtrls[side][3])
        
        lockAttr >> cond.firstTerm
        cond.secondTerm.set(1)
        dim1.distance >> cond.colorIfTrueR
        dim2.distance >> cond.colorIfTrueG
        cond.colorIfFalseR.set( jnt01.tx.get() )
        cond.colorIfFalseG.set( jnt02.tx.get() )
        
        cond.outColorR >> jnt01.tx
        cond.outColorG >> jnt02.tx
コード例 #43
0
ファイル: __init__.py プロジェクト: zakuro9715/mgear
    def addOperators(self):

        upvDir = self.settings["upVectorDirection"]
        if upvDir == 0:
            upvVec = [1,0,0]
        elif upvDir == 1:
            upvVec = [0,1,0]
        else:
            upvVec = [0,0,1]

        aop.aimCns(self.eye_npo, self.eyeIK_ctl, "zy", 2, upvVec, self.root, False)

        pm.scaleConstraint(self.eyeOver_ctl, self.eye_npo, maintainOffset=False)
        pm.pointConstraint(self.eyeOver_ctl, self.eye_npo, maintainOffset=False)
コード例 #44
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectSpine(namespace):

	tsmSpine = ['Spine_joint2','Spine_joint4','Spine_joint6','Head_joint1','Head_joint3']
	capcomSpine = ['Waist','Stomach','Chest','Neck','Head']


	i=0

	for jnt in tsmSpine:
		target = pm.ls(namespace + capcomSpine[i])[0]
		source = pm.ls( jnt )[0]
		i+=1

		pm.parentConstraint(source,target,mo=True)
		pm.scaleConstraint(source,target,mo=True)
コード例 #45
0
ファイル: __init__.py プロジェクト: Italic-/maya-scripts
def update_offset(con_node, targets):
    """
    Update offset of given constraint.

    :param con_node: Constraint PyNode.
    :param targets: List of PyNode targets (constraints can only be edited with a complete list of the original targets).
    """
    if isinstance(con_node, pmc.nodetypes.ParentConstraint):
        pmc.parentConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.PointConstraint):
        pmc.pointConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.OrientConstraint):
        pmc.orientConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.ScaleConstraint):
        pmc.scaleConstraint(targets, con_node, e=True, maintainOffset=True)
コード例 #46
0
def update_offset(con_node, targets):
    """
    Update offset of given constraint.

    :param con_node: Constraint PyNode.
    :param targets: List of PyNode targets (constraints can only be edited with a complete list of the original targets).
    """
    if isinstance(con_node, pmc.nodetypes.ParentConstraint):
        pmc.parentConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.PointConstraint):
        pmc.pointConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.OrientConstraint):
        pmc.orientConstraint(targets, con_node, e=True, maintainOffset=True)
    elif isinstance(con_node, pmc.nodetypes.ScaleConstraint):
        pmc.scaleConstraint(targets, con_node, e=True, maintainOffset=True)
コード例 #47
0
    def run(self):

        shouldCreateOffset = False
        if self.createFollowerOffset == 0:
            # Always
            shouldCreateOffset = True
        elif self.createFollowerOffset == 1 and self.follower.nodeType(
        ) != 'joint':
            # Exclude Joints and the follower is not a joint
            shouldCreateOffset = True

        _follower = self.follower
        if shouldCreateOffset:
            _follower = pulse.nodes.createOffsetGroup(self.follower)

        # parent constrain (translate and rotate)
        pc = pm.parentConstraint(self.leader, _follower, mo=True)
        # set interpolation mode to Shortest
        pc.interpType.set(2)

        # scale constrain
        sc = pm.scaleConstraint(self.leader, _follower, mo=True)
        if self.worldSpaceScaling:
            pulse.nodes.convertScaleConstraintToWorldSpace(sc)

        # lockup the constraints
        pulse.nodes.setConstraintLocked(pc, True)
        pulse.nodes.setConstraintLocked(sc, True)
コード例 #48
0
def parentConstraintBndsToMover(bnds, mover):
    '''
    this is better than using matrix weights
    '''
    # add frzgrp above ctl & bnd for constraining
    for bnd in bnds:
        priDrvBnd = pm.PyNode(bnd.replace('_bnd', '_priDrv_bnd'))
        ctg = pm.PyNode(bnd.replace('_bnd', '_ctrl_ctg'))
        
        def addFreezeGrp(node, suffix='_frzGrp'):
            par = node.getParent()
            frzGrp = pm.group(em=True, n=str(node)+suffix)
            mat = node.getMatrix(ws=True)
            frzGrp.setMatrix(mat, ws=True)
            par | frzGrp | node
            pm.select(frzGrp, r=True)
            return frzGrp
            
        bndFrz = addFreezeGrp(priDrvBnd, '_headShaperCons')
        ctgFrz = addFreezeGrp(ctg, '_headShaperCons')
        
        # constrain the control
        cons = pm.parentConstraint(mover, ctgFrz, mo=True, w=1)
        if 'eyelid_' in bnd.name():
            scaleCons = pm.scaleConstraint(mover, ctgFrz, mo=True, w=1)
        else:
            # no scale for socket bnds
            pass
        
        # connect bnd by direct trs (to keep it local)
        ctgFrz.t >> bndFrz.t
        ctgFrz.r >> bndFrz.r
        ctgFrz.s >> bndFrz.s
コード例 #49
0
ファイル: module_base.py プロジェクト: AtonLerin/littlewitch
	def constrain(self, *args, **kwargs):
		cType = kwargs.pop('type', None)

		## I want to be able to provide more than the standard Maya constraints in the
		## at some point, while also offering the module creator the ease of use of specifying 
		## names through these strings if the system is ported to another DCC in the future.
		validConstraints = ['point','orient','pointorient','parent','normal','axis','scale']

		if not cType in validConstraints:
			raise ValueError('constraint type invalid -- must be one of ' ', '.join(validConstraints) + '.')

		oblist = utils.makeList(args)

		results = []
		if cType == 'point' or cType == 'pointorient':
			results.append( pm.pointConstraint(*oblist, **kwargs) )
		elif  cType == 'orient' or cType == 'pointorient':
			results.append( pm.orientConstraint(*oblist, **kwargs) )
		elif cType == 'parent':
			results.append( pm.parentConstraint(*oblist, **kwargs) )
		elif cType == 'scale':
			results.append( pm.scaleConstraint(*oblist, **kwargs) )
		else:
			raise NotImplementedError('Constraint type not yet implemented.')

		if len(results) == 1:
			return(results[0])
		else:
			return(results)
コード例 #50
0
ファイル: control.py プロジェクト: AndresMWeber/Forge
 def makeOffsetGrp( object, prefix = '' ):
     
     """
     make offset group for given object
     
     @param object: transform object to get offset group
     @param prefix: str, prefix to name new objects
     @return: str, name of new offset group
     """
     
     #if not prefix:
         
     #    prefix = name.removeSuffix( object )
     self.namer.name.set(prefix)
     self.namer.type.set('offsetgrp')
     
     offsetGrp = pm.group( n = self.namer.get(), em = 1 )
     
     objectParents = pm.listRelatives( object, p = 1 )
     
     if objectParents:
         
         pm.parent( offsetGrp, objectParents[0] )
     
     # match object transform
     
     pm.delete( pm.parentConstraint( object, offsetGrp ) )
     pm.delete( pm.scaleConstraint( object, offsetGrp ) )
     
     # parent object under offset group
     
     pm.parent( object, offsetGrp )
     
     return offsetGrp
コード例 #51
0
def parentConstraintBndsToMover(bnds, mover):
    '''
    this is better than using matrix weights
    '''
    # add frzgrp above ctl & bnd for constraining
    for bnd in bnds:
        priDrvBnd = pm.PyNode(bnd.replace('_bnd', '_priDrv_bnd'))
        ctg = pm.PyNode(bnd.replace('_bnd', '_ctrl_ctg'))

        def addFreezeGrp(node, suffix='_frzGrp'):
            par = node.getParent()
            frzGrp = pm.group(em=True, n=str(node) + suffix)
            mat = node.getMatrix(ws=True)
            frzGrp.setMatrix(mat, ws=True)
            par | frzGrp | node
            pm.select(frzGrp, r=True)
            return frzGrp

        bndFrz = addFreezeGrp(priDrvBnd, '_headShaperCons')
        ctgFrz = addFreezeGrp(ctg, '_headShaperCons')

        # constrain the control
        cons = pm.parentConstraint(mover, ctgFrz, mo=True, w=1)
        if 'eyelid_' in bnd.name():
            scaleCons = pm.scaleConstraint(mover, ctgFrz, mo=True, w=1)
        else:
            # no scale for socket bnds
            pass

        # connect bnd by direct trs (to keep it local)
        ctgFrz.t >> bndFrz.t
        ctgFrz.r >> bndFrz.r
        ctgFrz.s >> bndFrz.s
コード例 #52
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectFingers(namespace):
	tsmFingers = ['LeftThumb_joint1','LeftThumb_joint2','LeftThumb_joint3','LeftFinger1_joint1','LeftFinger1_joint2','LeftFinger1_joint3','LeftFinger1_joint4','LeftFinger2_joint1','LeftFinger2_joint2','LeftFinger2_joint3','LeftFinger2_joint4','LeftFinger3_joint1','LeftFinger3_joint2','LeftFinger3_joint3','LeftFinger3_joint4','LeftFinger4_joint1','LeftFinger4_joint2','LeftFinger4_joint3','LeftFinger4_joint4']
	capcomFingers = ['LThumb1','LThumb2','LThumb3','LRH','LIndex1','LIndex2','LIndex3','LCH','LMiddle1','LMiddle2','LMiddle3','LLH','LRing1','LRing2','LRing3','LLH','LPinky1','LPinky2','LPinky3']
	i=0

	for jnt in tsmFingers:
		targetLeft = pm.ls(namespace + capcomFingers[i])[0]
		sourceLeft = pm.ls( jnt )[0]
		targetRight = pm.ls(namespace + 'R' + capcomFingers[i][1:])[0]
		sourceRight = pm.ls( jnt.replace('Left','Right') )[0]
		i+=1

		pm.parentConstraint(sourceLeft,targetLeft,mo=True)    
		pm.scaleConstraint(sourceLeft,targetLeft,mo=True)    
		pm.parentConstraint(sourceRight,targetRight,mo=True)
		pm.scaleConstraint(sourceRight,targetRight,mo=True)
コード例 #53
0
ファイル: fk.py プロジェクト: Shadowtags/ModularRiggingTool
	def CreateFKControl(self, _joint, _parent, _moduleContainer):
		jointName = utils.StripAllNamespaces(_joint)[1]
		containedNodes = []
		name = "%s_fkControl" %jointName
		
		controlObjectInstance = controlObject.ControlObject()
		
		fkControlInfo = controlObjectInstance.Create(name, "sphere.ma", self, _lod = 1, _translation = False, _rotation = True, _globalScale = False, _spaceSwitching = False)
		fkControl = fkControlInfo[0]
		
		pm.connectAttr("%s.rotateOrder" %_joint, "%s.rotateOrder" %fkControl)
		
		orientGrp = pm.group(name = "%s_orientGrp", empty = True, parent = _parent)
		containedNodes.append(orientGrp)
		
		pm.delete(pm.parentConstraint(_joint, orientGrp, maintainOffset = False))
		
		jointParent = pm.listRelatives(_joint, parent = True)[0]
		
		orientGrp_parentConstraint = pm.parentConstraint(jointParent, orientGrp, maintainOffset = True, name = "%s_parentConstraint" %orientGrp)
		orientGrp_scaleConstraint = pm.scaleConstraint(jointParent, orientGrp, maintainOffset = True, name = "%s_scaleConstraint" %orientGrp)
		
		pm.parent(fkControl, orientGrp, relative = True)
		
		orientConstraint = pm.orientConstraint(fkControl, _joint, maintainOffset = False, name = "%s_orientConstraint" %_joint)
		
		containedNodes.extend([orientGrp_parentConstraint, orientGrp_scaleConstraint, orientConstraint])
		
		utils.AddNodeToContainer(_moduleContainer, containedNodes)
		
		return fkControl
コード例 #54
0
    def setInput(self, transformNode=None):
        ''' input 설정 '''
        if transformNode:
            self.inputNode = transformNode

        # 이미 연결된 컨스트레인이 있으면 컨스트레인 삭제
        consts = self.root.constrinatFor_input.get()
        if consts:
            pm.delete(consts)

        # 컨스트레인
        parenConst = pm.parentConstraint(self.inputNode, self.input)
        parenConst.enableRestPosition.set(
            0)  # inputNode가 삭제 됐을때 input이 restPosition으로 돌아가지 않도록 세팅
        scaleConst = pm.scaleConstraint(self.inputNode, self.input)
        scaleConst.enableRestPosition.set(0)
        consts = [parenConst, scaleConst]

        # 메세지 노드로 root에 연결
        self.inputNode.message >> self.root.inputNode
        for const in consts:
            pm.connectAttr(const.message,
                           self.root.constrinatFor_input,
                           nextAvailable=True)

        # 컨스트레인을 const_grp에 페어런트
        pm.parent(consts, self.__const_grp)

        # rootNode 이름 변경
        self.__setRename()

        # 노드 선택
        pm.select(self.inputNode)
コード例 #55
0
    def connect_leg_ms_2jnt_01(self):
        """Connector for leg ms 2jnt"""

        # If the parent component hasn't been generated we skip the connection
        if self.parent_comp is None:
            return

        pm.connectAttr(self.parent_comp.blend_att, self.blend_att)
        pm.parent(self.root, self.parent_comp.ik_ctl)
        pm.parent(self.parent_comp.ik_ref, self.bk_ctl[-1])
        pm.parentConstraint(self.parent_comp.tws3_rot,
                            self.fk_ref,
                            maintainOffset=True)
        cns = pm.scaleConstraint(self.parent_comp.fk_ref,
                                 self.parent_comp.ik_ref,
                                 self.fk_ref,
                                 wal=True)
        bc_node = pm.createNode("blendColors")
        pm.connectAttr(bc_node + ".outputB",
                       cns + ".%sW0" % self.parent_comp.fk_ref)
        pm.connectAttr(bc_node + ".outputR",
                       cns + ".%sW1" % self.parent_comp.ik_ref)
        pm.connectAttr(self.parent_comp.blend_att, bc_node + ".blender")

        return
コード例 #56
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectMouth(namespace):
	zoobeCenter = ['lower_lip_center_speak','upper_lip_center_speak']
	capcomCenterDown = ['lower_lip_center_speak','lower_lip_open_center_speak']
	capcomCenterUp = ['upper_lip_center_speak','upper_lip_open_center_speak']
	
	zoobeMouth = ['upper_lip_left_speak','lip_corner_left_speak','lower_lip_left_speak']
	capcomMouth = ['upper_lip_left_speak','lip_corner_left_speak','lower_lip_left_speak']

	zoobeJaw = 'lower_jaw_speak'
	capcomJaw = 'lower_jaw_speak'
	
	sourceJaw = pm.ls(zoobeJaw)[0]
	targetJaw = pm.ls(namespace + capcomJaw)[0]
	
	pm.parentConstraint(sourceJaw,targetJaw,mo=True)    
	pm.scaleConstraint(sourceJaw,targetJaw,mo=True)
	
	
	sourceUp = pm.ls( zoobeCenter[1] )[0]
	sourceDown = pm.ls( zoobeCenter[0] )[0]
	
	for jnt in capcomCenterUp:
		target = pm.ls(namespace + jnt)[0]
		
		pm.parentConstraint(sourceUp,target,mo=True)    
		pm.scaleConstraint(sourceUp,target,mo=True)
	
	for jnt in capcomCenterDown:
		target = pm.ls(namespace + jnt)[0]
		
		pm.parentConstraint(sourceDown,target,mo=True)    
		pm.scaleConstraint(sourceDown,target,mo=True)
		
		i=0
	
	for jnt in zoobeMouth:
		targetLeft = pm.ls(namespace + capcomMouth[i])[0]
		sourceLeft = pm.ls( jnt )[0]
		targetRight = pm.ls(namespace + capcomMouth[i].replace('_left','_right'))[0]
		sourceRight = pm.ls( jnt.replace('_left','_right') )[0]
		i+=1

		pm.parentConstraint(sourceLeft,targetLeft,mo=True)    
		pm.scaleConstraint(sourceLeft,targetLeft,mo=True)    
		pm.parentConstraint(sourceRight,targetRight,mo=True)
		pm.scaleConstraint(sourceRight,targetRight,mo=True)
コード例 #57
0
def delson_boundToPuppet():
	cmds.file("/jobs/playstationFearless_5402239/build/delsin/release/work/model/delsin_lodC_proxy/vLatest/playstationFearless_5402239_build_delsin_model_delsin_lodC_proxy_vLatest.ma",
	        i=True, type="mayaAscii", ignoreVersion=True, rpr="playstationFearless_5402239_build_delsin_model_delsin_lodC_proxy_vLatest", options="v=0", pr=True, loadReferenceDepth="all")
	pm.parent('bodyA_GRP','clothes_GRP', w=True)
	pm.delete('playstationFearless_5402239RigBoundDelsinATop_GRP')
	g=pm.group(em=True,n='delsin_lodC_GRP')
	pm.parent('bodyA_GRP','clothes_GRP','delsin_lodC_GRP')
	g.setParent('model_GRP')
	pm.parent('delsin_lodC_proxy_GRP', 'model_GRP')
	pm.connectAttr('blockGeo_LOC.showBlockBody', 'delsin_lodC_proxy_GRP.visibility')
	pm.connectAttr('blockGeo_LOC.showSkinnedBody', 'delsin_lodC_GRP.visibility' )
	for attr in ['.tx','.ty','.tz','.rx','.ry','.rz','.sx','.sy','.sz',]:
		pm.setAttr('l_eye_PROXY'+attr,l=False)
	pm.parentConstraint('headJA_JNT','l_eye_PROXY',mo=True)
	cm.constraint_parseFile(file='/jobs/playstationFearless_5402239/build/delsin/maya/data/constraints/andres-w/_20140124T155034.constraints',selected=False)
	pm.delete(['hubModelDelsin_lodC_proxySet', 'hubRigBoundDelsinASet','hubGeometryCacheDelsinASet','hubSkeletonCacheDelsinASet'])
	pm.scaleConstraint('global_CTRL','delsin_lodC_proxy_GRP')
コード例 #58
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectEyebrows(namespace):
	zoobeEyebrows = ['inner_eyebrow_left','center_eyebrow_left','outer_eyebrow_left']
	capcomEyebrows = ['Face_LEyeBrows1','Face_LEyeBrows2','Face_LEyeBrows3']
	
	i=0

	for jnt in zoobeEyebrows:
		targetLeft = pm.ls(namespace + capcomEyebrows[i])[0]
		sourceLeft = pm.ls( jnt )[0]
		targetRight = pm.ls(namespace + capcomEyebrows[i].replace('_L','_R'))[0]
		sourceRight = pm.ls( jnt.replace('_left','_right') )[0]
		i+=1

		pm.parentConstraint(sourceLeft,targetLeft,mo=True)    
		pm.scaleConstraint(sourceLeft,targetLeft,mo=True)    
		pm.parentConstraint(sourceRight,targetRight,mo=True)
		pm.scaleConstraint(sourceRight,targetRight,mo=True)
コード例 #59
0
ファイル: bdHookSFChar.py プロジェクト: Mortaciunea/bdScripts
def bdConnectFace(namespace):
	zoobeFace = ['nose_wrinkle_left','nose_wing_left','cheek_raise_left','lip_stretch_left','cheek_puff_left']
	capcomFace = ['Face_LNose','Face_LCheekLineTop','Face_LCheekTop','Face_LCheekLineBottom','Face_LCheekBottom']
	
	i=0

	for jnt in zoobeFace:
		targetLeft = pm.ls(namespace + capcomFace[i])[0]
		sourceLeft = pm.ls( jnt )[0]
		targetRight = pm.ls(namespace + capcomFace[i].replace('_L','_R'))[0]
		sourceRight = pm.ls( jnt.replace('_left','_right') )[0]
		i+=1

		pm.parentConstraint(sourceLeft,targetLeft,mo=True)    
		pm.scaleConstraint(sourceLeft,targetLeft,mo=True)    
		pm.parentConstraint(sourceRight,targetRight,mo=True)
		pm.scaleConstraint(sourceRight,targetRight,mo=True)
コード例 #60
0
	def constrainBoundJoints(self):
		
		pm.select(cl = True)
		
		self.boundJointsOrientConstraintList = []
		
		#iterate len(boundJointsList) - 1 and orient constrain each joints
		for index in range(0, len(self.boundJointsList) - 1):
			orientConstraint = pm.orientConstraint( self.ikDynamicJointsList[index], self.ikAnimatedJointsList[index], self.fkAnimatedJointsList[index], self.completeSwingJointsList[index], self.boundJointsList[index],  mo = True )
			self.boundJointsOrientConstraintList.append(orientConstraint)
			pm.select(cl = True)
			
			
			
		#constrain bound joints grp to master manip
		pm.scaleConstraint( self.manip_master, self.boundJointsGrp,  mo = True ) 
		pm.parentConstraint( self.manip_master, self.boundJointsGrp,  mo = True ) 
		pm.select(cl = True)