Exporting nCloth animation to FBX using Blend Shapes in Maya3D

Lately I went through a quite tough process of figuring out how to export my nCloth animation to FBX. Here is description of my struggle and outcome.

Magda Odrowąż-Żelezik
Fink IT
9 min readMar 27, 2020

--

This article is part of my series of ‘Learning 3D animation’, where I cover problems I’ve solved, learning materials I’ve used and buttons I’ve clicked. Feel welcome to join me.

Universal message

You will learn how to convert physical object animation to general animation that does not require physical engine.

What I want to do

I have a nice animation of a floating dress prepared using nCloth in Maya. What I would like to have eventually is that animation displayed neatly on my website with help of Three.js library.

Note: I will prepare another article on importing FBX animation to Three.JS for babies (like me).

Tryouts

I baked animation of my nCloth and exported it from Maya in several formats. Three.js serves several formats for animation, of which Maya exports to: FBX and Collada. Noob as I am I thought that animation is something that moves and everything should be fine.

Googling didn’t come to rescue and finally I received help on three.js forum. Here’s what I’ve learned:

  1. nCloth can be exported and used without psychical engine only with addition of cache — as exported with alembic.
  2. You cannot use cache file with Three.js.
  3. You can implement physical engine in your WebGL website using another library like ammo.js for example
  4. You can however export morphing shapes with FBX format

Using entire engine to serve one animation was an overkill. Morphing or, as their called in Maya, blend shapes as suggested in the forum seemed like and easy path to follow.

The process of proper export of such animation turned out to be a little tricky. Below you may find entire workflow from creating blend shapes to FBX export settings in Maya.

Workflow

The animation is build as follows: the dress model is converted to nCloth and “hang” onto transparent horizontal cylinder — constrained to it’s rigid body. The cylinder is animated sliding from right to left and constrained material is dragged after it.

nCloth dress animation

What we will do:

  1. Stop the animation on crucial frames and duplicate the object shape from there
  2. Collect various stages of the current animation and modify them for our use
  3. Create blend shapes from them (and learn what the .. it is)
  4. Animate the blend shapes in time
  5. Prepare the animation for export
  6. Export the animation
  7. Test the export

Extracting the shapes

Best way to do this is to take another look at your animation and figure where are the most important shape changes. To me it was the beginning of the move, when the skirt starts to be dragged and the end where it stops and floats a bit afterwards.

This means I needed to extract some more shapes from the beginning and end of cloth animation than from the middle. I had to also make sure to be able key these shapes correctly in a timeline later.

What you need to do is to play animation and stop every few frames where you see the shape to be interesting. Then press ctrl+D to duplicate the current object and maybe use wedge (W) tool to drag it out of the way. If you decide to move the duplicates, be sure to translate them only in one axis, not used by your animation. Their position in relation to each other is very important to maintain.

Duplicating objects as the animation is paused. Wedging only in Y axis.
Notes on where in timeline which duplication has been made

To make your life easing when reproducing the animation in blend shapes, it is best to note the frame number where a certain shape is duplicated.

On the picture you may see my own notes, where on the left column I wrote number of the duplicate, and on the right number of the frame where I made the duplication.

After extraction

When you have extracted all the shapes it is best to select them all and copy to another Maya file.

If you moved the duplicates from their original position, it is best to even them out now. For me it was resetting the translate Y value to 0.

Duplicated objects evened out in another file

Now another important part. Since the objects are derived from different one and copied, they may have had preserved data which can later break your animation from exporting. First step is to remove the redundant data from the meshes. Having them selected, choose Edit->Delete (All) by Type, then delete History.

This operation should be sufficient for your animation to perform correctly, but I’ve learned the hard way it didn’t. I went down on the list and tried to delete every item on the list. Apparently I had some trash attached that I wasn’t aware of. I you experience problems with export this should be first thing to check.

Deleting redundant data after pasting objects

Last step is to choose you basic mesh. This is the shape you want to start your animation with. To maintain order, rename this object to something simple like “base object”.

Rename basic mesh to keep it visible

Creating blend shapes

Before reaching this part of the tutorial you could read names like shape, object, mesh interchangeably. I think you could benefit now with keeping things little bit more precise.

What we will be doing are object deformations. Deformation is reshaping the base object into another object or giving it a new shape. Deformation is only possible when base and target object have exactly the same topology. Which mean exactly the same number of vertices and faces.

According to Maya documentation, there are several terms you need to be familiar with:

  1. Base object (base mesh) — original object you are deforming. Blend Shape magic happens on this one object
  2. Base shape — initial pose of the base object, the one you start deforming with
  3. Target objects — like in our example, duplicates of the original mesh. They are optional, since you could transform base object directly without duplication
  4. Target shapes (targets) — shapes towards which base shape will be deforming. Target shapes are derived from target objects (as we are doing) or saved from deforming base object directly. Target shapes store information of the offset of all vertices.
  5. Blend shapes — result of the offset of target shape being applied on the base object. You can change the value of this application (from 0 to 1, 1 being complete transformation).

The process of obtaining blend shapes and animating them now is fairly simple. First, be sure to select all the target objects and, pressing shift, select base object. This order is crucial. Now, from the top menu choose Deform->Blend Shape. If you press the square on the right, you may see the menu of the action with presets. For this example, default presets are enough. Press Create.

Choosing Blend Shape and default options
blend shape node

Nothing happened on the first glimpse. If you select the base object, you will see in the Attribute Editor that blendShape1 node has appeared. On click, it should expand, showing all the target shapes with value 0. This means the current shape is base shape. To blend it into one of targets, target’s value should be changed to 1 (see images below).

We will use that now for animation. First, hide all target objects from view (ctrl+H). Then, prepare you sheet with frames numbers or just do as you feel.

Target shape applied on base mesh
Hide target objects

When adding keys, it is important to key previous shape, current shape and next shape (except on first or last frame). We do not want target shapes overlapping, only changing one into another. You can do it by hand (advised) or right-click and choose key all keyable. This will add keys to properties you are not modifying at all, which is pointless really.

Once finished, your graph editor should look like this:

Graph editor after keying targets properly

When you run the animation now, it should look exactly like the one you previously had, with the nCloth. Neat, right?

Preparing for export

As Autodesk support informs us, we need now bake topology to targets.

With Bake Topology to Targets, you can regenerate or update your blend shape deformations so that any topological changes made to the base object are also applied to its target objects.

To do this, select base object and blendShape1 node and go to Deform->Blend Shapes->Bake Topology To Targets.

Having done that, keeping both nodes selected go to Edit->Keys->Bake Simulation. This will bake your animation one key per frame.

Bake simulation, default settings are sufficient

Export

Select base object and blendShape1 node again. Go to File->Export Selection.

As export format choose FBX. Write down name and choose location for your file. From the presets on the right side of export window, be sure to have selected:

  1. Animation
  2. Deformed Models (all checkboxes)
  3. Connections (input Connections)

You may select Bake Animation, however you do not have to, since you have it already baked with Bake Simulation.

Test your Export

  1. Do not test in FBX Review. It will not work (up to version available as I am writing this article — 2019.2 Release).
  2. Test it either in Blender or any other 3D software different than Maya
  3. Use online tool like this one
  4. Test it directly in your Three.js code or Unity — whatever you are doing

Still not working?

Exporting to blend shapes from Maya can be tricky. I’ve found many issues people were sharing on forums:

FBX plugin is broken

  1. Try to uninstall it and install it
  2. Check Autodesk for updates
  3. Export to alembic and try to export it through Blender.

You still have some mess

Check your connections — open Windows->General Editors->Hypergraph:Connections. Remove any unnecessary nodes. If you don’t know what is what, trying and failing is your friend (you know, ctrl+Z).

Only basic nodes necessary

You missed something

Go and reread this text. Maybe delete non-deformer history again.

You are doomed

There is no hope. Sorry.

Last remarks

This tutorial is conclusion of a long struggle and extensive search as I am still a newbie. If you discover something new or have something to add, please share in the comments and let’s help the community together.

This article is based on a part of my engineer thesis. All the screenshot belong to me and depict my original work.

I use Maya 2018 Student Version.

--

--

Magda Odrowąż-Żelezik
Fink IT

Creative front end developer, currently excited about learning 3D graphics. Visit magdazelezik.com