Example #1
0
    def __init__(self, name='leg', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Leg Guide Component:" + name)
        super(LegComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        # Guide Controls
        self.femurCtrl = Control('femur',
                                 parent=self.ctrlCmpGrp,
                                 shape="sphere")
        self.kneeCtrl = Control('knee', parent=self.ctrlCmpGrp, shape="sphere")
        self.ankleCtrl = Control('ankle',
                                 parent=self.ctrlCmpGrp,
                                 shape="sphere")

        armGuideSettingsAttrGrp = AttributeGroup("DisplayInfo_ArmSettings",
                                                 parent=self.femurCtrl)
        self.armGuideDebugAttr = BoolAttribute('drawDebug',
                                               value=True,
                                               parent=armGuideSettingsAttrGrp)

        self.guideOpHost = Transform('guideOpHost', self.ctrlCmpGrp)

        # Guide Operator
        self.legGuideKLOp = KLOperator('guide', 'TwoBoneIKGuideSolver',
                                       'Kraken')
        self.addOperator(self.legGuideKLOp)

        # Add Att Inputs
        self.legGuideKLOp.setInput('drawDebug', self.armGuideDebugAttr)
        self.legGuideKLOp.setInput('rigScale', self.rigScaleInputAttr)

        # Add Source Inputs
        self.legGuideKLOp.setInput('root', self.femurCtrl)
        self.legGuideKLOp.setInput('mid', self.kneeCtrl)
        self.legGuideKLOp.setInput('end', self.ankleCtrl)

        # Add Target Outputs
        self.legGuideKLOp.setOutput('guideOpHost', self.guideOpHost)

        self.default_data = {
            "name": name,
            "location": "L",
            "createIKHandle": False,
            "femurXfo": Xfo(Vec3(1.0, 9.75, -0.5)),
            "kneeXfo": Xfo(Vec3(1.5, 5.5, -0.5)),
            "ankleXfo": Xfo(Vec3(1.75, 1.15, -1.25))
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #2
0
    def __init__(self, name='hand', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Hand Guide Component:" + name)
        super(HandComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # =========
        # Guide Controls
        self.guideSettingsAttrGrp = AttributeGroup("GuideSettings",
                                                   parent=self)
        self.digitNamesAttr = StringAttribute(
            'digitNames',
            value="thumb,index,middle,ring,pinky",
            parent=self.guideSettingsAttrGrp)
        self.digitNamesAttr.setValueChangeCallback(self.updateFingers)

        self.numJointsAttr = IntegerAttribute('numJoints',
                                              value=4,
                                              minValue=2,
                                              maxValue=20,
                                              parent=self.guideSettingsAttrGrp)
        self.numJointsAttr.setValueChangeCallback(self.resizeDigits)

        self.fingers = OrderedDict()

        self.handCtrl = Control('hand', parent=self.ctrlCmpGrp, shape="square")
        self.handCtrl.rotatePoints(0.0, 0.0, 90.0)
        self.handCtrl.scalePoints(Vec3(1.0, 0.75, 1.0))
        self.handCtrl.setColor('yellow')

        self.handGuideSettingsAttrGrp = AttributeGroup("Settings",
                                                       parent=self.handCtrl)
        self.ctrlShapeToggle = BoolAttribute(
            'ctrlShape_vis', value=False, parent=self.handGuideSettingsAttrGrp)
        self.handDebugInputAttr = BoolAttribute(
            'drawDebug', value=False, parent=self.handGuideSettingsAttrGrp)

        self.drawDebugInputAttr.connect(self.handDebugInputAttr)

        self.guideCtrlHrcGrp = HierarchyGroup('controlShapes',
                                              parent=self.ctrlCmpGrp)

        self.default_data = {
            "name": name,
            "location": "L",
            "handXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
            "digitNames": self.digitNamesAttr.getValue(),
            "numJoints": self.numJointsAttr.getValue(),
            "fingers": self.fingers
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #3
0
    def __init__(self, name='InsectLeg', parent=None, data=None):

        Profiler.getInstance().push("Construct InsectLeg Guide Component:" + name)
        super(InsectLegComponentGuide, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
        self.numJoints = IntegerAttribute('numJoints', value=5, minValue=2, maxValue=20, parent=guideSettingsAttrGrp)
        self.numJoints.setValueChangeCallback(self.updateNumLegControls)

        self.jointCtrls = []
        if data is None:
            numJoints = self.numJoints.getValue()
            jointPositions = self.generateGuidePositions(numJoints)

            for i in xrange(numJoints):
                self.jointCtrls.append(Control('leg' + str(i + 1).zfill(2), parent=self.ctrlCmpGrp, shape="sphere"))

            data = {
               "location": "L",
               "jointPositions": jointPositions,
               "numJoints": self.numJoints.getValue()
              }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #4
0
    def __init__(self, name, parent=None, flags=None, metaData=None):
        super(Object3D, self).__init__(name, parent=parent, metaData=metaData)
        self._children = []
        self._flags = {}
        self._attributeGroups = []
        self._constraints = []
        self._xfo = Xfo()
        self._ro = RotationOrder()
        self._color = None

        self._implicitAttrGrp = AttributeGroup("implicitAttrGrp", self)
        self._visibility = BoolAttribute('visibility', True,
                                         self._implicitAttrGrp)

        self._shapeVisibility = BoolAttribute('ShapeVisibility', True,
                                              self._implicitAttrGrp)

        if parent is not None:
            parent.addChild(self)

        if flags is not None:
            assert type(
                flags
            ) is str, "Flags argument must be a comma separated string."

            for flag in flags.replace(' ', '').split(','):
                if not re.match("[\w]*$", flag):
                    msg = "{} '{}' {} ({}: {}) {}\n".format(
                        "Invalid flag", flag, "set on", self.getName(),
                        self.getPath(), ". Alphanumeric and underscores only!")
                    logger.warn(msg)
                    continue

                self.setFlag(flag)
Example #5
0
    def __init__(self, name='head', parent=None):

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

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape="circle")
        self.headCtrl.rotatePoints(90.0, 0.0, 0.0)
        self.headCtrl.scalePoints(Vec3(3.5, 3.5, 3.5))

        self.jawCtrl = Control('jaw', parent=self.ctrlCmpGrp, shape="cube")
        self.jawCtrl.alignOnZAxis()
        self.jawCtrl.scalePoints(Vec3(2.0, 0.5, 2.0))
        self.jawCtrl.alignOnYAxis(negative=True)
        self.jawCtrl.setColor('orange')

        data = {
            "name": name,
            "location": "M",
            "headXfo": Xfo(Vec3(0.0, 1.67, 1.75)),
            "headCtrlCrvData": self.headCtrl.getCurveData(),
            "jawPosition": Vec3(0.0, 1.2787, 2.0078),
            "jawCtrlCrvData": self.jawCtrl.getCurveData(),
        }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #6
0
    def __init__(self, name='head', parent=None, data=None):

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


        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape="cube")
        self.headEndCtrl = Control('headEnd', parent=self.ctrlCmpGrp, shape="sphere")
        self.eyeLeftCtrl = Control('eyeLeft', parent=self.ctrlCmpGrp, shape="sphere")
        self.eyeRightCtrl = Control('eyeRight', parent=self.ctrlCmpGrp, shape="sphere")
        self.jawCtrl = Control('jaw', parent=self.ctrlCmpGrp, shape="cube")

        if data is None:
            data = {
                    "name": name,
                    "location": "M",
                    "headPosition": Vec3(0.0, 17.4756, -0.421),
                    "headEndPosition": Vec3(0.0, 19.5, -0.421),
                    "eyeLeftPosition": Vec3(0.3497, 18.0878, 0.6088),
                    "eyeRightPosition": Vec3(-0.3497, 18.0878, 0.6088),
                    "jawPosition": Vec3(0.0, 17.613, -0.2731)
                   }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #7
0
    def __init__(self, name='clavicle', parent=None, data=None):

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

        # =========
        # Controls
        # =========
        # Guide Controls
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.clavicleCtrl = Control('clavicle',
                                    parent=self.ctrlCmpGrp,
                                    shape="sphere")
        self.clavicleUpVCtrl = Control('clavicleUpV',
                                       parent=self.ctrlCmpGrp,
                                       shape="triangle")
        self.clavicleUpVCtrl.setColor('red')
        self.clavicleEndCtrl = Control('clavicleEnd',
                                       parent=self.ctrlCmpGrp,
                                       shape="sphere")

        if data is None:
            data = {
                "name": name,
                "location": "L",
                "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
                "clavicleUpVXfo": Xfo(Vec3(0.0, 1.0, 0.0)),
                "clavicleEndXfo": Xfo(Vec3(2.27, 15.295, -0.753))
            }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #8
0
    def __init__(self, name='leg', parent=None, data=None):

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


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

        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        # Guide Controls
        self.femurCtrl = Control('femur', parent=self.ctrlCmpGrp, shape="sphere")
        self.kneeCtrl = Control('knee', parent=self.ctrlCmpGrp, shape="sphere")
        self.ankleCtrl = Control('ankle', parent=self.ctrlCmpGrp, shape="sphere")
        self.toeCtrl = Control('toe', parent=self.ctrlCmpGrp, shape="sphere")
        self.toeTipCtrl = Control('toeTip', parent=self.ctrlCmpGrp, shape="sphere")

        if data is None:
            data = {
                    "name": name,
                    "location": "L",
                    "femurXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
                    "kneeXfo": Xfo(Vec3(1.4488, 5.4418, -0.5348)),
                    "ankleXfo": Xfo(Vec3(1.841, 1.1516, -1.237)),
                    "toeXfo": Xfo(Vec3(1.85, 0.4, 0.25)),
                    "toeTipXfo": Xfo(Vec3(1.85, 0.4, 1.5))
                   }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #9
0
    def __init__(self, name='spine', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Spine Guide Component:" + name)
        super(SpineComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
        self.numDeformersAttr = IntegerAttribute('numDeformers', value=1, minValue=0, maxValue=20, parent=guideSettingsAttrGrp)

        # Guide Controls
        self.cog = Control('cogPosition', parent=self.ctrlCmpGrp, shape="sphere")
        self.cog.scalePoints(Vec3(1.2, 1.2, 1.2))
        self.cog.setColor('red')

        self.spine01Ctrl = Control('spine01Position', parent=self.ctrlCmpGrp, shape='sphere')
        self.spine02Ctrl = Control('spine02Position', parent=self.ctrlCmpGrp, shape='sphere')
        self.spine03Ctrl = Control('spine03Position', parent=self.ctrlCmpGrp, shape='sphere')
        self.spine04Ctrl = Control('spine04Position', parent=self.ctrlCmpGrp, shape='sphere')

        data = {
            'name': name,
            'location': 'M',
            'cogPosition': Vec3(0.0, 11.1351, -0.1382),
            'spine01Position': Vec3(0.0, 11.1351, -0.1382),
            'spine02Position': Vec3(0.0, 11.8013, -0.1995),
            'spine03Position': Vec3(0.0, 12.4496, -0.3649),
            'spine04Position': Vec3(0.0, 13.1051, -0.4821),
            'numDeformers': 6
        }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #10
0
    def __init__(self, name='neck', parent=None, data=None):

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

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

        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        # Guide Controls
        self.neckCtrl = Control('neck', parent=self.ctrlCmpGrp, shape="sphere")
        self.neckEndCtrl = Control('neckEnd', parent=self.ctrlCmpGrp, shape="sphere")

        if data is None:
            data = {
                    "name": name,
                    "location": "M",
                    "neckPosition": Vec3(0.0, 16.5572, -0.6915),
                    "neckEndPosition": Vec3(0.0, 17.4756, -0.421)
                   }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #11
0
    def __init__(self, name='clavicle', parent=None):

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


        # =========
        # Controls
        # =========
        # Guide Controls
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.clavicleCtrl = Control('clavicle', parent=self.ctrlCmpGrp, shape="cube")
        self.clavicleCtrl.alignOnXAxis()
        self.clavicleCtrl.scalePoints(Vec3(1.0, 0.25, 0.25))

        data = {
                "name": name,
                "location": "L",
                "clavicleXfo": Xfo(Vec3(0.1322, 15.403, -0.5723)),
                'clavicleCtrlCrvData': self.clavicleCtrl.getCurveData()
               }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #12
0
    def __init__(self, name='mainSrt', parent=None):

        Profiler.getInstance().push("Construct MainSrt Guide Component:" + name)
        super(MainSrtComponentGuide, self).__init__(name, parent)

        # =========
        # Attributes
        # =========
        # Add Component Params to IK control
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.mainSrtSizeInputAttr = ScalarAttribute('mainSrtSize', value=5.0, minValue=1.0, maxValue=50.0, parent=guideSettingsAttrGrp)

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

        # Guide Controls
        self.mainSrtCtrl = Control('mainSrt', parent=self.ctrlCmpGrp, shape="circle")

        data = {
                "location": 'M',
                "mainSrtSize": self.mainSrtSizeInputAttr.getValue(),
                "mainSrtXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0))
               }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #13
0
    def __init__(self, name='', parent=None, *args, **kwargs):
        super(BaseExampleComponent, self).__init__(name, parent, *args, **kwargs)

        # ================
        # Setup Hierarchy
        # ================
        self.controlsLayer = self.getOrCreateLayer('controls')
        self.ctrlCmpGrp = ComponentGroup(self.getName(), self, parent=self.controlsLayer)
        self.addItem('ctrlCmpGrp', self.ctrlCmpGrp)

        # IO Hierarchies
        self.inputHrcGrp = HierarchyGroup('inputs', parent=self.ctrlCmpGrp)
        self.cmpInputAttrGrp = AttributeGroup('inputs', parent=self.inputHrcGrp)

        self.outputHrcGrp = HierarchyGroup('outputs', parent=self.ctrlCmpGrp)
        self.cmpOutputAttrGrp = AttributeGroup('outputs', parent=self.outputHrcGrp)
Example #14
0
    def __init__(self, name='limb', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct StretchyLimb Guide Component:" +
                                    name)
        super(StretchyLimbComponentGuide,
              self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        # Guide Controls
        self.upperCtl = Control('upper',
                                parent=self.ctrlCmpGrp,
                                shape="sphere")
        self.lowerCtl = Control('lower',
                                parent=self.ctrlCmpGrp,
                                shape="sphere")
        self.endCtl = Control('end', parent=self.ctrlCmpGrp, shape="sphere")

        self.default_data = {
            "name": name,
            "location": "L",
            "upperXfo": Xfo(Vec3(0.9811, 9.769, -0.4572)),
            "lowerXfo": Xfo(Vec3(1.4488, 5.4418, -0.5348)),
            "endXfo": Xfo(Vec3(1.841, 1.1516, -1.237))
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #15
0
    def __init__(self, name='foot', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Foot Component:" + name)
        super(FootComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        # Guide Controls
        self.ankleCtrl = Control('ankle', parent=self.ctrlCmpGrp, shape="pin")

        self.toeCtrl = Control('toe', parent=self.ctrlCmpGrp, shape="pin")
        self.toeCtrl.rotatePoints(-90.0, 0.0, 0.0)

        self.toeTipCtrl = Control('toeTip',
                                  parent=self.ctrlCmpGrp,
                                  shape="pin")
        self.toeTipCtrl.rotatePoints(-90.0, 0.0, 0.0)

        self.backPivotCtrl = Control('backPivot',
                                     parent=self.ctrlCmpGrp,
                                     shape="axesHalfTarget")
        self.backPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.frontPivotCtrl = Control('frontPivot',
                                      parent=self.ctrlCmpGrp,
                                      shape="axesHalfTarget")
        self.frontPivotCtrl.rotatePoints(0.0, 180.0, 0.0)
        self.frontPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.outerPivotCtrl = Control('outerPivot',
                                      parent=self.ctrlCmpGrp,
                                      shape="axesHalfTarget")
        self.outerPivotCtrl.rotatePoints(0.0, -90.0, 0.0)
        self.outerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.innerPivotCtrl = Control('innerPivot',
                                      parent=self.ctrlCmpGrp,
                                      shape="axesHalfTarget")
        self.innerPivotCtrl.rotatePoints(0.0, 90.0, 0.0)
        self.innerPivotCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.default_data = {
            "name": name,
            "location": 'L',
            "ankleXfo": Xfo(Vec3(1.75, 1.15, -1.25)),
            "toeXfo": Xfo(Vec3(1.75, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(1.75, 0.4, 1.5)),
            "backPivotXfo": Xfo(Vec3(1.75, 0.0, -2.5)),
            "frontPivotXfo": Xfo(Vec3(1.75, 0.0, 2.0)),
            "outerPivotXfo": Xfo(Vec3(2.5, 0.0, -1.25)),
            "innerPivotXfo": Xfo(Vec3(1.0, 0.0, -1.25))
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #16
0
    def __init__(self, name='head', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Head Guide Component:" + name)
        super(HeadComponentGuide, self).__init__(name, parent, *args, **kwargs)

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        sphereCtrl = Control('sphere', shape='sphere')
        sphereCtrl.scalePoints(Vec3(0.375, 0.375, 0.375))

        self.headCtrl = Control('head', parent=self.ctrlCmpGrp, shape='square')
        self.headCtrl.rotatePoints(90, 0, 0)
        self.headCtrl.translatePoints(Vec3(0.0, 0.5, 0.0))
        self.headCtrl.scalePoints(Vec3(1.8, 2.0, 2.0))

        self.eyeLeftCtrl = Control('eyeLeft',
                                   parent=self.headCtrl,
                                   shape='arrow_thin')
        self.eyeLeftCtrl.translatePoints(Vec3(0, 0, 0.5))
        self.eyeLeftCtrl.rotatePoints(0, 90, 0)
        self.eyeLeftCtrl.appendCurveData(sphereCtrl.getCurveData())

        self.eyeRightCtrl = Control('eyeRight',
                                    parent=self.headCtrl,
                                    shape='arrow_thin')
        self.eyeRightCtrl.translatePoints(Vec3(0, 0, 0.5))
        self.eyeRightCtrl.rotatePoints(0, 90, 0)
        self.eyeRightCtrl.appendCurveData(sphereCtrl.getCurveData())

        self.jawCtrl = Control('jaw', parent=self.headCtrl, shape='square')
        self.jawCtrl.rotatePoints(90, 0, 0)
        self.jawCtrl.rotatePoints(0, 90, 0)
        self.jawCtrl.translatePoints(Vec3(0.0, -0.5, 0.5))
        self.jawCtrl.scalePoints(Vec3(1.0, 0.8, 1.5))
        self.jawCtrl.setColor('orange')

        eyeXAlignOri = Quat()
        eyeXAlignOri.setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(-90))

        self.default_data = {
            "name": name,
            "location": "M",
            "headXfo": Xfo(Vec3(0.0, 17.5, -0.5)),
            "headCrvData": self.headCtrl.getCurveData(),
            "eyeLeftXfo": Xfo(tr=Vec3(0.375, 18.5, 0.5), ori=eyeXAlignOri),
            "eyeLeftCrvData": self.eyeLeftCtrl.getCurveData(),
            "eyeRightXfo": Xfo(tr=Vec3(-0.375, 18.5, 0.5), ori=eyeXAlignOri),
            "eyeRightCrvData": self.eyeRightCtrl.getCurveData(),
            "jawXfo": Xfo(Vec3(0.0, 17.875, -0.275)),
            "jawCrvData": self.jawCtrl.getCurveData()
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #17
0
    def __init__(self, name='clavicle', parent=None, *args, **kwargs):

        Profiler.getInstance().push("Construct Clavicle Guide Component:" + name)
        super(ClavicleComponentGuide, self).__init__(name, parent, *args, **kwargs)


        # =========
        # Controls
        # =========
        # Guide Controls
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.clavicleCtrl = Control('clavicle', parent=self.ctrlCmpGrp, shape="circle")
        self.clavicleCtrl.scalePoints(Vec3(0.75, 0.75, 0.75))
        self.clavicleCtrl.rotatePoints(0.0, 0.0, 90.0)

        self.clavicleGuideSettingsAttrGrp = AttributeGroup("Settings", parent=self.clavicleCtrl)
        self.handDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=self.clavicleGuideSettingsAttrGrp)

        self.drawDebugInputAttr.connect(self.handDebugInputAttr)

        self.clavicleUpVCtrl = Control('clavicleUpV', parent=self.clavicleCtrl, shape="triangle")
        self.clavicleUpVCtrl.setColor('red')
        self.clavicleUpVCtrl.rotatePoints(-90.0, 0.0, 0.0)
        self.clavicleUpVCtrl.rotatePoints(0.0, 90.0, 0.0)
        self.clavicleUpVCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.clavicleEndCtrl = Control('clavicleEnd', parent=self.ctrlCmpGrp, shape="cube")
        self.clavicleEndCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))

        self.default_data = {
            "name": name,
            "location": "L",
            "clavicleXfo": Xfo(Vec3(0.15, 15.5, -0.5)),
            "clavicleUpVXfo": Xfo(Vec3(0.15, 16.5, -0.5)),
            "clavicleEndXfo": Xfo(Vec3(2.25, 15.5, -0.75))
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #18
0
    def __init__(self, name='twist', parent=None):

        Profiler.getInstance().push('Construct Spine Guide Component:' + name)
        super(TwistComponentGuide, self).__init__(name, parent)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup('GuideSettings', parent=self)
        self.numDeformersAttr = IntegerAttribute('numDeformers',
                                                 value=1,
                                                 minValue=0,
                                                 maxValue=20,
                                                 parent=guideSettingsAttrGrp)
        self.blendBiasAttr = ScalarAttribute('blendBias',
                                             value=0.0,
                                             minValue=0,
                                             maxValue=1.0,
                                             parent=guideSettingsAttrGrp)

        # Guide Controls
        triangleCtrl = Control('triangle', shape='triangle')
        triangleCtrl.rotatePoints(90, 0, 0)
        triangleCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
        triangleCtrl.scalePoints(Vec3(1.0, 0.5, 1.0))
        triangleCtrl.translatePoints(Vec3(0.0, 1.25, 0.0))
        triangleCtrl.rotatePoints(0, 90, 0)

        self.originCtrl = Control('origin',
                                  parent=self.ctrlCmpGrp,
                                  shape='circle')
        self.originCtrl.rotatePoints(90, 0, 0)
        self.originCtrl.rotatePoints(0, 90, 0)
        self.originCtrl.appendCurveData(triangleCtrl.getCurveData())
        self.insertCtrl = Control('insert',
                                  parent=self.ctrlCmpGrp,
                                  shape='circle')
        self.insertCtrl.rotatePoints(90, 0, 0)
        self.insertCtrl.rotatePoints(0, 90, 0)
        self.insertCtrl.appendCurveData(triangleCtrl.getCurveData())

        self.default_data = {
            'name': name,
            'location': 'M',
            'blendBias': 0.5,
            'originXfo': Xfo(Vec3(0.0, 0.0, 0.0)),
            'insertXfo': Xfo(Vec3(5.0, 0.0, 0.0)),
            'numDeformers': 5
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #19
0
    def __init__(self, name='FKChain', parent=None, data=None):

        Profiler.getInstance().push("Construct FKCHain Guide Component:" +
                                    name)
        super(FKChainComponentGuide, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
        self.numJoints = IntegerAttribute('numJoints',
                                          value=4,
                                          minValue=1,
                                          maxValue=20,
                                          parent=guideSettingsAttrGrp)
        self.numJoints.setValueChangeCallback(self.updateNumJointControls)

        self.jointCtrls = []
        if data is None:
            numJoints = self.numJoints.getValue()
            jointPositions = self.generateGuidePositions(numJoints)

            for i in xrange(numJoints + 1):
                if i == 0:
                    ctrlParent = self.ctrlCmpGrp
                else:
                    ctrlParent = self.jointCtrls[i - 1]

                newCtrl = Control('chain' + str(i + 1).zfill(2),
                                  parent=ctrlParent,
                                  shape="sphere")
                newCtrl.scalePoints(Vec3(0.25, 0.25, 0.25))
                self.jointCtrls.append(newCtrl)

            data = {
                "location": "L",
                "jointPositions": jointPositions,
                "numJoints": self.numJoints.getValue()
            }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #20
0
    def __init__(self, name, parent=None):
        super(Object3D, self).__init__(name, parent)
        self._children = []
        self._flags = {}
        self._attributeGroups = []
        self._constraints = []
        self._xfo = Xfo()
        self._ro = RotationOrder()
        self._color = None

        self._implicitAttrGrp = AttributeGroup("implicitAttrGrp", self)
        self._visibility = BoolAttribute('visibility', True,
                                         self._implicitAttrGrp)

        self._shapeVisibility = BoolAttribute('ShapeVisibility', True,
                                              self._implicitAttrGrp)

        if parent is not None:
            parent.addChild(self)
Example #21
0
    def __init__(self, name='MultiSpring', parent=None):

        Profiler.getInstance().push("Construct FKCHain Guide Component:" +
                                    name)
        super(MultiSpringComponentGuide, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
        self.numSprings = IntegerAttribute('numSprings',
                                           value=5,
                                           minValue=1,
                                           maxValue=100,
                                           parent=guideSettingsAttrGrp)
        self.numSprings.setValueChangeCallback(self.updateNumJointControls)

        self.springCtrls = []

        numSprings = self.numSprings.getValue()
        springXfos = self.generateGuideXfos(numSprings)

        for i in xrange(numSprings):
            newCtrl = Control('spring' + str(i + 1).zfill(2),
                              parent=self.ctrlCmpGrp,
                              shape="squarePointed")
            newCtrl.alignOnXAxis()
            self.springCtrls.append(newCtrl)

        data = {
            "location": "L",
            "springXfos": springXfos,
            "numSprings": self.numSprings.getValue()
        }

        self.loadData(data)

        Profiler.getInstance().pop()
    def __init__(self, name='SimpleControl', parent=None):

        Profiler.getInstance().push(
            "Construct Simple Control Guide Component:" + name)
        super(SimpleControlComponentGuide, self).__init__(name, parent)

        # =========
        # Attributes
        # =========
        # Add Component Params to IK control
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)

        self.ctrlSizeInputAttr = ScalarAttribute('ctrlSize',
                                                 value=5.0,
                                                 minValue=1.0,
                                                 maxValue=50.0,
                                                 parent=guideSettingsAttrGrp)
        self.ctrlSizeInputAttr.setValueChangeCallback(self.resizeMainCtrl)

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

        # Guide Controls
        self.mainCtrl = Control('main', parent=self.ctrlCmpGrp, shape='square')
        self.mainCtrl.rotatePoints(90, 0, 0)

        data = {
            "location": 'M',
            "ctrlSize": self.ctrlSizeInputAttr.getValue(),
            "ctrlXfo": Xfo(tr=Vec3(0.0, 0.0, 0.0))
        }

        self.loadData(data)

        Profiler.getInstance().pop()
Example #23
0
    def __init__(self, name='FKChain', parent=None):

        Profiler.getInstance().push("Construct FK Chain Rig Component:" + name)
        super(FKChainComponentRig, self).__init__(name, parent)

        # =========
        # Controls
        # =========
        # FK
        self.fkCtrlSpaces = []
        self.fkCtrls = []
        self.setNumControls(4)

        # Add Component Params to IK control
        legSettingsAttrGrp = AttributeGroup("DisplayInfo_ChainSettings",
                                            parent=self.fkCtrls[0])
        legdrawDebugInputAttr = BoolAttribute('drawDebug',
                                              value=False,
                                              parent=legSettingsAttrGrp)

        # Connect IO to controls
        self.drawDebugInputAttr.connect(legdrawDebugInputAttr)

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

        # =====================
        # Create Component I/O
        # =====================

        # Set IO Targets
        self.boneOutputs.setTarget(self.boneOutputsTgt)

        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        rootInputConstraint = PoseConstraint('_'.join([
            self.fkCtrlSpaces[0].getName(), 'To',
            self.rootInputTgt.getName()
        ]))
        rootInputConstraint.setMaintainOffset(True)
        rootInputConstraint.addConstrainer(self.rootInputTgt)
        self.fkCtrlSpaces[0].addConstraint(rootInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add Output Splice Op
        self.outputsToControlsSpliceOp = SpliceOperator(
            'fkChainOutputSpliceOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.outputsToControlsSpliceOp)

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

        # Add Xfo Inputs
        self.outputsToControlsSpliceOp.setInput('constrainers', self.fkCtrls)

        # Add Xfo Outputs
        self.outputsToControlsSpliceOp.setOutput('constrainees',
                                                 self.boneOutputsTgt)

        # Add Deformer Splice Op
        self.deformersToOutputsSpliceOp = SpliceOperator(
            'fkChainDeformerSpliceOp', 'MultiPoseConstraintSolver', 'Kraken')
        self.addOperator(self.deformersToOutputsSpliceOp)

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

        # Add Xfo Inputs
        self.deformersToOutputsSpliceOp.setInput('constrainers',
                                                 self.boneOutputsTgt)

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

        Profiler.getInstance().pop()
Example #24
0
    def __init__(self, name, parent=None, location='M'):
        super(HandComponent, 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"
            handPosition = Vec3(-7.1886, 12.2819, 0.4906)
            handUpV = Vec3(-7.7463, 13.1746, 0.4477)
            handEndPosition = Vec3(-7.945, 11.8321, 0.9655)
        else:
            ctrlColor = "greenBright"
            handPosition = Vec3(7.1886, 12.2819, 0.4906)
            handUpV = Vec3(7.7463, 13.1746, 0.4477)
            handEndPosition = Vec3(7.945, 11.8321, 0.9655)

        # Calculate Clavicle Xfo
        rootToEnd = handEndPosition.subtract(handPosition).unit()
        rootToUpV = handUpV.subtract(handPosition).unit()
        bone1ZAxis = rootToEnd.cross(rootToUpV).unit()
        bone1Normal = rootToEnd.cross(bone1ZAxis).unit()
        handXfo = Xfo()

        if location == "R":
            handQuat = Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)
            handPos = Vec3(-7.1886, 12.2819, 0.4906)
        else:
            handQuat = Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)
            handPos = Vec3(7.1886, 12.2819, 0.4906)

        handXfo.rot = handQuat.clone()
        handXfo.tr.copy(handPos)

        # Add Controls
        handCtrlSrtBuffer = SrtBuffer('hand', parent=self)
        handCtrlSrtBuffer.xfo.copy(handXfo)

        handCtrl = CubeControl('hand', parent=handCtrlSrtBuffer)
        handCtrl.alignOnXAxis()
        handCtrl.scalePoints(Vec3(2.0, 0.75, 1.25))
        handCtrl.xfo.copy(handCtrlSrtBuffer.xfo)
        handCtrl.setColor(ctrlColor)

        # Rig Ref objects
        handRefSrt = Locator('handRef', parent=self)
        handRefSrt.xfo.copy(handCtrlSrtBuffer.xfo)


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

        handSettingsAttrGrp = AttributeGroup("DisplayInfo_HandSettings")
        handCtrl.addAttributeGroup(handSettingsAttrGrp)
        handSettingsAttrGrp.addAttribute(handDebugInputAttr)
        handSettingsAttrGrp.addAttribute(handLinkToWorldInputAttr)


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

        handDef = Joint('hand')
        handDef.setComponent(self)

        deformersLayer.addChild(handDef)


        # =====================
        # Create Component I/O
        # =====================
        # Setup Component Xfo I/O's
        armEndXfoInput = Locator('armEndXfo')
        armEndXfoInput.xfo.copy(handCtrlSrtBuffer.xfo)
        armEndPosInput = Locator('armEndPos')
        armEndPosInput.xfo.copy(handCtrlSrtBuffer.xfo)

        handEndOutput = Locator('handEnd')
        handEndOutput.xfo.copy(handCtrlSrtBuffer.xfo)
        handOutput = Locator('hand')
        handOutput.xfo.copy(handCtrlSrtBuffer.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(handDebugInputAttr)
        linkToWorldInputAttr.connect(handLinkToWorldInputAttr)


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

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

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


        # ==================
        # Add Component I/O
        # ==================
        # Add Xfo I/O's
        self.addInput(armEndXfoInput)
        self.addInput(armEndPosInput)
        self.addOutput(handOutput)
        self.addOutput(handEndOutput)

        # Add Attribute I/O's
        self.addInput(debugInputAttr)
        self.addInput(rightSideInputAttr)
        self.addInput(linkToWorldInputAttr)
Example #25
0
    def __init__(self, name, parent=None, location='M'):
        super(ArmComponent, self).__init__(name, parent, location)

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

        # Default values
        if self.getLocation() == "R":
            ctrlColor = "red"
            bicepPosition = Vec3(-2.27, 15.295, -0.753)
            forearmPosition = Vec3(-5.039, 13.56, -0.859)
            wristPosition = Vec3(-7.1886, 12.2819, 0.4906)
        else:
            ctrlColor = "greenBright"
            bicepPosition = Vec3(2.27, 15.295, -0.753)
            forearmPosition = Vec3(5.039, 13.56, -0.859)
            wristPosition = Vec3(7.1886, 12.2819, 0.4906)

        # Calculate Bicep Xfo
        rootToWrist = wristPosition.subtract(bicepPosition).unit()
        rootToElbow = forearmPosition.subtract(bicepPosition).unit()
        bone1Normal = rootToWrist.cross(rootToElbow).unit()
        bone1ZAxis = rootToElbow.cross(bone1Normal).unit()
        bicepXfo = Xfo()
        bicepXfo.setFromVectors(rootToElbow, bone1Normal, bone1ZAxis, bicepPosition)

        # Calculate Forearm Xfo
        elbowToWrist = wristPosition.subtract(forearmPosition).unit()
        elbowToRoot = bicepPosition.subtract(forearmPosition).unit()
        bone2Normal = elbowToRoot.cross(elbowToWrist).unit()
        bone2ZAxis = elbowToWrist.cross(bone2Normal).unit()
        forearmXfo = Xfo()
        forearmXfo.setFromVectors(elbowToWrist, bone2Normal, bone2ZAxis, forearmPosition)

        # Bicep
        bicepFKCtrl = CubeControl('bicepFK')
        bicepFKCtrl.alignOnXAxis()
        bicepLen = bicepPosition.subtract(forearmPosition).length()
        bicepFKCtrl.scalePoints(Vec3(bicepLen, 1.75, 1.75))
        bicepFKCtrl.setColor(ctrlColor)
        bicepFKCtrl.xfo.copy(bicepXfo)

        bicepFKCtrlSrtBuffer = SrtBuffer('bicepFK')
        self.addChild(bicepFKCtrlSrtBuffer)
        bicepFKCtrlSrtBuffer.xfo.copy(bicepFKCtrl.xfo)
        bicepFKCtrlSrtBuffer.addChild(bicepFKCtrl)

        # Forearm
        forearmFKCtrl = CubeControl('forearmFK')
        forearmFKCtrl.alignOnXAxis()
        forearmLen = forearmPosition.subtract(wristPosition).length()
        forearmFKCtrl.scalePoints(Vec3(forearmLen, 1.5, 1.5))
        forearmFKCtrl.setColor(ctrlColor)
        forearmFKCtrl.xfo.copy(forearmXfo)

        forearmFKCtrlSrtBuffer = SrtBuffer('forearmFK')
        bicepFKCtrl.addChild(forearmFKCtrlSrtBuffer)
        forearmFKCtrlSrtBuffer.xfo.copy(forearmFKCtrl.xfo)
        forearmFKCtrlSrtBuffer.addChild(forearmFKCtrl)

        # Arm IK
        armIKCtrlSrtBuffer = SrtBuffer('IK', parent=self)
        armIKCtrlSrtBuffer.xfo.tr.copy(wristPosition)

        armIKCtrl = PinControl('IK', parent=armIKCtrlSrtBuffer)
        armIKCtrl.xfo.copy(armIKCtrlSrtBuffer.xfo)
        armIKCtrl.setColor(ctrlColor)

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


        # Add Component Params to IK control
        armDebugInputAttr = BoolAttribute('debug', True)
        armBone1LenInputAttr = FloatAttribute('bone1Len', bicepLen, 0.0, 100.0)
        armBone2LenInputAttr = FloatAttribute('bone2Len', forearmLen, 0.0, 100.0)
        armFkikInputAttr = FloatAttribute('fkik', 0.0, 0.0, 1.0)
        armSoftIKInputAttr = BoolAttribute('softIK', True)
        armSoftDistInputAttr = FloatAttribute('softDist', 0.0, 0.0, 1.0)
        armStretchInputAttr = BoolAttribute('stretch', True)
        armStretchBlendInputAttr = FloatAttribute('stretchBlend', 0.0, 0.0, 1.0)

        armSettingsAttrGrp = AttributeGroup("DisplayInfo_ArmSettings")
        armIKCtrl.addAttributeGroup(armSettingsAttrGrp)
        armSettingsAttrGrp.addAttribute(armDebugInputAttr)
        armSettingsAttrGrp.addAttribute(armBone1LenInputAttr)
        armSettingsAttrGrp.addAttribute(armBone2LenInputAttr)
        armSettingsAttrGrp.addAttribute(armFkikInputAttr)
        armSettingsAttrGrp.addAttribute(armSoftIKInputAttr)
        armSettingsAttrGrp.addAttribute(armSoftDistInputAttr)
        armSettingsAttrGrp.addAttribute(armStretchInputAttr)
        armSettingsAttrGrp.addAttribute(armStretchBlendInputAttr)

        # UpV
        upVXfo = xfoFromDirAndUpV(bicepPosition, wristPosition, forearmPosition)
        upVXfo.tr.copy(forearmPosition)
        upVOffset = Vec3(0, 0, 5)
        upVOffset = upVXfo.transformVector(upVOffset)

        armUpVCtrl = TriangleControl('UpV')
        armUpVCtrl.xfo.tr.copy(upVOffset)
        armUpVCtrl.alignOnZAxis()
        armUpVCtrl.rotatePoints(180, 0, 0)
        armUpVCtrl.setColor(ctrlColor)

        armUpVCtrlSrtBuffer = SrtBuffer('UpV')
        self.addChild(armUpVCtrlSrtBuffer)
        armUpVCtrlSrtBuffer.xfo.tr.copy(upVOffset)
        armUpVCtrlSrtBuffer.addChild(armUpVCtrl)


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

        bicepDef = Joint('bicep')
        bicepDef.setComponent(self)

        forearmDef = Joint('forearm')
        forearmDef.setComponent(self)

        wristDef = Joint('wrist')
        wristDef.setComponent(self)

        deformersLayer.addChild(bicepDef)
        deformersLayer.addChild(forearmDef)
        deformersLayer.addChild(wristDef)


        # =====================
        # Create Component I/O
        # =====================
        # Setup component Xfo I/O's
        clavicleEndInput = Locator('clavicleEnd')
        clavicleEndInput.xfo.copy(bicepXfo)

        bicepOutput = Locator('bicep')
        bicepOutput.xfo.copy(bicepXfo)
        forearmOutput = Locator('forearm')
        forearmOutput.xfo.copy(forearmXfo)

        armEndXfo = Xfo()
        armEndXfo.rot = forearmXfo.rot.clone()
        armEndXfo.tr.copy(wristPosition)
        armEndXfoOutput = Locator('armEndXfo')
        armEndXfoOutput.xfo.copy(armEndXfo)

        armEndPosOutput = Locator('armEndPos')
        armEndPosOutput.xfo.copy(armEndXfo)

        # Setup componnent Attribute I/O's
        debugInputAttr = BoolAttribute('debug', True)
        bone1LenInputAttr = FloatAttribute('bone1Len', bicepLen, 0.0, 100.0)
        bone2LenInputAttr = FloatAttribute('bone2Len', forearmLen, 0.0, 100.0)
        fkikInputAttr = FloatAttribute('fkik', 0.0, 0.0, 1.0)
        softIKInputAttr = BoolAttribute('softIK', True)
        softDistInputAttr = FloatAttribute('softDist', 0.5, 0.0, 1.0)
        stretchInputAttr = BoolAttribute('stretch', True)
        stretchBlendInputAttr = FloatAttribute('stretchBlend', 0.0, 0.0, 1.0)
        rightSideInputAttr = BoolAttribute('rightSide', location is 'R')

        # Connect attrs to control attrs
        debugInputAttr.connect(armDebugInputAttr)
        bone1LenInputAttr.connect(armBone1LenInputAttr)
        bone2LenInputAttr.connect(armBone2LenInputAttr)
        fkikInputAttr.connect(armFkikInputAttr)
        softIKInputAttr.connect(armSoftIKInputAttr)
        softDistInputAttr.connect(armSoftDistInputAttr)
        stretchInputAttr.connect(armStretchInputAttr)
        stretchBlendInputAttr.connect(armStretchBlendInputAttr)


        # ==============
        # Constrain I/O
        # ==============
        # Constraint inputs
        armRootInputConstraint = PoseConstraint('_'.join([armIKCtrl.getName(), 'To', clavicleEndInput.getName()]))
        armRootInputConstraint.setMaintainOffset(True)
        armRootInputConstraint.addConstrainer(clavicleEndInput)
        bicepFKCtrlSrtBuffer.addConstraint(armRootInputConstraint)

        # Constraint outputs


        # ==================
        # Add Component I/O
        # ==================
        # Add Xfo I/O's
        self.addInput(clavicleEndInput)
        self.addOutput(bicepOutput)
        self.addOutput(forearmOutput)
        self.addOutput(armEndXfoOutput)
        self.addOutput(armEndPosOutput)

        # Add Attribute I/O's
        self.addInput(debugInputAttr)
        self.addInput(bone1LenInputAttr)
        self.addInput(bone2LenInputAttr)
        self.addInput(fkikInputAttr)
        self.addInput(softIKInputAttr)
        self.addInput(softDistInputAttr)
        self.addInput(stretchInputAttr)
        self.addInput(stretchBlendInputAttr)
        self.addInput(rightSideInputAttr)
Example #26
0
    def __init__(self, name='mjEyelid', parent=None):

        Profiler.getInstance().push("Construct Eyelid Guide Component:" + name)
        super(mjEyelidComponentGuide, self).__init__(name, parent)

        # =========
        # Attributes // Create Attributes Controls.
        # =========
        guideUpSettingsAttrGrp = AttributeGroup("Eyelid Up", parent=self)
        guideLowSettingsAttrGrp = AttributeGroup("Eyelid Low", parent=self)

        self.numUpDeformersAttr = IntegerAttribute(
            'Num Deformers',
            value=10,
            minValue=1,
            maxValue=50,
            parent=guideUpSettingsAttrGrp)
        self.upMedialFactorAttr = ScalarAttribute(
            'Medial Blink Factor',
            value=0.25,
            minValue=0,
            maxValue=1,
            parent=guideUpSettingsAttrGrp)
        self.upLateralFactorAttr = ScalarAttribute(
            'Lateral Blink Factor',
            value=0.65,
            minValue=0,
            maxValue=1,
            parent=guideUpSettingsAttrGrp)

        self.numLowDeformersAttr = IntegerAttribute(
            'Num Deformers',
            value=10,
            minValue=1,
            maxValue=50,
            parent=guideLowSettingsAttrGrp)
        self.lowMedialFactorAttr = ScalarAttribute(
            'Medial Blink Factor',
            value=0.25,
            minValue=0,
            maxValue=1,
            parent=guideLowSettingsAttrGrp)
        self.lowLateralFactorAttr = ScalarAttribute(
            'Lateral Blink Factor',
            value=0.65,
            minValue=0,
            maxValue=1,
            parent=guideLowSettingsAttrGrp)

        self.numUpDeformersAttr.setValueChangeCallback(
            self.updateNumUpDeformers)
        self.numLowDeformersAttr.setValueChangeCallback(
            self.updateNumLowDeformers)

        # =========
        # Controls // Create the Guide Controls, Name them, give them a shape, a color and scale it.
        # =========
        self.eyeballCtrl = Control('eyeball',
                                   parent=self.ctrlCmpGrp,
                                   shape="sphere")
        self.eyeballCtrl.scalePoints(Vec3(0.35, 0.35, 0.35))
        self.eyeballCtrl.setColor("red")

        self.lidMedialCtrl = Control('lidMedial',
                                     parent=self.eyeballCtrl,
                                     shape="sphere")
        self.lidMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidMedialCtrl.setColor("peach")

        self.lidLateralCtrl = Control('lidLateral',
                                      parent=self.eyeballCtrl,
                                      shape="sphere")
        self.lidLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLateralCtrl.setColor("peach")

        self.lidUpCtrl = Control('lidUp',
                                 parent=self.eyeballCtrl,
                                 shape="sphere")
        self.lidUpCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpCtrl.setColor("peach")

        self.lidUpMedialCtrl = Control('lidUpMedial',
                                       parent=self.eyeballCtrl,
                                       shape="sphere")
        self.lidUpMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpMedialCtrl.setColor("peach")

        self.lidUpLateralCtrl = Control('lidUpLateral',
                                        parent=self.eyeballCtrl,
                                        shape="sphere")
        self.lidUpLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidUpLateralCtrl.setColor("peach")

        self.lidLowCtrl = Control('lidLow',
                                  parent=self.eyeballCtrl,
                                  shape="sphere")
        self.lidLowCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowCtrl.setColor("peach")

        self.lidLowMedialCtrl = Control('lidLowMedial',
                                        parent=self.eyeballCtrl,
                                        shape="sphere")
        self.lidLowMedialCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowMedialCtrl.setColor("peach")

        self.lidLowLateralCtrl = Control('lidLowLateral',
                                         parent=self.eyeballCtrl,
                                         shape="sphere")
        self.lidLowLateralCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        self.lidLowLateralCtrl.setColor("peach")

        # ===============
        # Add Debug Splice Ops
        # ===============
        # Add Lid Up Canvas Op
        self.debugLidUpCanvasOp = CanvasOperator(
            'Debug_Canvas_Eyelid_Up_Op', 'MJCG.Solvers.mjEyelidDebugSolver')
        self.addOperator(self.debugLidUpCanvasOp)

        # Add Attributes Inputs
        self.debugLidUpCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.debugLidUpCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.debugLidUpCanvasOp.setInput('Deformer_Count',
                                         self.numUpDeformersInputAttr)

        # Add Xfo Inputs
        self.debugLidUpCanvasOp.setInput('Eye_Center', self.eyeballCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Medial', self.lidMedialCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_MedialCen', self.lidUpMedialCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Center_Ref', self.lidUpCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Center_Ctrl', self.lidUpCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_LateralCen',
                                         self.lidUpLateralCtrl)
        self.debugLidUpCanvasOp.setInput('Lid_Lateral', self.lidLateralCtrl)

        # Add Xfo Outputs
        self.debugLidUpCanvasOp.setOutput('result',
                                          self.eyelidUpOutput.getTarget())

        # Add Lid Low Canvas Op
        self.debugLidLowCanvasOp = CanvasOperator(
            'Debug_Canvas_Eyelid_Low_Op', 'MJCG.Solvers.mjEyelidDebugSolver')
        self.addOperator(self.debugLidLowCanvasOp)

        # Add Attributes Inputs
        self.debugLidLowCanvasOp.setInput('drawDebug', self.drawDebugInputAttr)
        self.debugLidLowCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.debugLidLowCanvasOp.setInput('Deformer_Count',
                                          self.numLowDeformersInputAttr)

        # Add Xfo Inputs
        self.debugLidLowCanvasOp.setInput('Eye_Center', self.eyeballCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Medial', self.lidMedialCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_MedialCen',
                                          self.lidLowMedialCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Center_Ref', self.lidLowCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Center_Ctrl', self.lidLowCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_LateralCen',
                                          self.lidLowLateralCtrl)
        self.debugLidLowCanvasOp.setInput('Lid_Lateral', self.lidLateralCtrl)

        # Add Xfo Outputs
        self.debugLidLowCanvasOp.setOutput('result',
                                           self.eyelidLowOutput.getTarget())

        # =========
        # Position Data // Get the Guide Controls Position data, else set them at their initial position.
        # =========
        self.default_data = {
            "name": name,
            "location": "L",
            "eyeballXfo": Xfo(Vec3(0.322, 15.500, 0.390)),
            "lidMedialXfo": Xfo(Vec3(0.168, 15.445, 0.520)),
            "lidLateralXfo": Xfo(Vec3(0.465, 15.47, 0.465)),
            "lidUpXfo": Xfo(Vec3(0.322, 15.585, 0.605)),
            "lidUpMedialXfo": Xfo(Vec3(0.203, 15.515, 0.525)),
            "lidUpLateralXfo": Xfo(Vec3(0.432, 15.55, 0.538)),
            "lidLowXfo": Xfo(Vec3(0.322, 15.434, 0.6)),
            "lidLowMedialXfo": Xfo(Vec3(0.24, 15.45, 0.513)),
            "lidLowLateralXfo": Xfo(Vec3(0.413, 15.44, 0.525)),
            "lidUpMedialBlink": self.upMedialFactorAttr.getValue(),
            "lidUpLateralBlink": self.upLateralFactorAttr.getValue(),
            "lidLowMedialBlink": self.lowMedialFactorAttr.getValue(),
            "lidLowLateralBlink": self.lowLateralFactorAttr.getValue(),
            "numUpDeformers": self.numUpDeformersAttr.getValue(),
            "numLowDeformers": self.numLowDeformersAttr.getValue(),
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Example #27
0
    def __init__(self, name='mjEyelid', parent=None):
        Profiler.getInstance().push("Construct Eyelid Rig Component:" + name)
        super(mjEyelidComponentRig, self).__init__(name, parent)

        # =========
        # Controls // Get the Guide Xfos data and create the final controllers, offset them if needed.
        # =========

        # Inputs
        self.eyelidCtrlSpace = CtrlSpace('eyelid', parent=self.ctrlCmpGrp)

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

        self.eyelidUpVLocator = Locator('eyelid_Upv',
                                        parent=self.eyelidCtrlSpace)
        self.eyelidUpVLocator.setShapeVisibility(False)

        # Lid Sides
        self.lidMedialLocator = Locator('lid_Medial',
                                        parent=self.eyelidCtrlSpace)
        self.lidMedialLocator.setShapeVisibility(False)

        self.lidLateralLocator = Locator('lid_Lateral',
                                         parent=self.eyelidCtrlSpace)
        self.lidLateralLocator.setShapeVisibility(False)

        # Lid Upper
        self.lidUpCtrlSpace = CtrlSpace('lid_Up', parent=self.eyelidCtrlSpace)
        self.lidUpCtrl = Control('lid_Up',
                                 parent=self.lidUpCtrlSpace,
                                 shape="cube")
        self.lidUpCtrl.scalePoints(Vec3(0.05, 0.05, 0.05))
        self.lidUpCtrl.lockTranslation(x=True, y=False, z=True)
        self.lidUpCtrl.setColor("yellow")

        self.lipUpMedialLocator = Locator('lid_Up_Medial',
                                          parent=self.eyelidCtrlSpace)
        self.lipUpMedialLocator.setShapeVisibility(False)
        self.lipUpLateralLocator = Locator('lid_Up_Lateral',
                                           parent=self.eyelidCtrlSpace)
        self.lipUpLateralLocator.setShapeVisibility(False)

        # Lid Lower
        self.lidLowCtrlSpace = CtrlSpace('lid_Low',
                                         parent=self.eyelidCtrlSpace)
        self.lidLowCtrl = Control('lid_Low',
                                  parent=self.lidLowCtrlSpace,
                                  shape="cube")
        self.lidLowCtrl.scalePoints(Vec3(0.05, 0.05, 0.05))
        self.lidLowCtrl.lockTranslation(x=True, y=False, z=True)
        self.lidLowCtrl.setColor("yellow")

        self.lidLowMedialLocator = Locator('lid_Low_Medial',
                                           parent=self.eyelidCtrlSpace)
        self.lidLowMedialLocator.setShapeVisibility(False)
        self.lidLowLateralLocator = Locator('lid_Low_Lateral',
                                            parent=self.eyelidCtrlSpace)
        self.lidLowLateralLocator.setShapeVisibility(False)

        # Lid Attributes
        lidUp_AttrGrp = AttributeGroup("Eyelid_Settings",
                                       parent=self.lidUpCtrl)
        lidLow_AttrGrp = AttributeGroup("Eyelid_Settings",
                                        parent=self.lidLowCtrl)

        self.lidUp_OffsetInputAttr = BoolAttribute('Eyeball_Offset',
                                                   value=True,
                                                   parent=lidUp_AttrGrp)
        self.lidUp_FollowFactorInputAttr = ScalarAttribute(
            'Eyeball_Follow_Factor', value=1.0, parent=lidUp_AttrGrp)
        self.lidUp_DebugInputAttr = BoolAttribute('DrawDebug',
                                                  value=False,
                                                  parent=lidUp_AttrGrp)
        self.lidUp_MedialBlinkInputAttr = ScalarAttribute(
            'Medial_Blink_Factor', value=0.25, parent=lidUp_AttrGrp)
        self.lidUp_LateralBlinkInputAttr = ScalarAttribute(
            'Lateral_Blink_Factor', value=0.65, parent=lidUp_AttrGrp)
        self.lidUp_DefCountInputAttr = IntegerAttribute('numDeformers',
                                                        value=10,
                                                        parent=lidUp_AttrGrp)

        self.lidLow_OffsetInputAttr = BoolAttribute('Eyeball_Offset',
                                                    value=True,
                                                    parent=lidLow_AttrGrp)
        self.lidLow_FollowFactorInputAttr = ScalarAttribute(
            'Eyeball_Follow_Factor', value=0.8, parent=lidLow_AttrGrp)
        self.lidLow_DebugInputAttr = BoolAttribute('DrawDebug',
                                                   value=False,
                                                   parent=lidLow_AttrGrp)
        self.lidLow_MedialBlinkInputAttr = ScalarAttribute(
            'Medial_Blink_Factor', value=0.25, parent=lidLow_AttrGrp)
        self.lidLow_LateralBlinkInputAttr = ScalarAttribute(
            'Lateral_Blink_Factor', value=0.65, parent=lidLow_AttrGrp)
        self.lidLow_DefCountInputAttr = IntegerAttribute('numDeformers',
                                                         value=10,
                                                         parent=lidLow_AttrGrp)

        self.lidUp_DebugInputAttr.connect(self.drawDebugInputAttr)
        self.lidLow_DebugInputAttr.connect(self.drawDebugInputAttr)
        self.lidUp_DefCountInputAttr.connect(self.numUpDeformersInputAttr)
        self.lidLow_DefCountInputAttr.connect(self.numLowDeformersInputAttr)

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

        # Lid Sides
        lidMedialDef = Joint('lid_Medial', parent=self.defCmpGrp)
        lidMedialDef.setComponent(self)

        lidLateralDef = Joint('lid_Lateral', parent=self.defCmpGrp)
        lidLateralDef.setComponent(self)

        # Lid Up
        self.eyelidUpDef = []
        self.eyelidUpOutputs = []
        self.setNumUpDeformers(1)

        # Lid Low
        self.eyelidLowDef = []
        self.eyelidLowOutputs = []
        self.setNumLowDeformers(1)

        # =====================
        # Create Component I/O
        # =====================
        # Setup component Xfo I/O's
        self.eyelidUpOutput.setTarget(self.eyelidUpOutputs)
        self.eyelidLowOutput.setTarget(self.eyelidLowOutputs)

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

        self.eyeballInputConstraint = PoseConstraint('_'.join([
            self.eyeballLocator.getName(), 'To',
            self.eyeballInputTgt.getName()
        ]))
        self.eyeballInputConstraint.setMaintainOffset(True)
        self.eyeballInputConstraint.addConstrainer(self.eyeballInputTgt)
        self.eyeballLocator.addConstraint(self.eyeballInputConstraint)

        # ===============
        # Add Splice Ops
        # ===============
        # Add MultiPoseConstraint Joints Splice Op
        self.outputsToDeformersKLOp = KLOperator('Canvas_Eyelid_Side_Op',
                                                 '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.lidMedialLocator,
            self.lidLateralLocator,
        ])
        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [
            lidMedialDef,
            lidLateralDef,
        ])

        # Add Lid Up Canvas Op
        self.lidUpCanvasOp = CanvasOperator(
            'Canvas_Eyelid_Up_Op', 'MJCG.Solvers.mjEyelidConstraintSolver')
        self.addOperator(self.lidUpCanvasOp)

        # Add Attributes Inputs
        self.lidUpCanvasOp.setInput('drawDebug', self.lidUp_DebugInputAttr)
        self.lidUpCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.lidUpCanvasOp.setInput('Eyeball_Offset',
                                    self.lidUp_OffsetInputAttr)
        self.lidUpCanvasOp.setInput('Eyeball_Follow_Factor',
                                    self.lidUp_FollowFactorInputAttr)
        self.lidUpCanvasOp.setInput('Medial_Blink_Factor',
                                    self.lidUp_MedialBlinkInputAttr)
        self.lidUpCanvasOp.setInput('Lateral_Blink_Factor',
                                    self.lidUp_LateralBlinkInputAttr)
        self.lidUpCanvasOp.setInput('Deformer_Count',
                                    self.lidUp_DefCountInputAttr)

        # Add Xfo Inputs
        self.lidUpCanvasOp.setInput('Eye_Center', self.eyeballLocator)
        self.lidUpCanvasOp.setInput('Lid_Global', self.eyelidCtrlSpace)
        self.lidUpCanvasOp.setInput('Lid_UpV', self.eyelidUpVLocator)
        self.lidUpCanvasOp.setInput('Lid_Medial', self.lidMedialLocator)
        self.lidUpCanvasOp.setInput('Lid_MedialCen', self.lipUpMedialLocator)
        self.lidUpCanvasOp.setInput('Lid_Center_Ref', self.lidUpCtrlSpace)
        self.lidUpCanvasOp.setInput('Lid_Center_Ctrl', self.lidUpCtrl)
        self.lidUpCanvasOp.setInput('Lid_LateralCen', self.lipUpLateralLocator)
        self.lidUpCanvasOp.setInput('Lid_Lateral', self.lidLateralLocator)
        #Add Xfo Outputs
        self.lidUpCanvasOp.setOutput('result', self.eyelidUpDef)

        # Add Lid Low Canvas Op
        self.lidLowCanvasOp = CanvasOperator(
            'Canvas_Eyelid_Low_Op', 'MJCG.Solvers.mjEyelidConstraintSolver')
        self.addOperator(self.lidLowCanvasOp)

        # Add Attributes Inputs
        self.lidLowCanvasOp.setInput('drawDebug', self.lidLow_DebugInputAttr)
        self.lidLowCanvasOp.setInput('rigScale', self.rigScaleInputAttr)
        self.lidLowCanvasOp.setInput('Eyeball_Offset',
                                     self.lidLow_OffsetInputAttr)
        self.lidLowCanvasOp.setInput('Eyeball_Follow_Factor',
                                     self.lidLow_FollowFactorInputAttr)
        self.lidLowCanvasOp.setInput('Medial_Blink_Factor',
                                     self.lidLow_MedialBlinkInputAttr)
        self.lidLowCanvasOp.setInput('Lateral_Blink_Factor',
                                     self.lidLow_LateralBlinkInputAttr)
        self.lidLowCanvasOp.setInput('Deformer_Count',
                                     self.lidLow_DefCountInputAttr)

        # Add Xfo Inputs
        self.lidLowCanvasOp.setInput('Eye_Center', self.eyeballLocator)
        self.lidLowCanvasOp.setInput('Lid_Global', self.eyelidCtrlSpace)
        self.lidLowCanvasOp.setInput('Lid_UpV', self.eyelidUpVLocator)
        self.lidLowCanvasOp.setInput('Lid_Medial', self.lidMedialLocator)
        self.lidLowCanvasOp.setInput('Lid_MedialCen', self.lidLowMedialLocator)
        self.lidLowCanvasOp.setInput('Lid_Center_Ref', self.lidLowCtrlSpace)
        self.lidLowCanvasOp.setInput('Lid_Center_Ctrl', self.lidLowCtrl)
        self.lidLowCanvasOp.setInput('Lid_LateralCen',
                                     self.lidLowLateralLocator)
        self.lidLowCanvasOp.setInput('Lid_Lateral', self.lidLateralLocator)

        #Add Xfo Outputs
        self.lidLowCanvasOp.setOutput('result', self.eyelidLowDef)

        Profiler.getInstance().pop()
Example #28
0
    def __init__(self, name, parent=None, location='M'):
        super(FootComponent, 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"
            footPosition = Vec3(-7.1886, 12.2819, 0.4906)
            footUpV = Vec3(-1.7454, 0.1922, -1.7397)
            footEndPosition = Vec3(-2.0939, 0.4288, 0.0944)
        else:
            ctrlColor = "greenBright"
            footPosition = Vec3(7.1886, 12.2819, 0.4906)
            footUpV = Vec3(1.7454, 0.1922, -1.7397)
            footEndPosition = Vec3(2.0939, 0.4288, 0.0944)

        # Calculate Clavicle Xfo
        rootToEnd = footEndPosition.subtract(footPosition).unit()
        rootToUpV = footUpV.subtract(footPosition).unit()
        bone1ZAxis = rootToEnd.cross(rootToUpV).unit()
        bone1Normal = rootToEnd.cross(bone1ZAxis).unit()
        footXfo = Xfo()

        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)
Example #29
0
    def addFinger(self, name):

        digitSizeAttributes = []
        fingerGuideCtrls = []

        firstDigitCtrl = Control(name + "01", parent=self.handCtrl, shape='sphere')
        firstDigitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))

        firstDigitShapeCtrl = Control(name + "Shp01", parent=self.guideCtrlHrcGrp, shape='square')
        firstDigitShapeCtrl.setColor('yellow')
        firstDigitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
        firstDigitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
        fingerGuideCtrls.append(firstDigitShapeCtrl)
        firstDigitCtrl.shapeCtrl = firstDigitShapeCtrl

        firstDigitVisAttr = firstDigitShapeCtrl.getVisibilityAttr()
        firstDigitVisAttr.connect(self.ctrlShapeToggle)

        triangleCtrl = Control('tempCtrl', parent=None, shape='triangle')
        triangleCtrl.rotatePoints(90.0, 0.0, 0.0)
        triangleCtrl.scalePoints(Vec3(0.025, 0.025, 0.025))
        triangleCtrl.translatePoints(Vec3(0.0, 0.0875, 0.0))

        firstDigitCtrl.appendCurveData(triangleCtrl.getCurveData())
        firstDigitCtrl.lockScale(True, True, True)

        digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=firstDigitCtrl)
        digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
        digitSizeAttributes.append(digitSizeAttr)

        # Set Finger
        self.fingers[name] = []
        self.fingers[name].append(firstDigitCtrl)

        parent = firstDigitCtrl
        numJoints = self.numJointsAttr.getValue()
        if name == "thumb":
            numJoints = 3
        for i in xrange(2, numJoints + 2):
            digitCtrl = Control(name + str(i).zfill(2), parent=parent, shape='sphere')

            if i != numJoints + 1:
                digitCtrl.scalePoints(Vec3(0.125, 0.125, 0.125))
                digitCtrl.appendCurveData(triangleCtrl.getCurveData())

                digitShapeCtrl = Control(name + 'Shp' + str(i).zfill(2), parent=self.guideCtrlHrcGrp, shape='circle')
                digitShapeCtrl.setColor('yellow')
                digitShapeCtrl.scalePoints(Vec3(0.175, 0.175, 0.175))
                digitShapeCtrl.getVisibilityAttr().connect(self.ctrlShapeToggle)

                digitCtrl.shapeCtrl = digitShapeCtrl

                if i == 2:
                    digitShapeCtrl.translatePoints(Vec3(0.0, 0.125, 0.0))
                else:
                    digitShapeCtrl.rotatePoints(0.0, 0.0, 90.0)

                fingerGuideCtrls.append(digitShapeCtrl)

                # Add size attr to all but last guide control
                digitSettingsAttrGrp = AttributeGroup("DigitSettings", parent=digitCtrl)
                digitSizeAttr = ScalarAttribute('size', value=0.25, parent=digitSettingsAttrGrp)
                digitSizeAttributes.append(digitSizeAttr)
            else:
                digitCtrl.scalePoints(Vec3(0.0875, 0.0875, 0.0875))

            digitCtrl.lockScale(True, True, True)

            self.fingers[name].append(digitCtrl)

            parent = digitCtrl

        # ===========================
        # Create Canvas Operators
        # ===========================
        # Add Finger Guide Canvas Op
        fingerGuideCanvasOp = CanvasOperator(name + 'FingerGuide', 'Kraken.Solvers.Biped.BipedFingerGuideSolver')
        self.addOperator(fingerGuideCanvasOp)

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

        # Add Xfo Inputs
        fingerGuideCanvasOp.setInput('controls', self.fingers[name])
        fingerGuideCanvasOp.setInput('planeSizes', digitSizeAttributes)

        # Add Xfo Outputs
        fingerGuideCanvasOp.setOutput('result', fingerGuideCtrls)
        fingerGuideCanvasOp.setOutput('forceEval', firstDigitCtrl.getVisibilityAttr())

        return firstDigitCtrl
Example #30
0
    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)

        # Constraint outputs
        self.footOutputConstraint = PoseConstraint('_'.join([self.footOutputTgt.getName(), 'To', self.footCtrl.getName()]))
        self.footOutputConstraint.addConstrainer(self.footCtrl)
        self.footOutputTgt.addConstraint(self.footOutputConstraint)

        self.toeOutputConstraint = PoseConstraint('_'.join([self.toeOutputTgt.getName(), 'To', self.toeCtrl.getName()]))
        self.toeOutputConstraint.addConstrainer(self.toeCtrl)
        self.toeOutputTgt.addConstraint(self.toeOutputConstraint)


        # ===============
        # Add Splice Ops
        # ===============
        # Add Leg Splice Op
        self.legIKSpliceOp = SpliceOperator('legSpliceOp', 'TwoBoneIKSolver', 'Kraken')
        self.addOperator(self.legIKSpliceOp)

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

        self.legIKSpliceOp.setInput('bone0Len', self.legBone0LenInputAttr)
        self.legIKSpliceOp.setInput('bone1Len', self.legBone1LenInputAttr)
        self.legIKSpliceOp.setInput('ikblend', legIKBlendInputAttr)
        self.legIKSpliceOp.setInput('softIK', legSoftIKInputAttr)
        self.legIKSpliceOp.setInput('softDist', legSoftDistInputAttr)
        self.legIKSpliceOp.setInput('stretch', legStretchInputAttr)
        self.legIKSpliceOp.setInput('stretchBlend', legStretchBlendInputAttr)
        self.legIKSpliceOp.setInput('rightSide', self.rightSideInputAttr)

        # Add Xfo Inputs
        self.legIKSpliceOp.setInput('root', self.legPelvisInputTgt)
        self.legIKSpliceOp.setInput('bone0FK', self.femurFKCtrl)
        self.legIKSpliceOp.setInput('bone1FK', self.shinFKCtrl)
        self.legIKSpliceOp.setInput('ikHandle', self.legIKCtrl)
        self.legIKSpliceOp.setInput('upV', self.legUpVCtrl)

        # Add Xfo Outputs
        self.legIKSpliceOp.setOutput('bone0Out', self.femurOutputTgt)
        self.legIKSpliceOp.setOutput('bone1Out', self.shinOutputTgt)
        self.legIKSpliceOp.setOutput('bone2Out', self.legEndXfoOutputTgt)


        # Add Leg Deformer Splice Op
        self.outputsToDeformersSpliceOp = SpliceOperator('legDeformerSpliceOp', '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.femurOutputTgt, self.shinOutputTgt, self.legEndXfoOutputTgt])

        # 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()
Example #31
0
    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()
        self.femurFKCtrl.lockTranslation(True, True, True)
        self.femurFKCtrl.lockScale(True, True, True)

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

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

        # Add Component Params to IK control
        legSettingsAttrGrp = AttributeGroup("DisplayInfo_LegSettings", parent=self.legIKCtrl)
        legDrawDebugInputAttr = BoolAttribute('drawDebug', value=False, parent=legSettingsAttrGrp)
        self.legRightSideInputAttr = BoolAttribute('rightSide', 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)

        # Util Objects
        self.ikRootPosition = Transform("ikRootPosition", parent=self.ctrlCmpGrp)

        # Connect Input Attrs
        self.drawDebugInputAttr.connect(legDrawDebugInputAttr)

        # Connect Output Attrs
        self.drawDebugOutputAttr.connect(legDrawDebugInputAttr)
        self.ikBlendOutputAttr.connect(legIKBlendInputAttr)

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


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

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

        kneeDef = Joint('knee', parent=self.defCmpGrp)
        kneeDef.setComponent(self)

        shinDef = Joint('shin', parent=self.defCmpGrp)
        shinDef.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.femurFKCtrlSpace.getName(), 'To', self.legPelvisInputTgt.getName()]))
        self.legRootInputConstraint.setMaintainOffset(True)
        self.legRootInputConstraint.addConstrainer(self.legPelvisInputTgt)
        self.femurFKCtrlSpace.addConstraint(self.legRootInputConstraint)

        self.ikRootPosInputConstraint = PoseConstraint('_'.join([self.ikRootPosition.getName(), 'To', self.legPelvisInputTgt.getName()]))
        self.ikRootPosInputConstraint.setMaintainOffset(True)
        self.ikRootPosInputConstraint.addConstrainer(self.legPelvisInputTgt)
        self.ikRootPosition.addConstraint(self.ikRootPosInputConstraint)

        # Constraint outputs
        self.legEndFKOutputConstraint = PoseConstraint('_'.join([self.legEndFKOutputTgt.getName(), 'To', self.shinFKCtrl.getName()]))
        self.legEndFKOutputConstraint.setMaintainOffset(True)
        self.legEndFKOutputConstraint.addConstrainer(self.shinFKCtrl)
        self.legEndFKOutputTgt.addConstraint(self.legEndFKOutputConstraint)

        self.ikHandleOutputConstraint = PoseConstraint('_'.join([self.ikHandleOutputTgt.getName(), 'To', self.legIKCtrl.getName()]))
        self.ikHandleOutputConstraint.setMaintainOffset(True)
        self.ikHandleOutputConstraint.addConstrainer(self.legIKCtrl)
        self.ikHandleOutputTgt.addConstraint(self.ikHandleOutputConstraint)


        # ===============
        # Add Splice Ops
        # ===============
        # Add Leg Splice Op
        self.legIKKLOp = KLOperator('legKLOp', 'TwoBoneIKSolver', 'Kraken')
        self.addOperator(self.legIKKLOp)

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

        self.legIKKLOp.setInput('bone0Len', self.legBone0LenInputAttr)
        self.legIKKLOp.setInput('bone1Len', self.legBone1LenInputAttr)
        self.legIKKLOp.setInput('ikblend', legIKBlendInputAttr)
        self.legIKKLOp.setInput('rightSide', self.legRightSideInputAttr)

        # Add Xfo Inputs
        self.legIKKLOp.setInput('root', self.ikRootPosition)
        self.legIKKLOp.setInput('bone0FK', self.femurFKCtrl)
        self.legIKKLOp.setInput('bone1FK', self.shinFKCtrl)
        self.legIKKLOp.setInput('ikHandle', self.legIKTargetInputTgt)
        self.legIKKLOp.setInput('upV', self.legUpVCtrl)

        # Add Xfo Outputs
        self.legIKKLOp.setOutput('bone0Out', self.femurOutputTgt)
        self.legIKKLOp.setOutput('bone1Out', self.shinOutputTgt)
        self.legIKKLOp.setOutput('bone2Out', self.legEndOutputTgt)
        self.legIKKLOp.setOutput('midJointOut', self.kneeOutputTgt)


        # Add Leg Deformer Splice Op
        self.outputsToDeformersKLOp = KLOperator('legDeformerKLOp', '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.femurOutputTgt, self.kneeOutputTgt, self.shinOutputTgt])

        # Add Xfo Outputs
        self.outputsToDeformersKLOp.setOutput('constrainees', [femurDef, kneeDef, shinDef])

        Profiler.getInstance().pop()
Example #32
0
    def __init__(self, name='tail', parent=None):

        Profiler.getInstance().push("Construct Fabrice Tail Guide Component:" + name)
        super(FabriceTailGuide, self).__init__(name, parent)

        # =========
        # Controls
        # ========
        guideSettingsAttrGrp = AttributeGroup("GuideSettings", parent=self)
        self.numDeformersAttr = IntegerAttribute('numDeformers', value=1, minValue=0, maxValue=20, parent=guideSettingsAttrGrp)
        self.numDeformersAttr.setValueChangeCallback(self.updateNumDeformers)


        # Guide Controls
        self.tailBaseCtrl = Control('tailBase', parent=self.ctrlCmpGrp, shape='sphere')
        self.tailBaseCtrl.scalePoints(Vec3(1.2, 1.2, 1.2))
        self.tailBaseCtrl.lockScale(x=True, y=True, z=True)
        self.tailBaseCtrl.setColor("turqoise")

        self.tailBaseHandleCtrl = Control('tailBaseHandle', parent=self.ctrlCmpGrp, shape='pin')
        self.tailBaseHandleCtrl.rotatePoints(90, 0, 0)
        self.tailBaseHandleCtrl.translatePoints(Vec3(0, 1.0, 0))
        self.tailBaseHandleCtrl.lockScale(x=True, y=True, z=True)
        self.tailBaseHandleCtrl.setColor("turqoise")

        self.tailEndHandleCtrl = Control('tailEndHandle', parent=self.ctrlCmpGrp, shape='pin')
        self.tailEndHandleCtrl.rotatePoints(90, 0, 0)
        self.tailEndHandleCtrl.translatePoints(Vec3(0, 1.0, 0))
        self.tailEndHandleCtrl.lockScale(x=True, y=True, z=True)
        self.tailEndHandleCtrl.setColor("turqoise")

        self.tailEndCtrl = Control('tailEnd', parent=self.ctrlCmpGrp, shape='pin')
        self.tailEndCtrl.rotatePoints(90, 0, 0)
        self.tailEndCtrl.translatePoints(Vec3(0, 1.0, 0))
        self.tailEndCtrl.lockScale(x=True, y=True, z=True)
        self.tailEndCtrl.setColor("turqoise")

        # ===============
        # Add Splice Ops
        # ===============
        # Add Tail Splice Op
        self.bezierSpineSpliceOp = SpliceOperator('spineGuideSpliceOp', 'BezierSpineSolver', 'Kraken', alwaysEval=True)
        self.bezierSpineSpliceOp.setOutput('outputs', self.tailVertebraeOutput.getTarget())

        self.addOperator(self.bezierSpineSpliceOp)

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

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

        self.loadData({
            'name': name,
            'location': 'M',
            'tailBasePos': Vec3(0.0, 0.65, -3.1),
            'tailBaseHandlePos': Vec3(0.0, 0.157, -4.7),
            'tailBaseHandleCtrlCrvData': self.tailBaseHandleCtrl.getCurveData(),
            'tailEndHandlePos': Vec3(0.0, 0.0625, -6.165),
            'tailEndHandleCtrlCrvData': self.tailEndHandleCtrl.getCurveData(),
            'tailEndPos': Vec3(0.0, -0.22, -7.42),
            'tailEndCtrlCrvData': self.tailEndCtrl.getCurveData(),
            'numDeformers': 6
        })

        Profiler.getInstance().pop()
Example #33
0
    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)

        # 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()