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


Python pose_constraint.PoseConstraint类代码示例

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


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

示例1: __init__

    def __init__(self, name='Clavicle', parent=None):

        Profiler.getInstance().push("Construct Clavicle Rig Component:" + name)
        super(FabriceClavicleRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Clavicle
        self.clavicleCtrlSpace = CtrlSpace('clavicle', parent=self.ctrlCmpGrp)
        self.clavicleCtrl = Control('clavicle', parent=self.clavicleCtrlSpace, shape="cube")
        self.clavicleCtrl.alignOnXAxis()


        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.ctrlCmpGrp.setComponent(self)

        self.clavicleDef = Joint('clavicle', parent=defCmpGrp)
        self.clavicleDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        clavicleInputConstraint = PoseConstraint('_'.join([self.clavicleCtrl.getName(), 'To', self.spineEndInputTgt.getName()]))
        clavicleInputConstraint.setMaintainOffset(True)
        clavicleInputConstraint.addConstrainer(self.spineEndInputTgt)
        self.clavicleCtrlSpace.addConstraint(clavicleInputConstraint)

        # Constraint outputs
        clavicleConstraint = PoseConstraint('_'.join([self.clavicleOutputTgt.getName(), 'To', self.clavicleCtrl.getName()]))
        clavicleConstraint.addConstrainer(self.clavicleCtrl)
        self.clavicleOutputTgt.addConstraint(clavicleConstraint)


        # ===============
        # Add Splice Ops
        # ===============
        # Add Deformer Splice Op
        spliceOp = KLOperator('clavicleDeformerKLOp', 'PoseConstraintSolver', 'Kraken')
        self.addOperator(spliceOp)

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

        # Add Xfo Inputs
        spliceOp.setInput('constrainer', self.clavicleOutputTgt)

        # Add Xfo Outputs
        spliceOp.setOutput('constrainee', self.clavicleDef)

        Profiler.getInstance().pop()
开发者ID:Leopardob,项目名称:Kraken,代码行数:59,代码来源:fabrice_clavicle.py

示例2: __init__

    def __init__(self, name='Hand', parent=None):

        Profiler.getInstance().push("Construct Hand Rig Component:" + name)
        super(HandComponentRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Hand
        self.handCtrlSpace = CtrlSpace('hand', parent=self.ctrlCmpGrp)
        self.handCtrl = Control('hand', parent=self.handCtrlSpace, shape="square")
        self.handCtrl.rotatePoints(0, 0, 90.0)
        self.handCtrl.lockScale(True, True, True)
        self.handCtrl.lockTranslation(True, True, True)


        # ==========
        # Deformers
        # ==========
        self.deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=self.deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        self.handDef = Joint('hand', parent=self.defCmpGrp)
        self.handDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.armEndInputConstraint = PoseConstraint('_'.join([self.handCtrlSpace.getName(), 'To', self.armEndInputTgt.getName()]))
        self.armEndInputConstraint.setMaintainOffset(True)
        self.armEndInputConstraint.addConstrainer(self.armEndInputTgt)
        self.handCtrlSpace.addConstraint(self.armEndInputConstraint)

        # Constraint outputs
        self.handOutputConstraint = PoseConstraint('_'.join([self.handOutputTgt.getName(), 'To', self.handCtrl.getName()]))
        self.handOutputConstraint.addConstrainer(self.handCtrl)
        self.handOutputTgt.addConstraint(self.handOutputConstraint)

        # Constraint deformers
        self.handDefConstraint = PoseConstraint('_'.join([self.handDef.getName(), 'To', self.handCtrl.getName()]))
        self.handDefConstraint.addConstrainer(self.handCtrl)
        self.handDef.addConstraint(self.handDefConstraint)

        Profiler.getInstance().pop()
开发者ID:AbedSHP,项目名称:Kraken,代码行数:48,代码来源:hand_component.py

示例3: buildXfoConnection

    def buildXfoConnection(self, kConnection):
        """Builds the connection between the xfo and the connection.

        Arguments:
        kConnection -- Object, kraken connection to build.

        Return:
        True if successful.

        """

        source = kConnection.getSource()
        target = kConnection.getTarget()

        if source is None or target is None:
            raise Exception("Component connection '" + kConnection.getName() + "'is invalid! Missing Source or Target!")

        constraint = PoseConstraint('_'.join([target.getName(), 'To', source.getName()]))
        constraint.setMaintainOffset(True)
        constraint.setConstrainee(target)
        constraint.addConstrainer(source)
        dccSceneItem = self.buildPoseConstraint(constraint)
        self._registerSceneItemPair(kConnection, dccSceneItem)

        return None
开发者ID:jhodgson,项目名称:Kraken,代码行数:25,代码来源:base_builder.py

示例4: buildXfoConnection

    def buildXfoConnection(self, componentInput):
        """Builds the constraint between the target and connection target.

        Args:
            componentInput (object): kraken component input to build connections for.

        Returns:
            bool: True if successful.

        """

        if componentInput.isConnected() is False:
            return False

        connection = componentInput.getConnection()
        connectionTarget = connection.getTarget()
        inputTarget = componentInput.getTarget()

        if connection.getDataType().endswith('[]'):
            if componentInput.getIndex() > len(connection.getTarget()) - 1:

                inputParent = componentInput.getParent()
                inputParentDecoration = inputParent.getNameDecoration()
                fullInputName = inputParent.getName() + inputParentDecoration + "." + componentInput.getName()

                raise Exception(fullInputName + " index ("
                                + str(componentInput.getIndex()) + ") is out of range ("
                                + str(len(connection.getTarget()) - 1) + ")!")

            connectionTarget = connection.getTarget()[componentInput.getIndex()]
        else:
            connectionTarget = connection.getTarget()

        constraint = PoseConstraint('_'.join([inputTarget.getName(), 'To', connectionTarget.getName()]))
        constraint.setMaintainOffset(True)
        constraint.setConstrainee(inputTarget)
        constraint.addConstrainer(connectionTarget)

        dccSceneItem = self.buildPoseConstraint(constraint)
        self._registerSceneItemPair(componentInput, dccSceneItem)

        return True
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:42,代码来源:builder.py

示例5: FabriceTailRig

class FabriceTailRig(FabriceTail):
    """Fabrice Tail Component"""

    def __init__(self, name="fabriceTail", parent=None):

        Profiler.getInstance().push("Construct Tail Rig Component:" + name)
        super(FabriceTailRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========

        # Tail Base
        # self.tailBaseCtrlSpace = CtrlSpace('tailBase', parent=self.ctrlCmpGrp)
        # self.tailBaseCtrl = Control('tailBase', parent=self.tailBaseCtrlSpace, shape="circle")
        # self.tailBaseCtrl.rotatePoints(90, 0, 0)
        # self.tailBaseCtrl.scalePoints(Vec3(2.0, 2.0, 2.0))
        # self.tailBaseCtrl.setColor("greenBlue")

        # Tail Base Handle
        self.tailBaseHandleCtrlSpace = CtrlSpace('tailBaseHandle', parent=self.ctrlCmpGrp)
        self.tailBaseHandleCtrl = Control('tailBaseHandle', parent=self.tailBaseHandleCtrlSpace, shape="pin")
        self.tailBaseHandleCtrl.lockScale(x=True, y=True, z=True)
        self.tailBaseHandleCtrl.setColor("turqoise")

        # Tail End Handle
        self.tailEndHandleCtrlSpace = CtrlSpace('tailEndHandle', parent=self.ctrlCmpGrp)
        self.tailEndHandleCtrl = Control('tailEndHandle', parent=self.tailEndHandleCtrlSpace, shape="pin")
        self.tailEndHandleCtrl.lockScale(x=True, y=True, z=True)
        self.tailEndHandleCtrl.setColor("turqoise")

        # Tail End
        self.tailEndCtrlSpace = CtrlSpace('tailEnd', parent=self.tailEndHandleCtrl)
        self.tailEndCtrl = Control('tailEnd', parent=self.tailEndCtrlSpace, shape="pin")
        self.tailEndCtrl.lockScale(x=True, y=True, z=True)
        self.tailEndCtrl.setColor("greenBlue")


        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.deformerJoints = []
        self.tailOutputs = []
        self.setNumDeformers(1)


        # =====================
        # Create Component I/O
        # =====================
        # Setup component Xfo I/O's
        self.tailVertebraeOutput.setTarget(self.tailOutputs)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.tailBaseHandleInputConstraint = PoseConstraint('_'.join([self.tailBaseHandleCtrlSpace.getName(), 'To', self.spineEndCtrlInputTgt.getName()]))
        self.tailBaseHandleInputConstraint.addConstrainer(self.spineEndCtrlInputTgt)
        self.tailBaseHandleInputConstraint.setMaintainOffset(True)
        self.tailBaseHandleCtrlSpace.addConstraint(self.tailBaseHandleInputConstraint)

        self.tailEndHandleInputConstraint = PoseConstraint('_'.join([self.tailEndHandleCtrlSpace.getName(), 'To', self.cogInputTgt.getName()]))
        self.tailEndHandleInputConstraint.addConstrainer(self.cogInputTgt)
        self.tailEndHandleInputConstraint.setMaintainOffset(True)
        self.tailEndHandleCtrlSpace.addConstraint(self.tailEndHandleInputConstraint)

        # Constraint outputs
        self.tailBaseOutputConstraint = PoseConstraint('_'.join([self.tailBaseOutputTgt.getName(), 'To', 'spineBase']))
        self.tailBaseOutputConstraint.addConstrainer(self.tailOutputs[0])
        self.tailBaseOutputTgt.addConstraint(self.tailBaseOutputConstraint)

        self.tailEndOutputConstraint = PoseConstraint('_'.join([self.tailEndOutputTgt.getName(), 'To', 'spineEnd']))
        self.tailEndOutputConstraint.addConstrainer(self.tailOutputs[0])
        self.tailEndOutputTgt.addConstraint(self.tailEndOutputConstraint)


        # ===============
        # Add Splice Ops
        # ===============
        # Add Tail Splice Op
        self.bezierTailKLOp = KLOperator('tailKLOp', 'BezierSpineSolver', 'Kraken')
        self.addOperator(self.bezierTailKLOp)

        # Add Att Inputs
        self.bezierTailKLOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.bezierTailKLOp.setInput('rigScale', self.rigScaleInputAttr)
        self.bezierTailKLOp.setInput('length', self.lengthInputAttr)

        # Add Xfo Inputs
        self.bezierTailKLOp.setInput('base', self.spineEndInputTgt)
        self.bezierTailKLOp.setInput('baseHandle', self.tailBaseHandleCtrl)
        self.bezierTailKLOp.setInput('tipHandle', self.tailEndHandleCtrl)
        self.bezierTailKLOp.setInput('tip', self.tailEndCtrl)

        # Add Xfo Outputs
        self.bezierTailKLOp.setOutput('outputs', self.tailOutputs)
#.........这里部分代码省略.........
开发者ID:Leopardob,项目名称:Kraken,代码行数:101,代码来源:fabrice_tail.py

示例6: __init__

    def __init__(self, name='leg', parent=None):

        Profiler.getInstance().push("Construct Leg Rig Component:" + name)
        super(LegComponentRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Femur
        self.femurFKCtrlSpace = CtrlSpace('femurFK', parent=self.ctrlCmpGrp)
        self.femurFKCtrl = Control('femurFK', parent=self.femurFKCtrlSpace, shape="cube")
        self.femurFKCtrl.alignOnXAxis()

        # Shin
        self.shinFKCtrlSpace = CtrlSpace('shinFK', parent=self.femurFKCtrl)
        self.shinFKCtrl = Control('shinFK', parent=self.shinFKCtrlSpace, shape="cube")
        self.shinFKCtrl.alignOnXAxis()

        # Ankle
        self.legIKCtrlSpace = CtrlSpace('IK', parent=self.ctrlCmpGrp)
        self.legIKCtrl = Control('IK', parent=self.legIKCtrlSpace, shape="pin")

        # FK Foot
        self.footCtrlSpace = CtrlSpace('foot', parent=self.ctrlCmpGrp)
        self.footCtrl = Control('foot', parent=self.footCtrlSpace, shape="cube")
        self.footCtrl.alignOnXAxis()

        # FK Toe
        self.toeCtrlSpace = CtrlSpace('toe', parent=self.footCtrl)
        self.toeCtrl = Control('toe', parent=self.toeCtrlSpace, shape="cube")
        self.toeCtrl.alignOnXAxis()

        # Rig Ref objects
        self.footRefSrt = Locator('footRef', parent=self.ctrlCmpGrp)

        # Add Component Params to IK control
        footSettingsAttrGrp = AttributeGroup("DisplayInfo_FootSettings", parent=self.footCtrl)
        footLinkToWorldInputAttr = ScalarAttribute('linkToWorld', 1.0, maxValue=1.0, parent=footSettingsAttrGrp)

        # Add Component Params to IK control
        legSettingsAttrGrp = AttributeGroup("DisplayInfo_LegSettings", parent=self.legIKCtrl)
        legDrawDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=legSettingsAttrGrp)
        self.legBone0LenInputAttr = ScalarAttribute('bone0Len', value=1.0, parent=legSettingsAttrGrp)
        self.legBone1LenInputAttr = ScalarAttribute('bone1Len', value=1.0, parent=legSettingsAttrGrp)
        legIKBlendInputAttr = ScalarAttribute('ikblend', value=1.0, minValue=0.0, maxValue=1.0, parent=legSettingsAttrGrp)
        legSoftIKInputAttr = BoolAttribute('softIK', value=True, parent=legSettingsAttrGrp)
        legSoftDistInputAttr = ScalarAttribute('softDist', value=0.0, minValue=0.0, parent=legSettingsAttrGrp)
        legStretchInputAttr = BoolAttribute('stretch', value=True, parent=legSettingsAttrGrp)
        legStretchBlendInputAttr = ScalarAttribute('stretchBlend', value=0.0, minValue=0.0, maxValue=1.0, parent=legSettingsAttrGrp)

        self.drawDebugInputAttr.connect(legDrawDebugInputAttr)

        # UpV
        self.legUpVCtrlSpace = CtrlSpace('UpV', parent=self.ctrlCmpGrp)
        self.legUpVCtrl = Control('UpV', parent=self.legUpVCtrlSpace, shape="triangle")
        self.legUpVCtrl.alignOnZAxis()


        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)

        femurDef = Joint('femur', parent=self.defCmpGrp)
        femurDef.setComponent(self)

        shinDef = Joint('shin', parent=self.defCmpGrp)
        shinDef.setComponent(self)

        ankleDef = Joint('ankle', parent=self.defCmpGrp)
        ankleDef.setComponent(self)

        self.footDef = Joint('foot', parent=self.defCmpGrp)
        self.footDef.setComponent(self)

        self.toeDef = Joint('toe', parent=self.defCmpGrp)
        self.toeDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.legIKCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.legIKCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.legIKCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.legIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.legIKCtrlSpace.addConstraint(self.legIKCtrlSpaceInputConstraint)

        self.legUpVCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.legUpVCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.legUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.legUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.legUpVCtrlSpace.addConstraint(self.legUpVCtrlSpaceInputConstraint)

        self.legRootInputConstraint = PoseConstraint('_'.join([self.legIKCtrl.getName(), 'To', self.legPelvisInputTgt.getName()]))
        self.legRootInputConstraint.setMaintainOffset(True)
        self.legRootInputConstraint.addConstrainer(self.legPelvisInputTgt)
        self.femurFKCtrlSpace.addConstraint(self.legRootInputConstraint)

#.........这里部分代码省略.........
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:101,代码来源:leg_component.py

示例7: Locator

from kraken import plugins
from kraken.core.objects.locator import Locator
from kraken.core.objects.constraints.pose_constraint import PoseConstraint
from kraken.core.traverser.traverser import Traverser

locA = Locator("locatorA")
locB = Locator("locatorB")

constraint = PoseConstraint("A to B")
constraint.addConstrainer(locB)
constraint.setConstrainee(locA)

trav = Traverser()
trav.addRootItem(locA)

def callback(**args):
    item = args.get('item', None)
    print 'Visited '+item.getDecoratedPath()

trav.traverse(itemCallback = callback)
开发者ID:AbedSHP,项目名称:Kraken,代码行数:20,代码来源:constraints.py

示例8: ArmComponentRig

class ArmComponentRig(ArmComponent):
    """Arm Component Rig"""

    def __init__(self, name="arm", parent=None):

        Profiler.getInstance().push("Construct Arm Rig Component:" + name)
        super(ArmComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Bicep
        self.bicepFKCtrlSpace = CtrlSpace("bicepFK", parent=self.ctrlCmpGrp)

        self.bicepFKCtrl = Control("bicepFK", parent=self.bicepFKCtrlSpace, shape="cube")
        self.bicepFKCtrl.alignOnXAxis()

        # Forearm
        self.forearmFKCtrlSpace = CtrlSpace("forearmFK", parent=self.bicepFKCtrl)

        self.forearmFKCtrl = Control("forearmFK", parent=self.forearmFKCtrlSpace, shape="cube")
        self.forearmFKCtrl.alignOnXAxis()

        self.handCtrlSpace = CtrlSpace("hand", parent=self.ctrlCmpGrp)
        self.handCtrl = Control("hand", parent=self.handCtrlSpace, shape="circle")
        self.handCtrl.rotatePoints(0, 0, 90)
        self.handCtrl.scalePoints(Vec3(1.0, 0.75, 0.75))

        # Arm IK
        self.armIKCtrlSpace = CtrlSpace("IK", parent=self.ctrlCmpGrp)
        self.armIKCtrl = Control("IK", parent=self.armIKCtrlSpace, shape="pin")

        # Add Params to IK control
        armSettingsAttrGrp = AttributeGroup("DisplayInfo_ArmSettings", parent=self.armIKCtrl)
        armDebugInputAttr = BoolAttribute("drawDebug", value=False, parent=armSettingsAttrGrp)
        self.armBone0LenInputAttr = ScalarAttribute("bone1Len", value=0.0, parent=armSettingsAttrGrp)
        self.armBone1LenInputAttr = ScalarAttribute("bone2Len", value=0.0, parent=armSettingsAttrGrp)
        armIKBlendInputAttr = ScalarAttribute("fkik", value=0.0, minValue=0.0, maxValue=1.0, parent=armSettingsAttrGrp)
        armSoftIKInputAttr = BoolAttribute("softIK", value=True, parent=armSettingsAttrGrp)
        armSoftDistInputAttr = ScalarAttribute("softDist", value=0.0, minValue=0.0, parent=armSettingsAttrGrp)
        armStretchInputAttr = BoolAttribute("stretch", value=True, parent=armSettingsAttrGrp)
        armStretchBlendInputAttr = ScalarAttribute(
            "stretchBlend", value=0.0, minValue=0.0, maxValue=1.0, parent=armSettingsAttrGrp
        )

        # Hand Params
        handSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings", parent=self.handCtrl)
        handLinkToWorldInputAttr = ScalarAttribute("linkToWorld", 0.0, maxValue=1.0, parent=handSettingsAttrGrp)

        self.drawDebugInputAttr.connect(armDebugInputAttr)

        # UpV
        self.armUpVCtrlSpace = CtrlSpace("UpV", parent=self.ctrlCmpGrp)
        self.armUpVCtrl = Control("UpV", parent=self.armUpVCtrlSpace, shape="triangle")
        self.armUpVCtrl.alignOnZAxis()
        self.armUpVCtrl.rotatePoints(180, 0, 0)

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer("deformers")
        defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)

        bicepDef = Joint("bicep", parent=defCmpGrp)
        bicepDef.setComponent(self)

        forearmDef = Joint("forearm", parent=defCmpGrp)
        forearmDef.setComponent(self)

        wristDef = Joint("wrist", parent=defCmpGrp)
        wristDef.setComponent(self)

        handDef = Joint("hand", parent=defCmpGrp)
        handDef.setComponent(self)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.armIKCtrlSpaceInputConstraint = PoseConstraint(
            "_".join([self.armIKCtrlSpace.getName(), "To", self.globalSRTInputTgt.getName()])
        )
        self.armIKCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.armIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.armIKCtrlSpace.addConstraint(self.armIKCtrlSpaceInputConstraint)

        self.armUpVCtrlSpaceInputConstraint = PoseConstraint(
            "_".join([self.armUpVCtrlSpace.getName(), "To", self.globalSRTInputTgt.getName()])
        )
        self.armUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.armUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.armUpVCtrlSpace.addConstraint(self.armUpVCtrlSpaceInputConstraint)

        self.armRootInputConstraint = PoseConstraint(
            "_".join([self.bicepFKCtrlSpace.getName(), "To", self.clavicleEndInputTgt.getName()])
        )
        self.armRootInputConstraint.setMaintainOffset(True)
        self.armRootInputConstraint.addConstrainer(self.clavicleEndInputTgt)
        self.bicepFKCtrlSpace.addConstraint(self.armRootInputConstraint)

#.........这里部分代码省略.........
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:101,代码来源:arm_component.py

示例9: __init__


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

        if location == "R":
            footQuat = Quat(Vec3(0.5695, -0.6377, 0.4190), 0.3053)
            footPos = Vec3(-1.841, 1.1516, -1.237)
        else:
            footQuat = Quat(Vec3(0.6377, -0.5695, 0.3053), 0.4190)
            footPos = Vec3(1.841, 1.1516, -1.237)

        footXfo.rot = footQuat.clone()
        footXfo.tr.copy(footPos)

        # Add Controls
        footCtrlSrtBuffer = SrtBuffer('foot', parent=self)
        footCtrlSrtBuffer.xfo.copy(footXfo)

        footCtrl = CubeControl('foot', parent=footCtrlSrtBuffer)
        footCtrl.alignOnXAxis()
        footCtrl.scalePoints(Vec3(2.5, 1.5, 0.75))
        footCtrl.xfo.copy(footCtrlSrtBuffer.xfo)
        footCtrl.setColor(ctrlColor)

        # Rig Ref objects
        footRefSrt = Locator('footRef', parent=self)
        footRefSrt.xfo.copy(footCtrlSrtBuffer.xfo)


        # Add Component Params to IK control
        footDebugInputAttr = BoolAttribute('debug', True)
        footLinkToWorldInputAttr = FloatAttribute('linkToWorld', 1.0, 0.0, 1.0)

        footSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings")
        footCtrl.addAttributeGroup(footSettingsAttrGrp)
        footSettingsAttrGrp.addAttribute(footDebugInputAttr)
        footSettingsAttrGrp.addAttribute(footLinkToWorldInputAttr)


        # ==========
        # Deformers
        # ==========
        container = self.getParent().getParent()
        deformersLayer = container.getChildByName('deformers')

        footDef = Joint('foot')
        footDef.setComponent(self)

        deformersLayer.addChild(footDef)


        # =====================
        # Create Component I/O
        # =====================
        # Setup Component Xfo I/O's
        legEndXfoInput = Locator('legEndXfo')
        legEndXfoInput.xfo.copy(footCtrlSrtBuffer.xfo)
        legEndPosInput = Locator('legEndPos')
        legEndPosInput.xfo.copy(footCtrlSrtBuffer.xfo)

        footEndOutput = Locator('handEnd')
        footEndOutput.xfo.copy(footCtrlSrtBuffer.xfo)
        footOutput = Locator('hand')
        footOutput.xfo.copy(footCtrlSrtBuffer.xfo)

        # Setup componnent Attribute I/O's
        debugInputAttr = BoolAttribute('debug', True)
        rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
        linkToWorldInputAttr = FloatAttribute('linkToWorld', 0.0, 0.0, 1.0)

        # Connect attrs to control attrs
        debugInputAttr.connect(footDebugInputAttr)
        linkToWorldInputAttr.connect(footLinkToWorldInputAttr)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs

        # Constraint outputs
        handConstraint = PoseConstraint('_'.join([footOutput.getName(), 'To', footCtrl.getName()]))
        handConstraint.addConstrainer(footCtrl)
        footOutput.addConstraint(handConstraint)

        handEndConstraint = PoseConstraint('_'.join([footEndOutput.getName(), 'To', footCtrl.getName()]))
        handEndConstraint.addConstrainer(footCtrl)
        footEndOutput.addConstraint(handEndConstraint)


        # ==================
        # Add Component I/O
        # ==================
        # Add Xfo I/O's
        self.addInput(legEndXfoInput)
        self.addInput(legEndPosInput)
        self.addOutput(footOutput)
        self.addOutput(footEndOutput)

        # Add Attribute I/O's
        self.addInput(debugInputAttr)
        self.addInput(rightSideInputAttr)
        self.addInput(linkToWorldInputAttr)
开发者ID:jhodgson,项目名称:Kraken,代码行数:101,代码来源:foot_component.py

示例10: HandComponentRig

class HandComponentRig(HandComponent):
    """Hand Component"""

    def __init__(self, name='Hand', parent=None):

        Profiler.getInstance().push("Construct Hand Rig Component:" + name)
        super(HandComponentRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Hand
        self.handCtrlSpace = CtrlSpace('hand', parent=self.ctrlCmpGrp)
        self.handCtrl = Control('hand', parent=self.handCtrlSpace, shape="square")
        self.handCtrl.rotatePoints(0, 0, 90.0)
        self.handCtrl.lockScale(True, True, True)
        self.handCtrl.lockTranslation(True, True, True)


        # ==========
        # Deformers
        # ==========
        self.deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=self.deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        self.handDef = Joint('hand', parent=self.defCmpGrp)
        self.handDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.armEndInputConstraint = PoseConstraint('_'.join([self.handCtrlSpace.getName(), 'To', self.armEndInputTgt.getName()]))
        self.armEndInputConstraint.setMaintainOffset(True)
        self.armEndInputConstraint.addConstrainer(self.armEndInputTgt)
        self.handCtrlSpace.addConstraint(self.armEndInputConstraint)

        # Constraint outputs
        self.handOutputConstraint = PoseConstraint('_'.join([self.handOutputTgt.getName(), 'To', self.handCtrl.getName()]))
        self.handOutputConstraint.addConstrainer(self.handCtrl)
        self.handOutputTgt.addConstraint(self.handOutputConstraint)

        # Constraint deformers
        self.handDefConstraint = PoseConstraint('_'.join([self.handDef.getName(), 'To', self.handCtrl.getName()]))
        self.handDefConstraint.addConstrainer(self.handCtrl)
        self.handDef.addConstraint(self.handDefConstraint)

        Profiler.getInstance().pop()


    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
#.........这里部分代码省略.........
开发者ID:AbedSHP,项目名称:Kraken,代码行数:101,代码来源:hand_component.py

示例11: __init__

    def __init__(self, name, parent=None, location='M'):
        super(ClavicleComponent, self).__init__(name, parent, location)

        # =========
        # Controls
        # =========
        # Setup component attributes
        defaultAttrGroup = self.getAttributeGroupByIndex(0)
        defaultAttrGroup.addAttribute(BoolAttribute("toggleDebugging", True))

        # Default values
        if location == 'R':
            ctrlColor = "red"
            claviclePosition = Vec3(-0.1322, 15.403, -0.5723)
            clavicleUpV = Vec3()
            clavicleUpV.copy(claviclePosition)
            clavicleUpV = clavicleUpV.add(Vec3(0.0, 1.0, 0.0)).unit()
            clavicleEndPosition = Vec3(-2.27, 15.295, -0.753)
        else:
            ctrlColor = "greenBright"
            claviclePosition = Vec3(0.1322, 15.403, -0.5723)
            clavicleUpV = Vec3()
            clavicleUpV.copy(claviclePosition)
            clavicleUpV = clavicleUpV.add(Vec3(0.0, 1.0, 0.0)).unit()
            clavicleEndPosition = Vec3(2.27, 15.295, -0.753)

        # Calculate Clavicle Xfo
        rootToEnd = clavicleEndPosition.subtract(claviclePosition).unit()
        rootToUpV = clavicleUpV.subtract(claviclePosition).unit()
        bone1ZAxis = rootToUpV.cross(rootToEnd).unit()
        bone1Normal = bone1ZAxis.cross(rootToEnd).unit()
        clavicleXfo = Xfo()

        clavicleXfo.setFromVectors(rootToEnd, bone1Normal, bone1ZAxis, claviclePosition)

        # Add Controls
        clavicleCtrl = CubeControl('clavicle', parent=self)
        clavicleCtrl.alignOnXAxis()
        clavicleLen = claviclePosition.subtract(clavicleEndPosition).length()
        clavicleCtrl.scalePoints(Vec3(clavicleLen, 0.75, 0.75))

        if location == "R":
            clavicleCtrl.translatePoints(Vec3(0.0, 0.0, -1.0))
        else:
            clavicleCtrl.translatePoints(Vec3(0.0, 0.0, 1.0))

        clavicleCtrl.xfo.copy(clavicleXfo)
        clavicleCtrl.setColor(ctrlColor)

        clavicleCtrlSrtBuffer = SrtBuffer('clavicle', parent=self)
        clavicleCtrlSrtBuffer.xfo.copy(clavicleCtrl.xfo)
        clavicleCtrlSrtBuffer.addChild(clavicleCtrl)


        # ==========
        # Deformers
        # ==========
        container = self.getParent().getParent()
        deformersLayer = container.getChildByName('deformers')

        clavicleDef = Joint('clavicle')
        clavicleDef.setComponent(self)

        deformersLayer.addChild(clavicleDef)


        # =====================
        # Create Component I/O
        # =====================
        # Setup Component Xfo I/O's
        spineEndInput = Locator('spineEnd')
        spineEndInput.xfo.copy(clavicleXfo)

        clavicleEndOutput = Locator('clavicleEnd')
        clavicleEndOutput.xfo.copy(clavicleXfo)
        clavicleOutput = Locator('clavicle')
        clavicleOutput.xfo.copy(clavicleXfo)

        # Setup componnent Attribute I/O's
        debugInputAttr = BoolAttribute('debug', True)
        rightSideInputAttr = BoolAttribute('rightSide', location is 'R')
        armFollowBodyOutputAttr = FloatAttribute('followBody', 0.0, 0.0, 1.0)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        clavicleInputConstraint = PoseConstraint('_'.join([clavicleCtrl.getName(), 'To', spineEndInput.getName()]))
        clavicleInputConstraint.setMaintainOffset(True)
        clavicleInputConstraint.addConstrainer(spineEndInput)
        clavicleCtrlSrtBuffer.addConstraint(clavicleInputConstraint)

        # Constraint outputs
        clavicleConstraint = PoseConstraint('_'.join([clavicleOutput.getName(), 'To', clavicleCtrl.getName()]))
        clavicleConstraint.addConstrainer(clavicleCtrl)
        clavicleOutput.addConstraint(clavicleConstraint)

        clavicleEndConstraint = PoseConstraint('_'.join([clavicleEndOutput.getName(), 'To', clavicleCtrl.getName()]))
        clavicleEndConstraint.addConstrainer(clavicleCtrl)
#.........这里部分代码省略.........
开发者ID:jhodgson,项目名称:Kraken,代码行数:101,代码来源:clavicle_component.py

示例12: __init__

    def __init__(self, name='head', parent=None):

        Profiler.getInstance().push("Construct Head Rig Component:" + name)
        super(HeadComponentRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        # Head
        self.headCtrlSpace = CtrlSpace('head', parent=self.ctrlCmpGrp)
        self.headCtrl = Control('head', parent=self.headCtrlSpace, shape="circle")
        self.headCtrl.rotatePoints(0, 0, 90)
        self.headCtrl.scalePoints(Vec3(3, 3, 3))
        self.headCtrl.translatePoints(Vec3(0, 1, 0.25))

        # Eye Left
        self.eyeLeftCtrlSpace = CtrlSpace('eyeLeft', parent=self.headCtrl)
        self.eyeLeftCtrl = Control('eyeLeft', parent=self.eyeLeftCtrlSpace, shape="sphere")
        self.eyeLeftCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.eyeLeftCtrl.setColor("blueMedium")

        # Eye Right
        self.eyeRightCtrlSpace = CtrlSpace('eyeRight', parent=self.headCtrl)
        self.eyeRightCtrl = Control('eyeRight', parent=self.eyeRightCtrlSpace, shape="sphere")
        self.eyeRightCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.eyeRightCtrl.setColor("blueMedium")

        # Jaw
        self.jawCtrlSpace = CtrlSpace('jawCtrlSpace', parent=self.headCtrl)
        self.jawCtrl = Control('jaw', parent=self.jawCtrlSpace, shape="cube")
        self.jawCtrl.alignOnYAxis(negative=True)
        self.jawCtrl.alignOnZAxis()
        self.jawCtrl.scalePoints(Vec3(1.45, 0.65, 1.25))
        self.jawCtrl.translatePoints(Vec3(0, -0.25, 0))
        self.jawCtrl.setColor("orange")


        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)

        headDef = Joint('head', parent=defCmpGrp)
        headDef.setComponent(self)

        jawDef = Joint('jaw', parent=defCmpGrp)
        jawDef.setComponent(self)

        eyeLeftDef = Joint('eyeLeft', parent=defCmpGrp)
        eyeLeftDef.setComponent(self)

        eyeRightDef = Joint('eyeRight', parent=defCmpGrp)
        eyeRightDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        headInputConstraint = PoseConstraint('_'.join([self.headCtrlSpace.getName(), 'To', self.headBaseInputTgt.getName()]))
        headInputConstraint.setMaintainOffset(True)
        headInputConstraint.addConstrainer(self.headBaseInputTgt)
        self.headCtrlSpace.addConstraint(headInputConstraint)

        # # Constraint outputs
        headOutputConstraint = PoseConstraint('_'.join([self.headOutputTgt.getName(), 'To', self.headCtrl.getName()]))
        headOutputConstraint.addConstrainer(self.headCtrl)
        self.headOutputTgt.addConstraint(headOutputConstraint)

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

        eyeLOutputConstraint = PoseConstraint('_'.join([self.eyeLOutputTgt.getName(), 'To', self.eyeLeftCtrl.getName()]))
        eyeLOutputConstraint.addConstrainer(self.eyeLeftCtrl)
        self.eyeLOutputTgt.addConstraint(eyeLOutputConstraint)

        eyeROutputConstraint = PoseConstraint('_'.join([self.eyeROutputTgt.getName(), 'To', self.eyeRightCtrl.getName()]))
        eyeROutputConstraint.addConstrainer(self.eyeRightCtrl)
        self.eyeROutputTgt.addConstraint(eyeROutputConstraint)


        # ==================
        # Add Component I/O
        # ==================
        # Add Xfo I/O's
        # self.addInput(self.headBaseInputTgt)

        # self.addOutput(self.headOutputTgt)
        # self.addOutput(self.jawOutputTgt)
        # self.addOutput(self.eyeLOutputTgt)
        # self.addOutput(self.eyeROutputTgt)

        # Add Attribute I/O's
        # self.addInput(self.drawDebugInputAttr)


        # ===============
#.........这里部分代码省略.........
开发者ID:hoorayfor3d,项目名称:Kraken,代码行数:101,代码来源:head_component.py

示例13: __init__

    def __init__(self, name='limb', parent=None):

        Profiler.getInstance().push("Construct StretchyLimb Rig Component:" + name)
        super(StretchyLimbComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Upper (FK)
        self.upperFKCtrlSpace = CtrlSpace('upperFK', parent=self.ctrlCmpGrp)
        self.upperFKCtrl = Control('upperFK', parent=self.upperFKCtrlSpace, shape="cube")
        self.upperFKCtrl.alignOnXAxis()

        # Lower (FK)
        self.lowerFKCtrlSpace = CtrlSpace('lowerFK', parent=self.upperFKCtrl)
        self.lowerFKCtrl = Control('lowerFK', parent=self.lowerFKCtrlSpace, shape="cube")
        self.lowerFKCtrl.alignOnXAxis()

        # End (IK)
        self.limbIKCtrlSpace = CtrlSpace('IK', parent=self.ctrlCmpGrp)
        self.limbIKCtrl = Control('IK', parent=self.limbIKCtrlSpace, shape="pin")

        # Add Component Params to IK control
        # TODO: Move these separate control
        limbSettingsAttrGrp = AttributeGroup("DisplayInfo_StretchyLimbSettings", parent=self.limbIKCtrl)
        limbDrawDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=limbSettingsAttrGrp)
        self.limbBone0LenInputAttr = ScalarAttribute('bone0Len', value=1.0, parent=limbSettingsAttrGrp)
        self.limbBone1LenInputAttr = ScalarAttribute('bone1Len', value=1.0, parent=limbSettingsAttrGrp)
        limbIKBlendInputAttr = ScalarAttribute('ikblend', value=1.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbSoftIKInputAttr = BoolAttribute('softIK', value=True, parent=limbSettingsAttrGrp)
        limbSoftRatioInputAttr = ScalarAttribute('softRatio', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbStretchInputAttr = BoolAttribute('stretch', value=True, parent=limbSettingsAttrGrp)
        limbStretchBlendInputAttr = ScalarAttribute('stretchBlend', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbSlideInputAttr = ScalarAttribute('slide', value=0.0, minValue=-1.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbPinInputAttr = ScalarAttribute('pin', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        self.rightSideInputAttr = BoolAttribute('rightSide', value=False, parent=limbSettingsAttrGrp)

        self.drawDebugInputAttr.connect(limbDrawDebugInputAttr)

        # UpV (IK Pole Vector)
        self.limbUpVCtrlSpace = CtrlSpace('UpV', parent=self.ctrlCmpGrp)
        self.limbUpVCtrl = Control('UpV', parent=self.limbUpVCtrlSpace, shape="triangle")
        self.limbUpVCtrl.alignOnZAxis()

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        upperDef = Joint('upper', parent=self.defCmpGrp)
        upperDef.setComponent(self)

        lowerDef = Joint('lower', parent=self.defCmpGrp)
        lowerDef.setComponent(self)

        endDef = Joint('end', parent=self.defCmpGrp)
        endDef.setComponent(self)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.limbIKCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbIKCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.limbIKCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.limbIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.limbIKCtrlSpace.addConstraint(self.limbIKCtrlSpaceInputConstraint)

        self.limbUpVCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbUpVCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.limbUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.limbUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.limbUpVCtrlSpace.addConstraint(self.limbUpVCtrlSpaceInputConstraint)

        self.limbRootInputConstraint = PoseConstraint('_'.join([self.limbIKCtrl.getName(), 'To', self.limbParentInputTgt.getName()]))
        self.limbRootInputConstraint.setMaintainOffset(True)
        self.limbRootInputConstraint.addConstrainer(self.limbParentInputTgt)
        self.upperFKCtrlSpace.addConstraint(self.limbRootInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add StretchyLimb Splice Op
        self.limbIKKLOp = KLOperator('limbKLOp', 'TwoBoneStretchyIKSolver', 'Kraken')
        self.addOperator(self.limbIKKLOp)

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

        self.limbIKKLOp.setInput('bone0Len', self.limbBone0LenInputAttr)
        self.limbIKKLOp.setInput('bone1Len', self.limbBone1LenInputAttr)
        self.limbIKKLOp.setInput('ikblend', limbIKBlendInputAttr)
        self.limbIKKLOp.setInput('softIK', limbSoftIKInputAttr)
        self.limbIKKLOp.setInput('softRatio', limbSoftRatioInputAttr)
        self.limbIKKLOp.setInput('stretch', limbStretchInputAttr)
        self.limbIKKLOp.setInput('stretchBlend', limbStretchBlendInputAttr)
        self.limbIKKLOp.setInput('slide', limbSlideInputAttr)
        self.limbIKKLOp.setInput('pin', limbPinInputAttr)
        self.limbIKKLOp.setInput('rightSide', self.rightSideInputAttr)
#.........这里部分代码省略.........
开发者ID:AbedSHP,项目名称:Kraken,代码行数:101,代码来源:stretchyLimb_component.py

示例14: StretchyLimbComponentRig

class StretchyLimbComponentRig(StretchyLimbComponent):
    """StretchyLimb Component"""

    def __init__(self, name='limb', parent=None):

        Profiler.getInstance().push("Construct StretchyLimb Rig Component:" + name)
        super(StretchyLimbComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # Upper (FK)
        self.upperFKCtrlSpace = CtrlSpace('upperFK', parent=self.ctrlCmpGrp)
        self.upperFKCtrl = Control('upperFK', parent=self.upperFKCtrlSpace, shape="cube")
        self.upperFKCtrl.alignOnXAxis()

        # Lower (FK)
        self.lowerFKCtrlSpace = CtrlSpace('lowerFK', parent=self.upperFKCtrl)
        self.lowerFKCtrl = Control('lowerFK', parent=self.lowerFKCtrlSpace, shape="cube")
        self.lowerFKCtrl.alignOnXAxis()

        # End (IK)
        self.limbIKCtrlSpace = CtrlSpace('IK', parent=self.ctrlCmpGrp)
        self.limbIKCtrl = Control('IK', parent=self.limbIKCtrlSpace, shape="pin")

        # Add Component Params to IK control
        # TODO: Move these separate control
        limbSettingsAttrGrp = AttributeGroup("DisplayInfo_StretchyLimbSettings", parent=self.limbIKCtrl)
        limbDrawDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=limbSettingsAttrGrp)
        self.limbBone0LenInputAttr = ScalarAttribute('bone0Len', value=1.0, parent=limbSettingsAttrGrp)
        self.limbBone1LenInputAttr = ScalarAttribute('bone1Len', value=1.0, parent=limbSettingsAttrGrp)
        limbIKBlendInputAttr = ScalarAttribute('ikblend', value=1.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbSoftIKInputAttr = BoolAttribute('softIK', value=True, parent=limbSettingsAttrGrp)
        limbSoftRatioInputAttr = ScalarAttribute('softRatio', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbStretchInputAttr = BoolAttribute('stretch', value=True, parent=limbSettingsAttrGrp)
        limbStretchBlendInputAttr = ScalarAttribute('stretchBlend', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbSlideInputAttr = ScalarAttribute('slide', value=0.0, minValue=-1.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        limbPinInputAttr = ScalarAttribute('pin', value=0.0, minValue=0.0, maxValue=1.0, parent=limbSettingsAttrGrp)
        self.rightSideInputAttr = BoolAttribute('rightSide', value=False, parent=limbSettingsAttrGrp)

        self.drawDebugInputAttr.connect(limbDrawDebugInputAttr)

        # UpV (IK Pole Vector)
        self.limbUpVCtrlSpace = CtrlSpace('UpV', parent=self.ctrlCmpGrp)
        self.limbUpVCtrl = Control('UpV', parent=self.limbUpVCtrlSpace, shape="triangle")
        self.limbUpVCtrl.alignOnZAxis()

        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        upperDef = Joint('upper', parent=self.defCmpGrp)
        upperDef.setComponent(self)

        lowerDef = Joint('lower', parent=self.defCmpGrp)
        lowerDef.setComponent(self)

        endDef = Joint('end', parent=self.defCmpGrp)
        endDef.setComponent(self)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        self.limbIKCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbIKCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.limbIKCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.limbIKCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.limbIKCtrlSpace.addConstraint(self.limbIKCtrlSpaceInputConstraint)

        self.limbUpVCtrlSpaceInputConstraint = PoseConstraint('_'.join([self.limbUpVCtrlSpace.getName(), 'To', self.globalSRTInputTgt.getName()]))
        self.limbUpVCtrlSpaceInputConstraint.setMaintainOffset(True)
        self.limbUpVCtrlSpaceInputConstraint.addConstrainer(self.globalSRTInputTgt)
        self.limbUpVCtrlSpace.addConstraint(self.limbUpVCtrlSpaceInputConstraint)

        self.limbRootInputConstraint = PoseConstraint('_'.join([self.limbIKCtrl.getName(), 'To', self.limbParentInputTgt.getName()]))
        self.limbRootInputConstraint.setMaintainOffset(True)
        self.limbRootInputConstraint.addConstrainer(self.limbParentInputTgt)
        self.upperFKCtrlSpace.addConstraint(self.limbRootInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add StretchyLimb Splice Op
        self.limbIKKLOp = KLOperator('limbKLOp', 'TwoBoneStretchyIKSolver', 'Kraken')
        self.addOperator(self.limbIKKLOp)

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

        self.limbIKKLOp.setInput('bone0Len', self.limbBone0LenInputAttr)
        self.limbIKKLOp.setInput('bone1Len', self.limbBone1LenInputAttr)
        self.limbIKKLOp.setInput('ikblend', limbIKBlendInputAttr)
        self.limbIKKLOp.setInput('softIK', limbSoftIKInputAttr)
        self.limbIKKLOp.setInput('softRatio', limbSoftRatioInputAttr)
        self.limbIKKLOp.setInput('stretch', limbStretchInputAttr)
        self.limbIKKLOp.setInput('stretchBlend', limbStretchBlendInputAttr)
#.........这里部分代码省略.........
开发者ID:AbedSHP,项目名称:Kraken,代码行数:101,代码来源:stretchyLimb_component.py

示例15: __init__

    def __init__(self, name="foot", parent=None):

        Profiler.getInstance().push("Construct Neck Rig Component:" + name)
        super(FootComponentRig, self).__init__(name, parent)


        # =========
        # Controls
        # =========
        self.ankleLenInputAttr = ScalarAttribute('ankleLen', 1.0, maxValue=1.0, parent=self.cmpInputAttrGrp)
        self.toeLenInputAttr = ScalarAttribute('toeLen', 1.0, maxValue=1.0, parent=self.cmpInputAttrGrp)
        self.rightSideInputAttr = BoolAttribute('rightSide', False, parent=self.cmpInputAttrGrp)

        self.footAll = Locator('footAll', parent=self.ctrlCmpGrp)
        self.footAll.setShapeVisibility(False)

        self.ankleIKCtrlSpace = CtrlSpace('ankleIK', parent=self.footAll)
        self.ankleIKCtrl = Control('ankleIK', parent=self.ankleIKCtrlSpace, shape="square")
        self.ankleIKCtrl.alignOnXAxis(negative=True)
        self.ankleIKCtrl.lockTranslation(True, True, True)
        self.ankleIKCtrl.lockScale(True, True, True)

        self.toeIKCtrlSpace = CtrlSpace('toeIK', parent=self.footAll)
        self.toeIKCtrl = Control('toeIK', parent=self.toeIKCtrlSpace, shape="square")
        self.toeIKCtrl.alignOnXAxis()
        self.toeIKCtrl.lockTranslation(True, True, True)
        self.toeIKCtrl.lockScale(True, True, True)

        self.ankleFKCtrlSpace = CtrlSpace('ankleFK', parent=self.ctrlCmpGrp)
        self.ankleFKCtrl = Control('ankleFK', parent=self.ankleFKCtrlSpace, shape="cube")
        self.ankleFKCtrl.alignOnXAxis()
        self.ankleFKCtrl.lockTranslation(True, True, True)
        self.ankleFKCtrl.lockScale(True, True, True)

        self.toeFKCtrlSpace = CtrlSpace('toeFK', parent=self.ankleFKCtrl)
        self.toeFKCtrl = Control('toeFK', parent=self.toeFKCtrlSpace, shape="cube")
        self.toeFKCtrl.alignOnXAxis()
        self.toeFKCtrl.lockTranslation(True, True, True)
        self.toeFKCtrl.lockScale(True, True, True)

        self.footSettingsAttrGrp = AttributeGroup("DisplayInfo_FootSettings", parent=self.ankleIKCtrl)
        self.footDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=self.footSettingsAttrGrp)
        self.footRockInputAttr = ScalarAttribute('footRock', value=0.0, minValue=-1.0, maxValue=1.0, parent=self.footSettingsAttrGrp)
        self.footBankInputAttr = ScalarAttribute('footBank', value=0.0, minValue=-1.0, maxValue=1.0, parent=self.footSettingsAttrGrp)

        self.drawDebugInputAttr.connect(self.footDebugInputAttr)

        self.pivotAll = Locator('pivotAll', parent=self.ctrlCmpGrp)
        self.pivotAll.setShapeVisibility(False)

        self.backPivotCtrl = Control('backPivot', parent=self.pivotAll, shape="axesHalfTarget")
        self.backPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.backPivotCtrl.lockScale(True, True, True)
        self.backPivotCtrlSpace = self.backPivotCtrl.insertCtrlSpace()

        self.frontPivotCtrl = Control('frontPivot', parent=self.pivotAll, shape="axesHalfTarget")
        self.frontPivotCtrl.rotatePoints(0.0, 180.0, 0.0)
        self.frontPivotCtrl.lockScale(True, True, True)
        self.frontPivotCtrlSpace = self.frontPivotCtrl.insertCtrlSpace()
        self.frontPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.outerPivotCtrl = Control('outerPivot', parent=self.pivotAll, shape="axesHalfTarget")
        self.outerPivotCtrl.rotatePoints(0.0, -90.0, 0.0)
        self.outerPivotCtrl.lockScale(True, True, True)
        self.outerPivotCtrlSpace = self.outerPivotCtrl.insertCtrlSpace()
        self.outerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.innerPivotCtrl = Control('innerPivot', parent=self.pivotAll, shape="axesHalfTarget")
        self.innerPivotCtrl.rotatePoints(0.0, 90.0, 0.0)
        self.innerPivotCtrl.lockScale(True, True, True)
        self.innerPivotCtrlSpace = self.innerPivotCtrl.insertCtrlSpace()
        self.innerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))


        # ==========
        # Deformers
        # ==========
        deformersLayer = self.getOrCreateLayer('deformers')
        self.defCmpGrp = ComponentGroup(self.getName(), self, parent=deformersLayer)
        self.addItem('defCmpGrp', self.defCmpGrp)

        self.ankleDef = Joint('ankle', parent=self.defCmpGrp)
        self.ankleDef.setComponent(self)

        self.toeDef = Joint('toe', parent=self.defCmpGrp)
        self.toeDef.setComponent(self)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint to inputs
        self.pivotAllInputConstraint = PoseConstraint('_'.join([self.pivotAll.getName(), 'To', self.ikHandleInputTgt.getName()]))
        self.pivotAllInputConstraint.setMaintainOffset(True)
        self.pivotAllInputConstraint.addConstrainer(self.ikHandleInputTgt)
        self.pivotAll.addConstraint(self.pivotAllInputConstraint)

        self.ankleFKInputConstraint = PoseConstraint('_'.join([self.ankleFKCtrlSpace.getName(), 'To', self.legEndFKInputTgt.getName()]))
        self.ankleFKInputConstraint.setMaintainOffset(True)
        self.ankleFKInputConstraint.addConstrainer(self.legEndFKInputTgt)
#.........这里部分代码省略.........
开发者ID:AbedSHP,项目名称:Kraken,代码行数:101,代码来源:foot_component.py


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