Home Website Youtube GitHub

Baked Animation from mGear rig for EXPORT

Hello everyone,

New here! …and a big fan of the mGear system! (using 4.0.9 in Maya 2022)

I am trying to find out how to get animation generated on the mGear rig, baked down to the joints accurately
When I select all of the joints, and use Smart Bake (any bake really), a few issues happen:

  1. The joints seem like they still have a connection to the rig? (yellow channels, not red)
  2. It seems like all of the keyframes are not baking?

I have encountered problems with this/similar baking issue in Maya 2022 when using HIK on another project; so it’s possible this is not an mGear issue.

That said, can anyone provide a process, or tutorial, settings, or information, about how to get my animation from the mGear rig baked down to FBX keyframes (baking process for real-time [VR])

Thanks in advance!

Hi there, welcome!

Yes this sounds like a regular Maya issue. How are you baking? Show your settings.

For example by default the Shifter joints are likely non-keyable. So if you selected “keyable” in your settings, it won’t bake anything.

Solution is to use “From Channel Box”, or make your joints keyable first.


If you use Python, you can specify which attributes you want to bake directly. Then it doesn’t matter if they are non-keyable or not.

For example, here is a little helper script I wrote. It’s a small portion of a larger GUI tool I wrote for a pipeline.

It’s runs on your time range, so either set your timeline, or edit the script. It also doesn’t do “Smart Bake”. So if you need that, you need to edit the script. This is just an example of what you can do.

It also runs an Euler Filter on all the rotations of the joints, to help stop flipping/popping.

import pymel.core as pm

# bake_selected_joints.py

# A simple helper script to bake selected joints.
# This automatically chooses all the attributes, so the animator
# Doesn't have to manually choose settings each time.

#TODO: It would be nice to have a little GUI so the animator can choose settings, like range.

def bake_selected_joints(bakeBlendshapes=False):
    startFrame = pm.playbackOptions(minTime=True, q=True)
    endFrame = pm.playbackOptions(maxTime=True, q=True)

    attrsToBake = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']
    everyJoint = pm.selected(type='joint')
    everyBakeAttr = []
    for eachNode in everyJoint:
        for eachAttr in attrsToBake:
            everyBakeAttr.append(eachNode.attr(eachAttr))
        
        # Then include every custom attribute too:
        for eachCustomAttr in eachNode.listAttr(userDefined=True):
            everyBakeAttr.append(eachCustomAttr)

    if bakeBlendshapes:
        # Include baking all blendshapes
        targetBlendshapes = pm.selected(type='blendShape')
        for eachBlendshape in targetBlendshapes:
            for eachTarget in eachBlendshape.w:
                if eachTarget.isLocked():
                    continue
                everyBakeAttr.append(eachTarget)

    pm.bakeResults(
        everyBakeAttr,
        simulation=True,
        shape=False,
        sampleBy=1,
        sparseAnimCurveBake=False,
        bakeOnOverrideLayer=False,
        removeBakedAnimFromLayer=True,
        #resolveWithoutLayer=cmds.ls(type='animLayer'),
        t=(startFrame, endFrame),
        )

    # Run an euler filter to help prevent flipping.
    everyRotation = [jnt.r for jnt in everyJoint]
    pm.filterCurve(everyRotation, filter='euler')

bake_selected_joints(bakeBlendshapes=True)

Chris:

Thank you! Yes. I am unlocking the joint channels by making them visible/unlocked/keyable by moving them through Channel Control. So they should be “unlocked” as you mention. (I did not try your Py script yet)

As for Maya’s Smart Bake settings: I haven’t been able to get satisfactory results with any settings. As mentioned, last year I was having similar smartBaking issues with Maya’s very own HIK system, and had hinted at there being a bug?

Thanks for your feedback. I’ll submit your script to my rigging dept for implementation

You’ve only mentioned the channels not baking. What other unsatisfactory results are you seeing?

Right now, nothing. Here, you can use this for your PR (it’s all true):

I’m a 27 year veteran animator/rigger with experience at the biggest VFX, game, and commercial studios in Los Angeles, NYC and Vancouver. I’ve worked with just about every kind of rig, and rigging system you can imagine; and I have built plenty of rigs myself for humanoids, creatures, robots, cameras, and all types of mechanisms. That said, mGear is one of the most versatile and solid rigging systems I’ve used. It’s predictable, easy to setup and maintain, and FAST. We’re using it currently on our project in VR development in medical simulations, and I would recommend it as a rigging system for beginners and experts. Great system guys! Thanks for making it and your continued support!

~

That said, I’d be cool to see “re-targetting” become more fluid (simple), similar to HIK. As in, being able to take FBX data and convert it to keyframes on the mGear controls. I use mocap data from [Rokoko, Xsens, Mixamo] and then clean-up, or animate on top of that data. This is one area of mGear where I haven’t invested the time (I did have some success with my initial tests). It may already be there…

Thanks again!

If you want the animation in FBX format, have you tried Maya’s built in Game Exporter?

You will need to play with the settings a bit, depending on whether you want to include the geo and materials with the FBX or not. Just make sure the jnt_org group is set to be exported and use the Game Exporter - Animation tab.

1 Like