Commit rBAcf871d6a3027: FBX exporter: add option to choose which type of FBX node to use as armature. does not fix the issues with the armature type, the type of the NodeAttribute needs to changed as well.
This patch accomplishes that.
Details
- Reviewers
Bastien Montagne (mont29)
Diff Detail
Event Timeline
Eeeeh, you have good point about NodeAttribute. But that patch is not valid - may work in some case, but it can generate invalid FBX.
FBX Template system is absolutely not what it should be - it's utterly fragile, totally unflexible, and a minor non-conformity in it will break importers based on SDK. Potentially adding twice the same template (for empties and armatures) won't work - so you gonna have to use Null one, LimbBone one, or a new Root one depending on chosen node type. And pretty sure TypeFlags prop cannot be left to Null for Root/LimbNode versions either (actually, I have seen some files having the three "Null", "Skeleton" and "Root" TypeFlags defined for some of their bones…).
Could even be worth testing only using Null type, but with Skeleton TypeFlag instead of Null one, if it works would be much simpler than supporting several nodetype options for our armatures.
Yikes, ok that does not sound very promising.
I am to not very familiar with the fbx spec, but I will see if I can come up with a better way.
@Michael Freundorfer (mordecai) If you are not so at ease with FBX (or just do not have much time for this patch), please say so, reporting the issue was already nice catch, I can work on fixing it too. ;)
@Bastien Montagne (mont29) I definetly wanted to give it a try myself :), but I am still not sure about some things (like what a 'root' template would look like).
So yes if you can invest the time to fix it please do so, I very much appreciate it.
One thing I can say is that using the Skeleton type flag on a null does not work.
So it will need to change the full node attribute.
I just ran into the issue the last couple of days. Is this something that is going to be fixed?
Wow, that is an old issue that has gone completely under the radar. Sorry that i did not follow up with anything.
@Dirk Gregorius (dgregorius) If you are experiencing these issues with Unity, as i did at the time, this was fixed on the importer side in Unity. If you enable the "Preserve Hierarchy" option in the importer Unity will not merge the armature with the root object.
If you are talking about other importers I unfortunately cannot help you here.
So if this is still just about Unity I would suggest closing this issue, since it has not been relevant for several years now.
This is for my own animation experiments and I fixed it in my importer as well. Still I think this idea of this fix is great and it would be great if it worked as expected. Eg I looked at the UE4 importer and it is quite some hackery there how they deal with this. The suggested fix here would make things more robust imo.
If you cannot change the attribute type it might be good enough to have something you can query during import. E.g. some custom property. Do you know how I could query the 'node type' (null, root, limbnode) you are exporting from the FBX SDK? If I could get that value this would be much better I think...
I don't know it is possible because the current implementation only sets the type on the node and not the node attribute. You might want to take a look if the SDK has a way to access the type of the node as opposed to the type of node attribute.
I had a quick look at how the FBX SDK exports a skeleton node and there are still a bunch of things that I do not understand about the template system.
For reference:
I don't know if the way fbx_template_def_bone defines a LimbNode template is valid. There was no such template in neither a file exported from Blender nor from the FBX SDK.
The file from the FBX SDK containted a FbxSkeleton template though, which seems to be the correct template for both the Root type and the LimbNode type. I assume the TypeFlags property defines the subtype of the NodeAttribute template. Both the root and the limb nodes had the Skeleton type flag.
I cannot easily define the FbxSkeleton template though because it has an H (unknown purpouse?) flag where the A (animatable) flag would be in the LimbLength property. There is no way to specify this in the template definition right now.
["ObjectType", ["NodeAttribute"], "S", [
["Count", [3], "I", []],
["PropertyTemplate", ["FbxSkeleton"], "S", [
["Properties70", [], "", [
["P", ["Color", "ColorRGB", "Color", "", 0.8, 0.8, 0.8], "SSSSDDD", []],
["P", ["Size", "double", "Number", "", 100.0], "SSSSD", []],
["P", ["LimbLength", "double", "Number", "H", 1.0], "SSSSD", []]]]]]]],The root node attribute should be
["NodeAttribute", [53428880, "SkeletonRoot::NodeAttribute", "Root"], "LSS", [
["TypeFlags", ["Null", "Skeleton", "Root"], "SSS", []]]],But it currently is
["NodeAttribute", [557975716, "Armature::NodeAttribute", "Null"], "LSS", [
["TypeFlags", ["Null"], "S", []],
["Properties70", [], "", []]]],