godotengine / FBX2glTF

A command-line tool for the conversion of 3D model assets on the FBX file format to the glTF file format.
Other
338 stars 89 forks source link

Fix GeometricTransform (fix #56) #58

Open hu-xd opened 5 months ago

hu-xd commented 5 months ago

when Fbx node has GeometricTransform, use an additional Gltf node to hold the mesh and the transform. fix #56

fire commented 5 months ago

@bqqbarbhg Could you take a look with some of your fbx test suite? You don't have to spend too much time.

bqqbarbhg commented 5 months ago

@bqqbarbhg Could you take a look with some of your fbx test suite? You don't have to spend too much time.

Unfortunately currently I don't really have much extra time to spend on non-critical ufbx stuff, as I have a lot going on simultaneously. Though, I can still give a few thoughts:

This seems to be quite similar to the ufbx helper nodes option, which was disabled by default as there was concerns about the node tree not matching up with the FBX file. So then to be consistent I think this should be an option, maybe not enabled by default. On the surface level this diff seems solid for basic cases, and does fix the problem of instanced geometry transforms, like the ufbx import option.

One key thing to pay attention to however is skinned meshes: the geometric transform is expected to be baked to the geometry when using the FBX bind matrices, so you'll need to include that into those manually if transforming it under a child, depending on how the whole glTF pipeline and Godot do things. In general I really recommend testing with skinned meshes that use geometric transforms.


About the dataset testing, if you want to replicate the testing setup I have for Godot ufbx, you can get started with the hacked editor I have, diff here: https://github.com/bqqbarbhg/godot/compare/7abe0c60140..5ce120bdd79 (you can ignore the changes to fbx_document.cpp and ufbx.c/h here).

Using this requires an empty project to load the files in and some way to iterate test cases from the command line, I used my execute_per_fbx.py. Here's an example of what I used for testing:

python3 /path/to/execute_per_fbx.py \
  --verbose --allow-fail \ # Just some options for execute_per_fbx.py: verbose and keep going if Godot crashes
  --exe /path/to/godot/godot.windows.editor.x86_64.exe \ # Godot editor built with '--import-fbx' hack
  -p ufbx -p gltf \ # This will execute every command twice for each FBX with #p="ufbx" and #p="gltf"
  --root /path/to/fbx-files \ # Directory with FBX files, searches recursively
  -- \ # Rest of the options are passed to the '--exe', Godot in this case
  -e --path /path/to/empty-godot-project \ # Usual Godot options
  --import-fbx "#p" /path/to/output "#" # Options to hacky loading, "#p" is ufbx/gltf, "#" is the FBX filename

The above command will start the editor for each FBX file contained in /path/to/fbx-files (and its subdirectories), and will dump loaded screenshots and logs to /path/to/output.

bqqbarbhg commented 5 months ago

Oh one thing to note about the --import-fbx option: It will delete almost everything in the project it's pointed at, so you want to be really careful not to use it when pointing the editor into a project that you care about.