Example #1
0
    def createAndConnectValueOut(self, source, valueBlender, valueOutput):
        print 'createAndConnectValueOut'
        for k in range(len(source.poseBlendInfoList)):
            print '--- k', k
            pose = source.poseBlendInfoList[k].pose

            valueOutNodeName = source.fullName + '_' + pose.name + '_ValueOut_UTL'

            valueOutNode =  rd.shadingNode('SampleValueOut', name = valueOutNodeName, asUtility = True)
            valueOutNode.setAttr('remapFromX',  source.poseBlendInfoList[k].remapFrom[0])
            valueOutNode.setAttr('remapFromY',  source.poseBlendInfoList[k].remapFrom[1])
            valueOutNode.setAttr('remapToX',    source.poseBlendInfoList[k].remapTo[0])
            valueOutNode.setAttr('remapToY',    source.poseBlendInfoList[k].remapTo[1])

            valueOutput.connect(valueOutNode.inValue)

            source.valueOutNodeList.append(valueOutNode)

            # Connect to value blender
            poseInfoNum = pm.Attribute.numElements(valueBlender.allSampleInfoList)
            for n in range(poseInfoNum):
                poseName = valueBlender.getAttr('allSampleInfoList[%s].poseName' %(n))
                if poseName == pose.name:
                    sampleNum = pm.Attribute.numElements(valueBlender.allSampleInfoList[n].sampleValue)
                    valueOutNode.outValue.connect(valueBlender.allSampleInfoList[n].sampleValue[sampleNum])
Example #2
0
def create_fk_ik_sn(controls, **kwargs):
	
	fk, ik = get_fk_ik_joints(controls)
	
	# Add the FkIkMode attribute to both controls and identify
	# which control is the fk control and which is the ik control.
	for c in controls:
		addAttr(c, longName='FkIkMode', niceName='FKIK Mode',
			attributeType='enum', enumName='FK:IK', keyable=True,
			defaultValue=1)
	
	sn = scriptNode(scriptType=2, sourceType='python',
		beforeScript=';'.join(['import pymel.core.nodetypes as nt',
			'import %s as x' % __name__,
			"x.create_fk_ik_sj(%s)" % controls]),
		afterScript=';'.join(['import pymel.core.nodetypes as nt',
			"[c.attr('FkIkMode').delete() for c in %s]" % controls]),
		**kwargs)
	
	# Make the appropriate connections to toggle both visibility and
	# orient constraints.
	rev = shadingNode('reverse', asUtility=True)
	ik['ctrl'].attr('FkIkMode').connect(ik['ctrl'].attr('visibility'))
	fk['ctrl'].attr('FkIkMode').connect(rev.attr('inputX'))
	rev.attr('outputX').connect(fk['ctrl'].attr('visibility'))
	ik['ctrl'].attr('FkIkMode').connect(ik['sj'].attr('visibility'))
	fk['ctrl'].attr('FkIkMode').connect(rev.attr('inputY'))
	rev.attr('outputY').connect(fk['sj'].attr('visibility'))
	for jtype in ('shoulder', 'elbow', 'hand'):
		kwargs = jtype == 'elbow' and dict(skip=('x', 'z')) or {}
		oc = orientConstraint(ik[jtype], fk[jtype], **kwargs)
		ik['ctrl'].attr('FkIkMode').connect( \
			oc.attr(ik[jtype].nodeName() + 'W0'))
	
	create_fk_ik_sj(controls)
Example #3
0
    def setupFacialConstraint(self):
        if len(self.facialConstraintPoseList) > 0:
            self.facialConstraint = rd.shadingNode('FacialControllerConstraint', name = self.fullName + '_FC_UTL', asUtility = True)
            self.facial.facialMeshBackup.outMesh.connect(self.facialConstraint.inBaseMesh)
            self.facialConstraint.setAttr('inPointIndex', self.facialConstraintPointIndex)
            self.facialConstraint.setAttr('inOffsetX', self.facialConstraintOffset[0])
            self.facialConstraint.setAttr('inOffsetY', self.facialConstraintOffset[1])
            self.facialConstraint.setAttr('inOffsetZ', self.facialConstraintOffset[2])

            self.facialConstraint.outPositionX.connect(self.node.translate.translateX)
            self.facialConstraint.outPositionY.connect(self.node.translate.translateY)
            self.facialConstraint.outPositionZ.connect(self.node.translate.translateZ)

            for fcPose in self.facialConstraintPoseList:
                blendShapeListAttr = self.facialConstraint.inBlendshapeInfoList
                numBT = pm.Attribute.numElements(blendShapeListAttr)
                fcPose.shapeMesh.outMesh.connect(blendShapeListAttr[numBT].inMesh)

                relatedWeightCombinerList = pm.ls('FB_' + fcPose.name + '_WgSolver_UTL')

                for weightCombiner in relatedWeightCombinerList:
                    weightListAttr = self.facialConstraint.inBlendshapeInfoList[numBT].inWeightList

                    numWeight = pm.Attribute.numElements(weightListAttr)
                    weightCombiner.outWeight.connect(weightListAttr[numWeight])
Example #4
0
    def __init__(self, poseManager, name):
        self.poseManager = poseManager
        self.name = name
        self.jointList = []

        self.triggerNode = rd.shadingNode('CorrectiveShapeTrigger', name=namespace + 'FB_' + self.name + '_CPTrigger_UTL',
                                          asUtility=True)

        self.shapeMesh = pm.ls('FB_' + self.name + '_BT')[0]
Example #5
0
    def setupRBFSolver(self):
        self.rbfSolver = rd.shadingNode('rbfBlender', name = self.fullName + '_RBF_UTL', asUtility = True)
        mel.addElement(str(self.rbfSolver) + '.inputsCompound')

        self.rbfSolver.setAttr('inputsCompound[0].sample[0]', 1.0)

        self.rbfOutValueBlender = rd.shadingNode('SampleValueBlender', name = self.fullName + '_RBFValueBlender_UTL', asUtility = True)

        # link the controller's translation to the blender lookup
        self.controller.tx.connect(self.rbfSolver.lookup[0])
        self.controller.ty.connect(self.rbfSolver.lookup[1])
        self.controller.tz.connect(self.rbfSolver.lookup[2])
        
        self.setupValueBlender(self.rbfOutValueBlender, self.samplePoseList, self.samplePoseBlendModeList)

        # link sample list to value blender
        for i in range(len(self.sampleList)):
            sample = self.sampleList[i]
            self.connectSample2RBF(sample, i + 1)
            self.createAndConnectValueOut(sample,
                                          self.rbfOutValueBlender,
                                          self.rbfSolver.output[i+1])
Example #6
0
    def setupTransformSolver(self):
        self.matrixCombiner = rd.shadingNode('MatrixCombine', name = self.fullName + '_matCombine_UTL', asUtility = True)

        self.matrixCombiner.outTranslationX.connect(self.node.translateX)
        self.matrixCombiner.outTranslationY.connect(self.node.translateY)
        self.matrixCombiner.outTranslationZ.connect(self.node.translateZ)
        self.matrixCombiner.outRotationX.connect(self.node.rotateX)
        self.matrixCombiner.outRotationY.connect(self.node.rotateY)
        self.matrixCombiner.outRotationZ.connect(self.node.rotateZ)

        self.matrixCombiner.setAttr("initialMatrix", self.initialTransform)

        self.editTransformNode = pm.spaceLocator(name = NodesUtility.swapSuffix('_EDT', nodeName=self.fullName))
        self.editTransformNode.matrix.connect(self.matrixCombiner.editMatrix)
        pm.parent(self.editTransformNode, self.jointManager.editNodeRoot)
Example #7
0
    def setupAttribute(self):
        print '---> setup all attributes'
        for attribute in self.attributeList:
            attribute.createReferenceOnNode()

        self.attributeOutValueBlender = rd.shadingNode('SampleValueBlender', name = self.fullName + '_AttrValueBlender_UTL', asUtility = True)

        self.setupValueBlender(self.attributeOutValueBlender, self.attributePoseList, self.attributePoseBlendModeList)

        # link attributes list to value blender
        for i in range(len(self.attributeList)):
            attribute = self.attributeList[i]
            self.createAndConnectValueOut(attribute,
                                          self.attributeOutValueBlender,
                                          attribute.referenceOnNode)
Example #8
0
def create_fk_ik_sn(controls, **kwargs):

    fk, ik = get_fk_ik_joints(controls)

    # Add the FkIkMode attribute to both controls and identify
    # which control is the fk control and which is the ik control.
    for c in controls:
        addAttr(c,
                longName='FkIkMode',
                niceName='FKIK Mode',
                attributeType='enum',
                enumName='FK:IK',
                keyable=True,
                defaultValue=1)

    sn = scriptNode(scriptType=2,
                    sourceType='python',
                    beforeScript=';'.join([
                        'import pymel.core.nodetypes as nt',
                        'import %s as x' % __name__,
                        "x.create_fk_ik_sj(%s)" % controls
                    ]),
                    afterScript=';'.join([
                        'import pymel.core.nodetypes as nt',
                        "[c.attr('FkIkMode').delete() for c in %s]" % controls
                    ]),
                    **kwargs)

    # Make the appropriate connections to toggle both visibility and
    # orient constraints.
    rev = shadingNode('reverse', asUtility=True)
    ik['ctrl'].attr('FkIkMode').connect(ik['ctrl'].attr('visibility'))
    fk['ctrl'].attr('FkIkMode').connect(rev.attr('inputX'))
    rev.attr('outputX').connect(fk['ctrl'].attr('visibility'))
    ik['ctrl'].attr('FkIkMode').connect(ik['sj'].attr('visibility'))
    fk['ctrl'].attr('FkIkMode').connect(rev.attr('inputY'))
    rev.attr('outputY').connect(fk['sj'].attr('visibility'))
    for jtype in ('shoulder', 'elbow', 'hand'):
        kwargs = jtype == 'elbow' and dict(skip=('x', 'z')) or {}
        oc = orientConstraint(ik[jtype], fk[jtype], **kwargs)
        ik['ctrl'].attr('FkIkMode').connect( \
         oc.attr(ik[jtype].nodeName() + 'W0'))

    create_fk_ik_sj(controls)
Example #9
0
 def createWeightSolver(self):
     self.weightSolver = rd.shadingNode('PoseWeightSolver', name=namespace + 'FB_' + self.name + '_WgSolver_UTL',
                                       asUtility=True)