blender_niftools_addon icon indicating copy to clipboard operation
blender_niftools_addon copied to clipboard

.kf export ignores IK and other bone constraints

Open arcusmaximus opened this issue 3 years ago • 2 comments

Issue Overview

When exporting a skeletal animation to .kf, the addon appears to only look at bone transformation keyframes, disregarding the effects of bone constraints. This means it's not possible to use IK - you have to manually rotate each bone in the chain, which of course takes much more time.

If you're just creating a static pose, this is relatively easy to work around by selecting all bones, running Blender's "Apply Visual Transform To Pose" feature, and creating Rotation keyframes to store the result. If you're creating an animation, however, you'd have to do this for every frame, which might be even more time-consuming than not using IK.

Version Information

Blender Niftools Addon Version Info

0.0.13

Blender Version Info

2.93.1

Platform information

Windows 10

Context

Trying to create a dragon animation for Skyrim.

Steps to Reproduce

These steps are based on the Dragon.blend attached below. It consists of the standard Skyrim dragon mesh parented to the standard dragon skeleton, with two changes:

  • Addition of a new "IK Head" controller bone (only for Blender usage, not for adding to skeleton.nif)
  • Addition of an IK constraint to the existing "NPC Neck5" bone, targeting the above controller.

Reproduction steps:

  1. Open the .blend file and note the dragon's pose: wings raised (through manual bone rotation) and neck bent downwards (through IK).
  2. Export the scene to .kf
  3. Delete the IK constraint from the yellow "NPC Neck5" bone (neck returns to rest state).
  4. Select all bones and run Pose -> Clear Transform -> All (wings return to rest state).
  5. Import the .kf you just exported.

Expected Result

Both the wings and the neck return to their original pose.

Actual Result

The wings return to their original pose, but the neck stays in the rest state.

Logs and Files

Blend File

Dragon.zip

Possible Fix

One easy fix might be to check if the armature contains any bones with constraints, and if so, apply the workaround described above: for each frame of the scene, set it as the current frame, run "Apply Visual Transform", and create keyframes which can then be read by the conversion code. Of course, these keyframes would ideally be cleaned up again afterwards to avoid leaving a mess for the user.

Another possibility would be to refactor the conversion code to work like the Animation Tools N3+ Blender file by Anton and tktk. The script there also loops through each frame of the scene, but then directly retrieves each bone's matrix_local rather than going through F-curves.

Similar Known Issues

None I could find.

arcusmaximus avatar Jan 21 '22 23:01 arcusmaximus

The animations have to be baked. Blender can do that automatically. I have a system that handles constraints etc for another plugin. Just a matter of how we want to implement it, how much control we give to the user. It could happen completely on the fly

HENDRIX-ZT2 avatar Jan 25 '22 17:01 HENDRIX-ZT2

Aha, didn't know baking worked for this (I assumed it was only for physics simulations). That makes for a nice and easy workaround for animations too then - thanks for the tip.

arcusmaximus avatar Jan 27 '22 14:01 arcusmaximus