FBX Binary format - Nested Nodes I'm currently writing a Java parser for reading FBX binary files and rendering them in OpenGL using the LWJGL (Light-Weight Java Games Library). I have pretty much managed to parse everything thanks to a couple of blog posts by the Blender Foundation, but there is one more challenge remaining. I thought I'd try posting here given that the Blender guys are the only ones who have tried to outline the format in full.

As, hopefully, you already know, the file consists of a series of nodes which are in turn comprised of nested nodes. These nested nodes (you guessed it), also can contain nested nodes.

My question is how do I detected when a nested node belongs to the node above, and isn't a separate nested node? For example:

Node: Objects&lt;br&gt;
Nested Node: Model&lt;br&gt;
Nested Node: Properties60&lt;br&gt;
Nested Node: Property&lt;br&gt;
[Series of data types]&lt;br&gt;
Nested Node: Property&lt;br&gt;
[Series of data types]&lt;br&gt;
Nested Node: [NULL]&lt;br&gt;
Nested Node: [NULL]&lt;br&gt;
End of Objects


In this situation, Model contains within itself another nested node called Properties60, which in turn contains several nested nodes, one for each property. You then have two null Nested Nodes representing the end of that particular node (like a closing bracket I guess).

My question is how do I detect the "opening" bracket? So I know by looking at the above that each "Property" nested node belongs to Properties60 and not to Model, but only because it makes sense to me as a human. How do I automatically detect that? I've tried examining each unicode value for each byte and cannot find a consistent character that is used to denote a change in scope. I've also checked and there doesn't appear to be an end offset value for nested nodes to tell you how big it is like you have with Nodes.

Have I missed something? I would much appreciate any help you can offer as it's the last piece of the puzzle for me :) Without it, I can't reliably tell when, for example, one model definition ends and another begins.
Everything is explained here, in Node Record Format section. Below I’m just rephrasing that document:


The first four bytes are an uint32, the total size (in bytes) of the node.
The next four bytes are an uint32, the total number of properties.
The next four bytes are an uint32, the total size (in bytes) of properties (aka propertieslen).
The next byte is a uint8, the total size (in bytes) of the node name (aka namelen).
Then you have the node name itself.
Then you have the properties.
Then you have the nested list of sub-nodes.
Then you have the final 13 NULL bytes.


So, you know nested subnodes (if any) start at 4 + 4 + 4 + 1 + &lt;namelen&gt; + &lt;propertieslen&gt; bytes from beginning of current node. This is your “opening bracket”.

If you can “read” python, you can also have a look to our FBX addon code, in particular parse_fbx.py and fbx2json.py, that code is fairly simple and short, and illustrate well how to parse binary FBX.