Esempio n. 1
0
    def rotatePoints(self, xRot, yRot, zRot):
        """Rotates the points by the input values.

        Args:
            xRot (float): Euler x rotate value.
            yRot (float): Euler y rotate value.
            zRot (float): Euler z rotate value.

        Returns:
            bool: True if successful.

        """

        curveData = list(self.getCurveData())

        quatRot = Quat()
        quatRot.setFromEuler(Euler(Math_degToRad(xRot), Math_degToRad(yRot),
                                   Math_degToRad(zRot)))

        for eachSubCurve in curveData:

            for eachPoint in eachSubCurve["points"]:
                pointVec = Vec3(eachPoint[0], eachPoint[1], eachPoint[2])
                rotVec = quatRot.rotateVector(pointVec)
                eachPoint[0] = rotVec.x
                eachPoint[1] = rotVec.y
                eachPoint[2] = rotVec.z

        self.setCurveData(curveData)

        return True
Esempio n. 2
0
    def rotatePoints(self, xRot, yRot, zRot):
        """Rotates the points by the input values.

        Arguments:
        xRot -- Float, euler x rotate value.
        yRot -- Float, euler y rotate value.
        zRot -- Float, euler z rotate value.

        Return:
        True if successful.

        """

        curveData = list(self.getCurveData())

        quatRot = Quat()
        quatRot.setFromEuler(
            Euler(Math_degToRad(xRot), Math_degToRad(yRot),
                  Math_degToRad(zRot)))

        newPoints = []
        for eachSubCurve in curveData:

            for eachPoint in eachSubCurve["points"]:
                pointVec = Vec3(eachPoint[0], eachPoint[1], eachPoint[2])
                rotVec = quatRot.rotateVector(pointVec)
                eachPoint[0] = rotVec.x
                eachPoint[1] = rotVec.y
                eachPoint[2] = rotVec.z

        self.setCurveData(curveData)

        return True
Esempio n. 3
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        if kObject.isOfAnyType(('Rig', 'Container', 'Layer', 'HierarchyGroup',
                                'ComponentInput', 'ComponentOutput')):
            logger.debug("SyncXfo: Skipping '" + kObject.getName() + "'!")
            return False

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            logger.warning("SyncXfo: 3D Object '" + kObject.getName() +
                           "' was not found in the mapping!")
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            logger.warning("SyncXfo: No DCC Item for :" + kObject.getPath())
            return False

        dccPos = dccItem.GetWorldPosition()
        dccQuat = dccItem.GetWorldRotation()
        dccScl = dccItem.GetWorldScale()

        pos = Vec3(x=dccPos.X, y=dccPos.Y, z=dccPos.Z)
        quat = Quat(v=Vec3(dccQuat.X, dccQuat.Y, dccQuat.Z), w=dccQuat.W)

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(x=dccScl.X, y=dccScl.Y, z=dccScl.Z)
        else:
            scl = Vec3(1.0, 1.0, 1.0)

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)
        rotateUpXfo = Xfo()
        rotateUpXfo.ori = Quat().setFromAxisAndAngle(Vec3(1, 0, 0),
                                                     Math_degToRad(-90))
        newXfo = rotateUpXfo * newXfo

        kObject.xfo = newXfo

        return True
Esempio n. 4
0
def buildArm(mode='guide'):

    Profiler.getInstance().push("arm_build")

    guideContainer = Container('armGuide')

    armGuide = ArmComponentGuide("arm", parent=guideContainer)
    armGuide.loadData({
        "name":
        "Arm",
        "location":
        "L",
        "bicepXfo":
        Xfo(Vec3(2.27, 15.295, -0.753)),
        "forearmXfo":
        Xfo(Vec3(5.039, 13.56, -0.859)),
        "wristXfo":
        Xfo(Vec3(7.1886, 12.2819, 0.4906)),
        "handXfo":
        Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
            ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
        "bicepFKCtrlSize":
        1.75,
        "forearmFKCtrlSize":
        1.5
    })

    if mode == 'guide':
        builder = plugins.getBuilder()
        builder.build(guideContainer)

    elif mode == 'rig':
        synchronizer = plugins.getSynchronizer()
        synchronizer.setTarget(guideContainer)
        synchronizer.sync()

        armGuideData = armGuide.getRigBuildData()

        rigContainer = Container('armRig')
        arm = ArmComponent(parent=rigContainer)
        arm.loadData(armGuideData)

        builder = plugins.getBuilder()
        builder.build(rigContainer)
    else:
        LogMessage('Invalid mode set')

    Profiler.getInstance().pop()

    if __name__ == "__main__":
        print Profiler.getInstance().generateReport()
    else:
        if mode == 'guide':
            logHierarchy(armGuide)
        elif mode == 'rig':
            logHierarchy(arm)
Esempio n. 5
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            ogger.warning("SyncXfo: 3D Object '" + kObject.getName() +
                          "' was not found in the mapping!")
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            logger.warning("SyncXfo: Syncing. No DCC Item for :" +
                           kObject.getPath())
            return False

        dccPos = dccItem.getTranslation(space='world')
        dccQuat = dccItem.getRotation(space='world', quaternion=True).get()
        dccScl = dccItem.getScale()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[0], dccQuat[1], dccQuat[2]), w=dccQuat[3])

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])
        else:
            scl = Vec3(1.0, 1.0, 1.0)

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
Esempio n. 6
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): object to sync the xfo for.

        Returns:
            Boolean: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            log("Warning! 3D Object '" + kObject.getName() + "' was not found in the mapping!", 8)
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            log("Warning Syncing. No DCC Item for :" + kObject.getPath(), 8)
            return False

        dccXfo = dccItem.Kinematics.Global.GetTransform2(None)
        dccPos = dccXfo.Translation.Get2()
        dccQuat = dccXfo.Rotation.Quaternion.Get2()
        dccScl = dccXfo.Scaling.Get2()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[1], dccQuat[2], dccQuat[3]), w=dccQuat[0])

        # If flag is set, pass the DCC Scale values.
        if kObject.testFlag('SYNC_SCALE') is True:
            scl = Vec3(1.0, 1.0, 1.0)
        else:
            scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
Esempio n. 7
0
    def syncXfo(self, kObject):
        """Syncs the xfo from the DCC object to the Kraken object.

        Args:
            kObject (object): Object to sync the xfo for.

        Returns:
            bool: True if successful.

        """

        hrcMap = self.getHierarchyMap()

        if kObject not in hrcMap.keys():
            print "Warning! 3D Object '" + kObject.getName(
            ) + "' was not found in the mapping!"
            return False

        dccItem = hrcMap[kObject]['dccItem']

        if dccItem is None:
            print "Warning Syncing. No DCC Item for :" + kObject.getPath()
            return

        dccPos = dccItem.getTranslation(space='world')
        dccQuat = dccItem.getRotation(space='world', quaternion=True).get()
        dccScl = dccItem.getScale()

        pos = Vec3(x=dccPos[0], y=dccPos[1], z=dccPos[2])
        quat = Quat(v=Vec3(dccQuat[0], dccQuat[1], dccQuat[2]), w=dccQuat[3])
        scl = Vec3(x=dccScl[0], y=dccScl[1], z=dccScl[2])

        newXfo = Xfo(tr=pos, ori=quat, sc=scl)

        kObject.xfo = newXfo

        return True
Esempio n. 8
0
    def __init__(self, name='neck', parent=None, *args, **kwargs):

        Profiler.getInstance().push('Construct Neck Component:' + name)
        super(NeckComponentGuide, self).__init__(name, parent, *args, **kwargs)

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

        # Guide Controls
        self.neckCtrl = Control('neck', parent=self.ctrlCmpGrp, shape='sphere')
        self.neckCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckMidCtrl = Control('neckMid',
                                   parent=self.ctrlCmpGrp,
                                   shape='sphere')
        self.neckMidCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckEndCtrl = Control('neckEnd',
                                   parent=self.ctrlCmpGrp,
                                   shape='sphere')
        self.neckEndCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.neckCtrlShape = Control('neck',
                                     parent=self.ctrlCmpGrp,
                                     shape='pin')
        self.neckCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckCtrlShape.setColor('orange')
        self.neckMidCtrlShape = Control('neckMid',
                                        parent=self.ctrlCmpGrp,
                                        shape='pin')
        self.neckMidCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckMidCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckMidCtrlShape.setColor('orange')

        # Guide Operator
        self.neckGuideKLOp = KLOperator(name + 'GuideKLOp', 'NeckGuideSolver',
                                        'Kraken')
        self.addOperator(self.neckGuideKLOp)

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

        # Add Source Inputs
        self.neckGuideKLOp.setInput(
            'sources', [self.neckCtrl, self.neckMidCtrl, self.neckEndCtrl])

        # Add Target Outputs
        self.neckGuideKLOp.setOutput(
            'targets', [self.neckCtrlShape, self.neckMidCtrlShape])

        # Calculate default values
        neckVec = Vec3(0.0, 16.00, -0.75)
        neckMidVec = Vec3(0.0, 16.50, -0.50)
        neckEndVec = Vec3(0.0, 17.00, -0.25)
        upVector = Vec3(0.0, 0.0, -1.0)

        neckOri = Quat()
        neckOri.setFromDirectionAndUpvector(
            (neckMidVec - neckVec).unit(),
            ((neckVec + upVector) - neckVec).unit())

        neckMidOri = Quat()
        neckMidOri.setFromDirectionAndUpvector(
            (neckEndVec - neckMidVec).unit(),
            ((neckMidVec + upVector) - neckMidVec).unit())

        self.default_data = {
            "name": name,
            "location": "M",
            "neckXfo": Xfo(tr=neckVec, ori=neckOri),
            "neckMidXfo": Xfo(tr=neckMidVec, ori=neckMidOri),
            "neckEndXfo": Xfo(tr=neckEndVec, ori=neckMidOri),
            "neckCrvData": self.neckCtrlShape.getCurveData(),
            "neckMidCrvData": self.neckMidCtrlShape.getCurveData()
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Esempio n. 9
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BipedGuideRig:" + name)
        super(BipedGuideRig, self).__init__(name)

        # ===========
        # Components
        # ===========
        mainSrtComponentGuide = MainSrtComponentGuide('mainSrt', parent=self)
        spineComponentGuide = SpineComponentGuide('spine', parent=self)
        neckComponentGuide = NeckComponentGuide('neck', parent=self)
        headComponentGuide = HeadComponentGuide('head', parent=self)

        clavicleLeftComponentGuide = ClavicleComponentGuide('clavicle', parent=self)
        clavicleRightComponentGuide = ClavicleComponentGuide('clavicle', parent=self)
        clavicleRightComponentGuide.loadData({
            "name": 'clavicle',
            "location": 'R',
            "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))
        })


        armLeftComponentGuide = ArmComponentGuide('arm', parent=self)
        armRightComponentGuide = ArmComponentGuide('arm', parent=self)
        armRightComponentGuide.loadData({
            "name": 'arm',
            "location": 'R',
            "bicepXfo": Xfo(Vec3(-2.275, 15.3, -0.75)),
            "forearmXfo": Xfo(Vec3(-5.0, 13.5, -0.75)),
            "wristXfo": Xfo(Vec3(-7.2, 12.25, 0.5)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        handLeftComponentGuide = HandComponentGuide('hand', parent=self)
        handRightComponentGuide = HandComponentGuide('hand', parent=self)

        handRightOri = Quat()
        handRightOri.setFromAxisAndAngle(Vec3(0, 1, 0), Math_degToRad(180))

        handRightComponentGuide.loadData({
            "name": 'hand',
            "location": 'R',
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906), ori=handRightOri),
            "digitNames": "thumb,index,middle,ring,pinky",
            "numJoints": 4,
            "fingersGuideXfos": {
                "pinky": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.0),
                        ori=handRightOri)
                ],
                "index": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.75),
                        ori=handRightOri)
                ],
                "ring": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.25),
                        ori=handRightOri)
                ],
                "thumb": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=1.0),
                        ori=handRightOri)
                ],
                "middle": [
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.439000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-7.814000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.064000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.314000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri),
                    Xfo(sc=Vec3(y=1.0, x=1.0, z=1.0),
                        tr=Vec3(x=-8.564000129699707, y=12.281900405883789, z=0.5),
                        ori=handRightOri)
                ]
            }
        })

        legLeftComponentGuide = LegComponentGuide('leg', parent=self)
        legRightComponentGuide = LegComponentGuide('leg', parent=self)
        legRightComponentGuide.loadData({
            "name": 'leg',
            "location": 'R',
            "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))
        })

        footLeftComponentGuide = FootComponentGuide('foot', parent=self)
        footRightComponentGuide = FootComponentGuide('foot', parent=self)
        footRightComponentGuide.loadData({
            "name": 'foot',
            "location": 'R',
            '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))
        })

        # ============
        # Connections
        # ============

        # =======
        # Outputs
        # =======
        mainSrtRigScaleOutput = mainSrtComponentGuide.getOutputByName('rigScale')
        mainSrtOffsetOutput = mainSrtComponentGuide.getOutputByName('offset')
        spineEndOutput = spineComponentGuide.getOutputByName('spineEnd')
        neckEndOutput = neckComponentGuide.getOutputByName('neckEnd')
        clavicleLeftEndOutput = clavicleLeftComponentGuide.getOutputByName('clavicleEnd')
        clavicleRightEndOutput = clavicleRightComponentGuide.getOutputByName('clavicleEnd')
        spinePelvisOutput = spineComponentGuide.getOutputByName('pelvis')

        # Arm Left
        armLeftWristOutput = armLeftComponentGuide.getOutputByName('wrist')

        # Arm Right
        armRightWristOutput = armRightComponentGuide.getOutputByName('wrist')

        # Leg Left
        legLeftIkHandleOutput = legLeftComponentGuide.getOutputByName('ikHandle')
        legLeftLegEndOutput = legLeftComponentGuide.getOutputByName('legEnd')
        legLeftLegEndFKOutput = legLeftComponentGuide.getOutputByName('legEndFK')

        # Leg Right
        legRightIkHandleOutput = legRightComponentGuide.getOutputByName('ikHandle')
        legRightLegEndOutput = legRightComponentGuide.getOutputByName('legEnd')
        legRightLegEndFKOutput = legRightComponentGuide.getOutputByName('legEndFK')

        # Foot Left
        footLeftIkTargetOutput = footLeftComponentGuide.getOutputByName('ikTarget')

        # Foot Right
        footRightIkTargetOutput = footRightComponentGuide.getOutputByName('ikTarget')

        # =========================
        # Inputs & Set Connections
        # =========================
        # Spine
        spineGlobalSrtInput = spineComponentGuide.getInputByName('globalSRT')
        spineGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        spineRigScaleInput = spineComponentGuide.getInputByName('rigScale')
        spineRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Neck
        neckGlobalSrtInput = neckComponentGuide.getInputByName('globalSRT')
        neckGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        neckSpineEndInput = neckComponentGuide.getInputByName('neckBase')
        neckSpineEndInput.setConnection(spineEndOutput)

        # Head
        headGlobalSrtInput = headComponentGuide.getInputByName('globalSRT')
        headGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        headBaseInput = headComponentGuide.getInputByName('neckRef')
        headBaseInput.setConnection(neckEndOutput)

        headBaseInput = headComponentGuide.getInputByName('worldRef')
        headBaseInput.setConnection(mainSrtOffsetOutput)

        # Clavicle Left
        clavicleLeftGlobalSrtInput = clavicleLeftComponentGuide.getInputByName('globalSRT')
        clavicleLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        clavicleLeftSpineEndInput = clavicleLeftComponentGuide.getInputByName('spineEnd')
        clavicleLeftSpineEndInput.setConnection(spineEndOutput)

        # Clavicle Right
        clavicleRightGlobalSrtInput = clavicleRightComponentGuide.getInputByName('globalSRT')
        clavicleRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        clavicleRightSpineEndInput = clavicleRightComponentGuide.getInputByName('spineEnd')
        clavicleRightSpineEndInput.setConnection(spineEndOutput)

        # Arm Left
        armLeftGlobalSrtInput = armLeftComponentGuide.getInputByName('globalSRT')
        armLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        armLeftRigScaleInput = armLeftComponentGuide.getInputByName('rigScale')
        armLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armLeftClavicleEndInput = armLeftComponentGuide.getInputByName('root')
        armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput)

        # Arm Right
        armRightGlobalSrtInput = armRightComponentGuide.getInputByName('globalSRT')
        armRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        armRightRigScaleInput = armRightComponentGuide.getInputByName('rigScale')
        armRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armRightClavicleEndInput = armRightComponentGuide.getInputByName('root')
        armRightClavicleEndInput.setConnection(clavicleRightEndOutput)

        # Hand Left
        handLeftGlobalSrtInput = handLeftComponentGuide.getInputByName('globalSRT')
        handLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        handLeftArmEndInput = handLeftComponentGuide.getInputByName('armEnd')
        handLeftArmEndInput.setConnection(armLeftWristOutput)

        # Hand Right
        handRightGlobalSrtInput = handRightComponentGuide.getInputByName('globalSRT')
        handRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        handRightArmEndInput = handRightComponentGuide.getInputByName('armEnd')
        handRightArmEndInput.setConnection(armRightWristOutput)

        # Leg Left
        legLeftGlobalSrtInput = legLeftComponentGuide.getInputByName('globalSRT')
        legLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        legLeftRigScaleInput = legLeftComponentGuide.getInputByName('rigScale')
        legLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legLeftPelvisInput = legLeftComponentGuide.getInputByName('pelvisInput')
        legLeftPelvisInput.setConnection(spinePelvisOutput)

        legLeftPelvisInput = legLeftComponentGuide.getInputByName('ikTarget')
        legLeftPelvisInput.setConnection(footLeftIkTargetOutput)

        # Leg Right
        legRightGlobalSrtInput = legRightComponentGuide.getInputByName('globalSRT')
        legRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        legRightRigScaleInput = legRightComponentGuide.getInputByName('rigScale')
        legRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legRightPelvisInput = legRightComponentGuide.getInputByName('pelvisInput')
        legRightPelvisInput.setConnection(spinePelvisOutput)

        legRightPelvisInput = legRightComponentGuide.getInputByName('ikTarget')
        legRightPelvisInput.setConnection(footRightIkTargetOutput)

        # Foot Left
        footLeftGlobalSrtInput = footLeftComponentGuide.getInputByName('globalSRT')
        footLeftGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        footLeftIkHandleInput = footLeftComponentGuide.getInputByName('ikHandle')
        footLeftIkHandleInput.setConnection(legLeftIkHandleOutput)

        footLeftLegEndInput = footLeftComponentGuide.getInputByName('legEnd')
        footLeftLegEndInput.setConnection(legLeftLegEndOutput)

        footLeftLegEndFKInput = footLeftComponentGuide.getInputByName('legEndFK')
        footLeftLegEndFKInput.setConnection(legLeftLegEndFKOutput)


        # Foot Right
        footRightGlobalSrtInput = footRightComponentGuide.getInputByName('globalSRT')
        footRightGlobalSrtInput.setConnection(mainSrtOffsetOutput)

        footRightIkHandleInput = footRightComponentGuide.getInputByName('ikHandle')
        footRightIkHandleInput.setConnection(legRightIkHandleOutput)

        footRightLegEndInput = footRightComponentGuide.getInputByName('legEnd')
        footRightLegEndInput.setConnection(legRightLegEndOutput)

        footRightLegEndFKInput = footRightComponentGuide.getInputByName('legEndFK')
        footRightLegEndFKInput.setConnection(legRightLegEndFKOutput)

        Profiler.getInstance().pop()
Esempio n. 10
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BobRig:" + name)
        super(BobRig, self).__init__(name)

        # Add Components
        mainSrtComponent = MainSrtComponentRig("mainSrt", self)

        spineComponent = SpineComponentRig("spine", self)
        spineComponent.loadData(data={
            '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': 4
        })

        neckComponentGuide = NeckComponentGuide(data={
            "location": "M",
            "neckPosition": Vec3(0.0, 16.5572, -0.6915),
            "neckEndPosition": Vec3(0.0, 17.4756, -0.421)
        })

        neckComponent = NeckComponentRig("neck", self)
        neckComponent.loadData(data=neckComponentGuide.getRigBuildData())

        headComponent = HeadComponentRig("head", self)
        headComponent.loadData(data={
            "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)
        })

        clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle", data={
            "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))
        })

        clavicleLeftComponent = ClavicleComponentRig("clavicle", self)
        clavicleLeftComponent.loadData(data=clavicleLeftComponentGuide.getRigBuildData())

        clavicleRightComponentGuide = ClavicleComponentGuide("clavicle", data={
            "location": "R",
            "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))
        })

        clavicleRightComponent = ClavicleComponentRig("clavicle", self)
        clavicleRightComponent.loadData(data=clavicleRightComponentGuide.getRigBuildData())

        armLeftComponentGuide = ArmComponentGuide("arm")
        armLeftComponentGuide.loadData({
            "location":"L",
            "bicepXfo": Xfo(Vec3(2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        armLeftComponent = ArmComponentRig("arm", self)
        armLeftComponent.loadData(data=armLeftComponentGuide.getRigBuildData())

        armRightComponentGuide = ArmComponentGuide("arm")
        armRightComponentGuide.loadData({
            "location":"R",
            "bicepXfo": Xfo(Vec3(-2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(-5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(-7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        armRightComponent = ArmComponentRig("arm", self)
        armRightComponent.loadData(data=armRightComponentGuide.getRigBuildData() )

        legLeftComponentGuide = LegComponentGuide("leg")
        legLeftComponentGuide.loadData({
            "name":"Leg",
            "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))
        })

        legLeftComponent = LegComponentRig("leg", self)
        legLeftComponent.loadData(data=legLeftComponentGuide.getRigBuildData())

        legRightComponentGuide = LegComponentGuide("leg")
        legRightComponentGuide.loadData({
            "name":"Leg",
            "location": "R",
            "femurXfo": Xfo(Vec3(-0.9811, 9.769, -0.4572)),
            "kneeXfo": Xfo(Vec3(-1.4488, 5.4418, -0.5348)),
            "ankleXfo": Xfo(Vec3(-1.85, 1.1516, -1.237)),
            "toeXfo": Xfo(Vec3(-1.85, 0.4, 0.25)),
            "toeTipXfo": Xfo(Vec3(-1.85, 0.4, 1.5))
        })

        legRightComponent = LegComponentRig("leg", self)
        legRightComponent.loadData(data=legRightComponentGuide.getRigBuildData() )

        # ============
        # Connections
        # ============
        # Spine to Main SRT
        mainSrtRigScaleOutput = mainSrtComponent.getOutputByName('rigScale')
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        spineInput = spineComponent.getInputByName('mainSrt')
        spineInput.setConnection(mainSrtOffsetOutput)

        spineRigScaleInput = spineComponent.getInputByName('rigScale')
        spineRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Neck to Spine
        spineEndOutput = spineComponent.getOutputByName('spineEnd')
        neckSpineEndInput = neckComponent.getInputByName('neckBase')
        neckSpineEndInput.setConnection(spineEndOutput)

        # Head to Neck
        neckEndOutput = neckComponent.getOutputByName('neckEnd')
        headBaseInput = headComponent.getInputByName('headBase')
        headBaseInput.setConnection(neckEndOutput)

        # Clavicle to Spine
        spineEndOutput = spineComponent.getOutputByName('spineEnd')
        clavicleLeftSpineEndInput = clavicleLeftComponent.getInputByName('spineEnd')
        clavicleLeftSpineEndInput.setConnection(spineEndOutput)
        clavicleRightSpineEndInput = clavicleRightComponent.getInputByName('spineEnd')
        clavicleRightSpineEndInput.setConnection(spineEndOutput)

        # Arm to Global SRT
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        armLeftGlobalSRTInput = armLeftComponent.getInputByName('globalSRT')
        armLeftGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        armLeftRigScaleInput = armLeftComponent.getInputByName('rigScale')
        armLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        armRightGlobalSRTInput = armRightComponent.getInputByName('globalSRT')
        armRightGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        armRightRigScaleInput = armRightComponent.getInputByName('rigScale')
        armRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Arm To Clavicle Connections
        clavicleLeftEndOutput = clavicleLeftComponent.getOutputByName('clavicleEnd')
        armLeftClavicleEndInput = armLeftComponent.getInputByName('clavicleEnd')
        armLeftClavicleEndInput.setConnection(clavicleLeftEndOutput)
        clavicleRightEndOutput = clavicleRightComponent.getOutputByName('clavicleEnd')
        armRightClavicleEndInput = armRightComponent.getInputByName('clavicleEnd')
        armRightClavicleEndInput.setConnection(clavicleRightEndOutput)

        # Leg to Global SRT
        mainSrtOffsetOutput = mainSrtComponent.getOutputByName('offset')
        legLeftGlobalSRTInput = legLeftComponent.getInputByName('globalSRT')
        legLeftGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        legLeftRigScaleInput = legLeftComponent.getInputByName('rigScale')
        legLeftRigScaleInput.setConnection(mainSrtRigScaleOutput)

        legRightGlobalSRTInput = legRightComponent.getInputByName('globalSRT')
        legRightGlobalSRTInput.setConnection(mainSrtOffsetOutput)

        legRightRigScaleInput = legRightComponent.getInputByName('rigScale')
        legRightRigScaleInput.setConnection(mainSrtRigScaleOutput)

        # Leg To Pelvis Connections
        spinePelvisOutput = spineComponent.getOutputByName('pelvis')
        legLeftPelvisInput = legLeftComponent.getInputByName('pelvisInput')
        legLeftPelvisInput.setConnection(spinePelvisOutput)
        legRightPelvisInput = legRightComponent.getInputByName('pelvisInput')
        legRightPelvisInput.setConnection(spinePelvisOutput)

        Profiler.getInstance().pop()
leftArmGuide = ArmComponentGuide('arm')
leftArmGuide.loadData({
    'name':
    'Arm',
    'location':
    'L',
    'bicepXfo':
    Xfo(Vec3(2.27, 15.295, -0.753)),
    'forearmXfo':
    Xfo(Vec3(5.039, 13.56, -0.859)),
    'wristXfo':
    Xfo(Vec3(7.1886, 12.2819, 0.4906)),
    'handXfo':
    Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
        ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
    'bicepFKCtrlSize':
    1.75,
    'forearmFKCtrlSize':
    1.5
})

# Save the arm guid data for persistence.
rightArmGuide = ArmComponentGuide('arm')
rightArmGuide.setLocation('R')

rightArmGuide.pasteData(leftArmGuide.copyData(), setLocation=False)

builder = plugins.getBuilder()
builder.build(leftArmGuide)
builder.build(rightArmGuide)
Esempio n. 12
0
siRot = XSIMath.CreateRotation()
siRot.SetFromMatrix3(siMat33)

siXfo.SetRotation(siRot)

siNull = si.ActiveProject3.ActiveScene.Root.AddNull("myNull")
siNull.Kinematics.Global.PutTransform2(None, siXfo)


# =====================
# Build through kraken
# =====================
builder = plugins.getBuilder()

config = builder.getConfig()
config.setExplicitNaming(True)

myXfo = Xfo()

myMat33 = Mat33()
myMat33.setColumns(Vec3(0.7071, 0.0, 0.7071), Vec3(0.5, 0.7071, -0.5), Vec3(-0.5, 0.7071, 0.50))

myQuat = Quat()
newQuat = myQuat.setFromMat33(myMat33)
myXfo.ori = newQuat

myLoc = Locator("myLocator")
myLoc.xfo = myXfo

builder.build(myLoc)
Esempio n. 13
0
    def __init__(self, name='neck', parent=None, *args, **kwargs):

        Profiler.getInstance().push('Construct Neck Component:' + name)
        super(NeckComponentGuide, self).__init__(name, parent, *args, **kwargs)

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

        # Guide Controls
        self.neckCtrl = Control('neck', parent=self.ctrlCmpGrp, shape='sphere')
        self.neckCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckMidCtrl = Control('neckMid', parent=self.ctrlCmpGrp, shape='sphere')
        self.neckMidCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))
        self.neckEndCtrl = Control('neckEnd', parent=self.ctrlCmpGrp, shape='sphere')
        self.neckEndCtrl.scalePoints(Vec3(0.5, 0.5, 0.5))

        self.neckCtrlShape = Control('neck', parent=self.ctrlCmpGrp, shape='pin')
        self.neckCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckCtrlShape.setColor('orange')
        self.neckMidCtrlShape = Control('neckMid', parent=self.ctrlCmpGrp, shape='pin')
        self.neckMidCtrlShape.rotatePoints(90.0, 0.0, 0.0)
        self.neckMidCtrlShape.rotatePoints(0.0, 90.0, 0.0)
        self.neckMidCtrlShape.setColor('orange')

        # Guide Operator
        self.neckGuideKLOp = KLOperator(name + 'GuideKLOp', 'NeckGuideSolver', 'Kraken')
        self.addOperator(self.neckGuideKLOp)

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

        # Add Source Inputs
        self.neckGuideKLOp.setInput('sources', [self.neckCtrl, self.neckMidCtrl, self.neckEndCtrl])

        # Add Target Outputs
        self.neckGuideKLOp.setOutput('targets', [self.neckCtrlShape, self.neckMidCtrlShape])


        # Calculate default values
        neckVec = Vec3(0.0, 16.00, -0.75)
        neckMidVec = Vec3(0.0, 16.50, -0.50)
        neckEndVec = Vec3(0.0, 17.00, -0.25)
        upVector = Vec3(0.0, 0.0, -1.0)

        neckOri = Quat()
        neckOri.setFromDirectionAndUpvector((neckMidVec - neckVec).unit(),
                                            ((neckVec + upVector) - neckVec).unit())

        neckMidOri = Quat()
        neckMidOri.setFromDirectionAndUpvector((neckEndVec - neckMidVec).unit(),
                                               ((neckMidVec + upVector) - neckMidVec).unit())

        self.default_data = {
            "name": name,
            "location": "M",
            "neckXfo": Xfo(tr=neckVec, ori=neckOri),
            "neckMidXfo": Xfo(tr=neckMidVec, ori=neckMidOri),
            "neckEndXfo": Xfo(tr=neckEndVec, ori=neckMidOri),
            "neckCrvData": self.neckCtrlShape.getCurveData(),
            "neckMidCrvData": self.neckMidCtrlShape.getCurveData()
        }

        self.loadData(self.default_data)

        Profiler.getInstance().pop()
Esempio n. 14
0
    def __init__(self, name):

        Profiler.getInstance().push("Construct BobGuide:" + name)
        super(BobGuide, self).__init__(name)

        # Add Components to Layers
        spineComponent = SpineComponentGuide('spine', self)
        neckComponentGuide = NeckComponentGuide('neck', self)
        headComponent = HeadComponentGuide("head", self)

        clavicleLeftComponentGuide = ClavicleComponentGuide("clavicle", self)
        clavicleLeftComponentGuide.loadData({
            "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))
        })

        armLeftComponentGuide = ArmComponentGuide("arm", self)
        armLeftComponentGuide.loadData({
            "location": "L",
            "bicepXfo": Xfo(Vec3(2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.0865, -0.2301, -0.2623), 0.9331)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5})

        clavicleRightComponentGuide = ClavicleComponentGuide("clavicle", self)
        clavicleRightComponentGuide.loadData({
            "location": "R",
            "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))
        })

        armRightComponentGuide = ArmComponentGuide("arm", self)
        armRightComponentGuide.loadData({
            "location": "R",
            "bicepXfo": Xfo(Vec3(-2.27, 15.295, -0.753)),
            "forearmXfo": Xfo(Vec3(-5.039, 13.56, -0.859)),
            "wristXfo": Xfo(Vec3(-7.1886, 12.2819, 0.4906)),
            "handXfo": Xfo(tr=Vec3(-7.1886, 12.2819, 0.4906),
                           ori=Quat(Vec3(-0.2301, -0.0865, -0.9331), 0.2623)),
            "bicepFKCtrlSize": 1.75,
            "forearmFKCtrlSize": 1.5
        })

        legLeftComponentGuide = LegComponentGuide("leg", self)
        legLeftComponentGuide.loadData({
            "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))
        })

        legRightComponentGuide = LegComponentGuide("leg", self)
        legRightComponentGuide.loadData({
            "location": "R",
            "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))
        })

        Profiler.getInstance().pop()