### [REL] Havok Animation Converter, Thread 2

Havok Command Line Tools 1.4
============================================

Previous Discussions:
http://www.gamesas.com/topic/1293826-rel-havok-animation-converter/

This tool enables converting Havok animation from the Skyrim-compatible binary format to the Havok XML format or to the Gamebryo KF animation format.

Currently the package only converts from native HKX files built with Havok 2010.2.0 SDK to the XML form of HKX or to the Gamebryo KF file format.

This is useful because it enables animators base animations to work with in their tool of choice.

Prerequisites:
• For Skyrim, you must unpack the BSA files using an appropriate tool. The files must be unpacked exactly as they are stored in the BSA with same folder structure.
For me I will refer to this location as "%TEMP%\Skyrim - Animations"
• I assume you have the 2010.2 Havok Content Tools and SDK from Intel.
You will need to provide infomation to get access to the tools but is free.
http://software.intel.com/sites/havok/en/

• For 3ds max support get the niftools.org exporter for Skyrim
• This is my persional fork of the importer. You might still get the official one from niftools.org if one is available.
Quick Start:
• Unpack BSA Files to a Folder
• First unpack the Skyrim - Animation.bsa and Skyrim - Meshes.bsa files to another location

• I will use my simple unpack tool to demonstrate this but other BSA tools presumably will work just need to maintain the folder structure

• Use a folder other than temp if you like but working folders tend to be different for everyone

• bsaunpak "c:\Steam\SteamApps\common\skyrim\Data\Skyrim - Animations.bsa" "%TEMP%\skya"						bsaunpak "c:\Steam\SteamApps\common\skyrim\Data\Skyrim - Meshes.bsa" "%TEMP%\skym"
• Convert Packed HKX to XML HKX files
• If you do not specify the output folder it will assume that it should write to the same folder and append "-out" the filename.
• The XML HKX files can be loaded into Havok tools like the Havok Preview Tool
• hkxcmd convert "%TEMP%\Skyrim - Animations"
• Convert Packed HKX to XML HKX files and place in another folder
• The following will convert all HKX files in the "%TEMP%\Skyrim - Animations" folder and subfolders and place them in the "%TEMP%\Skyrim - Animations - Output" folder.
• hkxcmd convert "%TEMP%\Skyrim - Animations" "%TEMP%\Skyrim - Animations - Output"
• Preview Animation in Havok Preview Tool
• Load the Preview Tool: Start | Havok | Havok PcXs Content Tools 2010.2.0 | Havok Preview Tool
• Convert Skeleton.hkx using step 1 or 2 above
• File | Open... | Browse for converted skeleton
Assuming you used Tutorial 2 that would be the following for the chicken
"%TEMP%\Skyrim - Animations - Output\meshes\actors\ambient\chicken\character assets\skeleton.hkx"
If you get a "Wrong platform for packfile" error when loading then you selected the original skeleton not the converted one.
• File | Add... | Browse for an animation for that skeleton
Assuming you used Tutorial 2 that would be the following for the chicken
"%TEMP%\Skyrim - Animations - Output\meshes\actors\ambient\chicken\animation\getup.hkx"
• Convert HKX file to Gamebryo KF files
• The following will just dump KF files into same folder as the HKX file. Note: Use the original files not the XML files since those don't load currently.
• hkxcmd exportkf "%TEMP%\Skyrim - Animations"
• Convert HKX file to Gamebryo KF files into a different folder
• The following will convert all HKX files in the "%TEMP%\Skyrim - Animations" folder and subfolders and place them in the "%TEMP%\Skyrim - Animations - Output" folder.
• hkxcmd exportkf "%TEMP%\Skyrim - Animations" "%TEMP%\Skyrim - Animations - Output"
• Import Skyrim Animation into 3ds Max
• First import the creature into max using niftools max importer
- Select Import | "Netimmerse/Gamebryo (*.nif, *.kf)" | Pick the file to import
- Continuing the chicken theme I used the following:
- "%TEMP%\Skyrim - Meshes\meshes\actors\ambient\chicken\character assets\chicken.nif"
• If you have problems with meshes try importing the skeleton explicitly before the mesh
- Not all creatures use the name skeleton.nif so you might have to manually adjust path
• Assuming this succeeded now import the animation
- Select Import | "Netimmerse/Gamebryo (*.nif, *.kf)" | Pick the animation
- Find an animation you which to import such as the getup animation
- Assuming you used Tutorial 5 that would be the following for the chicken:
- "%TEMP%\Skyrim - Animations - Output\meshes\actors\ambient\chicken\animation\getup.kf"
• Export Skyrim Animation from 3ds Max in KF format
• Select the root node (usually "NPC Root [Root]")
• Open Graph Editors | Track View - Dope Sheet
• Add a Note Track to the Root Node
• Note that the KF generated by the exportkf process will now add start and end note tracks
• Add a note at time 0 with text "start"
• Add a note on the final frame of animation with text "end"
• Select Export | "Netimmerse/Gamebryo (*.nif, *.kf)" | Specify an file name like "export.kf"
• Select "Single KF w/o NIF" under Animation in the "Export Nif" dialog
• Select "Export"
• I usually load in Nifskope after this just to make sure its valid enough
• Convert KF format to HKX Format
• The following will convert a KF file using the base skeleton for its bone layout and bind pose
• By default it exports as a Win32 Packed Binary HKX file but you can change that from the command line to export as XML adding -v:XML
hkxcmd convertkf "\path\to\skeleton.hkx" "\path\to\export.kf" "\path\to\export.hkx"
Troubleshooting:
• A lot of files show that they failed to load when converting.
- Ignore any errors about files it cannot convert as not every file can be read with the sdk.
- This is because the SDK only includes Physics and Animation support. Bethesda also uses Havok Behaviors which are not supported by the SDK and those file cannot be read currently.
• I keep getting the following message "Wrong platform for packfile" when using the Preview tool
- You are loading the original animations from Bethesda which are not directly compatible with the preview tool. Follow the tutorial parts 1 and 2 and export the XML HKX files and use those.
• The animation is corrupt after importing into 3ds Max
- Try Importing the Skeleton.NIF file explicitly before importing the mesh.
- Some animations just don't import correctly probably because of bone mapping issues
• When I try to load the converted HKX file into Havok Preview Tool fails.
- The Havok Preview Tool breaks with large files like the dragon.hkx files.
- You might be able to convert the file to a standard packed file with the -f switch on Convert command.
Known Issues:
• Some reports than human animation does not work. Embarrassingly I didn't try humans only creatures.
• I could not figure out how bones are mapped because I'm not sure the information is present. I've just assumed that there is a 1-to-1 skeleton to animation track but that is obviously not always a correct assumption
• Havok supports non-uniform scale in animation however Gamebryo does not. This means any animation exported to the Gamebryo format may lose information when this is present.
• KF was choosen because the niftools.org 3ds max importer largely works and this was the easiest way to do this porting. It may be worth while converting to FBX format instead but that is much more work but would presumably have broader support.
• There is no handling for visbility or camera tracks which seem to be used
Acknowledgements:
• Niftools team for niflib and the 3ds Max Importer
• Havok and Intel for the Havok SDK and perpetual license for 3rd party tools
Change Log:
• 1.4
• Add support for Havok Behavior files and Bethesda specific classes
• Altered ExportKF to used frame_increment = duration / (nframe-1)
• Use a round function when calculated frames in ConvertKF
• 1.3
• Change ExportKF to add "start" and "end" note tracks on root node for later export
• Added ConvertKF which takes a Gamebryo KF file and produces an HKX file
• Added DumpText which is a text file dump of bones in a skeleton may be useful in the Havok Export Pipeline when specifying the skeleton.
• 1.2
• Redid the directory handling for exportkf
• 1.1
• Fixed crash when no output folder was specified when using the exportkf command

http://www.mediafire.com/?54w2gnjvovlddv9 [mediafire.com]

Inol Wakhid

Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Someone will come along and create a simple editor for behavior files at some point it may just take a few years...

Hey Hologram may be that someone could be you ? ....
btw thanks a lot for this I managed to import a new animation and use it to make a better riging of my models ....

Lisha Boo

Posts: 3378
Joined: Fri Aug 18, 2006 2:56 pm

Finally. Using Saidenstorm's setup (thanks so much for that ) I was able make my first shareable animation, a breathing idle. But before I release I would like to do 2 more, if I can somehow circumvent those environment problems.

1. Adapt the male mt_idle. But to work on a new animation I have to "Imported the animation, double its duration and duplicate the keys", according to Saidenstorm's note. Could you please elaboreate why this is necessary, and what's the best way to do this?

2. Adapt to Cherry's skeleton. Since I don't have 3DS 2011 or later, I would like to stay with Saidenstorm'e setup. But how can I get Cherry's skeleton in there? Add those 4 bones? Or remove all existing skeleton bones (except those special ones like "X-NPC translate [Pos]", and import the new skeleton? Is it possible at all?

Any help is VERY much appreciated.

Darrell Fawcett

Posts: 3336
Joined: Tue May 22, 2007 12:16 am

One question, when I start hkxcmd if just flashes for half a second and disappears, crashes, that is. I've extracted it in the folder where I unpacked the animations, can someone tell me what's the problem?

Oh and, what I need is to extract animations of Alduin, but I don't notice a folder for his specific animations. Does he share regular dragon animations or...?

Dean Brown

Posts: 3472
Joined: Fri Aug 31, 2007 10:17 pm

1. Adapt the male mt_idle. But to work on a new animation I have to "Imported the animation, double its duration and duplicate the keys", according to Saidenstorm's note. Could you please elaboreate why this is necessary, and what's the best way to do this?

Its not -> I only did that for presentation purposes.

2. Adapt to Cherry's skeleton. Since I don't have 3DS 2011 or later, I would like to stay with Saidenstorm'e setup. But how can I get Cherry's skeleton in there? Add those 4 bones? Or remove all existing skeleton bones (except those special ones like "X-NPC translate [Pos]", and import the new skeleton? Is it possible at all?

You can just import her new skeleton and set up the x_nodes as needed the game itself does not care one bit what a node is named it applies transforms based on mapping order not naming.

One question, when I start hkxcmd if just flashes for half a second and disappears, crashes, that is. I've extracted it in the folder where I unpacked the animations, can someone tell me what's the problem?

It requires exact paths to the files.

Oh and, what I need is to extract animations of Alduin, but I don't notice a folder for his specific animations. Does he share regular dragon animations or...?

Yes he does.

Sara Lee

Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm

(double duration) Its not -> I only did that for presentation purposes.
That was confusing me, because your animation has the exact 9.1333 sec as the original animation. But it think I have used the converted original all the time

You can just import her new skeleton and set up the x_nodes as needed the game itself does not care one bit what a node is named it applies transforms based on mapping order not naming.
Here I'm a noob. What does it mean to "set up the x_nodes". Define them as bones? With the bone tools? And what parameters? Define controllers? Sorry if I bother you here, but I don't think 3DS Help will help me here.

Jaki Birch

Posts: 3379
Joined: Fri Jan 26, 2007 3:16 am

Hey Hologram may be that someone could be you ? ....

Maybe. I started a while back but looks to be too much work for too little gain and don't have enough relevant examples in the SDK to do what I think is needed quickly. I hoped that there might be some conversion between the publicly but old version of HBT via XML files might enable useful workflows without needing a new interface or toolset (other than the converter).

Anyway, too busy having fun with TESVsnip to work on it at the moment.

matt white

Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Hey, thanks, I managed to start it up, but I have another problem when trying to export to Gamebryo format, I am sure i have the right directory since I managed to start it...:

"No files found."

EDIT: Nevermind that problem, it solved itself... But when I follow the instructions in the cmd, I get the error "Skeleton file not found at [anim.kf]".

Btw, must I export every file individually like this >.>?

EDIT 2: So I have discovered the problem is the skeleton not being there. And I don't seem to be able to find him among the extracted folders either...

Hayley Bristow

Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am

EDIT 2: So I have discovered the problem is the skeleton not being there. And I don't seem to be able to find him among the extracted folders either...
I had the same problems. Don't know if the readme is not up-to-date, or if I miss something, too. What I use is the following
hkxcmd.exe exportkf skeleton.hkx mt_idle.hkx mt_idle.kf
where skeleton.kkx is the converted (xml) type of skeleton.

Jonathan Egan

Posts: 3432
Joined: Fri Jun 22, 2007 3:27 pm

I had the same problems. Don't know if the readme is not up-to-date, or if I miss something, too. What I use is the following
hkxcmd.exe exportkf skeleton.hkx mt_idle.hkx mt_idle.kf
where skeleton.kkx is the converted (xml) type of skeleton.

Ok thanks, will try that when I come home =). So I need to conver the files to the xml type first, and then use the skeleton from that format (these export with "-out" appended to the end of their filename if their output destination is the same folder, that is, unspecified, right?)

EDIT: Works =)!

Any way I can export them all at once?

Brittany Abner

Posts: 3401
Joined: Wed Oct 24, 2007 10:48 pm

You can export all at once by using the commands I laid out in the tutorial and my other post in Thread 1 which has a lot of commands as far as I know. The full export requires you export all files as laid out in the archive. bsaunpak pointed to in first post will do that properly but is a command line tool as well.

Basically point a the source directory and the output directory and it will search or any skeletons and convert any animations it finds along the way.

Cameron Garrod

Posts: 3427
Joined: Sat Jun 30, 2007 7:46 am

sorry, this may not be the best place to ask this but, I just installed the Havok Animation tools.

See here: http://software.intel.com/sites/havok/en/

With that, I do not need to convert anything correct? I should be able to just load in a vanilla Skyrim animation file and work with it with no other steps?

I guess what I am asking is, does Skyrim use the same xml, hkx, hkt files that HAVOK TOOLS program wants to open? Or does Skyrim use some other format and and must be converted before HAVOK TOOLS can import it?

I cannot tell from READING the OP if the what I downloaded IS the same tool as the one used in this thread. If it is, then I guess I need to follow all the directions here just to load the Skyrim animation into the HAVOK TOOLS I have...right?

If I do not then the vanilla animations from Skyrim will not work in the HAVOK TOOLS program I have installed... is that correct?

Assuming that I must follow the directions here to convert the Skyrim animations files to a format that HAVOK TOOLS can import, then I do not need any other tool such as blender or 3dmax?

I guess what I am basically asking is if the program I downloaded : http://software.intel.com/sites/havok/en/ is all I need to alter existing animations files from skyrim or not.

Once I started it on my PC it LOOKED like it should be able to load and edit animations files from skyrim but when I tried to load one from skyrim it would not work.

Edit: ok now I am really confused, I got the "havok tools for game artist and designers" 2011.3.0 64 bit

But is that NOT the one I need? do I need the Havok Physics and Havok Animation SDK for programmers"?

oh god... all I want to do is alter the Skyrim sword swing animations...what do I need to do this?

Dominic Vaughan

Posts: 3531
Joined: Mon May 14, 2007 1:47 pm

HCT is an EXPORTER not an Importer and as such it has no way of getting animations into Max/Maya/XSI for that you absolutely need this program and to convert those anims to kf and use the NifTools Importer -> after imported and altered you can export them using HCT straight into the game -> if you read the last thread I posted DL links to Max Scenes properly set up to receive imported anims and to properly export straight in game -> you will also have to DL some Rig Files from my web page for the exported animations to map correctly to nodes.

Alex Vincent

Posts: 3514
Joined: Thu Jun 28, 2007 9:31 pm

You can export all at once by using the commands I laid out in the tutorial and my other post in Thread 1 which has a lot of commands as far as I know. The full export requires you export all files as laid out in the archive. bsaunpak pointed to in first post will do that properly but is a command line tool as well.

Basically point a the source directory and the output directory and it will search or any skeletons and convert any animations it finds along the way.

Thank you very much, I finally did what I wanted to =)!

Ymani Hood

Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Hologram,

there is a problem re-importing any of the animations Cherry or I have made. Scale is destroyed for many bones. Cherry has confirmed, and since he and I use different setups and 3DS versions, it is possibly caused by hkxcmd.

In kf files converted from new animations about 40 % of the bones have scales defined for all or almost all frames. For Root, COM and the 3 x_nodes these scales are oszillating (e.g. between around 600 and - 150), for all other bad bones (mostly upperbody) they are linear. And always identical for x/y/z.

Neither me nor Cherry have touched the scales. And I don't think the exported hxk files have these set. E.g. one animation has a R UpperArm scale set to 139.7, and this would certainly be seen in-game. I looked into the xml file, but scales seem hidden in the bulk data.

If you look into my animations (http://skyrim.nexusmods.com/downloads/file.php?id=7093) you will see that they are pretty oversized. I had not discovered yet the "Bake Scale" filter in HCT. But I tried that as well, and it's the same problem.

joannARRGH

Posts: 3431
Joined: Mon Mar 05, 2007 6:09 am

Hi I am wondering if there is something wrong in the converter when I import a converted animation sometimes I notice that id doesn't exactly correspond to how looks ingame ....

for example I tried this idel

sneak1hm_idle

Ingame looks fine but is here how looks in 3dsmax ....

any idea?

http://img515.imageshack.us/img515/2515/sneack.jpg

Shianne Donato

Posts: 3422
Joined: Sat Aug 11, 2007 5:55 am

Hi I am wondering if there is something wrong in the converter when I import a converted animation sometimes I notice that id doesn't exactly correspond to how looks ingame ....

for example I tried this idel

sneak1hm_idle

Ingame looks fine but is here how looks in 3dsmax ....

any idea?

http://img515.imageshack.us/img515/2515/sneack.jpg
That reminds me of the scale problem I've described above. As if the scale for 1 axis is reduced for NPC L Calf.

I have checked my converted file, and it is not. Can you check yours?
You might also like to check the bone's stretch factor with bone tools.

Jamie Lee

Posts: 3415
Joined: Sun Jun 17, 2007 9:15 am

Noactually all theimports work on the male models but not on the female ones do I need to use a different skeleton or what?

Dewayne Quattlebaum

Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Noactually all theimports work on the male models but not on the female ones do I need to use a different skeleton or what?
Works for me, but I'm using female skeletons only. I started with Saidenstorm's setup earlier in this thread, and for Cherry's model I replaced the skeleton with the CHSBHC skeleton_female.nif (simply re-import).

You only have to reset stretch&scale for all bones in the bones tool.

Robert DeLarosa

Posts: 3415
Joined: Tue Sep 04, 2007 3:43 pm

Is there still a problem? Basically sounds like a classic case of non-uniform scaling. NIF/KF does not support separate scaling x/y/z factors while Max and Havok do. The correct solution usually is to use the "Reset XForm" utility. Or I guess the bones tool solution pointed to above.

CRuzIta LUVz grlz

Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Is there still a problem? Basically sounds like a classic case of non-uniform scaling. NIF/KF does not support separate scaling x/y/z factors while Max and Havok do. The correct solution usually is to use the "Reset XForm" utility. Or I guess the bones tool solution pointed to above.

Yes, the problem persists. And it really looks like it's caused by hkxcmd. The only other possible causes are our (Cherry's and mine) different setups, or HCT.

But there is at least one indication that the hkx file is ok. In the kf there are scales like 139.7 on the upper arm, which would be noticable in-game, but isn't.
I don't think you had the chance to test with modded animations. And Beth was using a different HCT version than we do. If you compare the xml files (vanilla vs. modded) you will see some small but still existing differences. I simply believe that the modded animations have some differences which cause this mis-interpretation in hkxcmd. And you are the only one who can tell.

Ice Fire

Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

I honestly dunno what you are talking about ... I am more a modeller than animator , I use the anims to test the rigging , but what shoudl I do to make them work if possible a step by step description?

OTTO

Posts: 3367
Joined: Thu May 17, 2007 6:22 pm

I honestly dunno what you are talking about ... I am more a modeller than animator , I use the anims to test the rigging , but what shoudl I do to make them work if possible a step by step description?
Prometheus, I don't know how to make it work. I only can tell what to look for, if it's really a scale problem. From a 3DS beginner's point-of-view.

1. Check the converted kf. file:
- Open kf with NifSkope
- View -> Blocklist & View -> Block Details, if not already open
- Click 0 NiControllerSequence in BL (Block List)
- Open Controlled Blocks in BD (Block Details)
- Lookup the number behind the 'NPC L Calf' BD entry (it's 7 in my setup)
- Open the NiTransformInterpolator entry in the BL (7 - 1 = 6 in my setup)
- Click the opened NiTransformData
- Open Scales in BL
If Num Keys > 0, then there is a problem (scales, when ther shouldn't be)

2. Check you skeleton setup in 3DS:
- Open "Select from Scene" (press H in the animation window)
- Look for 'NPC L Calf' and double-click
- Open Animation -> Bone Tools, expand on Object Properties
- Check, if "1 bone selected" (if not, you havn't correctly selecte the NPC L Calf"; do it again)
- Stretch factor has to be "1.0".
- if not, press "Reset Stretch" and "Reset Scale", BUT NEVER "Realign" (SaidenStorm has warned us)
You might also do this for all other bones in your setup

3. Check your imported animation (if skeleton is ok):
- Import kf
- Do the same as in Check (2)
.

remi lasisi

Posts: 3307
Joined: Sun Jul 02, 2006 2:26 pm

This tool really is a godsend. Thank you.

I am a poor man and don't have access to 3Ds Max, only Blender ... but now I am at least able to import Skyrim animations into Blender and play around with them. Exporting will have to wait a little while longer

I have a small question. I am completely now to Havok animations and behavior and whatnot, please forgive my ignorance if this is a stupid question. Is there any way to convert the XML HKX file generated with this tool back into the packed binary HKX format Skyrim uses? Or does the XML no longer have all the needed information? What tool would be needed for that? I am a little reluctant to give “Try Havok” my personal information to download their free SDK unless it will actually help me ... *readjusts-tinfoil-hat*

I am asking because I did a side-by-side comparison of the vanilla walking and some modded walking animations in XML and noticed that all those made by modders are always missing a few blocks.
All those modded animations break the footstep sounds and I have the suspicion it has something to do with those missing parts.

Tamara Primo

Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

@fore, thanks for the assistance. I'll look in to what I can but do need some info. I thought my tool would put out a warning when it did non-uniform conversion of scale but I will have to double check that.

@Tefnacht, I thought the hkxcmd convert command will do this or should with -f SAVE_DEFAULT. Assetcc2 does a better job of it though. (You can always give a legal General Delivery address though you still need to provide an email. ) The ConvertKF will convert kf to binary packed hkx by default.

Spoiler
Usage: hkxcmd convert [-opts[modifiers]] [infile] [outfile]  Simply read and write the file back out with specified format.-i 		  Input File or directory-o 		  Output File - Defaults to input file with '-out' appended-f 		 Havok saving flags (Defaults:  SAVE_TEXT_FORMAT|SAVE_TEXT_NUMBERS)	 SAVE_DEFAULT		   = All flags default to OFF, enable whichever are needed	 SAVE_TEXT_FORMAT	   = Use text (usually XML) format, default is binary format if available.	 SAVE_SERIALIZE_IGNORED_MEMBERS = Write members which are usually ignored.	 SAVE_WRITE_ATTRIBUTES	= Include extended attributes in metadata, default is to write minimum metadata.	 SAVE_CONCISE		   = Doesnt provide any extra information which would make the file easier to interpret.					E.g. additionally write hex floats as text comments.	 SAVE_TEXT_NUMBERS	  = Floating point numbers output as text, not as binary.				  Makes them easily readable/editable, but values may not be exact.

Melissa De Thomasis

Posts: 3412
Joined: Tue Feb 27, 2007 6:52 pm

Next