当前位置: 首页>>代码示例>>Python>>正文


Python PoseConstraint.evaluate方法代码示例

本文整理汇总了Python中kraken.core.objects.constraints.pose_constraint.PoseConstraint.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python PoseConstraint.evaluate方法的具体用法?Python PoseConstraint.evaluate怎么用?Python PoseConstraint.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kraken.core.objects.constraints.pose_constraint.PoseConstraint的用法示例。


在下文中一共展示了PoseConstraint.evaluate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LegComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........
        # Add Xfo Outputs
        self.outputsToDeformersSpliceOp.setOutput('constrainees', [femurDef, shinDef, ankleDef])

        # Add Foot Deformer Splice Op
        self.footDefSpliceOp = SpliceOperator('footDeformerSpliceOp', 'PoseConstraintSolver', 'Kraken')
        self.addOperator(self.footDefSpliceOp)

        # Add Att Inputs
        self.footDefSpliceOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.footDefSpliceOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs)
        self.footDefSpliceOp.setInput('constrainer', self.footOutputTgt)

        # Add Xfo Outputs
        self.footDefSpliceOp.setOutput('constrainee', self.footDef)

        # Add Toe Deformer Splice Op
        self.toeDefSpliceOp = SpliceOperator('toeDeformerSpliceOp', 'PoseConstraintSolver', 'Kraken')
        self.addOperator(self.toeDefSpliceOp)

        # Add Att Inputs
        self.toeDefSpliceOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.toeDefSpliceOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.toeDefSpliceOp.setInput('constrainer', self.toeOutputTgt)

        # Add Xfo Outputs
        self.toeDefSpliceOp.setOutput('constrainee', self.toeDef)

        Profiler.getInstance().pop()

    # =============
    # Data Methods
    # =============
    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(LegComponentRig, self).loadData( data )

        self.femurFKCtrlSpace.xfo = data['femurXfo']
        self.femurFKCtrl.xfo = data['femurXfo']
        self.femurFKCtrl.scalePoints(Vec3(data['femurLen'], 1.75, 1.75))

        self.femurOutputTgt.xfo = data['femurXfo']
        self.shinOutputTgt.xfo = data['kneeXfo']

        self.shinFKCtrlSpace.xfo = data['kneeXfo']
        self.shinFKCtrl.xfo = data['kneeXfo']
        self.shinFKCtrl.scalePoints(Vec3(data['shinLen'], 1.5, 1.5))

        self.footCtrlSpace.xfo.tr = data['ankleXfo'].tr
        self.footCtrl.xfo.tr = data['ankleXfo'].tr

        self.toeCtrlSpace.xfo = data['toeXfo']
        self.toeCtrl.xfo = data['toeXfo']

        self.legIKCtrlSpace.xfo.tr = data['ankleXfo'].tr
        self.legIKCtrl.xfo.tr = data['ankleXfo'].tr

        if self.getLocation() == "R":
            self.legIKCtrl.rotatePoints(0, 90, 0)
            self.legIKCtrl.translatePoints(Vec3(-1.0, 0.0, 0.0))
        else:
            self.legIKCtrl.rotatePoints(0, -90, 0)
            self.legIKCtrl.translatePoints(Vec3(1.0, 0.0, 0.0))

        self.legUpVCtrlSpace.xfo = data['upVXfo']
        self.legUpVCtrl.xfo = data['upVXfo']

        self.rightSideInputAttr.setValue(self.getLocation() is 'R')
        self.legBone0LenInputAttr.setMin(0.0)
        self.legBone0LenInputAttr.setMax(data['femurLen'] * 3.0)
        self.legBone0LenInputAttr.setValue(data['femurLen'])
        self.legBone1LenInputAttr.setMin(0.0)
        self.legBone1LenInputAttr.setMax(data['shinLen'] * 3.0)
        self.legBone1LenInputAttr.setValue(data['shinLen'])

        self.legPelvisInputTgt.xfo = data['femurXfo']

        # Eval Constraints
        self.legIKCtrlSpaceInputConstraint.evaluate()
        self.legUpVCtrlSpaceInputConstraint.evaluate()
        self.legRootInputConstraint.evaluate()
        self.footOutputConstraint.evaluate()
        self.toeOutputConstraint.evaluate()

        # Eval Operators
        self.legIKSpliceOp.evaluate()
        self.outputsToDeformersSpliceOp.evaluate()
        self.footDefSpliceOp.evaluate()
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:104,代码来源:leg_component.py

示例2: FabriceTailRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........

        # Add Att Inputs
        self.deformersToOutputsKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.deformersToOutputsKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setInput('constrainers', self.tailOutputs)

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees', self.deformerJoints)

        Profiler.getInstance().pop()


    def setNumDeformers(self, numDeformers):

        # Add new deformers and outputs
        for i in xrange(len(self.tailOutputs), numDeformers):
            name = 'tail' + str(i + 1).zfill(2)
            tailOutput = ComponentOutput(name, parent=self.outputHrcGrp)
            self.tailOutputs.append(tailOutput)

        for i in xrange(len(self.deformerJoints), numDeformers):
            name = 'tail' + str(i + 1).zfill(2)
            tailDef = Joint(name, parent=self.defCmpGrp)
            tailDef.setComponent(self)
            self.deformerJoints.append(tailDef)

        return True


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(FabriceTailRig, self).loadData( data )

        tailBasePos = data['tailBasePos']

        tailBaseHandlePos = data['tailBaseHandlePos']
        tailBaseHandleCtrlCrvData = data['tailBaseHandleCtrlCrvData']

        tailEndHandlePos = data['tailEndHandlePos']
        tailEndHandleCtrlCrvData = data['tailEndHandleCtrlCrvData']

        tailEndPos = data['tailEndPos']
        tailEndCtrlCrvData = data['tailEndCtrlCrvData']

        numDeformers = data['numDeformers']

        # Set Xfos
        self.spineEndInputTgt.xfo.tr = tailBasePos
        self.spineEndCtrlInputTgt.xfo.tr = tailBasePos

        self.tailBaseHandleCtrlSpace.xfo.tr = tailBaseHandlePos
        self.tailBaseHandleCtrl.xfo.tr = tailBaseHandlePos
        self.tailBaseHandleCtrl.setCurveData(tailBaseHandleCtrlCrvData)

        self.tailEndHandleCtrlSpace.xfo.tr = tailEndHandlePos
        self.tailEndHandleCtrl.xfo.tr = tailEndHandlePos
        self.tailEndHandleCtrl.setCurveData(tailEndHandleCtrlCrvData)

        self.tailEndCtrlSpace.xfo.tr = tailEndPos
        self.tailEndCtrl.xfo.tr = tailEndPos
        self.tailEndCtrl.setCurveData(tailEndCtrlCrvData)

        length = tailBasePos.distanceTo(tailBaseHandlePos) + tailBaseHandlePos.distanceTo(tailEndHandlePos) + tailEndHandlePos.distanceTo(tailEndPos)
        self.lengthInputAttr.setMax(length * 3.0)
        self.lengthInputAttr.setValue(length)

        # Update number of deformers and outputs
        self.setNumDeformers(numDeformers)

        # Updating constraint to use the updated last output.
        self.tailEndOutputConstraint.setConstrainer(self.tailOutputs[-1], index=0)

        # ============
        # Set IO Xfos
        # ============

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the spine op so that all the output transforms are updated.
        self.bezierTailKLOp.evaluate()

        # evaluate the constraint op so that all the joint transforms are updated.
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.tailBaseHandleInputConstraint.evaluate()
        self.tailBaseOutputConstraint.evaluate()
        self.tailEndOutputConstraint.evaluate()
开发者ID:Leopardob,项目名称:Kraken,代码行数:104,代码来源:fabrice_tail.py

示例3: HeadComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........

        # Add Att Inputs
        self.outputsToDeformersKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.outputsToDeformersKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.outputsToDeformersKLOp.setInput('constrainers', [self.headOutputTgt, self.jawOutputTgt, self.eyeROutputTgt, self.eyeLOutputTgt])

        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [headDef, jawDef, eyeRightDef, eyeLeftDef])

        Profiler.getInstance().pop()


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(HeadComponentRig, self).loadData(data)

        headXfo = data.get('headXfo')
        headCrvData = data.get('headCrvData')
        eyeLeftXfo = data.get('eyeLeftXfo')
        eyeLeftCrvData = data.get('eyeLeftCrvData')
        eyeRightXfo = data.get('eyeRightXfo')
        eyeRightCrvData = data.get('eyeRightCrvData')
        jawXfo = data.get('jawXfo')
        jawCrvData = data.get('jawCrvData')

        self.headCtrlSpace.xfo = headXfo
        self.headCtrl.xfo = headXfo
        self.headCtrl.setCurveData(headCrvData)

        # self.eyeLeftCtrlSpace.xfo = eyeLeftXfo
        # self.eyeLeftCtrl.xfo = eyeLeftXfo
        self.eyeLeftCtrl.setCurveData(eyeLeftCrvData)

        # self.eyeRightCtrlSpace.xfo = eyeRightXfo
        # self.eyeRightCtrl.xfo = eyeRightXfo
        self.eyeRightCtrl.setCurveData(eyeRightCrvData)

        # LookAt
        eyeLeftRelXfo = headXfo.inverse() * eyeLeftXfo
        eyeRightRelXfo = headXfo.inverse() * eyeRightXfo
        eyeMidRelPos = eyeLeftRelXfo.tr.linearInterpolate(eyeRightRelXfo.tr, 0.5)
        eyeMidRelPos = eyeMidRelPos + Vec3(0.0, 0.0, 8.0)
        eyeLen = eyeLeftRelXfo.tr.distanceTo(eyeRightRelXfo.tr)

        self.eyeLeftBase.xfo = eyeLeftXfo
        self.eyeRightBase.xfo = eyeRightXfo

        self.eyeLeftUpV.xfo = eyeLeftXfo * Xfo(Vec3(0, 1, 0))
        self.eyeRightUpV.xfo = eyeRightXfo * Xfo(Vec3(0, 1, 0))

        self.eyeLeftAtV.xfo.tr = eyeLeftXfo.transformVector(Vec3(8.0, 0.0, 0.0))
        self.eyeRightAtV.xfo.tr = eyeRightXfo.transformVector(Vec3(8.0, 0.0, 0.0))

        lookAtXfo = headXfo.clone()
        lookAtXfo.tr = headXfo.transformVector(eyeMidRelPos)

        self.lookAtCtrl.scalePoints(Vec3(eyeLen * 1.6, eyeLen * 0.65, 1.0))
        self.lookAtCtrl.xfo = lookAtXfo
        self.lookAtCtrlSpace.xfo = lookAtXfo

        self.jawCtrlSpace.xfo = jawXfo
        self.jawCtrl.xfo = jawXfo
        self.jawCtrl.setCurveData(jawCrvData)

        # ============
        # Set IO Xfos
        # ============
        self.neckRefInputTgt.xfo = headXfo
        self.worldRefInputTgt.xfo = headXfo
        self.headOutputTgt.xfo = headXfo
        self.jawOutputTgt.xfo = jawXfo
        self.eyeLOutputTgt.xfo = eyeLeftXfo
        self.eyeROutputTgt.xfo = eyeRightXfo

        # Eval Constraints
        self.headInputConstraint.evaluate()
        self.headOutputConstraint.evaluate()
        self.jawOutputConstraint.evaluate()
        self.eyeLOutputConstraint.evaluate()
        self.eyeROutputConstraint.evaluate()

        # Eval Operators
        self.eyeLeftDirKLOp.evaluate()
        self.eyeRightDirKLOp.evaluate()
        self.outputsToDeformersKLOp.evaluate()

        # Have to set the eye control xfos to match the evaluated xfos from
        self.eyeLeftCtrl.xfo = self.eyeLeftCtrlSpace.xfo
        self.eyeRightCtrl.xfo = self.eyeRightCtrlSpace.xfo
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:head_component.py

示例4: ArmComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........
        self.spliceOp.setInput("bone1Len", self.armBone1LenInputAttr)
        self.spliceOp.setInput("ikblend", armIKBlendInputAttr)
        self.spliceOp.setInput("softIK", armSoftIKInputAttr)
        self.spliceOp.setInput("softDist", armSoftDistInputAttr)
        self.spliceOp.setInput("stretch", armStretchInputAttr)
        self.spliceOp.setInput("stretchBlend", armStretchBlendInputAttr)
        self.spliceOp.setInput("rightSide", self.rightSideInputAttr)

        # Add Xfo Inputs
        self.spliceOp.setInput("root", self.clavicleEndInputTgt)
        self.spliceOp.setInput("bone0FK", self.bicepFKCtrl)
        self.spliceOp.setInput("bone1FK", self.forearmFKCtrl)
        self.spliceOp.setInput("ikHandle", self.armIKCtrl)
        self.spliceOp.setInput("upV", self.armUpVCtrl)

        # Add Xfo Outputs
        self.spliceOp.setOutput("bone0Out", self.bicepOutputTgt)
        self.spliceOp.setOutput("bone1Out", self.forearmOutputTgt)
        self.spliceOp.setOutput("bone2Out", self.armEndXfoOutputTgt)

        # Add Deformer Splice Op
        self.outputsToDeformersSpliceOp = SpliceOperator("armDeformerSpliceOp", "MultiPoseConstraintSolver", "Kraken")
        self.addOperator(self.outputsToDeformersSpliceOp)

        # Add Att Inputs
        self.outputsToDeformersSpliceOp.setInput("drawDebug", self.drawDebugInputAttr)
        self.outputsToDeformersSpliceOp.setInput("rigScale", self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.outputsToDeformersSpliceOp.setInput(
            "constrainers", [self.bicepOutputTgt, self.forearmOutputTgt, self.armEndXfoOutputTgt, self.handOutputTgt]
        )

        # Add Xfo Outputs
        self.outputsToDeformersSpliceOp.setOutput("constrainees", [bicepDef, forearmDef, wristDef, handDef])

        Profiler.getInstance().pop()

    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(ArmComponentRig, self).loadData(data)

        self.clavicleEndInputTgt.xfo.tr = data["bicepXfo"].tr

        self.bicepFKCtrlSpace.xfo = data["bicepXfo"]
        self.bicepFKCtrl.xfo = data["bicepXfo"]
        self.bicepFKCtrl.scalePoints(Vec3(data["bicepLen"], data["bicepFKCtrlSize"], data["bicepFKCtrlSize"]))

        self.bicepOutputTgt.xfo = data["bicepXfo"]
        self.forearmOutputTgt.xfo = data["forearmXfo"]

        self.forearmFKCtrlSpace.xfo = data["forearmXfo"]
        self.forearmFKCtrl.xfo = data["forearmXfo"]
        self.forearmFKCtrl.scalePoints(Vec3(data["forearmLen"], data["forearmFKCtrlSize"], data["forearmFKCtrlSize"]))

        self.handCtrlSpace.xfo = data["handXfo"]
        self.handCtrl.xfo = data["handXfo"]

        self.armIKCtrlSpace.xfo.tr = data["armEndXfo"].tr
        self.armIKCtrl.xfo.tr = data["armEndXfo"].tr

        if self.getLocation() == "R":
            self.armIKCtrl.rotatePoints(0, 90, 0)
        else:
            self.armIKCtrl.rotatePoints(0, -90, 0)

        self.armUpVCtrlSpace.xfo = data["upVXfo"]
        self.armUpVCtrl.xfo = data["upVXfo"]

        self.rightSideInputAttr.setValue(self.getLocation() is "R")
        self.armBone0LenInputAttr.setMin(0.0)
        self.armBone0LenInputAttr.setMax(data["bicepLen"] * 3.0)
        self.armBone0LenInputAttr.setValue(data["bicepLen"])
        self.armBone1LenInputAttr.setMin(0.0)
        self.armBone1LenInputAttr.setMax(data["forearmLen"] * 3.0)
        self.armBone1LenInputAttr.setValue(data["forearmLen"])

        # Outputs
        self.handOutputTgt.xfo = data["handXfo"]

        # Eval Constraints
        self.armIKCtrlSpaceInputConstraint.evaluate()
        self.armUpVCtrlSpaceInputConstraint.evaluate()
        self.armRootInputConstraint.evaluate()
        self.armRootInputConstraint.evaluate()
        self.handConstraint.evaluate()
        self.handCtrlSpaceConstraint.evaluate()

        # Eval Operators
        self.spliceOp.evaluate()
        self.outputsToDeformersSpliceOp.evaluate()
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:104,代码来源:arm_component.py

示例5: FabriceHeadRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........
        self.headOutputConstraint = PoseConstraint('_'.join([self.headOutputTgt.getName(), 'To', self.headCtrl.getName()]))
        self.headOutputConstraint.addConstrainer(self.headCtrl)
        self.headOutputTgt.addConstraint(self.headOutputConstraint)

        self.jawOutputConstraint = PoseConstraint('_'.join([self.jawOutputTgt.getName(), 'To', self.jawCtrl.getName()]))
        self.jawOutputConstraint.addConstrainer(self.jawCtrl)
        self.jawOutputTgt.addConstraint(self.jawOutputConstraint)

        # ==============
        # Add Operators
        # ==============

        # Add Aim Canvas Op
        # =================
        self.headAimCanvasOp = CanvasOperator('headAimCanvasOp', 'Kraken.Solvers.DirectionConstraintSolver')
        self.addOperator(self.headAimCanvasOp)

        # Add Att Inputs
        self.headAimCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.headAimCanvasOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.headAimCanvasOp.setInput('position', self.headBaseInputTgt)
        self.headAimCanvasOp.setInput('upVector', self.headAimUpV)
        self.headAimCanvasOp.setInput('atVector', self.headAimCtrl)

        # Add Xfo Outputs
        self.headAimCanvasOp.setOutput('constrainee', self.headAim)

        # Add Deformer KL Op
        # ==================
        self.deformersToOutputsKLOp = KLOperator('headDeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.deformersToOutputsKLOp)

        # Add Att Inputs
        self.deformersToOutputsKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.deformersToOutputsKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setInput('constrainers', [self.headOutputTgt, self.jawOutputTgt])

        # Add Xfo Outputs
        self.deformersToOutputsKLOp.setOutput('constrainees', [headDef, jawDef])

        Profiler.getInstance().pop()


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(FabriceHeadRig, self).loadData( data )

        headXfo = data['headXfo']
        headCtrlCrvData = data['headCtrlCrvData']
        jawPosition = data['jawPosition']
        jawCtrlCrvData = data['jawCtrlCrvData']

        self.headAimCtrlSpace.xfo.ori = headXfo.ori
        self.headAimCtrlSpace.xfo.tr = headXfo.tr.add(Vec3(0, 0, 4))
        self.headAimCtrl.xfo = self.headAimCtrlSpace.xfo

        self.headAimUpV.xfo.ori = self.headAimCtrl.xfo.ori
        self.headAimUpV.xfo.tr = self.headAimCtrl.xfo.tr.add(Vec3(0, 3, 0))

        self.headAim.xfo = headXfo
        self.headCtrlSpace.xfo = headXfo
        self.headCtrl.xfo = headXfo
        self.headCtrl.setCurveData(headCtrlCrvData)

        self.jawCtrlSpace.xfo.tr = jawPosition
        self.jawCtrl.xfo.tr = jawPosition
        self.jawCtrl.setCurveData(jawCtrlCrvData)

        # ============
        # Set IO Xfos
        # ============
        self.headBaseInputTgt.xfo = headXfo
        self.headOutputTgt.xfo = headXfo
        self.jawOutputTgt.xfo.tr = jawPosition

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the constraint op so that all the joint transforms are updated.
        self.headAimCanvasOp.evaluate()
        self.deformersToOutputsKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.headToAimConstraint.evaluate()
        self.headAimInputConstraint.evaluate()
        self.headOutputConstraint.evaluate()
        self.jawOutputConstraint.evaluate()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:fabrice_head.py

示例6: SpineComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........
        self.addOperator(self.pelvisDefKLOp)

        # Add Att Inputs
        self.pelvisDefKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.pelvisDefKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.pelvisDefKLOp.setInput('constrainer', self.pelvisOutputTgt)

        # Add Xfo Outputs
        self.pelvisDefKLOp.setOutput('constrainee', pelvisDef)


        Profiler.getInstance().pop()


    def setNumDeformers(self, numDeformers):

        # Add new deformers and outputs
        for i in xrange(len(self.spineOutputs), numDeformers):
            name = 'spine' + str(i + 1).zfill(2)
            spineOutput = ComponentOutput(name, parent=self.outputHrcGrp)
            self.spineOutputs.append(spineOutput)

        for i in xrange(len(self.deformerJoints), numDeformers):
            name = 'spine' + str(i + 1).zfill(2)
            spineDef = Joint(name, parent=self.defCmpGrp)
            spineDef.setComponent(self)
            self.deformerJoints.append(spineDef)

        return True


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(SpineComponentRig, self).loadData( data )

        cogPosition = data['cogPosition']
        spine01Position = data['spine01Position']
        spine02Position = data['spine02Position']
        spine03Position = data['spine03Position']
        spine04Position = data['spine04Position']
        numDeformers = data['numDeformers']

        self.cogCtrlSpace.xfo.tr = cogPosition
        self.cogCtrl.xfo.tr = cogPosition

        self.pelvisCtrlSpace.xfo.tr = cogPosition
        self.pelvisCtrl.xfo.tr = cogPosition

        self.spine01CtrlSpace.xfo.tr = spine01Position
        self.spine01Ctrl.xfo.tr = spine01Position

        self.spine02CtrlSpace.xfo.tr = spine02Position
        self.spine02Ctrl.xfo.tr = spine02Position

        self.spine03CtrlSpace.xfo.tr = spine03Position
        self.spine03Ctrl.xfo.tr = spine03Position

        self.spine04CtrlSpace.xfo.tr = spine04Position
        self.spine04Ctrl.xfo.tr = spine04Position

        length = spine01Position.distanceTo(spine02Position) + spine02Position.distanceTo(spine03Position) + spine03Position.distanceTo(spine04Position)
        self.lengthInputAttr.setMax(length * 3.0)
        self.lengthInputAttr.setValue(length)

        # Update number of deformers and outputs
        self.setNumDeformers(numDeformers)

        # Updating constraint to use the updated last output.
        self.spineEndOutputConstraint.setConstrainer(self.spineOutputs[-1], index=0)

        # ============
        # Set IO Xfos
        # ============

        # ====================
        # Evaluate Splice Ops
        # ====================
        # evaluate the spine op so that all the output transforms are updated.
        self.bezierSpineKLOp.evaluate()

        # evaluate the constraint op so that all the joint transforms are updated.
        self.deformersToOutputsKLOp.evaluate()
        self.pelvisDefKLOp.evaluate()

        # evaluate the constraints to ensure the outputs are now in the correct location.
        self.spineCogOutputConstraint.evaluate()
        self.spineBaseOutputConstraint.evaluate()
        self.pelvisOutputConstraint.evaluate()
        self.spineEndOutputConstraint.evaluate()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:spine_component.py

示例7: HandComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........


    def addFinger(self, name, data):

        fingerCtrls = []
        fingerJoints = []

        parentCtrl = self.handCtrl
        for i, joint in enumerate(data):
            if i == 0:
                jointName = name + 'Meta'
            else:
                jointName = name + str(i).zfill(2)

            jointXfo = joint.get('xfo', Xfo())
            jointCrvData = joint.get('curveData')

            # Create Controls
            newJointCtrlSpace = CtrlSpace(jointName, parent=parentCtrl)
            newJointCtrl = Control(jointName, parent=newJointCtrlSpace, shape='square')
            newJointCtrl.lockScale(True, True, True)
            newJointCtrl.lockTranslation(True, True, True)

            if jointCrvData is not None:
                newJointCtrl.setCurveData(jointCrvData)

            fingerCtrls.append(newJointCtrl)

            # Create Deformers
            jointDef = Joint(jointName, parent=self.defCmpGrp)
            fingerJoints.append(jointDef)

            # Create Constraints

            # Set Xfos
            newJointCtrlSpace.xfo = jointXfo
            newJointCtrl.xfo = jointXfo

            parentCtrl = newJointCtrl


        # =================
        # Create Operators
        # =================
        # Add Deformer KL Op
        deformersToCtrlsKLOp = KLOperator(name + 'DeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(deformersToCtrlsKLOp)

        # Add Att Inputs
        deformersToCtrlsKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        deformersToCtrlsKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        deformersToCtrlsKLOp.setInput('constrainers', fingerCtrls)

        # Add Xfo Outputs
        deformersToCtrlsKLOp.setOutput('constrainees', fingerJoints)

        return deformersToCtrlsKLOp


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(HandComponentRig, self).loadData(data)

        # Data
        fingerData = data.get('fingerData')
        handXfo = data.get('handXfo', Xfo())

        self.handCtrlSpace.xfo = handXfo
        self.handCtrl.xfo = handXfo

        fingerOps = []
        for finger in fingerData.keys():
            fingerOp = self.addFinger(finger, fingerData[finger])
            fingerOps.append(fingerOp)

        # ============
        # Set IO Xfos
        # ============
        self.armEndInputTgt.xfo = handXfo
        self.handOutputTgt.xfo = handXfo

        # Eval Constraints
        self.armEndInputConstraint.evaluate()
        self.handOutputConstraint.evaluate()
        self.handDefConstraint.evaluate()

        # Eval Operators
        for op in fingerOps:
            op.evaluate()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:hand_component.py

示例8: StretchyLimbComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........

        # Add Xfo Inputs
        self.limbIKKLOp.setInput('root', self.limbParentInputTgt)
        self.limbIKKLOp.setInput('bone0FK', self.upperFKCtrl)
        self.limbIKKLOp.setInput('bone1FK', self.lowerFKCtrl)
        self.limbIKKLOp.setInput('ikHandle', self.limbIKCtrl)
        self.limbIKKLOp.setInput('upV', self.limbUpVCtrl)

        # Add Xfo Outputs
        self.limbIKKLOp.setOutput('bone0Out', self.limbUpperOutputTgt)
        self.limbIKKLOp.setOutput('bone1Out', self.limbLowerOutputTgt)
        self.limbIKKLOp.setOutput('bone2Out', self.limbEndOutputTgt)

        # =====================
        # Connect the deformers
        # =====================

        # Add StretchyLimb Deformer Splice Op
        self.outputsToDeformersKLOp = KLOperator('limbDeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.outputsToDeformersKLOp)

        # Add Att Inputs
        self.outputsToDeformersKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.outputsToDeformersKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.outputsToDeformersKLOp.setInput('constrainers', [self.limbUpperOutputTgt, self.limbLowerOutputTgt, self.limbEndOutputTgt])

        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [upperDef, lowerDef, endDef])

        Profiler.getInstance().pop()

    # =============
    # Data Methods
    # =============
    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(StretchyLimbComponentRig, self).loadData(data)

        upperXfo = data.get('upperXfo')
        upperLen = data.get('upperLen')
        lowerXfo = data.get('lowerXfo')
        lowerLen = data.get('lowerLen')
        endXfo = data.get('endXfo')
        upVXfo = data.get('upVXfo')

        self.upperFKCtrlSpace.xfo = upperXfo
        self.upperFKCtrl.xfo = upperXfo
        self.upperFKCtrl.scalePoints(Vec3(upperLen, 1.75, 1.75))

        self.limbUpperOutputTgt.xfo = upperXfo
        self.limbLowerOutputTgt.xfo = lowerXfo

        self.lowerFKCtrlSpace.xfo = lowerXfo
        self.lowerFKCtrl.xfo = lowerXfo
        self.lowerFKCtrl.scalePoints(Vec3(lowerLen, 1.5, 1.5))

        self.limbIKCtrlSpace.xfo.tr = endXfo.tr
        self.limbIKCtrl.xfo.tr = endXfo.tr

        if self.getLocation() == "R":
            self.limbIKCtrl.rotatePoints(0, 90, 0)
            self.limbIKCtrl.translatePoints(Vec3(-1.0, 0.0, 0.0))
        else:
            self.limbIKCtrl.rotatePoints(0, -90, 0)
            self.limbIKCtrl.translatePoints(Vec3(1.0, 0.0, 0.0))

        self.limbUpVCtrlSpace.xfo = upVXfo
        self.limbUpVCtrl.xfo = upVXfo

        self.limbBone0LenInputAttr.setMin(0.0)
        self.limbBone0LenInputAttr.setMax(upperLen * 3.0)
        self.limbBone0LenInputAttr.setValue(upperLen)
        self.limbBone1LenInputAttr.setMin(0.0)
        self.limbBone1LenInputAttr.setMax(lowerLen * 3.0)
        self.limbBone1LenInputAttr.setValue(lowerLen)

        self.limbParentInputTgt.xfo = upperXfo

        # Set Attrs
        self.rightSideInputAttr.setValue(self.getLocation() is 'R')

        # Eval Constraints
        self.limbIKCtrlSpaceInputConstraint.evaluate()
        self.limbUpVCtrlSpaceInputConstraint.evaluate()
        self.limbRootInputConstraint.evaluate()

        # Eval Operators
        self.limbIKKLOp.evaluate()
        self.outputsToDeformersKLOp.evaluate()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:stretchyLimb_component.py

示例9: FootComponentRig

# 需要导入模块: from kraken.core.objects.constraints.pose_constraint import PoseConstraint [as 别名]
# 或者: from kraken.core.objects.constraints.pose_constraint.PoseConstraint import evaluate [as 别名]

#.........这里部分代码省略.........
        # Add Deformer KL Op
        # ===================
        self.outputsToDeformersKLOp = KLOperator('foot' + self.getLocation() + 'DeformerKLOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.outputsToDeformersKLOp)

        # Add Att Inputs
        self.outputsToDeformersKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.outputsToDeformersKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Xfo Inputs
        self.outputsToDeformersKLOp.setInput('constrainers', [self.ankleOutputTgt, self.toeOutputTgt])

        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [self.ankleDef, self.toeDef])

        Profiler.getInstance().pop()


    def loadData(self, data=None):
        """Load a saved guide representation from persisted data.

        Arguments:
        data -- object, The JSON data object.

        Return:
        True if successful.

        """

        super(FootComponentRig, self).loadData( data )

        footXfo = data.get('footXfo')
        ankleXfo = data.get('ankleXfo')
        toeXfo = data.get('toeXfo')
        ankleFKXfo = data.get('ankleFKXfo')
        toeFKXfo = data.get('toeFKXfo')
        ankleLen = data.get('ankleLen')
        toeLen = data.get('toeLen')
        backPivotXfo = data.get('backPivotXfo')
        frontPivotXfo = data.get('frontPivotXfo')
        outerPivotXfo = data.get('outerPivotXfo')
        innerPivotXfo = data.get('innerPivotXfo')

        self.footAll.xfo = footXfo
        self.ankleIKCtrlSpace.xfo = ankleXfo
        self.ankleIKCtrl.xfo = ankleXfo
        self.toeIKCtrlSpace.xfo = toeXfo
        self.toeIKCtrl.xfo = toeXfo

        self.ankleFKCtrl.scalePoints(Vec3(ankleLen, 1.0, 1.0))
        self.toeFKCtrl.scalePoints(Vec3(toeLen, 1.0, 1.0))

        self.ankleFKCtrlSpace.xfo.tr = footXfo.tr
        self.ankleFKCtrlSpace.xfo.ori = ankleFKXfo.ori
        self.ankleFKCtrl.xfo.tr = footXfo.tr
        self.ankleFKCtrl.xfo.ori = ankleFKXfo.ori
        self.toeFKCtrlSpace.xfo = toeFKXfo
        self.toeFKCtrl.xfo = toeFKXfo

        self.pivotAll.xfo = footXfo
        self.backPivotCtrlSpace.xfo = backPivotXfo
        self.backPivotCtrl.xfo = backPivotXfo
        self.frontPivotCtrlSpace.xfo = frontPivotXfo
        self.frontPivotCtrl.xfo = frontPivotXfo
        self.outerPivotCtrlSpace.xfo = outerPivotXfo
        self.outerPivotCtrl.xfo = outerPivotXfo
        self.innerPivotCtrlSpace.xfo = innerPivotXfo
        self.innerPivotCtrl.xfo = innerPivotXfo

        if self.getLocation() == 'R':
            self.outerPivotCtrl.rotatePoints(0.0, 180.0, 0.0)
            self.innerPivotCtrl.rotatePoints(0.0, 180.0, 0.0)

        self.ankleIKCtrl.scalePoints(Vec3(ankleLen, 1.0, 1.5))
        self.toeIKCtrl.scalePoints(Vec3(toeLen, 1.0, 1.5))

        # Set Attribute Values
        self.rightSideInputAttr.setValue(self.getLocation() is 'R')
        self.ankleLenInputAttr.setValue(ankleLen)
        self.ankleLenInputAttr.setMax(ankleLen * 3.0)
        self.toeLenInputAttr.setValue(toeLen)
        self.toeLenInputAttr.setMax(toeLen * 3.0)

        # Set IO Xfos
        self.ikHandleInputTgt.xfo = footXfo
        self.legEndInputTgt.xfo.tr = footXfo.tr
        self.legEndInputTgt.xfo.ori = ankleXfo.ori
        self.legEndFKInputTgt.xfo.tr = footXfo.tr
        self.legEndFKInputTgt.xfo.ori = ankleXfo.ori

        self.ikTargetOutputTgt.xfo.tr = footXfo.tr
        self.ikTargetOutputTgt.xfo.ori = ankleXfo.ori

        # Eval Canvas Ops
        self.footPivotCanvasOp.evaluate()
        self.footSolverCanvasOp.evaluate()

        # Eval Constraints
        self.ikTargetOutputConstraint.evaluate()
        self.ankleFKInputConstraint.evaluate()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:104,代码来源:foot_component.py


注:本文中的kraken.core.objects.constraints.pose_constraint.PoseConstraint.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。