Importing Animations from Blender

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search


Tools used in this tutorial

Required


Introduction[edit | edit source]

Screenshot of altered spell casting animation.

Creating animations for Oblivion, so far, has only been possible for users of 3DS Max versions 6 to 8 (AFAIK). If you're like me and don't have access to these versions (and don't want to obtain copies from ~those~ places), then you're stuck with Blender, Milkshape, etc.

Getting animations from Blender into Oblivion is a bit more work than that for 3DS Max users, but it can still be done. For this tutorial, the player's cast self animation will be altered partially, but the same process can be used to change the entire animation if you want too.

The first thing you need to do is make sure you have the correct tools.

Tools Needed[edit | edit source]

Before you start making animations for Oblivion, you need (at least) the following tools:

Obviously it helps if you've read some tutorials on how to use these tools. Tutorials are available on the pages linked too above, as well as in the tutorials section.

Creating an Animation in Blender[edit | edit source]

The first thing you need to do is import a skeleton and mesh from Oblivion into Blender. The Creature Meshes 101 tutorial is quite good for explaining how to do this.

Once you have a clean mesh in Blender, animate it. For this tutorial, simply rotate the left upper arm (Bip01 L UpperArm) so that it is above the character's head about mid-way through the animation.

Exporting an Animation from Blender to NifSkope[edit | edit source]

A poorly documented fact, only found by me when examining the export scripts and checking out the of the scripts on the NifSkope page and which hadn't been mentioned on the forums (AFAIK) was that the script could actually export animations! So export the model using the export script.

This will create a .nif file that contains:

  • the skeleton,
  • mesh and
  • animation.

The only problem is that these three are merged and are not usable as an animation (.kf) as is. An animation file simply contains the changes in position, orientation and scale of the bones. Oblivion will not accept the file that is exported.

So, export the skeleton, mesh and animation from Blender and save it in a .nif file, e.g. test.nif

Creating an Animation File (.kf)[edit | edit source]

To obtain an animation file in the correct format, pieces of the exported file needs to be extracted and placed in an animation file in the correct format. To do this:

  • open an existing animation file (e.g. castself.kf) in NifSkope
  • open another window in NifSkope and load the exported file (e.g. test.nif)

If you press the play button in the window containing test.nif, you will see the model being animated.

Note: for this example, keep the time range to 1.3 seconds as this is the duration of the cast self animation.

Extracting Animation Data from the Blender .nif File[edit | edit source]

Examining test.nif will show that the animations are bound to the individual bones using NiKeyframeController blocks. So if you animated the left upper arm, navigating down the tree to test->Scene Root->Bip01->Bip01 NonAccum->Bip01 Pelvis->Bip01 Spine->Bip01 Spine1->Bip01 Spine2->Bip01 Neck->Bip01 L Clavicle->Bip01 L UpperArm you will see a NiKeyframeController block that contains the animation information for the left upper arm.

Very important is the NiKeyframeData block beneath the NiKeyframeController block. This block contains the animation keys and is the block that will be extracted.

Select the NiKeyframeData block for the left upper arm and copy it. Paste it in the castself.kf file. It will be added to the end of the list of blocks and is not yet connected to the animation.

Updating the Existing .kf File[edit | edit source]

Controller vs Interpolator

A controller block is connected to a bone and controls the animation of this bone directly. A controller cannot exist in a file without a bone.

An interpolator, on the other hand, does not need to be directly connected to a bone. An interpolator indicates the bone it effects by specifying the name in a string block containing extra information.

The castself.kf file has a NiControllerSequence block that contains controller sequences. A number of NiTransformInterpolator blocks attached to NiTransformData blocks are in this file (one per animated bone). The NiTransformData block contains the actual animation keys (and the exact same structure as NiKeyframeData blocks. We need to replace the existing Data block with the one containing the new animation.

To do this:

  • click on the root NiControllerSequence block
  • in this block, scroll down to the field called Controlled Blocks
  • open this field and scroll down to the controlled block called "Bip01 L UpperArm"
  • open it and scroll down to the field called "Interpolator"
  • right click on the value and choose "follow link". This will take you to the correct interpolator for the left upper arm (there are LOTS, so it's easy to make a mistake in selection)
  • in the selected interpolator, change the value in the data field to the number of the NiKeyframeData block you pasted earlier. This should unlink the old data block and link the new one.
  • double click on the name of the NiKeyframeData and rename it to NiTransformData
  • select the old NiTransformData block and delete it
Importing Animations INTO Blender

You can import animations as well, AS LONG AS the animation is merged with the skeleton (i.e. the way it gets exported). So to import an animation into Blender, perform the reverse of what you did to export it. I.e. copy the data blocks from the .kf file into the .nif file and attach these to controllers on the bones that animate and remember to rename the block correctly.

Tedious, but it works.

A better way to import an animation into blender is this: At the import screen, select skeleton.nif as target. If you see the import options screen, look below. You will see a "load .kf" button. Select as .kf your .kf animation. Import

And you will have a skeleton + your animation as a action. Your animation is called Defaultaction. Faster and better then copy-paste all those data blocks.

You now have a correctly set up .kf file. Save it. Ignore the "error message" about "unassigned parent link", it doesn't matter. You can use the attach .kf spell to see that the animation does work.

Start up Oblivion, cast a self spell and the animation should have been changed so that, in addition to the normal cast self animation, the player lifts his/her left upper arm as well.

Note:

  • if the animation duration is longer than the one in the .kf file, simply select the NiControllerSequence block and change the value of the "Stop Time" field.
  • if more than one bone is animated, you need to repeat the copy/paste/update process for each bone.


Check out the Basic Animation Tutorial for more details on the .kf file blocks.

Conclusion[edit | edit source]

Well, now we can change animations using Blender. Creating entirely new creatures and animations using Blender should not be too far off... It certainly appears doable.

Hope some people found this useful. Let me know if anything needs a bit more clarity or explanation.

Breeze582000 06:42, 9 February 2007 (EST)