Santos
13th Dec 10, 6:47 AM
Santos Tools 2 - Tutorial 4 - Adding New Bones to Existing Animations
A common problem in Dawn of War 2 modding, is using various accessories or wargear with different animation sets. For example Space Marine Veteran's Cape can only be used when space marine is wielding a thunder hammer. In this tutorial I'm going to show, how to make Veteran's Cape usable with bolter & chainsword animation set. The method described below can be used to add all sorts of animated elements like capes, loincloths, trophies, plumed helmets, fancy hair styles etc.
Here's what you need:
Dawn of War II (:p)
Santos Tools 2 (http://forums.relicnews.com/showthread.php?244744)
3D Studio MAX 8-12
Havok Content Tools v5.5.0 or v6.6.0
Havok Content Tools are available for free via Try Havok (http://software.intel.com/sites/havok/) program. Currently versions 5.5.0 and 6.6.0 are supported. Other versions may be supported in the future.
Step 1: Convert animations to custom format
As in previous tutorial (http://forums.relicnews.com/showthread.php?255600-Tutorial-Santos-Tools-2-Tutorial-3-Exporting-Animation), we start by exporting Space Marine's animations into Santos Tools 2 custom animation format. To do this launch Model Editor, open space marine model and go to Animations page. There are several folders here but we are currently interested only in melee_blade_range_pistol directory, which contains animations for bolter & chainsword combo. Right click this folder and choose Export from context menu to convert all animations in this folder into custom format (the folder itself will be created as well).
Step 2: Find out which bones are missing
Next we need to determine if any bones are missing from reference skeleton. Launch MAX and import space marine model. You can check Save Scene to save reference file into MAX scene file. Now with reference file loaded, use Quick Import button on Animations rollout to import single animation into the scene (for example: fb_run.anim). Open MAXScript Listener (F11) and look for warnings about missing bones:
"WARNING: Bone 'chainsword_teeth_01' is missing!"
"WARNING: Bone 'chainsword_teeth_02' is missing!"
"WARNING: Bone 'chainsword_teeth_03' is missing!"
"WARNING: Bone 'chainsword_teeth_04' is missing!"
"WARNING: Bone 'chainsword_teeth_05' is missing!"
"WARNING: Bone 'chainsword_teeth_06' is missing!"
"WARNING: Bone 'chainsword_teeth_07' is missing!"
"WARNING: Bone 'chainsword_teeth_08' is missing!"
"WARNING: Bone 'chainsword_teeth_09' is missing!"
"WARNING: Bone 'chainsword_teeth_10' is missing!"
"WARNING: Bone 'chainsword_teeth_11' is missing!"
"WARNING: Bone 'chainsword_teeth_12' is missing!"
"WARNING: Bone 'chainsword_teeth_13' is missing!"
"WARNING: Bone 'chainsword_teeth_14' is missing!"
"WARNING: Bone 'chainsword_teeth_15' is missing!"
"WARNING: Bone 'chainsword_teeth_16' is missing!"
"WARNING: Bone 'chainsword_teeth_17' is missing!"
"WARNING: Bone 'chainsword_teeth_18' is missing!"
"WARNING: Bone 'chainsword_teeth_19' is missing!"
"WARNING: Bone 'chainsword_teeth_20' is missing!"
"WARNING: Bone 'bip01_banner' is missing!"As you can see we're missing 21 bones in total, from two following models:
art\race_marine\troops_wargear\weapons_melee\chainsword_common\chainsword_common.model
art\race_marine\troops_wargear\accessories\bloodravens_banner\bloodravens_banne.model
Step 3: Create animation reference file
In this step we need to create a reference file with full skeleton, which will be used for importing animations. In previous tutorial (http://forums.relicnews.com/showthread.php?255600-Tutorial-Santos-Tools-2-Tutorial-3-Exporting-Animation), I've shown how to create animation reference file step by step. Here I'm going to show a different (and possibly better) way to do it.
Open Model Editor again and load space marine model. Go to Attachments page and add following models:
art\race_marine\troops_wargear\armour\power_armour_common\power_armour_common.model
art\race_marine\troops_wargear\heads\space_marine\space_marine_head.model
art\race_marine\troops_wargear\accessories\bloodravens_banner\bloodravens_banner.model
art\race_marine\troops_wargear\weapons_melee\chainsword_common\chainsword_common.model
art\race_marine\troops_wargear\weapons_ranged\bolt_pistol_common\bolt_pistol_common.model
When imported to MAX this will give us a model with full skeleton and some meshes for reference. However since we're also adding Veteran's Cape, we need to include this model as well:
art\race_marine\troops_wargear\accessories\veterans_cape\veterans_cape.model
http://img529.imageshack.us/img529/9648/modelset.png
Save entire model set as melee_blade_range_pistol.modelset. Now, go back to MAX, import this file with Import Model button and save scene as melee_blade_range_pistol.max in model's Reference folder.
You can also clean the model up a little bit by removing the elements we won't really need (banner, lod2 meshes, wreck mesh group) and scaling some bones to fit better into the mesh.
http://img440.imageshack.us/img440/8861/referencei.png
Step 4: Create reference rig and tracks
Normally when you import animations, script will create separate rig and track list for each animation. When working with multiple animations, it may be useful to create rig and track list for reference scene. When importing script will cross check rig and tracks extracted from animations with provided reference rig and track list and will only create RIG or TRACKS files if there is any difference. What this means in practice is that we won't have to go through rig and track list for every animation and edit them to contain added bones, because most animations will use reference files instead.
In order to create reference RIG file, click Edit Rig button (with melee_blade_range_pistol.max loaded as current scene). Next click Import button and select animation file to import from (it's best to pick some common animation like idle, run, melee eg. fb_run.anim). This will import skeleton from selected animation. Click OK button to save RIG file as melee_blade_range_pistol.rig.
Now do the same for TRACKS file with Edit Tracks button. Again remember to pick some common animation, as special animations like aims will typically have only one or two tracks. File will be saved as melee_blade_range_pistol.tracks.
Step 5: Import animations
Next we need to import animations for editing. In MAX go to Animations rollout and click Batch Import. Script will ask for source directory with animations (the one from step 1) and output directory to save MAX scene files (you can choose here Animations directory created when importing space marine model). You should have your animation reference scene loaded into MAX before importing or else script will ask to provide it.
Note that this process may take a while (~10 minutes for me), so feel free to go for a coffee. ;)
Step 6: Animate the cape
Ok, now when we have all imported animations stored in MAX scene files, we need to open them one by one and modify each animation by making the cape to follow and react approprietly to overall space marine body movement.
Animations that have their own TRACKS file (which basically means they're not using all bones in the skeleton), should be exported without changes (in most cases).
Step 7: Update reference rig and track list
At this point we could export our modified animations, however since we added some new bones to the skeleton, we need to update reference RIG and TRACKS files. Open melee_blade_range_pistol.max, go to Animations rollout and click Edit Rig. We need to move bones listed below from the list on the left to the list on the right, by clicking the [>] button:
bip01 l cape
bip01 l cape1
bip01 m cape
bip01 m cape1
bip01 r cape
bip01 r cape1
Notice that bones are placed on the list with regards to their parent bone (hierarchy is not visible since it's just a plain list). Now do the same for tracks with Edit Tracks button.
Step 8: Export animations
When done, click Batch Export button, select directory containing MAX scene files with animations as source and empty output directory where all the HKX files will be created. Note that this function also requires animation reference file (melee_blade_range_pistol.max in our case) to be loaded, else you will be prompted to pick one.
Export process is much faster than import, however due to technical reasons it doesn't show total export progress so you just need to wait patiently until message box appears confirming export has been completed.
Step 9: Add animations to container
Open Model Editor and load space marine model. Go to Animations page and click Import Directory. This function will import entire directory of animations into container. Existing animations will be replaced, if directory already exists. Check the log after import for any warnings or errors.
Save entire container as space_marine.hkanim using Pack button and we're done!
http://img525.imageshack.us/img525/9831/capez.png
Appendix A
It may happen that your new or modified animations won't import properly into Model Editor, despite HKX files being created upon export from MAX and no errors being reported. The reason for this is usually the same. In order for animation to be usable in the game, it needs to be delta compressed by Havok exporter. Havok's delta compression algorithm apparently requires at least 8 frames of animation to work with. If there is not enough frames, animation will export in uncompressed format, which unfortunately is not usable for our purposes.
To verify animation in being compressed upon export, you can use Export Animation button, which will display Havok Content Tools window. After pressing Run Configuration to export animation, look at the export log:
http://imageshack.us/a/img20/3348/havoki.png
The warning Animations with less than 8 frames cannot be compressed tells you, that animation was not compressed and needs to be adjusted in order to export properly. If animation has less than 8 frames on the timeline, there's unfortunately no workaround available at present - it needs to be extended to 8 frames or more. If animation is meant to be looping you can just copy over existing keys until there is enough frames. Other animations can be usually expanded to cover entire timeline.
In some cases animation may still not compress upon export, despite having required number of frames. Delta compression requires 8 frames of actual animation, not just being there on the timeline. So you need to have at least one bone in your rig that has at least 8 frames of motion.
This poses problems however with certain animations like weapon aim or being dead. Typically these kind of animations won't have any bones animated because model is expected to remain static (if you're moving you're not quite dead yet, are you? :lol:). There is a way to trick the exporter here fortunately. As was said before you need at least one bone in your skeleton to be animated, but apparently this bone doesn't have to be included in animation track list! Tracks are specifying which bones will be used in the animation (they count as used even if they don't move or rotate), so if we animate some bone but not include it in track list, it's motion won't be visible in the game at all and animation will still get compressed.
What about situations where entire skeleton is used by animation (pretty common for infantry models)? In such case the only solution I've found, is to add an extra bone to animation's rig and use it just for exporting purposes as described above. This bone doesn't have to be included in animation tracks and adding it to model's main skeleton is not necessary as well.
A common problem in Dawn of War 2 modding, is using various accessories or wargear with different animation sets. For example Space Marine Veteran's Cape can only be used when space marine is wielding a thunder hammer. In this tutorial I'm going to show, how to make Veteran's Cape usable with bolter & chainsword animation set. The method described below can be used to add all sorts of animated elements like capes, loincloths, trophies, plumed helmets, fancy hair styles etc.
Here's what you need:
Dawn of War II (:p)
Santos Tools 2 (http://forums.relicnews.com/showthread.php?244744)
3D Studio MAX 8-12
Havok Content Tools v5.5.0 or v6.6.0
Havok Content Tools are available for free via Try Havok (http://software.intel.com/sites/havok/) program. Currently versions 5.5.0 and 6.6.0 are supported. Other versions may be supported in the future.
Step 1: Convert animations to custom format
As in previous tutorial (http://forums.relicnews.com/showthread.php?255600-Tutorial-Santos-Tools-2-Tutorial-3-Exporting-Animation), we start by exporting Space Marine's animations into Santos Tools 2 custom animation format. To do this launch Model Editor, open space marine model and go to Animations page. There are several folders here but we are currently interested only in melee_blade_range_pistol directory, which contains animations for bolter & chainsword combo. Right click this folder and choose Export from context menu to convert all animations in this folder into custom format (the folder itself will be created as well).
Step 2: Find out which bones are missing
Next we need to determine if any bones are missing from reference skeleton. Launch MAX and import space marine model. You can check Save Scene to save reference file into MAX scene file. Now with reference file loaded, use Quick Import button on Animations rollout to import single animation into the scene (for example: fb_run.anim). Open MAXScript Listener (F11) and look for warnings about missing bones:
"WARNING: Bone 'chainsword_teeth_01' is missing!"
"WARNING: Bone 'chainsword_teeth_02' is missing!"
"WARNING: Bone 'chainsword_teeth_03' is missing!"
"WARNING: Bone 'chainsword_teeth_04' is missing!"
"WARNING: Bone 'chainsword_teeth_05' is missing!"
"WARNING: Bone 'chainsword_teeth_06' is missing!"
"WARNING: Bone 'chainsword_teeth_07' is missing!"
"WARNING: Bone 'chainsword_teeth_08' is missing!"
"WARNING: Bone 'chainsword_teeth_09' is missing!"
"WARNING: Bone 'chainsword_teeth_10' is missing!"
"WARNING: Bone 'chainsword_teeth_11' is missing!"
"WARNING: Bone 'chainsword_teeth_12' is missing!"
"WARNING: Bone 'chainsword_teeth_13' is missing!"
"WARNING: Bone 'chainsword_teeth_14' is missing!"
"WARNING: Bone 'chainsword_teeth_15' is missing!"
"WARNING: Bone 'chainsword_teeth_16' is missing!"
"WARNING: Bone 'chainsword_teeth_17' is missing!"
"WARNING: Bone 'chainsword_teeth_18' is missing!"
"WARNING: Bone 'chainsword_teeth_19' is missing!"
"WARNING: Bone 'chainsword_teeth_20' is missing!"
"WARNING: Bone 'bip01_banner' is missing!"As you can see we're missing 21 bones in total, from two following models:
art\race_marine\troops_wargear\weapons_melee\chainsword_common\chainsword_common.model
art\race_marine\troops_wargear\accessories\bloodravens_banner\bloodravens_banne.model
Step 3: Create animation reference file
In this step we need to create a reference file with full skeleton, which will be used for importing animations. In previous tutorial (http://forums.relicnews.com/showthread.php?255600-Tutorial-Santos-Tools-2-Tutorial-3-Exporting-Animation), I've shown how to create animation reference file step by step. Here I'm going to show a different (and possibly better) way to do it.
Open Model Editor again and load space marine model. Go to Attachments page and add following models:
art\race_marine\troops_wargear\armour\power_armour_common\power_armour_common.model
art\race_marine\troops_wargear\heads\space_marine\space_marine_head.model
art\race_marine\troops_wargear\accessories\bloodravens_banner\bloodravens_banner.model
art\race_marine\troops_wargear\weapons_melee\chainsword_common\chainsword_common.model
art\race_marine\troops_wargear\weapons_ranged\bolt_pistol_common\bolt_pistol_common.model
When imported to MAX this will give us a model with full skeleton and some meshes for reference. However since we're also adding Veteran's Cape, we need to include this model as well:
art\race_marine\troops_wargear\accessories\veterans_cape\veterans_cape.model
http://img529.imageshack.us/img529/9648/modelset.png
Save entire model set as melee_blade_range_pistol.modelset. Now, go back to MAX, import this file with Import Model button and save scene as melee_blade_range_pistol.max in model's Reference folder.
You can also clean the model up a little bit by removing the elements we won't really need (banner, lod2 meshes, wreck mesh group) and scaling some bones to fit better into the mesh.
http://img440.imageshack.us/img440/8861/referencei.png
Step 4: Create reference rig and tracks
Normally when you import animations, script will create separate rig and track list for each animation. When working with multiple animations, it may be useful to create rig and track list for reference scene. When importing script will cross check rig and tracks extracted from animations with provided reference rig and track list and will only create RIG or TRACKS files if there is any difference. What this means in practice is that we won't have to go through rig and track list for every animation and edit them to contain added bones, because most animations will use reference files instead.
In order to create reference RIG file, click Edit Rig button (with melee_blade_range_pistol.max loaded as current scene). Next click Import button and select animation file to import from (it's best to pick some common animation like idle, run, melee eg. fb_run.anim). This will import skeleton from selected animation. Click OK button to save RIG file as melee_blade_range_pistol.rig.
Now do the same for TRACKS file with Edit Tracks button. Again remember to pick some common animation, as special animations like aims will typically have only one or two tracks. File will be saved as melee_blade_range_pistol.tracks.
Step 5: Import animations
Next we need to import animations for editing. In MAX go to Animations rollout and click Batch Import. Script will ask for source directory with animations (the one from step 1) and output directory to save MAX scene files (you can choose here Animations directory created when importing space marine model). You should have your animation reference scene loaded into MAX before importing or else script will ask to provide it.
Note that this process may take a while (~10 minutes for me), so feel free to go for a coffee. ;)
Step 6: Animate the cape
Ok, now when we have all imported animations stored in MAX scene files, we need to open them one by one and modify each animation by making the cape to follow and react approprietly to overall space marine body movement.
Animations that have their own TRACKS file (which basically means they're not using all bones in the skeleton), should be exported without changes (in most cases).
Step 7: Update reference rig and track list
At this point we could export our modified animations, however since we added some new bones to the skeleton, we need to update reference RIG and TRACKS files. Open melee_blade_range_pistol.max, go to Animations rollout and click Edit Rig. We need to move bones listed below from the list on the left to the list on the right, by clicking the [>] button:
bip01 l cape
bip01 l cape1
bip01 m cape
bip01 m cape1
bip01 r cape
bip01 r cape1
Notice that bones are placed on the list with regards to their parent bone (hierarchy is not visible since it's just a plain list). Now do the same for tracks with Edit Tracks button.
Step 8: Export animations
When done, click Batch Export button, select directory containing MAX scene files with animations as source and empty output directory where all the HKX files will be created. Note that this function also requires animation reference file (melee_blade_range_pistol.max in our case) to be loaded, else you will be prompted to pick one.
Export process is much faster than import, however due to technical reasons it doesn't show total export progress so you just need to wait patiently until message box appears confirming export has been completed.
Step 9: Add animations to container
Open Model Editor and load space marine model. Go to Animations page and click Import Directory. This function will import entire directory of animations into container. Existing animations will be replaced, if directory already exists. Check the log after import for any warnings or errors.
Save entire container as space_marine.hkanim using Pack button and we're done!
http://img525.imageshack.us/img525/9831/capez.png
Appendix A
It may happen that your new or modified animations won't import properly into Model Editor, despite HKX files being created upon export from MAX and no errors being reported. The reason for this is usually the same. In order for animation to be usable in the game, it needs to be delta compressed by Havok exporter. Havok's delta compression algorithm apparently requires at least 8 frames of animation to work with. If there is not enough frames, animation will export in uncompressed format, which unfortunately is not usable for our purposes.
To verify animation in being compressed upon export, you can use Export Animation button, which will display Havok Content Tools window. After pressing Run Configuration to export animation, look at the export log:
http://imageshack.us/a/img20/3348/havoki.png
The warning Animations with less than 8 frames cannot be compressed tells you, that animation was not compressed and needs to be adjusted in order to export properly. If animation has less than 8 frames on the timeline, there's unfortunately no workaround available at present - it needs to be extended to 8 frames or more. If animation is meant to be looping you can just copy over existing keys until there is enough frames. Other animations can be usually expanded to cover entire timeline.
In some cases animation may still not compress upon export, despite having required number of frames. Delta compression requires 8 frames of actual animation, not just being there on the timeline. So you need to have at least one bone in your rig that has at least 8 frames of motion.
This poses problems however with certain animations like weapon aim or being dead. Typically these kind of animations won't have any bones animated because model is expected to remain static (if you're moving you're not quite dead yet, are you? :lol:). There is a way to trick the exporter here fortunately. As was said before you need at least one bone in your skeleton to be animated, but apparently this bone doesn't have to be included in animation track list! Tracks are specifying which bones will be used in the animation (they count as used even if they don't move or rotate), so if we animate some bone but not include it in track list, it's motion won't be visible in the game at all and animation will still get compressed.
What about situations where entire skeleton is used by animation (pretty common for infantry models)? In such case the only solution I've found, is to add an extra bone to animation's rig and use it just for exporting purposes as described above. This bone doesn't have to be included in animation tracks and adding it to model's main skeleton is not necessary as well.