Importing animations into Blender - eArmada8/ed8pkg2gltf GitHub Wiki

Importing animations into Blender

Blender's glTF import tool a little idiosyncratic, which means there are a few steps to getting animations into Blender successfully. Also, as far as I can tell, there is no easy way to merge a model and an animation for that model in Blender, so we will use my included tool for this step.

You want to know how to get a model into Blender and through the compilation process in the first place. Please try this tutorial at least once (the decompile and recompile steps), then come back.

Please note that this is not a tutorial on 3D animation in Blender - I am not an animator and I do not know how to animate. This is a tutorial on how to get animations into and out of Blender, and back into the game. Please consult other tutorials on animating in Blender.

Decompiling and preparing the animations

  • Grab the animation package you would like to edit. I am going to edit Juna's base animations, in C_CHR011_DF1.pkg. Also grab the base model for your character; in my case this would be C_CHR011.pkg.

  • Use ed8pkg2gltf.py on both .pkg files.

  • If you were to import the animations as is, you would only find a pose and key frames. You can animate this way, but it would be much easier with the model present. (Particularly because you cannot allow Blender to orient the bones - more on this later.)

Left: The animation as-is. Right: The animation, merged with the model.

  • Copy the .glb file from the model directory to the animation directory. (If you want to see textures, then also copy over the images which are typically in the assetconv_temp folder and convert any BC7 textures into DXT1 or DXT5. Or use uyjulian's original tool - the latest version creates a .glb with embedded PNG textures!) The .glb file you need is the model that has the root name of your animation. For example, since my animations all start with chr011 (e.g. chr011_BTL_WALK.glb), then I need chr011.glb.

  • Place merge_model_into_animations.py into the folder with the animations, and double click the script. This script will insert all the model data into each animation (notice that the resultant file size of each animation will be substantially larger). NOTE: Like all my tools, I actually recommend running python merge_model_into_animations.py from the command line so that you can see error messages.

In case you are wondering - yes, it is possible to use a different character's model. I recommend using the customTRS version of my merge script for this purpose.

Correctly importing glTF models into Blender

  • When importing the model into Blender, be sure to set Bone Dir to "Blender (best for re-importing)".

  • This is critical if you want to be able to use the animation in the game. If you keep the default "Temperance (average)" then the bones will look correct in Blender but will be horribly distorted in the game.

Note: these images are from applying the transformation to the base model, not the animation model, but the effect is the same. It is just easier for me to take a screenshot when doing it this way.

Finding the animation in Blender

To find the animation, first select it in the Outliner. It belongs to up_point, and is right above Pose and Armature.

  • Expand VisualSceneNode, and up_point. Select Animation.

  • On the Timeline editor, zoom out until you see the animation (mouse wheel scroll). The first frame of this animation is actually frame 320. You can also open up animation_metadata.json in a text editor, and you would see that the start time for chr011_WALK is 13.333 seconds, which is frame 320 when the animation plays at 24 frames per second.
"chr011_WALK": {
            "starttime_offset": [
                13.333333015441895
            ],
  • If you set the starting frame to 320 and the ending frame to 349, then pressing the play button will cause the animation to loop smoothly.

Compiling the model

  • Once you are done, export your animation as .glb and overwrite the original. build_collada.py will ignore the model inside your .glb and export only the animation data; you do not need to remove the model prior to compile.

NOTE: If your animation is choppy when playing, be sure to turn off "Optimize Animation Size" in the glTF export options in Blender.

  • Recompile the model.

  • Note that you may need to update ani script with your new start and stop times. This is beyond the scope of this tutorial; please visit the Trails Research Group for more information.

  • Place your new .pkg file in the correct folder (see the basic tutorial). If everything went well, your animation should play in-game!