Skip to content

Instantly share code, notes, and snippets.

@olie304
Last active March 15, 2024 00:53
Show Gist options
  • Save olie304/d22bdb8cd864842fb06267f3e3037ab9 to your computer and use it in GitHub Desktop.
Save olie304/d22bdb8cd864842fb06267f3e3037ab9 to your computer and use it in GitHub Desktop.
Very rough and non-robust script for batch converting animations into XAnims. By default it handles converting SEAnims into xanim_bins. Works with Blackops 3 or other CoDMayaTools compatible games.
// https://github.com/olie304
// Very rough and non-robust script for batch converting animations into XAnims. By default it handles converting SEAnims into xanim_bins
// Tested with Maya 2022, Requires: CoDMayaTools (https://github.com/LunaRyuko/CoDMayaTools) and SETools (https://github.com/dtzxporter/SETools). Make sure you download and build the pull requests that update each plugin for Maya 2022 and Python 3!
// $animPath should be a full, forward slashed, path to a directory with exclusively SEAnims.
// $outputPath is where the xanim_bins should be exported to
// Edit the import options in the `file -import -ty...` command in the script if needed.
// Open the Export XAnim tab in Call of Duty Tools and edit some of the settings if needed. Leave the window open!
{
string $animPath = "C:/my/seanim/dir/";
string $outputPath = "C:/Program Files (x86)/Steam/steamapps/common/Call of Duty Black Ops III/xanim_export/my_dir/";
string $files[] = {};
string $items[] = `getFileList -fld $animPath`;
for ($item in $items)
{
string $full = ($animPath+$item);
if (`filetest -f $full`)
{
$files[size($files)] = $item;
}
}
//print $files;
for($i=0; $i<size($files); $i++)
{
// Import and setup export options
string $buffer[];
tokenize $files[$i] "." $buffer;
// Imports and overrides current animations. Change this if you want to do something other than SEAnim. SETools has a built in file handler for seanim so we can import using the built-in cmd.
file -import -type "SEAnim Animations" -ignoreVersion -ra true -mergeNamespacesOnClash false -namespace $buffer[0] -pr -importFrameRate true -importTimeRange "override" ($animPath+$files[$i]);
select -r Joints;
SelectHierarchy;
python("CoDMayaTools.ShowWindow('xanim')"); // CoDMayaTools compliance, some of the options in the window are editable, change them before running script if desired
python("CoDMayaTools.SetFrames('xanim')");
catch(python("CoDMayaTools.ReadNotetracks('xanim')")); // Don't worry about the 'iter..' or 'No items' exceptions. There are just no notetracks (probably)
// Create progress bar window for CoDMayaTools compliance
if (`control -exists "wCoDMayaToolsProgressbar"`) deleteUI "wCoDMayaToolsProgressbar";
string $progressWindow = `window -title "Progress" -widthHeight 302 22 -sizeable false "wCoDMayaToolsProgressbar"`;
columnLayout;
string $progressControl = `progressBar -width 300 "CoDMayaToolsProgressbar"`;
showWindow $progressWindow;
refresh;
// Export
string $buffer[];
tokenize $files[$i] "." $buffer;
python("CoDMayaTools.ExportXAnim('" + $outputPath + $buffer[0] + ".xanim_bin')"); // You will have to change this up if you want to do xanim_export instead, don't know the full details
deleteUI -window $progressWindow;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment