Thursday, September 2, 2010

Exporting Simple Skeleton and Mesh data via FBX in Maya

Its something that you think should be really easy, taking your animated rig data and spitting out an nice clean fbx containing just the animated skeleton and mesh data, but in practice Fbx is such a beast it needs a little pre-setup to achieve. What you need to do is to first select the nodes you want to output. FBX has no concept of what it should, or shouldn't output, so use the export selected option from Maya.

If like most rigs you have a master bind skeleton, select it's root, then run something like this to select any joint and mesh data under it, you may need to shift select your skin, the key is to get what you want selected and nothing else:

import maya.cmds as cmds
meshes=[]
joints=cmds.ls(sl=True)

#find all joints
joints.extend(cmds.listRelatives(type='joint',allDescendents=True))

#find your Skinned Geo
for skin in cmds.listConnections(joints,type='skinCluster'):
    if skin:
        shape=cmds.skinCluster(skin,query=True,geometry=True)
        meshTransform=cmds.listRelatives(shape,parent=True)[0]
        if meshTransform not in meshes:
            meshes.append(meshTransform)

cmds.select(joints,meshes)

Right, now you have the nodes you actually want to go through for export. I should point out here that this only works from Maya2010 onwards, there was an FBX bug in older versions of the export selected.

Here's the key, in the FBX output options (use fbs not fbx_dae) you need to go to the Animation Options block and make sure that these 2 flags are set.

Bake-Animations = ON, InputConnections= OFF




That's it. You should end up with a nice clean fbx with JUST the data you wanted in it.

1 comment:

  1. Hi - can you explain a little more about why those two options specifically?

    ReplyDelete