libgdx / fbx-conv

Command line utility using the FBX SDK to convert FBX/Collada/Obj files to a custom text/binary format for static, keyframed and skinned meshes.
Apache License 2.0
448 stars 116 forks source link

FBX-Conv generates incorrect animations from FBX exported from 3D Studio Max #39

Closed Zoonmaan closed 10 years ago

Zoonmaan commented 10 years ago

First off, I use the tool "FBX Multi Take" from here: http://www.turbosquid.com/FullPreview/Index.cfm/ID/701878 (there is a trial somewhere), and the trial version of 3D Studio Max 2010.

The Multi Take tool/plugin allows one to specify more than one animation in the exported FBX file. Out of the box, 3DS Max only supports one!

After exporting the FBX file, I open the file in "Autodesk FBX Converter 2013" (free). Here I can preview the takes, and verify that they work as expected.

After running them through the FBX-conv tool, it finds all the animations, eg. "Walk", "Run", "Attack" and so forth. But when I try to play the animation in LibGDX, it always plays the entire animation (Walk+Run+Attack). Looking at the generated g3dj file, all the animations "keyframes":"keytime" start at 0.000000

xoppa commented 10 years ago

Please supply (e.g. pastebin) the fbx file that exposes the issue.

Btw, LibGDX allows you to play/loop only a portion of an animation so splitting the animation is not necessary (although its probably cleaner / easier to work with separate animations).

Zoonmaan commented 10 years ago

Interesting - I've been Goggling like crazy to find a way to only play a part of an animation. Can you point me in the right direction? 3DS Max uses frame numbers to build the animation. I have not been able to find LibGDX documentation on that - but again, I'm pretty new to LibGDX.

The FBX file I currently have is provided under licence, so I can not provide the FBX file as a Pastebin. Can I email it to you?

xoppa commented 10 years ago

Would you mind to try to reproduce the issue using a very simple model and post the FBX of that model? For example a simple cube model with two animations "up" and "right". Eventually, to resolve this issue, a very basic test is required anyway and to be honest I don't have any experience with the application you used.

Every relevant method of AnimationController has a signature taking an offset and duration argument. For example: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/AnimationController.html#animate(java.lang.String, float, float, int, float, com.badlogic.gdx.graphics.g3d.utils.AnimationController.AnimationListener, float) Those values are in seconds (mainly because fbx-conv removes the original keyframe information to bake interpolation). Most modeling applications target a 30fps by default, so using framenumber / 30f should do as the required offset and duration values.

Zoonmaan commented 10 years ago

Here is an example, with 2 animations: http://www.zoon.dk/xoppa.fbx and the converted file: xoppa.fbx http://www.zoon.dk/downloadfile.php?id=500 xoppa.g3dj http://www.zoon.dk/downloadfile.php?id=501

In the meantime, I'll have a look at the method you provided :)

Zoonmaan commented 10 years ago

Got the latest nightly with the new animate(..) method, and now it works! It would still be nice if FBX-conv could do it right though :) Thanks for the heads up!

xoppa commented 10 years ago

Your first link appears to be invalid. When I import your FBX file of the second link in maya, I receive the errors below and all the animations are in a sequence on the same take (Maya only supports one take). It seems like your model relies on an extension to split the animations (PlasticAntSoftwareLtd_FBXExt_MultiTake)? If you like, you can export to the easier readable ASCII FBX format and post (pastebin e.g.) it. Then it should be immediately clear how many animations your fbx file actually contains.

The following Link node(s) is/are not part of the BindPose definition. BoneHead BoneJaw BoneRightEye BoneRightHand BoneRighFoot BoneLeftFoot BoneLeftHand

The following parent and/or ancestor node of the Link(s) is/are not part of the BindPose definition. miniZombieDummy

While reading or writing a file the following notifications have been raised. The FBX plug-in cannot locate FBX plug-in extension PlasticAntSoftwareLtd_FBXExt_MultiTake version 1.0 that is associated with this file. The import process will continue without it, which may cause unexpected results.

Zoonmaan commented 10 years ago

Try the first link again. It had a download cap of 1 :) or http://pastebin.com/U0GCfZbB

Correct, the plugin in 3DS Max (FBX Multitake) takes care of the splitting on export. I can open the file in Autodesk FBX Converter without any problems (free download!), and using the build-in viewer, I can see the two different takes in the FBX file.

xoppa commented 10 years ago

Would you mind trying this test version of fbx-conv? (assuming you're on windows) http://blog.xoppa.com/wp-content/uploads/fbx-conv1.zip

Zoonmaan commented 10 years ago

Just tried it - works as expected :) Thank you for your help!

xoppa commented 10 years ago

Thanks for testing, glad it works. It needs some additional testing to make sure it doesn't break compatibility with e.g. Blender, before I can commit the changes. Therefore leaving this issue open for now.

goph-R commented 7 years ago

Hi!

I had a similar problem (opacity problem with the current downloadable binary: http://libgdx.badlogicgames.com/fbx-conv, bone transform problem with this version: http://blog.xoppa.com/wp-content/uploads/2015/02/fbx-conv-win.zip), but the linked version above worked perfectly.