Ejemplo n.º 1
0
def buildBob(mode='guide'):

    Profiler.getInstance().push("bob_build")

    bobGuideRig = Rig("char_bob")
    bobGuideRig.loadRigDefinition(bob_guide_data)

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

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

        bobRigData = bobGuideRig.getGuideData()
        bobRig = Rig()
        bobRig.loadRigDefinition(bobRigData)

        builder = plugins.getBuilder()
        builder.build(bobRig)

    else:
        print 'Invalid mode set'

    Profiler.getInstance().pop()

    if __name__ == "__main__":
        print Profiler.getInstance().generateReport()
    else:
        if mode == 'guide':
            logHierarchy(bobGuideRig)
        elif mode == 'rig':
            logHierarchy(bobRig)
Ejemplo n.º 2
0
def buildBob(mode='guide'):

    Profiler.getInstance().push("bob_build")

    bobGuideRig = Rig("char_bob")
    bobGuideRig.loadRigDefinition(bob_guide_data)

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

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

        bobRigData = bobGuideRig.getGuideData()
        bobRig = Rig()
        bobRig.loadRigDefinition(bobRigData)

        builder = plugins.getBuilder()
        builder.build(bobRig)

    else:
        LogMessage('Invalid mode set')

    Profiler.getInstance().pop()

    if __name__ == "__main__":
        print Profiler.getInstance().generateReport()
    else:
        if mode == 'guide':
            logHierarchy(bobGuideRig)
        elif mode == 'rig':
            logHierarchy(bobRig)
Ejemplo n.º 3
0
    def doIt(self, argList):

        selObjects = self.parseArgs(argList)
        if selObjects.length() < 1:
            OpenMaya.MGlobal.displayWarning('Kraken: No objects selected, Build Rig cancelled.')
            return False

        firstObj = OpenMaya.MObject()
        selObjects.getDependNode(0, firstObj)

        firstObjDepNode = maya.OpenMaya.MFnDependencyNode(firstObj)
        if firstObjDepNode.hasAttribute('krakenRig') is False:
            OpenMaya.MGlobal.displayWarning('Kraken: Selected object is not the top node of a Kraken Rig!')
            return False

        guideName = firstObjDepNode.name()
        guideRig = BipedGuideRig(guideName)

        synchronizer = plugins.getSynchronizer()

        if guideRig.getName().endswith('_guide') is False:
            guideRig.setName(guideRig.getName() + '_guide')

        synchronizer.setTarget(guideRig)
        synchronizer.sync()

        rigBuildData = guideRig.getRigBuildData()
        rig = Rig()
        rig.loadRigDefinition(rigBuildData)
        rig.setName(rig.getName().replace('_guide', '_rig'))

        builder = plugins.getBuilder()
        builtRig = builder.build(rig)

        return builtRig
Ejemplo n.º 4
0
    def synchGuideRig(self):
        synchronizer = plugins.getSynchronizer()

        # Guide is always  built with "_guide" need this so synchronizer not confused with real Rig nodes
        if self.guideRig.getName().endswith('_guide') is False:
            self.guideRig.setName(self.guideRig.getName() + '_guide')

        synchronizer.setTarget(self.guideRig)
        synchronizer.sync()
Ejemplo n.º 5
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)
Ejemplo n.º 6
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':
            for each in armGuide.getItems().values():
                # Only log hierarchy for Layer objects as Layers in this test are added to
                # the component since there is no rig object.
                if each.isTypeOf('Layer'):
                    logHierarchy(each)
        elif mode == 'rig':
            for each in arm.getItems().values():
                # Only log hierarchy for Layer objects as Layers in this test are added to
                # the component since there is no rig object.
                if each.isTypeOf('Layer'):
                    logHierarchy(each)
Ejemplo n.º 7
0
def buildArm(mode='guide'):

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

    guideContainer = Container('armGuide')

    armGuide = ArmComponentGuide("arm", parent=guideContainer)
    armGuide.loadData({
            "name": "L_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)),
            "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.getGuideData()

        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)
Ejemplo n.º 8
0
def KrakenBuildBipedRig_Execute(bipedGuide):

    # Deffered importing: We can only import the kraken modules after the
    # plugin has loaded, as it configures the python import paths on load.
    from kraken.core.objects.rig import Rig
    from kraken import plugins

    from kraken_examples.biped.biped_guide_rig import BipedGuideRig

    guideName = "Biped"
    if bipedGuide == None and si.Interactive is True:
        pickGuide = si.PickElement(constants.siModelFilter,
                                   "Kraken: Pick Guide Rig",
                                   "Kraken: Pick Guide Rig")
        if pickGuide('ButtonPressed') == 0:
            pass
        else:
            pickedGuide = pickGuide('PickedElement')

            if pickedGuide.Properties('krakenRig') is None:
                log(
                    "Kraken: Picked object is not the top node of a Kraken Rig!",
                    4)
                return False

            guideName = pickedGuide.Name
    else:
        if bipedGuide.Properties('krakenRig') is None:
            log(
                "Kraken: 'bipedGuide' argument is not the top node of a Kraken Rig!",
                4)
            return False

        guideName = bipedGuide.Name

    guideRig = BipedGuideRig(guideName)

    synchronizer = plugins.getSynchronizer()

    if guideRig.getName().endswith('_guide') is False:
        guideRig.setName(guideRig.getName() + '_guide')

    synchronizer.setTarget(guideRig)
    synchronizer.sync()

    rigBuildData = guideRig.getRigBuildData()
    rig = Rig()
    rig.loadRigDefinition(rigBuildData)
    rig.setName(rig.getName().replace('_guide', '_rig'))

    builtRig = None
    progressBar = None
    try:

        progressBar = XSIUIToolkit.ProgressBar
        progressBar.Caption = "Building Kraken Rig: " + rig.getName()
        progressBar.CancelEnabled = False
        progressBar.Visible = True

        builder = plugins.getBuilder()
        builtRig = builder.build(rig)

    finally:
        if progressBar is not None:
            progressBar.Visible = False

    return builtRig
Ejemplo n.º 9
0
def KrakenBuildBipedRig_Execute(bipedGuide):

    # Deffered importing: We can only import the kraken modules after the
    # plugin has loaded, as it configures the python import paths on load.
    from kraken.core.objects.rig import Rig
    from kraken import plugins

    from kraken_examples.biped.biped_guide_rig import BipedGuideRig

    guideName = "Biped"
    if bipedGuide == None and si.Interactive is True:
        pickGuide = si.PickElement(constants.siModelFilter, "Kraken: Pick Guide Rig", "Kraken: Pick Guide Rig")
        if pickGuide('ButtonPressed') == 0:
            pass
        else:
            pickedGuide = pickGuide('PickedElement')

            if pickedGuide.Properties('krakenRig') is None:
                log("Kraken: Picked object is not the top node of a Kraken Rig!", 4)
                return False

            guideName = pickedGuide.Name
    else:
        if bipedGuide.Properties('krakenRig') is None:
            log("Kraken: 'bipedGuide' argument is not the top node of a Kraken Rig!", 4)
            return False

        guideName = bipedGuide.Name

    guideRig = BipedGuideRig(guideName)

    synchronizer = plugins.getSynchronizer()

    if guideRig.getName().endswith('_guide') is False:
        guideRig.setName(guideRig.getName() + '_guide')

    synchronizer.setTarget(guideRig)
    synchronizer.sync()

    rigBuildData = guideRig.getRigBuildData()
    rig = Rig()
    rig.loadRigDefinition(rigBuildData)
    rig.setName(rig.getName().replace('_guide', '_rig'))

    builtRig = None
    progressBar = None
    try:

        progressBar = XSIUIToolkit.ProgressBar
        progressBar.Caption = "Building Kraken Rig: " + rig.getName()
        progressBar.CancelEnabled = False
        progressBar.Visible = True

        builder = plugins.getBuilder()
        builtRig = builder.build(rig)

    finally:
        if progressBar is not None:
            progressBar.Visible = False

    return builtRig
Ejemplo n.º 10
0
 def synchGuideRig(self):
     synchronizer = plugins.getSynchronizer()
     synchronizer.setTarget(self.guideRig)
     synchronizer.sync()