Sunday, June 29, 2014

Extending Alembic Export with Parent Constraints

PYTHON CODE SAMPLE


With the Alembic Export tools that have existed in our animation pipeline toolset up until now, there was one feature that was missing even after the refactoring that I mentioned in a previous blog post. 

Problem: When exporting a separate Alembic file for each piece of geometry, there is no way for Parent Constraints that reference separate geometry objects to read the necessary animation data, because the data is excluded from the Alembic file.

For example, in the following scene from OWNED, the easiest way to animate the controller in Jeff's hand was to constrain the animation of the controller to Jeff's wrist using a parent constraint, and so that's what the animator decided to do in this case. However, when the Alembic export tools were used, the controller existed in a separate Alembic file from Jeff and so the controller lost its valuable constraint data and so did not appear in the final render.


So, to fix this problem, they couldn't use these tools. Instead, they would have to be guided through the process of exporting the Alembic File manually to include the geometry object that it references, effectively ruining the productivity of the automated Alembic export tool.

Solution: The solution involved adding another method to the automatic Alembic Exporter tool for this. The solution that I came up with added only a little overhead to the existing tool, such that there is no noticeable addition to the time elapsed when using this tool. What the method I did add does the following:

(1) Finds all the parent constraints attached to the objects that are marked for alembic export
(2) Finds the target of each of these parent constraints
(3) Figures out if the targets are outside the geometry marked for export
(4) If it is, it makes a special exception and adds the target geometry to the same Alembic file as the current geometry.

This puts little extra strain on the scene that it is loaded into Houdini because the nodes added to read in the Alembic files ignore the additional geometry, but the original geometry now has this additional geometry to reference through its parent constraints.