/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. //////////////////////////////////////////////////////////////////// // // CryAnim.mel // // Libraries for exporting animation for the cry exporter // ////////////////////////////////////////////////////////////////////// python( "import mayaAnimUtilities as mau" ); // keeping track of the last folder global string $cryAnimArrangeLastPath = ""; //obsolete global proc cryAnimZeroJointRotation() { string $response = `confirmDialog -title "Lumberyard Animation" -message ("This will try to remove any rotation and set the joint-orientation to\nzero on the selected joints by pushing it down to the joints children.") -button "OK" -button "Cancel"`; if( $response != "OK" ) { return; } string $selected[] = `ls -sl`; if( size($selected) == 0 ) { confirmDialog -title "Lumberyard Animation" -message ("No nodes are selected.") -button "OK"; return; } string $tempGroup = `group -empty -name "cryAnimTempGroup"`; for( $node in $selected ) { if( `objectType $node` == "joint" ) { string $children[]; // Unparent all children $children = `listRelatives -children -fullPath $node`; for ($child in $children) { parent $child $tempGroup; } // Make sure the attributes are unlocked and set the rotation and joint orientation to 0 setAttr -lock off ($node+".rotateX"); setAttr -lock off ($node+".rotateY"); setAttr -lock off ($node+".rotateZ"); setAttr -lock off ($node+".jointOrientX"); setAttr -lock off ($node+".jointOrientY"); setAttr -lock off ($node+".jointOrientZ"); setAttr ($node+".rotateX") 0; setAttr ($node+".rotateY") 0; setAttr ($node+".rotateZ") 0; setAttr ($node+".jointOrientX") 0; setAttr ($node+".jointOrientY") 0; setAttr ($node+".jointOrientZ") 0; // Re-parent the children $children = `listRelatives -children -fullPath $tempGroup`; for ($child in $children) { parent $child $node; } } else { confirmDialog -title "Lumberyard Animation" -message ("Node `"+$node+"` is not a joint.") -button "OK"; } } delete $tempGroup; select $selected; } ///////////////////////////////////////////////////////////////////////// // These save and load functions need to be merged into a setting system // of some sort thats sharded with the export window etc. ///////////////////////////////////////////////////////////////////////// // Load from the AnimRanges field in the settings node global proc cryAnimManagerLoadSettings() { if( `control -exists CRYANIMMANAGER_ANIMRANGES` ) { textScrollList -e -removeAll CRYANIMMANAGER_ANIMRANGES; string $rangesString = `cryAnimLoadRangesString`; string $tokens[]; $numTokens = `tokenize $rangesString "," $tokens`; if( $numTokens != 0 ) { for( $i = 0;$i<$numTokens;$i++ ) { if( size($tokens[$i]) > 0 ) { textScrollList -e -append $tokens[$i] CRYANIMMANAGER_ANIMRANGES; } } } } } // Save to the AnimRanges field in the settings node global proc cryAnimManagerSaveSettings() { string $rangesString = ""; string $animRanges[]; $animRanges = `textScrollList -q -allItems CRYANIMMANAGER_ANIMRANGES`; for( $i = 0;$i 0 ) $rangesString += ","; $rangesString += $animRanges[$i]; } cryAnimSaveRangesString $rangesString; } global proc animManagerAddAnimRangeCloseWindow() { deleteUI -window CRYANIMMANAGER_ADDRANGEWINDOW; } proc int animManagerAnimRangeValidate( int $editEntry, string $name, int $start, int $end, string $rootNode, string $path ) { int $editIndex = $editEntry; int $rangeCount = `cryAnimGetNumRanges`; string $animRanges[] = `cryAnimGetRanges`; // Make sure there is not a range with the same name already in the list for( $i = 0;$i<$rangeCount;$i++ ) { string $decode[]; //bypassing c++ code //$decode = `cryExportDecodeRangeString $animRanges[$i]`; $decode = python("mau.AMZN_DecodeAnimRangeString(\"" + $animRanges[$i] + "\")"); if( size($decode) >= 5 ) { if(( `strcmp $decode[2] $name` == 0 )&&(`strcmp $decode[4] $path` == 0)) { if( $i != $editIndex ) { confirmDialog -title "Anim Range" -message "A range with that name already exists." -button "Ok"; return 0; } } } } // Make sure the root node is valid if( `size($rootNode)` != 0 ) { string $rootNodes[]; $numRoots = `tokenize $rootNode ";" $rootNodes`; for( $root in $rootNodes ) { $foundRoots = `ls $root`; if( `size($foundRoots)` == 0 ) { confirmDialog -title "Anim Range" -message "The root node could not be found." -button "Ok"; return 0; } else if( `size($foundRoots)` > 1 ) { confirmDialog -title "Anim Range" -message "Root node name matches more than one node." -button "Ok"; return 0; } else { string $tokens[]; $numTokens = `tokenize $root "|" $tokens`; string $nodeNameLC = `tolower $tokens[$numTokens-1]`; string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix(); if( `objectType -isType "joint" $root` == 0 && `startsWith $nodeNameLC $lumberyardExportNodePrefix` == 0 ) { confirmDialog -title "Anim Range" -message "The root node needs to be a joint or a `LumberyardExportNode`." -button "Ok"; return 0; } } } } return 1; } global proc addAnimRangeUseCurrent() { setMinMaxPlayback ADDRANGE_START ADDRANGE_END; string $lumberyardExportNodes[]; $lumberyardExportNodes = `cryMayaSupportPlugin gatherExportNodes selectedOnly`; if ( size($lumberyardExportNodes) == 1 ) { string $tokens[]; $numTokens = `tokenize $lumberyardExportNodes[0] "_" $tokens`; if ( $numTokens > 1 ) { textField -e -text $tokens[1] ADDRANGE_NAME; } } } global proc string GetRootJointForSelection(string $defaultRootJoint) { string $rootJointString = $defaultRootJoint; string $selected[]; $selected = `ls -sl -l`; if( `size($selected)` > 0 ) { int $selectedCount = size($selected); $rootJointString = ""; for( $i = 0; $i < $selectedCount; $i++ ) { string $rootJoint = $selected[$i]; string $tokens[]; $numTokens = `tokenize $rootJoint "|" $tokens`; string $nodeNameLC = `tolower $tokens[$numTokens-1]`; string $rootJointStrip = $rootJoint; if( `startsWith $rootJoint "|"` ) // Remove the leading `|` { $length = size($rootJoint); $rootJointStrip = `substring $rootJoint 2 $length`; } string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix(); if( `objectType -isType "joint" $rootJoint` || `startsWith $nodeNameLC $lumberyardExportNodePrefix`) { if( $i > 0 ) { $rootJointString += (";"); } $rootJointString += $rootJointStrip; } } } return $rootJointString; } global proc selectAnimRangeRoot() { string $rootNodeString = `textField -query -text ADDRANGE_ROOTNODE`; $rootNodeString = `GetRootJointForSelection $rootNodeString`; textField -e -text $rootNodeString ADDRANGE_ROOTNODE; } ////////////////////////////// // // ui function // ////////////////////////////// global proc animManagerAddAnimRangeAdd( int $editEntry ) { string $name = strip(`textField -q -text ADDRANGE_NAME`); int $start = `floatField -q -value ADDRANGE_START`; int $end = `floatField -q -value ADDRANGE_END`; string $root = `textField -q -text ADDRANGE_ROOTNODE`; string $path = `textField -q -text ADDRANGE_PATH`; if( size($name) == 0 ) $name = "noName"; string $currentLayerSettings = `textField -q -text ADDRANGE_ADDLAYERINFO`; if( `animManagerAnimRangeValidate $editEntry $name $start $end $root $path` ) { string $rangeString = `cryAnimFormatRangeString $start $end $name $root $path $currentLayerSettings`; if( $editEntry >= 0 ) { cryAnimReplaceRange $editEntry $rangeString; } else { cryAnimAddRange $rangeString; } animManagerAddAnimRangeCloseWindow; cryAnimManagerLoadSettings; cryAnimPopulateRangeList; cryExportUpdateExportLists; } } global proc cryAnimManagerSetAnimLayerInfo() { string $layers = cryReturnActiveAnimLayers(); textField -e -text $layers ADDRANGE_ADDLAYERINFO; } global proc cryAnimManagerClearAnimLayerInfo() { textField -e -text "" ADDRANGE_ADDLAYERINFO; } ////////////////////////////// // // ui function // ////////////////////////////// global proc cryAnimManagerSetPathText() { global string $cryAnimArrangeLastPath; string $folderPath = `textField -q -text ADDRANGE_PATH`; $folderPath = `cryExportFixupPath $folderPath`; // do not save empty paths e.g. if the user cancels $cryAnimArrangeLastPath = $folderPath; textField -e -text $folderPath ADDRANGE_PATH; } // parameter name: $editEntry // value range: >= -1 // -1: when the function is called for "New" an animation range item; // >= 0: when the function is called for "Edit" an existed animation range item, // the value is the id of the item in the list. // It is used for retrieving the animation range item from the list for editing // its folder path. global proc cryAnimManagerBrowseForFolder( int $editEntry ) { global string $cryAnimArrangeLastPath; // if this is the first time we browse for folder, // start at the path that the scene file is located if ($cryAnimArrangeLastPath == "") { $cryAnimArrangeLastPath = `file -q -sceneName`; $cryAnimArrangeLastPath = `dirname $cryAnimArrangeLastPath`; } string $startingFolder = $cryAnimArrangeLastPath; int $numRanges = `cryAnimGetNumRanges`; string $ranges[] = `cryAnimGetRanges`; // get the previously assigned path of a specific animation item, // if it's not in "NEW" mode (which will take -1 as $editEntry) if( $editEntry != -1 && $numRanges > 0 ) { string $editText = $ranges[$editEntry]; string $decode[]; //bypassing C++ code //$decode = `cryExportDecodeRangeString $editText`; $decode = python("mau.AMZN_DecodeAnimRangeString(\"" + $editText + "\")"); if( size($decode) >= 5 ) { string $animPath = $decode[4]; $startingFolder = `cryExportFixupPath $animPath`; $cryAnimArrangeLastPath = $startingFolder; } } string $absPath = `cryExportRelativeToAbsolutePath $startingFolder`; string $result[] = `fileDialog2 -fileMode 3 -startingDirectory $absPath -fileFilter ("Directories only (*)")`; if( size($result) == 1 ) { textField -e -text $result[0] ADDRANGE_PATH; cryAnimManagerSetPathText(); } } ////////////////////////////// // // ui function // ////////////////////////////// global proc cryAnimManagerEditAnimRangeWin( int $mode, int $editEntry ) { if( $mode == 0 || $mode == 1 ) { if(!`window -ex CRYANIMMANAGER_ADDRANGEWINDOW`) { if(`windowPref -exists CRYANIMMANAGER_ADDRANGEWINDOW`) { windowPref -wh 473 210 -tlc `windowPref -q -topEdge CRYANIMMANAGER_ADDRANGEWINDOW` `windowPref -q -leftEdge CRYANIMMANAGER_ADDRANGEWINDOW` CRYANIMMANAGER_ADDRANGEWINDOW; } window -titleBar true -title "Add Anim Range" -widthHeight 460 210 -sizeable false -mnb false -mxb false CRYANIMMANAGER_ADDRANGEWINDOW; $layout1 = `formLayout -numberOfDivisions 100`; $collayout = `columnLayout -rowSpacing 5 -adjustableColumn true`; button -label "Use Range From Time Slider" -command ("addAnimRangeUseCurrent"); $rcLayout = `rowColumnLayout -numberOfColumns 4 -columnAttach 1 "right" 0 -columnWidth 1 110 -columnWidth 2 200 -columnWidth 3 70 -columnWidth 4 70 -columnSpacing 2 5 -columnSpacing 3 5`; { text -label "Name"; textField -text "New" ADDRANGE_NAME; text -label ""; text -label ""; text -label "Start Frame"; float $animStartTime = `playbackOptions -q -ast`; floatField -precision 0 -step 1 -value $animStartTime ADDRANGE_START; text -label ""; text -label ""; text -label "End Frame"; float $animEndTime = `playbackOptions -q -aet`; floatField -precision 0 -step 1 -value $animEndTime ADDRANGE_END; text -label ""; text -label ""; text -label "Root"; textField -text "" ADDRANGE_ROOTNODE; $rootButton = `button -label "Select" -command ("selectAnimRangeRoot")`; text -label ""; text -label "Path"; global string $cryAnimArrangeLastPath; textField -text $cryAnimArrangeLastPath -changeCommand("cryAnimManagerSetPathText ") ADDRANGE_PATH; // use the last browsed path as the default path for a new animation range item button -label "Browse" -command ("cryAnimManagerBrowseForFolder "+$editEntry); text -label ""; text -label "Anim Layer Commands"; textField -text "" ADDRANGE_ADDLAYERINFO; button -label "Set" -command ("cryAnimManagerSetAnimLayerInfo"); button -label "Clear" -command ("cryAnimManagerClearAnimLayerInfo"); } setParent ..; setParent ..; string $addText = "Add"; if( $mode == 1 ) $addText = "Edit"; $addbutton = `button -label $addText -command ("animManagerAddAnimRangeAdd "+$editEntry)`; $cancelbutton = `button -label "Cancel" -command ("animManagerAddAnimRangeCloseWindow")`; setParent ..; formLayout -edit -attachForm $collayout "top" 5 -attachForm $collayout "left" 5 -attachForm $collayout "right" 5 -attachNone $collayout "bottom" -attachForm $addbutton "bottom" 5 -attachForm $addbutton "left" 5 -attachPosition $addbutton "right" 5 50 -attachNone $addbutton "top" -attachForm $cancelbutton "bottom" 5 -attachPosition $cancelbutton "left" 5 50 -attachForm $cancelbutton "right" 5 -attachNone $cancelbutton "top" $layout1; if( $mode == 1 ) { // Fill out the window with the selected entry int $numRanges = `cryAnimGetNumRanges`; string $ranges[] = `cryAnimGetRanges`; if( $editEntry >= 0 && $editEntry < $numRanges ) { string $editText = $ranges[$editEntry]; string $decode[]; //bypassing c++ code //$decode = `cryExportDecodeRangeString $editText`; $decode = python("mau.AMZN_DecodeAnimRangeString(\"" + $editText + "\")"); if( size($decode) >= 5 ) { int $animStart = $decode[0]; int $animEnd = $decode[1]; string $animName = $decode[2]; string $animRoot = $decode[3]; string $animPath = $decode[4]; string $animLayers = $decode[5]; textField -e -text $animName ADDRANGE_NAME; floatField -e -value $animStart ADDRANGE_START; floatField -e -value $animEnd ADDRANGE_END; textField -e -text $animRoot ADDRANGE_ROOTNODE; textField -e -text $animPath ADDRANGE_PATH; textField -e -text $animLayers ADDRANGE_ADDLAYERINFO; } } } showWindow CRYANIMMANAGER_ADDRANGEWINDOW; } } else if( $mode == 2 ) { // Remove indexed item cryAnimRemoveAnimRange $editEntry; cryAnimManagerLoadSettings; cryAnimPopulateRangeList; cryExportUpdateExportLists; } else if( $mode == 3 ) { // Remove all items string $response = `confirmDialog -title "Lumberyard Animation" -message ("Delete all animations?") -button "Yes" -button "No"`; if( $response == "Yes" ) { cryAnimRemoveAllAnimRanges; cryAnimManagerLoadSettings; cryAnimPopulateRangeList; cryExportUpdateExportLists; } } } global proc cryAnimManagerSelectRoots( string $rootNodes ) { string $rootTokens[]; $numTokens = `tokenize $rootNodes ";" $rootTokens`; select -clear; for( $root in $rootTokens ) { select -add $root; } } global proc cryAnimManagerCopyRangeText( string $rangeText ) { cryMayaSupportPlugin copyToClipboard $rangeText; } global proc cryAnimManagerEditAnimRange( int $mode ) { int $editEntry = -1; if( $mode == 1 || $mode == 2 ) { int $selectedArray[]; $selectedArray = `textScrollList -q -selectIndexedItem CRYANIMMANAGER_ANIMRANGES`; if( size($selectedArray) == 1 ) { // Subtract 1 as the list is 1 based but the array is 0 based $editEntry = ($selectedArray[0] - 1); } else { confirmDialog -title "Error" -message "No anim range is selected." -button "Ok" -defaultButton "Ok"; return; } } cryAnimManagerEditAnimRangeWin $mode $editEntry; } ////////////////////////////// // // ui function // ////////////////////////////// global proc cryAnimManagerAnimRangesDClick( int $inIndex ) { int $index = $inIndex; if( `control -q -exists CRYANIMMANAGER_ANIMRANGES` ) { int $selectedArray[]; $selectedArray = `textScrollList -q -selectIndexedItem CRYANIMMANAGER_ANIMRANGES`; if( size($selectedArray) == 1 ) $index = $selectedArray[0] - 1; } int $numRanges = `cryAnimGetNumRanges`; string $ranges[] = `cryAnimGetRanges`; if( $index >= 0 && $index < $numRanges ) { string $decode[]; //bypassing c++ function //$decode = cryExportDecodeRangeString( $ranges[$index] ); $decode = `python("mau.AMZN_DecodeAnimRangeString(\"" + $ranges[$index] + "\")")`; string $animStart = $decode[0]; string $animEnd = $decode[1]; playbackOptions -min $animStart -max $animEnd; currentTime $animStart; } } ////////////////////////////// // // ui function // ////////////////////////////// global proc cryAnimManagerUICloseWindow() { //cryAnimManagerSaveSettings; // Removed as we should only save when something changes. deleteUI -window CRYANIMMANAGER_WINDOW; } ////////////////////////////// // // ui function // ////////////////////////////// proc string cryAnimCreateParentRowLayout() { $rowname = `rowLayout -numberOfColumns 4 -columnWidth4 20 100 65 65 -adjustableColumn 2 -columnAlign 2 "left" -columnAlign 3 "center" -columnAlign 4 "center" -columnAttach 3 "both" 0 -columnAttach 4 "both" 0 -bgc .4 .4 .4`; return $rowname; } ////////////////////////////// // // ui function // ////////////////////////////// proc string cryAnimCreateChildRowLoyout() { $rowname = `rowLayout -numberOfColumns 6 -columnWidth6 35 35 150 150 250 85 -adjustableColumn 5 -bgc .4 .4 .4 -columnAlign 1 "center" -columnAttach 1 "both" 0 -columnAlign 2 "center" -columnAttach 2 "both" 0 -columnAlign 3 "center" -columnAttach 3 "both" 0 -columnAlign 4 "center" -columnAttach 4 "both" 0 -columnAlign 5 "center" -columnAttach 5 "both" 0 -columnAlign 6 "center" -columnAttach 6 "both" 0`; return $rowname; } ////////////////////////////// // // ui function // ////////////////////////////// proc cryAnimAddRangeToList( string $range, int $rangeNum ) { if( !`control -q -exists CRYANIM_COLUMNLAYOUT` ) return; setParent CRYANIM_COLUMNLAYOUT; $rowName = `cryAnimCreateParentRowLayout`; { button -label "#" -command ("cryAnimManagerAnimRangesDClick "+$rangeNum); string $rootNodes = ""; cryAnimCreateChildRowLoyout; { string $decode[]; //bypassing c++ code //$decode = `cryExportDecodeRangeString $range`; $decode = `python("mau.AMZN_DecodeAnimRangeString(\"" + $range + "\")")`; if( size($decode) >= 5 ) { text -h 22 -label ($decode[0]) -bgc .5 .55 .5; text -h 22 -label ($decode[1]) -bgc .5 .5 .55; text -h 22 -label ($decode[2]) -bgc .5 .55 .5; text -h 22 -label ($decode[3]) -bgc .5 .5 .55; text -h 22 -label ($decode[4]) -bgc .5 .55 .5; if ($decode[5] != "") text -h 22 -label "Set" -bgc .5 .55 .55; else text -h 22 -label "Not Set" -bgc .5 .55 .55; $rootNodes = $decode[3]; } //$messageText = `text -h 22 -label (" "+$range)`; } setParent ..; button -align "center" -label "Edit" -command ( "cryAnimManagerEditAnimRangeWin 1 "+$rangeNum ); button -align "center" -label "Delete" -command ( "cryAnimManagerEditAnimRangeWin 2 "+$rangeNum ); popupMenu -parent $rowName -button 3; { menuItem -label "Select root nodes" -command ( "cryAnimManagerSelectRoots \""+$rootNodes+"\"" ); menuItem -divider true; menuItem -label "Copy range text" -command ( "cryAnimManagerCopyRangeText \""+$range+"\"" ); menuItem -divider true; menuItem -label "Show in Explorer" -command ( "cryExportAnimIndexShowInExplorer "+$rangeNum ); menuItem -divider true; menuItem -label "Find Anims" -command ("cryAnimManagerFindAnims"); } } setParent ..; } ////////////////////////////// // // ui function // ////////////////////////////// global proc cryAnimPopulateRangeList() { if( !`control -q -exists CRYANIM_COLUMNLAYOUT` ) return; setParent CRYANIM_COLUMNLAYOUT; string $childControls[]; $childControls = `layout -q -childArray CRYANIM_COLUMNLAYOUT`; for( $child in $childControls ) { deleteUI $child; } int $numRanges = `cryAnimGetNumRanges`; string $ranges[] = `cryAnimGetRanges`; cryAnimCreateParentRowLayout; { text -h 10 -label ""; cryAnimCreateChildRowLoyout; { text -h 10 -label "Start"; text -h 10 -label "End"; text -h 10 -label "Name"; text -h 10 -label "Root Node"; text -h 10 -label "Export Path"; text -h 10 -label "Layers"; } setParent ..; text -h 10 -label ""; text -h 10 -label ""; } setParent ..; separator -height 2 -style "in"; if( $numRanges > 0 ) { int $rangeNum = 0; for( $range in $ranges ) { cryAnimAddRangeToList $range $rangeNum; $rangeNum++; } } } // This function is currently not being called from anywhere. It is related to the old system of storing animations. global proc cryAnimManagerFindAnims() { string $namespaces[] = `namespaceInfo -listOnlyNamespaces`; int $foundNode = 0; for($namespace in $namespaces ) { string $settingsName = $namespace + ":" + LumberyardGetExportSettingNodeName(); if( `objExists $settingsName` ) { if( `attributeExists "AnimRanges" $settingsName` ) { string $rangesString = `getAttr ($settingsName+".AnimRanges")`; print("Ranges String `"+$rangesString+"`\n"); string $rangeTokens[]; $numTokens = `tokenize $rangesString "," $rangeTokens`; $foundNode = 1; string $response = `confirmDialog -title "Lumberyard Animation" -message ("Found "+$numTokens+" animations on node "+$settingsName+". Merge them with the animations from this scene?") -button "Yes" -button "No"`; if( $response == "Yes" ) { for( $range in $rangeTokens ) { cryAnimAddRange $range; } } } } } if( $foundNode == 0 ) { confirmDialog -title "Lumberyard Animation" -message ("No referanced settings nodes were found that contain animation ranges.") -button "OK"; } else { cryAnimPopulateRangeList; } } ////////////////////////////// // // ui function // ////////////////////////////// proc createCryAnimManagerWindow() { if(!`window -ex CRYANIMMANAGER_WINDOW`) { if(`windowPref -exists CRYANIMMANAGER_WINDOW`) { windowPref -wh 1100 600 -tlc `windowPref -q -topEdge CRYANIMMANAGER_WINDOW` `windowPref -q -leftEdge CRYANIMMANAGER_WINDOW` CRYANIMMANAGER_WINDOW; //windowPref -remove CRYANIMMANAGER_WINDOW; } window -titleBar true -title "Lumberyard Animation Manager" -widthHeight 1100 600 -sizeable true -mnb false -mxb false CRYANIMMANAGER_WINDOW; formLayout -numberOfDivisions 100 -visible false CRYANIM_FORMLAYOUT; { scrollLayout -childResizable true -hst 0 -vst 15 -height 1 -bgc .4 .4 .4 CRYANIM_SCROLLLAYOUT; { popupMenu CRYANIMMANAGER_FORMIDMENU; { menuItem -label "Find Anims" -command ("cryAnimManagerFindAnims"); } columnLayout -adjustableColumn true -columnOffset "both" 5 -rowSpacing 5 -bgc .4 .4 .4 CRYANIM_COLUMNLAYOUT; { } setParent ..; } setParent ..; button -label "New" -command("cryAnimManagerEditAnimRangeWin 0 -1") CRYANIM_NEW; button -label "Delete All" -command("cryAnimManagerEditAnimRangeWin 3 -1") CRYANIM_DELETEALL; button -label "Close" -command ("cryAnimManagerUICloseWindow") CRYANIM_CLOSE; } formLayout -edit -attachForm CRYANIM_NEW "top" 5 -attachForm CRYANIM_NEW "left" 5 -attachPosition CRYANIM_NEW "right" 5 50 -attachNone CRYANIM_NEW "bottom" -attachForm CRYANIM_DELETEALL "top" 5 -attachPosition CRYANIM_DELETEALL "left" 5 50 -attachForm CRYANIM_DELETEALL "right" 5 -attachNone CRYANIM_DELETEALL "bottom" -attachControl CRYANIM_SCROLLLAYOUT "top" 5 CRYANIM_NEW -attachForm CRYANIM_SCROLLLAYOUT "left" 5 -attachForm CRYANIM_SCROLLLAYOUT "right" 5 -attachControl CRYANIM_SCROLLLAYOUT "bottom" 5 CRYANIM_CLOSE -attachForm CRYANIM_CLOSE "bottom" 5 -attachForm CRYANIM_CLOSE "left" 5 -attachForm CRYANIM_CLOSE "right" 5 -attachNone CRYANIM_CLOSE "top" CRYANIM_FORMLAYOUT; } cryAnimPopulateRangeList; formLayout -e -visible true CRYANIM_FORMLAYOUT; scriptJob -event "NewSceneOpened" "cryAnimPopulateRangeList" -p "CRYANIMMANAGER_WINDOW"; scriptJob -event "PostSceneRead" "cryAnimPopulateRangeList" -p "CRYANIMMANAGER_WINDOW"; showWindow CRYANIMMANAGER_WINDOW; } proc cryAnimSourceDependencies() { eval("source cryExport.mel"); eval("source LumberyardUtilities.mel"); } global proc cryAnimManagerWin() { //cryAnimManagerUpgradeSettingsString; cryAnimSourceDependencies; createCryAnimManagerWindow; } ///////////////////////////////////////////////////////////////////////// // Generic anim access functions ///////////////////////////////////////////////////////////////////////// global proc string cryAnimLoadRangesString() { string $rangesString = ""; string $exportSettingsNode = LumberyardGetExportSettingNodeName(); if( `objExists $exportSettingsNode` ) { if( `attributeExists "AnimRanges" $exportSettingsNode` ) { $rangesString = `getAttr ($exportSettingsNode+".AnimRanges")`; } } return $rangesString; } global proc cryAnimSaveRangesString( string $rangesString ) { string $exportSettingsNode = LumberyardGetExportSettingNodeName(); // Create the node if it dosen't exist if( !`objExists $exportSettingsNode` ) { select -clear; string $settingsNode = `group -empty`; rename $settingsNode $exportSettingsNode; select -clear; } if( `objExists $exportSettingsNode` ) { if( !`attributeExists "AnimRanges" $exportSettingsNode` ) { addAttr -ln "AnimRanges" -dt "string" $exportSettingsNode; } setAttr ($exportSettingsNode+".AnimRanges") -type "string" $rangesString; } } global proc cryAnimSaveRangesStringArray( string $ranges[] ) { string $rangesString = ""; int $count = 0; for( $range in $ranges ) { if( $count > 0 ) $rangesString += ","; $rangesString += $range; $count++; } cryAnimSaveRangesString $rangesString; } global proc int cryAnimGetNumRanges() { string $rangesString = `cryAnimLoadRangesString`; string $tokens[]; $numTokens = `tokenize $rangesString "," $tokens`; // We still get 1 token even if the string is empty, so test for that and make sure we return 0 as the range count if( $numTokens == 1 && size($tokens[0]) == 0 ) $numTokens = 0; return $numTokens; } global proc string[] cryAnimGetRanges() { string $rangesString = `cryAnimLoadRangesString`; string $tokens[]; $numTokens = `tokenize $rangesString "," $tokens`; return $tokens; } global proc string[] cryAnimGetRangeNames() { string $animRanges[]; $animRanges = `cryAnimGetRanges`; int $rangeCount = `cryAnimGetNumRanges`; string $animNames[]; for( $i = 0;$i<$rangeCount;$i++ ) { string $decode[]; //bypassing plug-in command for python script //$decode = `cryExportDecodeRangeString $animRanges[$i]`; $decode = python("mau.AMZN_DecodeAnimRangeString(\"" + $animRanges[$i] + "\")"); if( size($decode) >= 5 ) { $animNames[$i] = $decode[2]; } } return $animNames; } global proc cryAnimRemoveAnimRange( int $index ) { int $numRanges = `cryAnimGetNumRanges`; if( $index >= 0 && $index < $numRanges ) { string $ranges[] = `cryAnimGetRanges`; stringArrayRemoveAtIndex $index $ranges; cryAnimSaveRangesStringArray $ranges; } } global proc cryAnimRemoveAllAnimRanges() { int $numRanges = `cryAnimGetNumRanges`; if( $numRanges > 0 ) { cryAnimSaveRangesString ""; } } global proc cryAnimReplaceRange( int $index, string $rangeString ) { int $numRanges = `cryAnimGetNumRanges`; if( $index >= 0 && $index < $numRanges ) { string $ranges[] = `cryAnimGetRanges`; $ranges[$index] = $rangeString; cryAnimSaveRangesStringArray $ranges; } } //modified 12/15/2014 to include layers global proc string cryAnimFormatRangeString( string $start, string $end, string $name, string $root, string $path, string $layers ) { string $rangeString = ("[" + $start + "-" + $end + "] - " + $name + " - " + $root + " - " + $path ); if($layers != "") $rangeString = ($rangeString + " - " + $layers); return $rangeString; } global proc cryAnimAddRange( string $rangeString ) { int $numRanges = `cryAnimGetNumRanges`; string $ranges[] = `cryAnimGetRanges`; for( $range in $ranges ) { if( `strcmp $range $rangeString` == 0 ) // An identical range is already in the ranges list. { return; } } $ranges[$numRanges] = $rangeString; cryAnimSaveRangesStringArray $ranges; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // returns the current status of the anim layers // returns name of anim layer, whether layer is set to mute or solo // returns data as a mel command that can be executed to restore the settings // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// global proc string cryReturnActiveAnimLayers() { string $sel[] = `ls -type "animLayer"`; string $returnString = ""; for($cur in $sel) { int $mute = `getAttr ($cur + ".mute")`; int $solo = `getAttr ($cur + ".solo")`; string $layer = ("setAttr " + $cur + ".mute " + $mute + ";setAttr " + $cur + ".solo " + $solo + ";"); $returnString = $returnString+$layer; } return $returnString; }