Integrating latest 47acbe8
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
// Creates the attribute editor controls for the cryHelperNode
|
||||
|
||||
global proc AEcryHelperNodeTemplate( string $nodeName )
|
||||
{
|
||||
// Block copied from AEgeometryShapeTemplate.mel
|
||||
{
|
||||
editorTemplate -suppress "compInstObjGroups";
|
||||
editorTemplate -suppress "ignoreSelfShadowing";
|
||||
}
|
||||
// Block copied from AEgeometryShapeTemplate.mel
|
||||
{
|
||||
editorTemplate -beginNoOptimize;
|
||||
editorTemplate -suppress "castsShadows";
|
||||
editorTemplate -suppress "receiveShadows";
|
||||
editorTemplate -suppress "motionBlur";
|
||||
editorTemplate -suppress "primaryVisibility";
|
||||
editorTemplate -suppress "visibleInReflections";
|
||||
editorTemplate -suppress "visibleInRefractions";
|
||||
editorTemplate -suppress "doubleSided";
|
||||
editorTemplate -suppress "opposite";
|
||||
editorTemplate -suppress "geometryAntialiasingOverride";
|
||||
editorTemplate -suppress "antialiasingLevel";
|
||||
editorTemplate -suppress "shadingSamplesOverride";
|
||||
editorTemplate -suppress "shadingSamples";
|
||||
editorTemplate -suppress "maxShadingSamples";
|
||||
editorTemplate -suppress "volumeSamplesOverride";
|
||||
editorTemplate -suppress "volumeSamples";
|
||||
editorTemplate -suppress "depthJitter";
|
||||
editorTemplate -suppress "maxVisibilitySamplesOverride";
|
||||
editorTemplate -suppress "maxVisibilitySamples";
|
||||
editorTemplate -suppress "boundingBoxScale";
|
||||
editorTemplate -suppress "featureDisplacement";
|
||||
editorTemplate -suppress "initialSampleRate";
|
||||
editorTemplate -suppress "extraSampleRate";
|
||||
editorTemplate -suppress "textureThreshold";
|
||||
editorTemplate -suppress "normalThreshold";
|
||||
editorTemplate -endNoOptimize;
|
||||
}
|
||||
|
||||
// Suppress the local pos and scale
|
||||
editorTemplate -suppress "localPosition";
|
||||
editorTemplate -suppress "localScale";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Parameters
|
||||
editorTemplate -beginScrollLayout;
|
||||
editorTemplate -beginLayout "General Parameters" -collapse false;
|
||||
editorTemplate -addControl "size";
|
||||
editorTemplate -endLayout;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AEshapeTemplate $nodeName;
|
||||
|
||||
editorTemplate -addExtraControls;
|
||||
editorTemplate -endScrollLayout;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,768 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Shared UI parameters
|
||||
global int $g_heightPerRow = 29;
|
||||
global int $g_controlHeight = 22;
|
||||
global string $g_lastRow = "";
|
||||
|
||||
LumberyardAnimationManagerLoadDependencies();
|
||||
|
||||
//! Loads all scripts that the Animation Manager relies on.
|
||||
global proc LumberyardAnimationManagerLoadDependencies()
|
||||
{
|
||||
eval("source cryAnim.mel");
|
||||
eval("source LumberyardUtilities.mel");
|
||||
}
|
||||
|
||||
//! Creates the title row for the Animation Manager.
|
||||
/*!
|
||||
\note
|
||||
This will contain the column titles for all animation data. If you choose to customize animation data, and want to expose it to the
|
||||
Animation Manager, you will want to create a new column here as well as when you create the data.
|
||||
\sa LumberyardAnimationManagerCreateUIRow()
|
||||
*/
|
||||
proc LumberyardAnimationManagerCreateColumnTitles()
|
||||
{
|
||||
global int $g_controlHeight;
|
||||
setParent LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
|
||||
rowLayout -numberOfColumns 3 -columnWidth3 35 805 35 -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 - columnAlign 2 "center" -columnAttach 2 "both" 0
|
||||
-columnAlign 3 "center" -columnAttach 3 "both" 0;
|
||||
|
||||
// For <> button column
|
||||
text -height $g_controlHeight -label "";
|
||||
|
||||
// Main animation columns;
|
||||
rowLayout -numberOfColumns 6 -columnWidth6 35 35 150 150 150 250 -adjustableColumn 6 -backgroundColor 0.26 0.26 0.26
|
||||
-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 LUMBERYARDTOOL_ANIMMANAGER_COLUMNTITLES;
|
||||
{
|
||||
text -height $g_controlHeight -label "Start";
|
||||
text -height $g_controlHeight -label "End";
|
||||
text -height $g_controlHeight -label "Name";
|
||||
text -height $g_controlHeight -label "Root Node";
|
||||
text -height $g_controlHeight -label "Animation Layers";
|
||||
text -height $g_controlHeight -label "Export Path";
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
// For the +/X buttons
|
||||
text -height $g_controlHeight -label "";
|
||||
}
|
||||
|
||||
//! Resize the Animation Manager window.
|
||||
/*!
|
||||
\param $newExportListHeight The new height for the columnLayout containing the animation export data
|
||||
\param $newWindowListHeight The new height for the Animation Manager window
|
||||
*/
|
||||
global proc LumberyardAnimationManagerResize(int $newExportListHeight, int $newWindowHeight)
|
||||
{
|
||||
columnLayout -edit -height $newExportListHeight LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT;
|
||||
columnLayout -edit -height $newWindowHeight LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
window -edit -height $newWindowHeight LUMBERYARDANIMATIONMANAGER_WINDOW;
|
||||
}
|
||||
|
||||
//! Change the height of the Animation Manager and export list by a fixed delta.
|
||||
/*!
|
||||
\param $heightDelta Offset to change height of elements by. Can be positive or negative.
|
||||
\note
|
||||
This is a utility function used to simplify the logic in several places where determining an offset is
|
||||
far less expensive than recalculating the desired height from scratch. It should be preferred over
|
||||
LumberyardAnimationManagerResize in such cases.
|
||||
\sa LumberyardAnimationManagerResize()
|
||||
*/
|
||||
proc LumberyardAnimationManagerChangeHeight(int $heightDelta)
|
||||
{
|
||||
int $exportListHeight = `columnLayout -query -height LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT`;
|
||||
int $windowHeight = `window -query -height LUMBERYARDANIMATIONMANAGER_WINDOW`;
|
||||
|
||||
$windowHeight = $windowHeight + $heightDelta;
|
||||
$exportListHeight = $exportListHeight + $heightDelta;
|
||||
|
||||
LumberyardAnimationManagerResize($exportListHeight, $windowHeight);
|
||||
}
|
||||
|
||||
//! Wrapper command used to remove the export data for an animation being managed by the Animation Manager.
|
||||
/*!
|
||||
/param $row The name of the row UI element corresponding to the export data to be removed.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerRemoveItem(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
LumberyardUtilitiesDeleteAnimationExport($managedNode);
|
||||
}
|
||||
|
||||
//! Open a file browser dialog and update the export path for an animation based on selection.
|
||||
/*!
|
||||
/param $row The name of the rowLayout UI element corresponding to the export data to be updated.
|
||||
/param $textField The name of the text field UI element corresponding to the export data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerFolderBrowser(string $row, string $textField)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $currentPath = `LumberyardUtilitiesGetAnimationExportPath $managedNode`;
|
||||
|
||||
if ($currentPath == "")
|
||||
{
|
||||
$currentPath = `file -query -sceneName`;
|
||||
$currentPath = `dirname $currentPath`;
|
||||
}
|
||||
|
||||
string $result[] = `LumberyardBrowseForPath $currentPath "Set Export Path"`;
|
||||
// We need to requery this in case this took focus from the name text box
|
||||
$managedNode = `rowLayout -query -annotation $row`;
|
||||
|
||||
if (size($result) == 1)
|
||||
{
|
||||
// Update the UI
|
||||
textField -edit -text $result[0] $textField;
|
||||
// Update the data
|
||||
LumberyardUtilitiesSetAnimationExportPath($managedNode, $result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
//! Update the root joint of the export data and the UI based on current selection in Maya.
|
||||
/*!
|
||||
/param $row The name of the rowLayout UI element corresponding to the export data to be updated.
|
||||
/param $textField The name of the textField UI element corresponding to the export data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerGetRootJointFromSelection(string $row, string $textField)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $currentRootJoint = `LumberyardUtilitiesGetAnimationRootJoint $managedNode`;
|
||||
|
||||
$currentRootJoint = `GetRootJointForSelection $currentRootJoint`;
|
||||
|
||||
// Update the UI
|
||||
textField -edit -text $currentRootJoint $textField;
|
||||
// Update the data
|
||||
LumberyardUtilitiesSetAnimationRootJoint($managedNode, $currentRootJoint);
|
||||
}
|
||||
|
||||
//! Utility function to get the name of a UI control in the nested rowLayouts used in Animation Manager.
|
||||
/*!
|
||||
\param $row Root rowLayout corresponding to a single animation export.
|
||||
\param $indices The sequence of indices used to index into nested rowLayouts.
|
||||
\note If you are changing the layout in any way, be aware that calls to this function many need to be updated.
|
||||
\sa LumberyardAnimationManagerGetStartFrame(), LumberyardAnimationManagerGetEndFrame(), LumberyardAnimationManagerGetExportName(), LumberyardAnimationManagerGetRootJoint(), and LumberyardAnimationManagerGetExportPath()
|
||||
*/
|
||||
proc string LumberyardAnimationManagerGetRowControl(string $row, int $indices[])
|
||||
{
|
||||
string $control = $row;
|
||||
|
||||
if(size($indices) == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
for($index in $indices)
|
||||
{
|
||||
if(!`rowLayout -query -exists $control`)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string $children[] = `rowLayout -query -childArray $control`;
|
||||
if($index >= size($children))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
$control = $control + "|" + $children[$index];
|
||||
}
|
||||
|
||||
return $control;
|
||||
}
|
||||
|
||||
//! Get the value contained in the start frame intField in an animation export rowLayout.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element containing the intField to query
|
||||
*/
|
||||
global proc int LumberyardAnimationManagerGetStartFrame(string $row)
|
||||
{
|
||||
int $startFrame = -1;
|
||||
int $controlMapping[] = {1, 0};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
if($control != "" && `intField -query -exists $control`)
|
||||
{
|
||||
$startFrame = `intField -query -value $control`;
|
||||
}
|
||||
return $startFrame;
|
||||
}
|
||||
|
||||
//! Get the value contained in the end frame intField in an animation export rowLayout.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element containing the intField to query
|
||||
*/
|
||||
global proc int LumberyardAnimationManagerGetEndFrame(string $row)
|
||||
{
|
||||
int $endFrame = -1;
|
||||
int $controlMapping[] = {1, 1};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
if($control != "" && `intField -query -exists $control`)
|
||||
{
|
||||
$endFrame = `intField -query -value $control`;
|
||||
}
|
||||
return $endFrame;
|
||||
}
|
||||
|
||||
//! Get the value contained in the export name textField in an animation export rowLayout.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element containing the textField to query
|
||||
*/
|
||||
global proc string LumberyardAnimationManagerGetExportName(string $row)
|
||||
{
|
||||
string $exportName = "";
|
||||
int $controlMapping[] = {1, 2};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
if($control != "" && `textField -query -exists $control`)
|
||||
{
|
||||
$exportName = `textField -query -text $control`;
|
||||
}
|
||||
return $exportName;
|
||||
}
|
||||
|
||||
//! Get the value contained in the root joint textField in an animation export rowLayout.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element containing the textField to query
|
||||
*/
|
||||
global proc string LumberyardAnimationManagerGetRootJoint(string $row)
|
||||
{
|
||||
string $rootJoint = "";
|
||||
int $controlMapping[] = {1, 3, 0};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
if($control != "" && `textField -query -exists $control`)
|
||||
{
|
||||
$rootJoint = `textField -query -text $control`;
|
||||
}
|
||||
return $rootJoint;
|
||||
}
|
||||
|
||||
//! Get the value contained in the export path textField in an animation export rowLayout.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element containing the textField to query
|
||||
*/
|
||||
global proc string LumberyardAnimationManagerGetExportPath(string $row)
|
||||
{
|
||||
string $exportPath = "";
|
||||
int $controlMapping[] = {1, 5, 0};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
if($control != "" && `textField -query -exists $control`)
|
||||
{
|
||||
$exportPath = `textField -query -text $control`;
|
||||
}
|
||||
return $exportPath;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Functions to transmit UI changes to the data backend
|
||||
|
||||
//! Transmit value contained in the start frame UI to the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateStartFrame(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
int $startFrame = `LumberyardAnimationManagerGetStartFrame $row`;
|
||||
LumberyardUtilitiesSetAnimationStartFrame($managedNode, $startFrame);
|
||||
}
|
||||
|
||||
//! Transmit value contained in the end frame UI to the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateEndFrame(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
int $endFrame = `LumberyardAnimationManagerGetEndFrame $row`;
|
||||
LumberyardUtilitiesSetAnimationEndFrame($managedNode, $endFrame);
|
||||
}
|
||||
|
||||
//! Transmit value contained in the export name UI to the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateExportName(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
|
||||
string $newExportName = `LumberyardAnimationManagerGetExportName $row`;
|
||||
LumberyardUtilitiesSetAnimationExportName( $managedNode, $newExportName);
|
||||
}
|
||||
|
||||
//! Transmit value contained in the root joint UI to the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateRootJoint(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $rootJoint = `LumberyardAnimationManagerGetRootJoint $row`;
|
||||
LumberyardUtilitiesSetAnimationRootJoint($managedNode, $rootJoint);
|
||||
}
|
||||
|
||||
//! Transmit value contained in the export path UI to the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the data to be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateExportPath(string $row)
|
||||
{
|
||||
string $exportPath = `LumberyardAnimationManagerGetExportPath $row`;
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $finalExportPath = `LumberyardUtilitiesSetAnimationExportPath $managedNode $exportPath`;
|
||||
if($exportPath != $finalExportPath)
|
||||
{
|
||||
int $controlMapping[] = {1, 5, 0};
|
||||
string $control = `LumberyardAnimationManagerGetRowControl $row $controlMapping`;
|
||||
textField -edit -text $finalExportPath $control;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sets the animLayer selection in the data backend based on the current UI state.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the animation export data to update.
|
||||
\param $layerPullDown the frameLayout containing the UI data that will be transmitted.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateExportLayers(string $row, string $layerPullDown)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $children[] = `frameLayout -query -childArray $layerPullDown`;
|
||||
string $activeLayers[];
|
||||
|
||||
for($child in $children)
|
||||
{
|
||||
string $controls[] = `rowLayout -query -childArray $child`;
|
||||
int $checked = `checkBox -query -value $controls[0]`;
|
||||
if($checked)
|
||||
{
|
||||
string $layerName = `text -query -label $controls[1]`;
|
||||
$activeLayers[size($activeLayers)] = $layerName;
|
||||
}
|
||||
}
|
||||
|
||||
LumberyardUtilitiesSetAnimationExportLayers($managedNode, $activeLayers);
|
||||
LumberyardAnimationManagerSetLayerListTitle($row, $layerPullDown);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// UI Update calls for layout and default values
|
||||
|
||||
//! Identifies and stores the last export node rowLayout in the Animation Manager.
|
||||
/*!
|
||||
/note This stored value is used to poll for default values when creating new rows
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateLastRow()
|
||||
{
|
||||
global string $g_lastRow;
|
||||
|
||||
string $children[] = `columnLayout -query -childArray LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT`;
|
||||
|
||||
if (size($children) == 0)
|
||||
{
|
||||
$g_lastRow = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$g_lastRow = $children[(size($children)) - 1];
|
||||
}
|
||||
}
|
||||
|
||||
//! Gets the default export path for newly added items in the Animation Manager.
|
||||
/*!
|
||||
\note
|
||||
The default path will be that of the last row in the Animation Manager. If there are no
|
||||
rows present in the Animation Manager, the path will default to the top level path for the engine
|
||||
installation. (i.e. the directory containing Bin64, Code, etc.)
|
||||
\todo
|
||||
Consider setting the default path based on the sys_game_folder in setup.cfg instead of the root
|
||||
engine path.
|
||||
*/
|
||||
proc string LumberyardAnimationManagerGetDefaultExportPath()
|
||||
{
|
||||
global string $g_lastRow;
|
||||
string $exportPath = "";
|
||||
|
||||
if($g_lastRow != "")
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $g_lastRow`;
|
||||
$exportPath = `LumberyardUtilitiesGetAnimationExportPath $managedNode`;
|
||||
}
|
||||
|
||||
// if this is the first time we create a row, start at the parent directory for the engine
|
||||
if ($exportPath == "")
|
||||
{
|
||||
$exportPath = eval("getenv \"LY_MAYA_PLUG_IN_PATH\"");
|
||||
// equivalent to ../../../
|
||||
for($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$exportPath = `dirname $exportPath`;
|
||||
}
|
||||
$exportPath = `cryExportFixupPath $exportPath`;
|
||||
}
|
||||
|
||||
return $exportPath;
|
||||
}
|
||||
|
||||
//! Gets the default root joint for newly added items in the Animation Manager.
|
||||
/*!
|
||||
\note
|
||||
The default root joint will be that of the last row in the Animation Manager. If there are no
|
||||
rows present in the Animation Manager, the root joint will default to an empty string.
|
||||
\todo Consider using selection as default root joint if the first selected item is a joint.
|
||||
*/
|
||||
proc string LumberyardAnimationManagerGetDefaultRootJoint()
|
||||
{
|
||||
global string $g_lastRow;
|
||||
string $rootJoint = "";
|
||||
|
||||
if($g_lastRow != "")
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $g_lastRow`;
|
||||
$rootJoint = `LumberyardUtilitiesGetAnimationRootJoint $managedNode`;
|
||||
}
|
||||
|
||||
return $rootJoint;
|
||||
}
|
||||
|
||||
//! Calculates the correct UI heights based on the number of animation exports.
|
||||
/*!
|
||||
\note
|
||||
This is only called when first creating the Animation Manager. It is more expensive, and should only be used if you
|
||||
cannot calculate the size offset.
|
||||
\sa LumberyardAnimationManagerUpdateHeight()
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateHeight()
|
||||
{
|
||||
global int $g_heightPerRow;
|
||||
$childCount = `columnLayout -query -numberOfChildren LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT`;
|
||||
$newExportListHeight = ($childCount * $g_heightPerRow) + 1;
|
||||
// For the title and add rows
|
||||
$childCount = $childCount + 2;
|
||||
$newWindowHeight = ($childCount * $g_heightPerRow) + 2;
|
||||
LumberyardAnimationManagerResize $newExportListHeight $newWindowHeight;
|
||||
}
|
||||
|
||||
//! Get the selected animLayers for an animation export from the data backend.
|
||||
/*!
|
||||
\param $row The name of the rowLayout corresponding to the animation export to fetch the data for.
|
||||
*/
|
||||
proc string[] LumberyardAnimationManagerGetSelectedLayers(string $row)
|
||||
{
|
||||
string $managedNode = `rowLayout -query -annotation $row`;
|
||||
string $exportLayers[] = `LumberyardUtilitiesGetAnimationExportLayers $managedNode`;
|
||||
|
||||
return $exportLayers;
|
||||
}
|
||||
|
||||
//! Callback to keep the animLayer selections in the UI and data backend synchronized with Maya's animLayer state.
|
||||
/*!
|
||||
\note This callback occurs when an animLayer is renamed, moved, deleted, or added.
|
||||
\todo
|
||||
This currently forces a full UI redraw, which collapses any open animLayer frameLayouts. We should preserve expanded
|
||||
state for each row during UI rebuilds.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerUpdateLayers()
|
||||
{
|
||||
LumberyardUtilitiesUpdateAnimationLayers();
|
||||
LumberyardAnimationManagerReadExports();
|
||||
}
|
||||
|
||||
//! Updates the animLayer frameLayout title based on the number of animLayers selected for an animation export.
|
||||
/*!
|
||||
\param $row The name of the UI rowLayout corresponding to the animation export data to query.
|
||||
\param $layerPullDown The name of the UI frameLayout whose title should be updated.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerSetLayerListTitle(string $row, string $layerPullDown)
|
||||
{
|
||||
string $layers[];
|
||||
|
||||
$layers = `LumberyardAnimationManagerGetSelectedLayers $row`;
|
||||
int $count = size($layers);
|
||||
|
||||
string $newTitle = "Select Layers";
|
||||
if($count > 0)
|
||||
{
|
||||
$newTitle = "Selected "+$count;
|
||||
}
|
||||
|
||||
frameLayout -edit -label $newTitle $layerPullDown;
|
||||
}
|
||||
|
||||
//! Callback to fill the animLayer frameLayout when the user expands it.
|
||||
/*!
|
||||
\param $row The name of the rowLayout UI element corresponding to the animation export data to fetch.
|
||||
\param $layerPullDown The frameLayout UI element that will be populated.
|
||||
\note This will also handle adjusting UI heights to accommodate the number of animLayers displayed.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerExpandLayerList(string $row, string $layerPullDown)
|
||||
{
|
||||
global int $g_controlHeight;
|
||||
global int $g_heightPerRow;
|
||||
setParent $layerPullDown;
|
||||
|
||||
string $animLayers[] = `LumberyardUtilitiesGetAnimLayers`;
|
||||
int $layerCount = size($animLayers);
|
||||
// +1 to handle frameLayout title
|
||||
int $newHeight = $g_controlHeight * ($layerCount + 1);
|
||||
int $parentWidth = `frameLayout -query -width $layerPullDown`;
|
||||
if($layerCount == 0)
|
||||
{
|
||||
$newHeight = $g_controlHeight * 2;
|
||||
text -align "left" -label "<No Layers Found>" -width $parentWidth;
|
||||
}
|
||||
LumberyardAnimationManagerChangeHeight($newHeight - $g_controlHeight);
|
||||
frameLayout -edit -height $newHeight $layerPullDown;
|
||||
rowLayout -edit -height ($newHeight + $g_heightPerRow - $g_controlHeight) $row;
|
||||
|
||||
string $layers[] = `LumberyardAnimationManagerGetSelectedLayers $row`;
|
||||
|
||||
for($i = 0; $i < $layerCount; $i++)
|
||||
{
|
||||
int $enabled = ($animLayers[$i] != "BaseAnimation");
|
||||
int $value = `stringArrayContains $animLayers[$i] $layers`;
|
||||
rowLayout -height $g_controlHeight -width $parentWidth -numberOfColumns 2;
|
||||
checkBox -label "" -value $value -backgroundColor 0.5 0.5 0.5 -enable $enabled -enableBackground $enabled
|
||||
-changeCommand ("LumberyardAnimationManagerUpdateExportLayers " + $row + " " + $layerPullDown);
|
||||
text -align "left" -label $animLayers[$i] -width ($parentWidth - $g_controlHeight);
|
||||
setParent ..;
|
||||
}
|
||||
}
|
||||
|
||||
//! Callback used to adjust UI height when user collapses an animLayer frameLayout.
|
||||
/*
|
||||
\param $row The name of the rowLayout UI element whose animLayer pulldown is being collapsed
|
||||
\param $layerPullDown the name of the frameLayout UI element being collapsed
|
||||
*/
|
||||
global proc LumberyardAnimationManagerCollapseLayerList(string $row, string $layerPullDown)
|
||||
{
|
||||
global int $g_controlHeight;
|
||||
global int $g_heightPerRow;
|
||||
|
||||
int $currentRowHeight = `rowLayout -query -height $row`;
|
||||
int $heightDiff = $currentRowHeight - $g_heightPerRow;
|
||||
$heightDiff = 0 - $heightDiff;
|
||||
|
||||
string $children[] = `frameLayout -query -childArray $layerPullDown`;
|
||||
for($child in $children)
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
|
||||
LumberyardAnimationManagerChangeHeight($heightDiff);
|
||||
rowLayout -edit -height $g_heightPerRow $row;
|
||||
frameLayout -edit -height $g_controlHeight $layerPullDown;
|
||||
}
|
||||
|
||||
//! Creates a new UI rowLayout in the Animation Manager corresponding to an animation export node.
|
||||
/*!
|
||||
\param $exportNode The name of the exportNode in the sceneName
|
||||
\note
|
||||
No guarantee is made about avoiding multiple rows referring to the same export node, so it is
|
||||
incumbent on the caller to ensure that this does not occur. The layout of the UI row is heavily
|
||||
integrated into several other UI components, so it will need to be updated if any new data is
|
||||
exposed to the Animation Manager. The row maintains a string reference to the name of the data
|
||||
node that it corresponds to in the annotation field. It is very important that these nodes are
|
||||
not renamed outside the tool flow, or the UI will not be able to fetch or manipulate data until
|
||||
a full UI rebuild.
|
||||
\sa LumberyardAnimationManagerCreateColumnTitles(), LumberyardAnimationManagerGetRowControl()
|
||||
*/
|
||||
global proc LumberyardAnimationManagerCreateUIRow(string $exportNode)
|
||||
{
|
||||
global int $g_controlHeight;
|
||||
global string $g_lastRow;
|
||||
global float $g_UIColor[];
|
||||
|
||||
if(!`LumberyardUtilitiesAnimationExportIsValid($exportNode)`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int $startFrame = getAttr($exportNode+".startFrame");
|
||||
int $endFrame = getAttr($exportNode+".endFrame");
|
||||
string $exportName = getAttr($exportNode+".exportName");
|
||||
string $rootJoint = getAttr($exportNode+".rootJoint");
|
||||
string $exportPath = getAttr($exportNode+".exportPath");
|
||||
|
||||
setParent LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT;
|
||||
|
||||
$newRow = `rowLayout -numberOfColumns 3 -columnWidth3 35 805 35 -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 -rowAttach 1 "top" 2
|
||||
-columnAlign 2 "center" -columnAttach 2 "both" 0 -rowAttach 2 "top" 0
|
||||
-columnAlign 3 "center" -columnAttach 3 "both" 0 -rowAttach 3 "top" 2 -annotation $exportNode`;
|
||||
|
||||
//Sets the start and end frame for an animation export to match the Maya timeline
|
||||
button -height $g_controlHeight -label "<>" -annotation "Sets the start and end frame for an animation export to match the Maya timeline." -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command ("LumberyardUtilitiesSnapAnimationToTimeline " + $exportNode);
|
||||
|
||||
// Main animation columns;
|
||||
rowLayout -numberOfColumns 6 -columnWidth6 35 35 150 150 150 350 -adjustableColumn 6 -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 -rowAttach 1 "top" 0
|
||||
-columnAlign 2 "center" -columnAttach 2 "both" 0 -rowAttach 2 "top" 0
|
||||
-columnAlign 3 "center" -columnAttach 3 "both" 0 -rowAttach 3 "top" 0
|
||||
-columnAlign 4 "center" -columnAttach 4 "both" 0 -rowAttach 4 "top" 0
|
||||
-columnAlign 5 "center" -columnAttach 5 "both" 0 -rowAttach 5 "top" 3
|
||||
-columnAlign 6 "center" -columnAttach 6 "both" 0 -rowAttach 6 "top" 0;
|
||||
{
|
||||
// Start Frame
|
||||
string $startFrameControl = `intField -height $g_controlHeight -value $startFrame -backgroundColor 0 0 0 -changeCommand ("LumberyardAnimationManagerUpdateStartFrame " + $newRow)`;
|
||||
|
||||
// End Frame
|
||||
string $endFrameControl = `intField -height $g_controlHeight -value $endFrame -backgroundColor 0 0 0 -changeCommand ("LumberyardAnimationManagerUpdateEndFrame " + $newRow)`;
|
||||
|
||||
// Export Name
|
||||
string $exportNameControl = `textField -height $g_controlHeight -text $exportName -backgroundColor 0 0 0 -changeCommand ("LumberyardAnimationManagerUpdateExportName " + $newRow)`;
|
||||
|
||||
// Root Joint
|
||||
rowLayout -numberOfColumns 2 -columnWidth 128 $g_controlHeight -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 -columnAlign 2 "center" -columnAttach 2 "both" 0;
|
||||
{
|
||||
string $rootJointControl = `textField -height $g_controlHeight -width 128 -text $rootJoint -backgroundColor 0 0 0 -changeCommand ("LumberyardAnimationManagerUpdateRootJoint " + $newRow)`;
|
||||
button -height $g_controlHeight -label "+" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command ("LumberyardAnimationManagerGetRootJointFromSelection " + $newRow + " " + $rootJointControl);
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
// Animation Layers
|
||||
$layerPullDown = `frameLayout -height $g_controlHeight -width 150 -collapsable true -collapse true`;
|
||||
frameLayout -edit -preExpandCommand ("LumberyardAnimationManagerExpandLayerList " + $newRow + " " + $layerPullDown) $layerPullDown;
|
||||
frameLayout -edit -preCollapseCommand ("LumberyardAnimationManagerCollapseLayerList " + $newRow + " " + $layerPullDown) $layerPullDown;
|
||||
LumberyardAnimationManagerSetLayerListTitle($newRow, $layerPullDown);
|
||||
setParent ..;
|
||||
|
||||
// Export Path
|
||||
rowLayout -numberOfColumns 2 -columnWidth 228 $g_controlHeight -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 -columnAlign 2 "center" -columnAttach 2 "both" 0;
|
||||
{
|
||||
string $exportPathControl = `textField -height $g_controlHeight -width 248 -text $exportPath -backgroundColor 0 0 0 -changeCommand ("LumberyardAnimationManagerUpdateExportPath " + $newRow)`;
|
||||
iconTextButton -image "icons/lumberyard_folder_icon.png" -height $g_controlHeight -width 20 -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command ("LumberyardAnimationManagerFolderBrowser " + $newRow + " " + $exportPathControl);
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
|
||||
button -height $g_controlHeight -label "X" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command ("LumberyardAnimationManagerRemoveItem " + $newRow);
|
||||
$g_lastRow = $newRow;
|
||||
}
|
||||
|
||||
//! Creates all required elements when a new animation export is requested.
|
||||
/*!
|
||||
\note
|
||||
Determines the default values for a new node, creates it in the data backend,
|
||||
and generates the UI elements for it.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerAddNewItem()
|
||||
{
|
||||
int $startFrame = `playbackOptions -query -minTime`;
|
||||
int $endFrame = `playbackOptions -query -maxTime`;
|
||||
string $exportName = `LumberyardUtilitiesGetUniqueAnimationName ""`;
|
||||
string $rootJoint = `LumberyardAnimationManagerGetDefaultRootJoint`;
|
||||
string $exportPath = `LumberyardAnimationManagerGetDefaultExportPath`;
|
||||
string $exportLayers[] = `LumberyardUtilitiesGetAnimLayers`;
|
||||
|
||||
LumberyardUtilitiesCreateAnimationExport($startFrame, $endFrame, $exportName, $rootJoint, $exportPath, $exportLayers);
|
||||
|
||||
LumberyardUtilitiesUpdateAnimationUI();
|
||||
}
|
||||
|
||||
//! Creates the + button in the lower right of the Animation Manager which will generate new animation exports when clicked
|
||||
global proc LumberyardAnimationManagerCreateAddButton()
|
||||
{
|
||||
global int $g_controlHeight;
|
||||
global float $g_UIColor[];
|
||||
|
||||
if(`rowLayout -exists LUMBERYARDANIMATIONMANAGER_ADDITEM_ROW`)
|
||||
{
|
||||
deleteUI LUMBERYARDANIMATIONMANAGER_ADDITEM_ROW;
|
||||
}
|
||||
setParent LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
|
||||
rowLayout -numberOfColumns 3 -columnWidth3 35 806 35 -backgroundColor 0.26 0.26 0.26
|
||||
-columnAlign 1 "center" -columnAttach 1 "both" 0 - columnAlign 2 "center" -columnAttach 2 "both" 0
|
||||
-columnAlign 3 "center" -columnAttach 3 "both" 0 LUMBERYARDANIMATIONMANAGER_ADDITEM_ROW;
|
||||
{
|
||||
text -height $g_controlHeight -label "";
|
||||
text -height $g_controlHeight -label "";
|
||||
button -height $g_controlHeight -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2] -label "+" -command ("LumberyardAnimationManagerAddNewItem");
|
||||
}
|
||||
}
|
||||
|
||||
//! Rebuilds the animation export list in the Animation Manager based on the current state of the data backend
|
||||
/*!
|
||||
\todo
|
||||
Move the querying of children of LUMBERYARD_ANIMATIONEXPORT_GROUP to LumberyardUtilities for proper data/UI
|
||||
separation.
|
||||
*/
|
||||
global proc LumberyardAnimationManagerReadExports()
|
||||
{
|
||||
global string $g_lastRow;
|
||||
$g_lastRow = "";
|
||||
|
||||
string $children[] = `columnLayout -query -childArray LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT`;
|
||||
for ($child in $children)
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
|
||||
if(!`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string $exportNodes[] = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
|
||||
for($exportNode in $exportNodes)
|
||||
{
|
||||
LumberyardAnimationManagerCreateUIRow($exportNode);
|
||||
}
|
||||
|
||||
LumberyardAnimationManagerUpdateHeight();
|
||||
LumberyardAnimationManagerUpdateLastRow();
|
||||
}
|
||||
|
||||
//! Creates the Animation Manager window and calls the necessary functions to populate it.
|
||||
global proc LumberyardAnimationManagerCreateWindow()
|
||||
{
|
||||
if(!`window -exists LUMBERYARDANIMATIONMANAGER_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists LUMBERYARDANIMATIONMANAGER_WINDOW`)
|
||||
{
|
||||
windowPref -widthHeight 905 65
|
||||
-topLeftCorner `windowPref -query -topEdge LUMBERYARDANIMATIONMANAGER_WINDOW` `windowPref -query -leftEdge LUMBERYARDANIMATIONMANAGER_WINDOW` LUMBERYARDANIMATIONMANAGER_WINDOW;
|
||||
}
|
||||
//Picked 900 so that the Animation Manager UI is long enough to fit the information for a typical 1920 x 1080 monitor. For 4K, the user can stretch the UI.
|
||||
window -titleBar true -title "Lumberyard Animation Manager" -widthHeight 905 65
|
||||
-sizeable true -minimizeButton false -maximizeButton false LUMBERYARDANIMATIONMANAGER_WINDOW;
|
||||
|
||||
columnLayout -adjustableColumn true -height 65 -backgroundColor 0.26 0.26 0.26 LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
{
|
||||
// Title Bar
|
||||
LumberyardAnimationManagerCreateColumnTitles();
|
||||
setParent LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
columnLayout -height 1 -backgroundColor 0.26 0.26 0.26 LUMBERYARDANIMATIONMANAGER_EXPORT_SCROLLLAYOUT;
|
||||
setParent LUMBERYARDANIMATIONMANAGER_MAINLAYOUT;
|
||||
LumberyardAnimationManagerCreateAddButton();
|
||||
}
|
||||
}
|
||||
|
||||
scriptJob -event "NewSceneOpened" "LumberyardAnimationManagerReadExports" -parent "LUMBERYARDANIMATIONMANAGER_WINDOW";
|
||||
scriptJob -event "PostSceneRead" "LumberyardAnimationManagerReadExports" -parent "LUMBERYARDANIMATIONMANAGER_WINDOW";
|
||||
scriptJob -event "animLayerRebuild" "LumberyardAnimationManagerUpdateLayers" -parent "LUMBERYARDANIMATIONMANAGER_WINDOW";
|
||||
|
||||
LumberyardUtilitiesUpdateAnimationLayers();
|
||||
LumberyardAnimationManagerReadExports();
|
||||
|
||||
showWindow LUMBERYARDANIMATIONMANAGER_WINDOW;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//////////////////////////////
|
||||
// Creates the Animation Pane UI
|
||||
|
||||
LumberyardAnimationPaneLoadDependencies();
|
||||
|
||||
//! Load required scripts for the Lumberyard Animation Pane
|
||||
global proc LumberyardAnimationPaneLoadDependencies()
|
||||
{
|
||||
eval("source cryAnim.mel");
|
||||
eval("source LumberyardAnimationManager.mel");
|
||||
eval("source LumberyardAnimationUtilities.mel");
|
||||
}
|
||||
|
||||
//! Creates a rowLayout UI item in the Animation Pane corresponding to an animation export
|
||||
/*!
|
||||
\param $animationExportNode The animation export node corresponding to the new rowLayout
|
||||
*/
|
||||
proc LumberyardAnimationPaneCreateUIRow(string $animationExportNode)
|
||||
{
|
||||
global int $g_rowItemHeight;
|
||||
|
||||
if($animationExportNode == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setParent LUMBERYARDTOOL_ANIMATION_LISTBOX;
|
||||
string $animationExportName = `LumberyardUtilitiesGetAnimationExportName $animationExportNode`;
|
||||
|
||||
rowLayout -numberOfColumns 2 -columnWidth2 19 240
|
||||
-height $g_rowItemHeight -columnAttach2 "left" "left" -columnOffset2 4 4;
|
||||
{
|
||||
$newCheckBox = `checkBox -label "" -value 1 -backgroundColor 0.5 0.5 0.5`;
|
||||
connectControl $newCheckBox ($animationExportNode+".shouldExport");
|
||||
text -align "left" -label $animationExportName -width 240;
|
||||
}
|
||||
}
|
||||
|
||||
//! Create instruction texts for Animation export list and add it
|
||||
proc LumberyardAnimationCreateInstsructionTexts()
|
||||
{
|
||||
setParent LUMBERYARDTOOL_ANIMATION_LISTBOX;
|
||||
rowColumnLayout -numberOfRows 1 -rowOffset 1 "top" 45 -columnOffset 1 "both" 80;
|
||||
text -label "To add an animation, click on Animation Manager";
|
||||
}
|
||||
|
||||
//! Gets all animation export names from the data backend and creates the UI elements for them
|
||||
global proc LumberyardAnimationPaneReadExports()
|
||||
{
|
||||
if (!`LumberyardUtilitiesUpgradeAnimationData`)
|
||||
{
|
||||
window -edit -visible false LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
return;
|
||||
}
|
||||
setParent LUMBERYARDTOOL_ANIMATION_LISTBOX;
|
||||
string $children[] = `scrollLayout -query -childArray LUMBERYARDTOOL_ANIMATION_LISTBOX`;
|
||||
for ($child in $children)
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
|
||||
string $exportNodes[] = `LumberyardUtilitiesGetAnimationExportNodes`;
|
||||
|
||||
if (size($exportNodes) == 0)
|
||||
{
|
||||
LumberyardAnimationCreateInstsructionTexts;
|
||||
return;
|
||||
}
|
||||
|
||||
for($exportNode in $exportNodes)
|
||||
{
|
||||
LumberyardAnimationPaneCreateUIRow($exportNode);
|
||||
}
|
||||
}
|
||||
|
||||
//! Creates the main Animation Pane UI for the Lumberyard Tool
|
||||
global proc LumberyardAnimationPaneCreate()
|
||||
{
|
||||
global float $g_UIColor[];
|
||||
global int $g_animationHeightDiff;
|
||||
|
||||
setParent LUMBERYARDTOOL_MAIN_LAYOUT;
|
||||
frameLayout -collapsable true -marginHeight 5 -marginWidth 5 -label "Animation Export"
|
||||
-collapseCommand ("LumberyardToolResizeWindow " + (-$g_animationHeightDiff)) -expandCommand ("LumberyardToolResizeWindow " + $g_animationHeightDiff)
|
||||
LUMBERYARDTOOL_ANIMATION_FRAME;
|
||||
{
|
||||
columnLayout -adjustableColumn true LUMBERYARDTOOL_ANIMATION_LAYOUT;
|
||||
{
|
||||
scrollLayout -height 120 -backgroundColor 0 0 0 -visible true LUMBERYARDTOOL_ANIMATION_LISTBOX;
|
||||
setParent LUMBERYARDTOOL_ANIMATION_LAYOUT;
|
||||
button -label "Animation Manager" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command "LumberyardAnimationManagerCreateWindow" LUMBERYARDTOOL_ANIMATIONMANAGER_BUTTON;
|
||||
button -label "Export Animations" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command "LumberyardUtilitiesExportSelectedAnimations 1" LUMBERYARDTOOL_ANIMATIONEXPORT_BUTTON;
|
||||
}
|
||||
}
|
||||
|
||||
LumberyardAnimationPaneReadExports();
|
||||
scriptJob -event "NewSceneOpened" "LumberyardAnimationPaneReadExports" -parent "LUMBERYARDTOOL_MAIN_WINDOW";
|
||||
scriptJob -event "PostSceneRead" "LumberyardAnimationPaneReadExports" -parent "LUMBERYARDTOOL_MAIN_WINDOW";
|
||||
}
|
||||
@@ -0,0 +1,658 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// List of the current animLayers known to the Utilities, this is
|
||||
// used to determine operations performed in the Maya main workflow and
|
||||
// keep the data backend synchronized with it.
|
||||
global string $g_animLayers[];
|
||||
|
||||
//! Forces a refresh of the Lumberyard Animation Manager and Lumberyard Animation Pane.
|
||||
global proc LumberyardUtilitiesUpdateAnimationUI()
|
||||
{
|
||||
if(`window -exists LUMBERYARDANIMATIONMANAGER_WINDOW`)
|
||||
{
|
||||
LumberyardAnimationManagerReadExports();
|
||||
}
|
||||
|
||||
if(`window -exists LUMBERYARDTOOL_MAIN_WINDOW`)
|
||||
{
|
||||
LumberyardAnimationPaneReadExports();
|
||||
}
|
||||
}
|
||||
|
||||
//! Generates a unique animation export name based on a requested name.
|
||||
/*!
|
||||
\param $requestedName The desired name that may be changed to guarantee uniqueness.
|
||||
*/
|
||||
global proc string LumberyardUtilitiesGetUniqueAnimationName(string $requestedName)
|
||||
{
|
||||
if ($requestedName == "")
|
||||
{
|
||||
$requestedName = "animationExport";
|
||||
}
|
||||
return `LumberyardUtilitiesVerifyAnimationRequestName $requestedName ""`;
|
||||
}
|
||||
|
||||
//! Verify if requested name is valid and return a proper name for the animation.
|
||||
/*
|
||||
\param $requestedName The desired name of the animation.
|
||||
\param $currentName The current name of the animation.
|
||||
*/
|
||||
global proc string LumberyardUtilitiesVerifyAnimationRequestName(string $requestedName, string $currentName)
|
||||
{
|
||||
return `LumberyardVerifySceneObjectRequestNameWithPrefix $requestedName $currentName "LUMBERYARD_ANIMATIONEXPORT_GROUP|"`;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// For manipulating layer data
|
||||
|
||||
//! Returns the list of animLayers defined by Maya.
|
||||
/*!
|
||||
\note
|
||||
This will return the identical ordering to Maya, but only if displaying
|
||||
them newest animLayer first, which is the default view. It will not
|
||||
guarantee identical ordering for other Maya animLayer displays.
|
||||
*/
|
||||
global proc string[] LumberyardUtilitiesGetAnimLayers()
|
||||
{
|
||||
string $layers[];
|
||||
if(`animLayer -query -exists "BaseAnimation"`)
|
||||
{
|
||||
$layers = `animLayer -query -children "BaseAnimation"`;
|
||||
|
||||
$layers = `LumberyardUtilitiesReverseStringArray $layers`;
|
||||
}
|
||||
$layers[size($layers)] = "BaseAnimation";
|
||||
return $layers;
|
||||
}
|
||||
|
||||
//! This removes the specified animLayers from the active list for all animation exports.
|
||||
/*!
|
||||
\param $removeLayers The name of all animLayers that should be removed.
|
||||
*/
|
||||
proc LumberyardUtilitiesRemoveAnimLayers(string $removeLayers[])
|
||||
{
|
||||
if(`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
string $exportNodes[] = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
for($exportNode in $exportNodes)
|
||||
{
|
||||
string $exportLayers[] = `LumberyardUtilitiesGetAnimationExportLayers $exportNode`;
|
||||
$exportLayers = `stringArrayRemove $removeLayers $exportLayers`;
|
||||
LumberyardUtilitiesSetAnimationExportLayers($exportNode, $exportLayers);
|
||||
LumberyardUtilitiesUpdateAnimationUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! This will update an old animLayer name to a new name for all animation exports' active animLayer list.
|
||||
/*!
|
||||
\param $oldName The name of the animLayer to replace.
|
||||
\param $newName The name that should be stored in its place.
|
||||
*/
|
||||
proc LumberyardUtilitiesRenameAnimLayer(string $oldName, string $newName)
|
||||
{
|
||||
if(`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
string $exportNodes[] = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
for($exportNode in $exportNodes)
|
||||
{
|
||||
string $exportLayers[] = `LumberyardUtilitiesGetAnimationExportLayers $exportNode`;
|
||||
int $index = `stringArrayFind $oldName 0 $exportLayers`;
|
||||
if($index >= 0)
|
||||
{
|
||||
$exportLayers[$index] = $newName;
|
||||
}
|
||||
LumberyardUtilitiesSetAnimationExportLayers($exportNode, $exportLayers);
|
||||
LumberyardUtilitiesUpdateAnimationUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Callback which queries Maya animLayer state, and synchronizes the data backend with the current state.
|
||||
/*!
|
||||
\note
|
||||
This should be called whenever an animLayer is added, removed, renamed or deleted in Maya. If animLayer is
|
||||
manipulated by scripts, this should be called after any operations of these types.
|
||||
*/
|
||||
global proc LumberyardUtilitiesUpdateAnimationLayers()
|
||||
{
|
||||
global string $g_animLayers[];
|
||||
string $layers[];
|
||||
$layers = `ls -type "animLayer"`;
|
||||
|
||||
if(size($g_animLayers) == size($layers))
|
||||
{
|
||||
// A layer was renamed
|
||||
string $oldNames[];
|
||||
string $newName;
|
||||
|
||||
for($animLayer in $g_animLayers)
|
||||
{
|
||||
if(!`stringArrayContains $animLayer $layers`)
|
||||
{
|
||||
$oldNames[size($oldNames)] = $animLayer;
|
||||
}
|
||||
}
|
||||
|
||||
if(size($oldNames) > 1)
|
||||
{
|
||||
print("Warning: Received multiple rename requests in a single operation, removing nodes instead\n");
|
||||
LumberyardUtilitiesRemoveAnimLayers($oldNames);
|
||||
$g_animLayers = $layers;
|
||||
return;
|
||||
}
|
||||
if(size($oldNames) == 0)
|
||||
{
|
||||
// No renamed asset found
|
||||
return;
|
||||
}
|
||||
|
||||
for($animLayer in $layers)
|
||||
{
|
||||
if(!`stringArrayContains $animLayer $g_animLayers`)
|
||||
{
|
||||
$newName = $animLayer;
|
||||
}
|
||||
}
|
||||
|
||||
LumberyardUtilitiesRenameAnimLayer($oldNames[0], $newName);
|
||||
}
|
||||
else if(size($g_animLayers) > size($layers))
|
||||
{
|
||||
// One or more layers were deleted
|
||||
if(`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
string $deletedLayers[];
|
||||
for($animLayer in $g_animLayers)
|
||||
{
|
||||
if(!`stringArrayContains $animLayer $layers`)
|
||||
{
|
||||
// Deleted Layer
|
||||
$deletedLayers[size($deletedLayers)] = $animLayer;
|
||||
}
|
||||
}
|
||||
|
||||
string $exportNodes[] = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
for($exportNode in $exportNodes)
|
||||
{
|
||||
LumberyardUtilitiesRemoveAnimLayers($deletedLayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store layer list for next AnimLayer operation
|
||||
$g_animLayers = $layers;
|
||||
}
|
||||
|
||||
//! Utility function to create a command that will generate correct export behavior based on animLayer settings.
|
||||
/*!
|
||||
\param $exportLayerString The string attribute encoding animLayer selections for an animation export.
|
||||
\note The default behavior is to mute any layers not contained in the exportLayer selections during export.
|
||||
*/
|
||||
proc string LumberyardUtilitiesConvertAnimLayerStringToCommand(string $exportLayerString)
|
||||
{
|
||||
string $exportLayers[] = `stringToStringArray $exportLayerString ","`;
|
||||
string $validLayers[] = `LumberyardUtilitiesGetAnimLayers`;
|
||||
string $command = "";
|
||||
|
||||
for($i = 0; $i < size($validLayers); $i++)
|
||||
{
|
||||
if($validLayers[$i] != "BaseAnimation")
|
||||
{
|
||||
int $value = !`stringArrayContains $validLayers[$i] $exportLayers`;
|
||||
$command = $command + "setAttr " + $validLayers[$i] + ".mute " + $value + ";";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
//! Upgrades the old Crytek format for animLayer commands into the new Lumberyard format.
|
||||
/*!
|
||||
\param $animLayerCommand The animLayer command for an animation export encoded in Crytek format.
|
||||
*/
|
||||
proc string[] LumberyardUtilitiesUpgradeAnimLayerCommand(string $animLayerCommand)
|
||||
{
|
||||
string $animLayers[];
|
||||
string $commands[];
|
||||
int $numCommands = `tokenize $animLayerCommand ";" $commands`;
|
||||
|
||||
string $elements[];
|
||||
|
||||
for($i = 0; $i < $numCommands; $i = $i + 2)
|
||||
{
|
||||
tokenize $commands[$i] " " $elements;
|
||||
// Validate for proper command formatting.
|
||||
if(size($elements) == 3)
|
||||
{
|
||||
int $value = (int)$elements[2];
|
||||
if($value != 0)
|
||||
{
|
||||
tokenize $elements[1] "." $elements;
|
||||
if(size($elements) == 2)
|
||||
{
|
||||
$animLayers[size($animLayers)] = $elements[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $animLayers;
|
||||
}
|
||||
|
||||
//! Upgrades old Crytek into properly formatted Lumberyard animation export data.
|
||||
/*!
|
||||
\note
|
||||
The old Crytek format used a single monolithic string that was constantly built and tokenized to store this data.
|
||||
The data was moved into a node attributes to make it less computationally expensive, as well as easier to read and
|
||||
manipulate. Note that this is a destructive operation, the old Crytek data is removed to prevent detecting old data
|
||||
every time the file is opened.
|
||||
\todo
|
||||
We may consider backing up the Crytek data in a separate location so it can be restored if it is requested by customers,
|
||||
but we would prefer to only forward port data in the long term.
|
||||
*/
|
||||
global proc int LumberyardUtilitiesUpgradeAnimationData()
|
||||
{
|
||||
string $exportStringsRaw[] = `cryAnimGetRanges`;
|
||||
|
||||
if(size($exportStringsRaw) >= 1 && $exportStringsRaw[0] != "")
|
||||
{
|
||||
string $upgradeChoice = `confirmDialog -title "Upgrade"
|
||||
-message "Detected old animation data. Do you wish to upgrade it to the new tool format? (This operation will remove the old data)"
|
||||
-button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`;
|
||||
|
||||
if($upgradeChoice == "Yes")
|
||||
{
|
||||
string $exportStringsRaw[] = `cryAnimGetRanges`;
|
||||
cryAnimRemoveAllAnimRanges();
|
||||
for($exportStringRaw in $exportStringsRaw)
|
||||
{
|
||||
string $exportParameters[] = `python("mau.AMZN_DecodeAnimRangeString(\"" + $exportStringRaw + "\")")`;
|
||||
|
||||
string $exportLayers[];
|
||||
if(size($exportParameters) >= 6)
|
||||
{
|
||||
$exportLayers = `LumberyardUtilitiesUpgradeAnimLayerCommand $exportParameters[5]`;
|
||||
}
|
||||
|
||||
LumberyardUtilitiesCreateAnimationExport($exportParameters[0], $exportParameters[1], $exportParameters[2],
|
||||
$exportParameters[3], $exportParameters[4], $exportLayers);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Creates the node to contain animation export data, and store requested values in the node
|
||||
/*!
|
||||
\param $startFrame The first frame to export for the animation
|
||||
\param $endFrame The last frame to export for the animation
|
||||
\param $exportName The name of the i_caf file to generate when exporting the animation
|
||||
\param $rootJoint The root joint to use when exporting the animation. Only joints below the root will be exported.
|
||||
\param $exportPath The absolute path to store the i_caf when exporting the animation.
|
||||
\param $exportLayers A list of the layers that should be active (not muted) when exporting the animation.
|
||||
*/
|
||||
global proc LumberyardUtilitiesCreateAnimationExport(int $startFrame, int $endFrame, string $exportName, string $rootJoint,
|
||||
string $exportPath, string $exportLayers[])
|
||||
{
|
||||
if(!`objExists "LUMBERYARD_EXPORT_GROUP"`)
|
||||
{
|
||||
group -world -empty -name "LUMBERYARD_EXPORT_GROUP";
|
||||
}
|
||||
|
||||
|
||||
if(!`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
group -empty -parent "LUMBERYARD_EXPORT_GROUP" -name "LUMBERYARD_ANIMATIONEXPORT_GROUP";
|
||||
}
|
||||
else
|
||||
{
|
||||
string $parents[] = `listRelatives -parent "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
if (!stringArrayContains("LUMBERYARD_EXPORT_GROUP", $parents))
|
||||
{
|
||||
parent ("LUMBERYARD_ANIMATIONEXPORT_GROUP", "LUMBERYARD_EXPORT_GROUP");
|
||||
}
|
||||
}
|
||||
|
||||
string $newExportNode = `createNode "transform" -name AnimationExport -parent "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
addAttr -longName "shouldExport" -attributeType bool $newExportNode;
|
||||
setAttr ($newExportNode+".shouldExport") 1;
|
||||
LumberyardUtilitiesSetAnimationStartFrame($newExportNode, $startFrame);
|
||||
LumberyardUtilitiesSetAnimationEndFrame($newExportNode, $endFrame);
|
||||
LumberyardUtilitiesSetAnimationExportName($newExportNode, $exportName);
|
||||
LumberyardUtilitiesSetAnimationRootJoint($newExportNode, $rootJoint);
|
||||
LumberyardUtilitiesSetAnimationExportPath($newExportNode, $exportPath);
|
||||
LumberyardUtilitiesSetAnimationExportLayers($newExportNode, $exportLayers);
|
||||
}
|
||||
|
||||
//! Deletes an animation export and its data
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to delete
|
||||
*/
|
||||
global proc LumberyardUtilitiesDeleteAnimationExport(string $exportNode)
|
||||
{
|
||||
if(!`objExists ("LUMBERYARD_ANIMATIONEXPORT_GROUP|" + $exportNode)`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delete ("LUMBERYARD_ANIMATIONEXPORT_GROUP|" + $exportNode);
|
||||
LumberyardUtilitiesUpdateAnimationUI();
|
||||
}
|
||||
|
||||
//! Returns a list of all animation exports in the scene
|
||||
global proc string[] LumberyardUtilitiesGetAnimationExportNodes()
|
||||
{
|
||||
string $exportNodes[];
|
||||
|
||||
if(`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
$exportNodes = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
}
|
||||
|
||||
return $exportNodes;
|
||||
}
|
||||
|
||||
//! Returns true if the animation export node exists, and has all required attributes
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to validate
|
||||
*/
|
||||
global proc int LumberyardUtilitiesAnimationExportIsValid(string $exportNode)
|
||||
{
|
||||
string $fullname = "LUMBERYARD_ANIMATIONEXPORT_GROUP|"+$exportNode;
|
||||
if (!`objExists $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!`attributeExists "startFrame" $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!`attributeExists "endFrame" $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!`attributeExists "exportName" $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!`attributeExists "rootJoint" $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!`attributeExists "exportPath" $fullname`)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//! Sets an integer attribute on an animation export node, creating it if needed
|
||||
/*!
|
||||
\param $exportNode The node to set the attribute on
|
||||
\param $attribute The name of the attribute to set
|
||||
\param $value The value to store in the attribute
|
||||
*/
|
||||
proc LumberyardUtilitiesSetAnimationIntAttr(string $exportNode, string $attribute, int $value)
|
||||
{
|
||||
if(!`attributeExists $attribute $exportNode`)
|
||||
{
|
||||
addAttr -longName $attribute -attributeType long $exportNode;
|
||||
}
|
||||
|
||||
setAttr ("LUMBERYARD_ANIMATIONEXPORT_GROUP|" + $exportNode + "." + $attribute) $value;
|
||||
}
|
||||
|
||||
//! Sets a string attribute on an animation export node, creating it if needed
|
||||
/*!
|
||||
\param $exportNode The node to set the attribute on
|
||||
\param $attribute The name of the attribute to set
|
||||
\param $value The value to store in the attribute
|
||||
*/
|
||||
proc LumberyardUtilitiesSetAnimationStringAttr(string $exportNode, string $attribute, string $value)
|
||||
{
|
||||
if(!`attributeExists $attribute $exportNode`)
|
||||
{
|
||||
addAttr -longName $attribute -dataType "string" $exportNode;
|
||||
}
|
||||
|
||||
setAttr -type "string" ("LUMBERYARD_ANIMATIONEXPORT_GROUP|" + $exportNode + "." + $attribute) $value;
|
||||
}
|
||||
|
||||
//! Gets the value of an animation export node attribute if it exists. If not, returns a default value.
|
||||
/*!
|
||||
\param $exportNode The animation export node to fetch the value for.
|
||||
\param $attribute The name of the attribute to query.
|
||||
\param $defaultValue The default value that will be returned if the attribute or node are not found.
|
||||
\note
|
||||
This always returns a string. The caller is responsible to cast the return value to the appropriate type.
|
||||
*/
|
||||
proc string LumberyardUtilitiesGetAnimationAttr(string $exportNode, string $attribute, string $defaultValue)
|
||||
{
|
||||
string $return = $defaultValue;
|
||||
|
||||
if(`LumberyardUtilitiesAnimationExportIsValid $exportNode`)
|
||||
{
|
||||
$return = `getAttr ("LUMBERYARD_ANIMATIONEXPORT_GROUP|" + $exportNode + "." + $attribute) $exportNode`;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
//! Sets the start frame value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the start frame for
|
||||
\param $startFrame The first frame for the animation export.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSetAnimationStartFrame(string $exportNode, int $startFrame)
|
||||
{
|
||||
LumberyardUtilitiesSetAnimationIntAttr($exportNode, "startFrame", $startFrame);
|
||||
|
||||
}
|
||||
|
||||
//! Gets the start frame value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the start frame for
|
||||
*/
|
||||
global proc int LumberyardUtilitiesGetStartFrame(string $exportNode)
|
||||
{
|
||||
string $value = `LumberyardUtilitiesGetAnimationAttr $exportNode "startFrame" "-1"`;
|
||||
int $intValue = (int)$value;
|
||||
return $intValue;
|
||||
}
|
||||
|
||||
//! Sets the end frame value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the end frame for
|
||||
\param $endFrame The last frame for the animation export.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSetAnimationEndFrame(string $exportNode, int $endFrame)
|
||||
{
|
||||
LumberyardUtilitiesSetAnimationIntAttr($exportNode, "endFrame", $endFrame);
|
||||
}
|
||||
|
||||
//! Gets the end frame value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the end frame for
|
||||
*/
|
||||
global proc int LumberyardUtilitiesGetAnimationEndFrame(string $exportNode)
|
||||
{
|
||||
string $value = `LumberyardUtilitiesGetAnimationAttr $exportNode "endFrame" "-1"`;
|
||||
int $intValue = (int)$value;
|
||||
return $intValue;
|
||||
}
|
||||
|
||||
//! Sets the export name value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the export name for
|
||||
\param $exportName The name of the i_caf to create for the animation export.
|
||||
*/
|
||||
global proc string LumberyardUtilitiesSetAnimationExportName(string $exportNode, string $exportName)
|
||||
{
|
||||
LumberyardUtilitiesSetAnimationStringAttr($exportNode, "exportName", $exportName);
|
||||
if(`window -exists LUMBERYARDTOOL_MAIN_WINDOW`)
|
||||
{
|
||||
LumberyardAnimationPaneReadExports();
|
||||
}
|
||||
return $exportName;
|
||||
}
|
||||
|
||||
//! Gets the export name value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the export name for
|
||||
*/
|
||||
global proc string LumberyardUtilitiesGetAnimationExportName(string $exportNode)
|
||||
{
|
||||
return `LumberyardUtilitiesGetAnimationAttr $exportNode "exportName" ""`;
|
||||
}
|
||||
|
||||
//! Sets the root joint value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the root joint for
|
||||
\param $rootJoint The root joint for the animation export. Only joints below this will be exported.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSetAnimationRootJoint(string $exportNode, string $rootJoint)
|
||||
{
|
||||
LumberyardUtilitiesSetAnimationStringAttr($exportNode, "rootJoint", $rootJoint);
|
||||
}
|
||||
|
||||
//! Gets the root joint value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the root joint for
|
||||
*/
|
||||
global proc string LumberyardUtilitiesGetAnimationRootJoint(string $exportNode)
|
||||
{
|
||||
return `LumberyardUtilitiesGetAnimationAttr $exportNode "rootJoint" ""`;
|
||||
}
|
||||
|
||||
//! Sets the export layers used for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the export layers for.
|
||||
\param $exportLayers A list containing all animLayers that should be active when exporting the animation export.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSetAnimationExportLayers(string $exportNode, string $exportLayers[])
|
||||
{
|
||||
string $exportLayerString = `stringArrayToString $exportLayers ","`;
|
||||
LumberyardUtilitiesSetAnimationStringAttr($exportNode, "exportLayers", $exportLayerString);
|
||||
}
|
||||
|
||||
//! Gets a list of the export layers used for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the export layers for.
|
||||
*/
|
||||
global proc string[] LumberyardUtilitiesGetAnimationExportLayers(string $exportNode)
|
||||
{
|
||||
string $animLayerString = `LumberyardUtilitiesGetAnimationAttr $exportNode "exportLayers" ""`;
|
||||
string $animLayers[] = `stringToStringArray $animLayerString ","`;
|
||||
|
||||
if(!`stringArrayContains "BaseAnimation" $animLayers`)
|
||||
{
|
||||
$animLayers[size($animLayers)] = "BaseAnimation";
|
||||
}
|
||||
|
||||
return $animLayers;
|
||||
}
|
||||
|
||||
//! Sets the export path value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to set the export path for
|
||||
\param $exportPath The absolute export path used when generating the i_caf for the animation export.
|
||||
*/
|
||||
global proc string LumberyardUtilitiesSetAnimationExportPath(string $exportNode, string $exportPath)
|
||||
{
|
||||
$exportPath = `cryExportFixupPath $exportPath`;
|
||||
LumberyardUtilitiesSetAnimationStringAttr($exportNode, "exportPath", $exportPath);
|
||||
return $exportPath;
|
||||
}
|
||||
|
||||
//! Gets the export path value for an animation export
|
||||
/*!
|
||||
\param $exportNode The name of the animation export node to get the export path for
|
||||
*/
|
||||
global proc string LumberyardUtilitiesGetAnimationExportPath(string $exportNode)
|
||||
{
|
||||
return `LumberyardUtilitiesGetAnimationAttr $exportNode "exportPath" ""`;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Functions tied to buttons
|
||||
|
||||
//! Sets the start and end frame for an animation export to match the Maya timeline
|
||||
/*!
|
||||
\param $exportName The name of the animation export node to snap to the Maya timeline.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSnapAnimationToTimeline(string $exportNode)
|
||||
{
|
||||
if(!`LumberyardUtilitiesAnimationExportIsValid $exportNode`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int $startFrame = `playbackOptions -query -minTime`;
|
||||
int $endFrame = `playbackOptions -query -maxTime`;
|
||||
setAttr ($exportNode+".startFrame") $startFrame;
|
||||
setAttr ($exportNode+".endFrame") $endFrame;
|
||||
|
||||
if(`window -exists LUMBERYARDANIMATIONMANAGER_WINDOW`)
|
||||
{
|
||||
LumberyardAnimationManagerReadExports();
|
||||
}
|
||||
}
|
||||
|
||||
//! Exports all animation exports that have the shouldExport attribute set to true.
|
||||
/*!
|
||||
\param $blockOnWarnings If not zero/false, this will keep Export Progress UI from blocking for user input for warnings.
|
||||
\note
|
||||
$blockOnWarnings is only intended for use for batch operations at this time.
|
||||
*/
|
||||
global proc LumberyardUtilitiesExportSelectedAnimations(int $blockOnWarnings)
|
||||
{
|
||||
if(!`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string $children[] = `listRelatives -children "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
|
||||
for($child in $children)
|
||||
{
|
||||
if(`LumberyardUtilitiesAnimationExportIsValid $child`)
|
||||
{
|
||||
string $fullname = "LUMBERYARD_ANIMATIONEXPORT_GROUP|"+$child;
|
||||
int $shouldExport = `getAttr ($fullname+".shouldExport")`;
|
||||
if($shouldExport != 0)
|
||||
{
|
||||
string $startFrame = `getAttr ($fullname+".startFrame")`;
|
||||
string $endFrame = `getAttr ($fullname+".endFrame")`;
|
||||
string $exportName = `getAttr ($fullname+".exportName")`;
|
||||
string $rootJoint = `getAttr ($fullname+".rootJoint")`;
|
||||
string $exportPath = `getAttr ($fullname+".exportPath")`;
|
||||
string $exportLayers = `getAttr ($fullname+".exportLayers")`;
|
||||
string $layerCommand = `LumberyardUtilitiesConvertAnimLayerStringToCommand $exportLayers`;
|
||||
cryIssueAnimationExportCommand($startFrame, $endFrame, $exportName, $rootJoint, $exportPath, $layerCommand, $blockOnWarnings, LumberyardExportGetAdditionalExportOptions());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//! Data record of geometry export nodes.
|
||||
global string $g_geometryExportNodes[];
|
||||
|
||||
//! Retrieve all lumberyard export nodes by Maya plugin, and save them in the backend data record.
|
||||
/*!
|
||||
\note This function is costly as it will traverse through the scene hierarchy to search for nodes. Only use when necessary.
|
||||
Use LumberyardToolGetGeometryExportNodes instead when you just want to get the record of the nodes.
|
||||
*/
|
||||
global proc LumberyardToolLoadGeometryExportNodes()
|
||||
{
|
||||
global string $g_geometryExportNodes[];
|
||||
$g_geometryExportNodes = `cryMayaSupportPlugin gatherExportNodes`;
|
||||
}
|
||||
|
||||
//! Get export nodes from backend data record.
|
||||
global proc string[] LumberyardToolGetGeometryExportNodes()
|
||||
{
|
||||
global string $g_geometryExportNodes[];
|
||||
return $g_geometryExportNodes;
|
||||
}
|
||||
|
||||
//! Get the number of export nodes from backend data record.
|
||||
global proc int LumberyardToolGetGeometryExportNodeCount()
|
||||
{
|
||||
global string $g_geometryExportNodes[];
|
||||
return size($g_geometryExportNodes);
|
||||
}
|
||||
|
||||
//! Delete a export node record from backend data record.
|
||||
/*!
|
||||
\param $node the node name to remove from the record.
|
||||
*/
|
||||
global proc LumberyardToolDeleteGeometryExportNode(string $node)
|
||||
{
|
||||
global string $g_geometryExportNodes[];
|
||||
string $removeNodes[];
|
||||
$removeNodes[0] = $node;
|
||||
$g_geometryExportNodes = stringArrayRemove($removeNodes, $g_geometryExportNodes);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,445 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
from maya import cmds
|
||||
import math
|
||||
import maya.mel
|
||||
|
||||
#defines the shape labels
|
||||
g_shapeTypes = ['box', 'capsule', 'sphere']
|
||||
g_materialNames = ['mat_proxy_phys', 'no material']
|
||||
g_boxIndex = 0
|
||||
g_capsuleIndex = 1
|
||||
g_sphereIndex = 2
|
||||
|
||||
g_orientTypes = ['x', 'y', 'z', 'xCenter', 'yCenter', 'zCenter']
|
||||
g_defaultOrientTypeIndex = 0
|
||||
g_xIndex = 0
|
||||
g_yIndex = 1
|
||||
g_zIndex = 2
|
||||
g_xCenterIndex = 3
|
||||
g_yCenterIndex = 4
|
||||
g_zCenterIndex = 5
|
||||
g_centerString = 'Center'
|
||||
|
||||
##########
|
||||
##The colors that will be used in the editor
|
||||
##########
|
||||
g_UIColor = [0.165, 0.165, 0.165]
|
||||
|
||||
g_defaultMaterialColor = [0, 1, 0]
|
||||
|
||||
##########
|
||||
##Width and height definitions for ui elements
|
||||
##########
|
||||
g_uiProxyWidthColumnWidth = 30
|
||||
g_controlHeight = 22
|
||||
g_listboxHeight = 35
|
||||
g_buttonSpace = 4
|
||||
g_rowItemHeight = 22
|
||||
|
||||
g_uiShapePulldownColumnWidth = 75
|
||||
g_uiOrientPulldownColumnWidth = 50
|
||||
g_uiMaterialNamePulldownWidth = 120
|
||||
g_uiMaterialFieldColumnWidth = 125
|
||||
g_scrollBarPadding = 36
|
||||
|
||||
g_buttonMarginPadding = 10
|
||||
g_marginWidth = 5
|
||||
g_boxWidth = 400
|
||||
|
||||
g_uiColumnWidth = [g_uiProxyWidthColumnWidth, g_uiShapePulldownColumnWidth, g_uiOrientPulldownColumnWidth, g_uiMaterialFieldColumnWidth]
|
||||
|
||||
|
||||
#TODO: make width/height dynamic
|
||||
g_windowHeight = 120
|
||||
g_windowWidth = 318
|
||||
|
||||
#default name of display layer where proxies will reside
|
||||
g_nameOfDisplayLayer = 'lyr_lumberyard_phys'
|
||||
|
||||
#postfix of the physics proxy
|
||||
g_physPostfix = '_phys';
|
||||
|
||||
#the default width of proxies
|
||||
g_proxyShapeDefaultWidth = 10
|
||||
|
||||
#estimating that the proxy width is 1/10th of the hip height
|
||||
g_proxyWidthRatioToHeight = 0.1
|
||||
|
||||
class ProxyObject(object):
|
||||
|
||||
##This class represents both the variables and the ui of the proxy editor
|
||||
def __init__(self) :
|
||||
|
||||
#defines the ui of the width text field
|
||||
self.uiTextFieldWidth = ''
|
||||
|
||||
#defines the value of the width and depth
|
||||
self.width = g_proxyShapeDefaultWidth
|
||||
|
||||
#defines the ui of the shape drop down ui
|
||||
self.menuDropDownShape = ''
|
||||
|
||||
#defines this proxy's shape
|
||||
self.shape = g_shapeTypes[g_boxIndex]
|
||||
|
||||
#defines this proxies material name
|
||||
self.proxyMaterialName = ''
|
||||
|
||||
#defines the ui used to modify orientation
|
||||
self.menuDropDownOrient = ''
|
||||
|
||||
#defines the orientation of the proxy
|
||||
self.objectOrient = g_orientTypes[g_defaultOrientTypeIndex]
|
||||
|
||||
self.menuDropDownMaterialName = ''
|
||||
|
||||
proxyCreationSettings = ProxyObject()
|
||||
|
||||
|
||||
def LumberyardProxyTool():
|
||||
##Create the main window. If it exists, delete it, and then create it
|
||||
if cmds.window('LUMBERYARDTOOL_PROXY_WINDOW', exists=True):
|
||||
cmds.deleteUI('LUMBERYARDTOOL_PROXY_WINDOW')
|
||||
|
||||
LumberyardProxyToolUI()
|
||||
|
||||
def LumberyardProxyToolUI():
|
||||
##This script defines the window or primary canvas of the ui.
|
||||
lumberyardProxyWindow = cmds.window('LUMBERYARDTOOL_PROXY_WINDOW', title = "Proxy Tool (Experimental)", sizeable = False, iconName = 'Proxy Tool', widthHeight = (g_windowWidth, g_windowHeight))
|
||||
LumberyardToolCreateProxyFrameMain()
|
||||
cmds.showWindow(lumberyardProxyWindow)
|
||||
cmds.window(lumberyardProxyWindow, edit = True, widthHeight = (g_windowWidth, g_windowHeight))
|
||||
|
||||
def LumberyardToolCreateProxyFrameMain():
|
||||
##When the window is first open this is what the user will see
|
||||
cmds.columnLayout('LUMBERYARDTOOL_PROXY_LAYOUT', adjustableColumn = True)
|
||||
|
||||
cmds.text(height = g_controlHeight, enable = True, font = 'tinyBoldLabelFont', align = 'center', width = g_uiProxyWidthColumnWidth+3, label = 'Select joints and click "Create Proxies"', backgroundColor = g_UIColor)
|
||||
|
||||
cmds.setParent('LUMBERYARDTOOL_PROXY_WINDOW')
|
||||
|
||||
cmds.rowLayout(numberOfColumns = 4, columnWidth4 = g_uiColumnWidth, backgroundColor = g_UIColor)
|
||||
|
||||
#title labels for all the variable categories that we'll have control over
|
||||
cmds.text(height = g_controlHeight, enable = True, font = 'tinyBoldLabelFont', align = 'left', width = g_uiProxyWidthColumnWidth+3, label = 'width', backgroundColor = g_UIColor)
|
||||
cmds.text(height = g_controlHeight, enable = True, font = 'tinyBoldLabelFont', align = 'left', width = g_uiShapePulldownColumnWidth, label = 'shape', backgroundColor = g_UIColor)
|
||||
cmds.text(height = g_controlHeight, enable = True, font = 'tinyBoldLabelFont', align = 'left', width = g_uiOrientPulldownColumnWidth+25, label = 'orient', backgroundColor = g_UIColor)
|
||||
cmds.text(height = g_controlHeight, enable = True, font = 'tinyBoldLabelFont', align = 'left', width = g_uiMaterialFieldColumnWidth + g_marginWidth, label = 'material name', backgroundColor = g_UIColor)
|
||||
|
||||
##This is the editable area of the ui that will be populated by our variables. In the beginning it is unpopulated but has instruction on what to do
|
||||
cmds.setParent('LUMBERYARDTOOL_PROXY_LAYOUT')
|
||||
cmds.scrollLayout ('LUMBERYARDTOOL_PROXY_LISTBOX', height = g_listboxHeight, width = g_boxWidth , backgroundColor = [0, 0, 0], visible = True)
|
||||
|
||||
cmds.setParent('LUMBERYARDTOOL_PROXY_LISTBOX')
|
||||
|
||||
#create a row
|
||||
cmds.rowLayout(numberOfColumns = 4, columnWidth4 = g_uiColumnWidth)
|
||||
|
||||
#create the width ui
|
||||
LumberyardCreateWidthTextField()
|
||||
|
||||
#create the shape ui
|
||||
LumberyardCreateShapePullDown()
|
||||
|
||||
#create the orient ui
|
||||
LumberyardCreateOrientPullDown()
|
||||
|
||||
LumberyardCreateMaterialPullDown()
|
||||
|
||||
#create the ui underneath the editable variables window. This is the canvas for our create button
|
||||
cmds.setParent('LUMBERYARDTOOL_PROXY_LAYOUT')
|
||||
cmds.setParent('..')
|
||||
cmds.rowColumnLayout(numberOfRows = 1, width = g_boxWidth , columnSpacing = [1, g_buttonSpace])
|
||||
cmds.button(label = 'Create Proxies', width = g_windowWidth-4, command = LumberyardCreateProxies, backgroundColor = g_UIColor)
|
||||
|
||||
def LumberyardCreateWidthTextField():
|
||||
##This function creates the ui element that defines the width and depth of the proxy
|
||||
|
||||
#get the width of the proxy from the class
|
||||
uiTextFieldProxyWidthValue = g_proxyShapeDefaultWidth
|
||||
|
||||
#create the ui text field
|
||||
proxyCreationSettings.uiTextFieldWidth = cmds.textField(width = g_uiProxyWidthColumnWidth , backgroundColor = g_UIColor, text = uiTextFieldProxyWidthValue)
|
||||
|
||||
#add a command that will add functionality when the textfield is changed
|
||||
cmds.textField(proxyCreationSettings.uiTextFieldWidth, edit = True, changeCommand = lambda *args: LumberyardChangeProxyWidth(cmds.textField(proxyCreationSettings.uiTextFieldWidth, query = True, text = True)))
|
||||
|
||||
LumberyardChangeProxyWidth(g_uiProxyWidthColumnWidth)
|
||||
|
||||
def LumberyardChangeProxyWidth(widthInput):
|
||||
##This function is run when the width text field is updated
|
||||
|
||||
#get current width
|
||||
currentWidth = proxyCreationSettings.width
|
||||
|
||||
#determine if this entry is a float
|
||||
if LumberyardFloatConfirm(widthInput) == True:
|
||||
|
||||
if float(widthInput) > 0:
|
||||
#if the entry is a float and greater than zero, update the class with the new width
|
||||
proxyCreationSettings.width = widthInput
|
||||
|
||||
else:
|
||||
#zero or negative floats are not a valid width value, so revert to previous value
|
||||
cmds.textField(proxyCreationSettings.uiTextFieldWidth, edit = True, text = currentWidth)
|
||||
|
||||
else:
|
||||
#if the entry is not a float, revert it to its previous value
|
||||
cmds.textField(proxyCreationSettings.uiTextFieldWidth, edit = True, text = currentWidth)
|
||||
|
||||
def LumberyardCreateOrientPullDown():
|
||||
##This function creates the ui pulldown for orientation
|
||||
|
||||
#create the ui pulldown
|
||||
orientOptionPullDown = cmds.optionMenu(label = '', width = g_uiShapePulldownColumnWidth, backgroundColor = g_UIColor, changeCommand = lambda *args: LumberyardProxySetOrientType())
|
||||
|
||||
#add it to the class
|
||||
proxyCreationSettings.menuDropDownOrient = orientOptionPullDown
|
||||
|
||||
#populate the pulldown with the predefined orient types
|
||||
for orient in g_orientTypes:
|
||||
cmds.menuItem('button_' + orient, label = orient)
|
||||
|
||||
LumberyardProxySetOrientType()
|
||||
|
||||
def LumberyardProxySetOrientType():
|
||||
##This function is launched when the orient value is changed in the editor
|
||||
|
||||
#get the new value from the menu
|
||||
orientString = (cmds.optionMenu(proxyCreationSettings.menuDropDownOrient, query = True, value = True))
|
||||
|
||||
#store the new value in the class
|
||||
proxyCreationSettings.objectOrient = orientString
|
||||
|
||||
def LumberyardCreateShapePullDown():
|
||||
##This function creates the ui pulldown for shape types in the editor
|
||||
|
||||
#create the ui pulldown
|
||||
shapeOptionPullDown = cmds.optionMenu(label = '', width = g_uiShapePulldownColumnWidth, backgroundColor = g_UIColor,changeCommand = lambda *args: LumberyardProxySetShapeType())
|
||||
|
||||
#add it to the class
|
||||
proxyCreationSettings.menuDropDownShape = shapeOptionPullDown
|
||||
|
||||
#populate the pulldown with the predefined shape types
|
||||
for shapeType in g_shapeTypes:
|
||||
cmds.menuItem('button_' + shapeType, label = shapeType)
|
||||
|
||||
LumberyardProxySetShapeType()
|
||||
|
||||
def LumberyardCreateMaterialPullDown():
|
||||
##This function creates the ui pulldown for material name
|
||||
|
||||
#create the ui pulldown
|
||||
materialOptionPullDown = cmds.optionMenu(label = '', width = g_uiMaterialFieldColumnWidth, backgroundColor = g_UIColor, changeCommand = lambda *args: LumberyardProxySetMaterialName())
|
||||
|
||||
#add it to the class
|
||||
proxyCreationSettings.menuDropDownMaterialName = materialOptionPullDown
|
||||
|
||||
#populate the pulldown with the predefined materialName types
|
||||
for materialName in g_materialNames :
|
||||
cmds.menuItem('button_' + materialName, label = materialName)
|
||||
|
||||
LumberyardProxySetMaterialName()
|
||||
|
||||
def LumberyardProxySetMaterialName():
|
||||
|
||||
materialNameString = (cmds.optionMenu(proxyCreationSettings.menuDropDownMaterialName, query = True, value = True))
|
||||
|
||||
proxyCreationSettings.proxyMaterialName = materialNameString
|
||||
|
||||
def LumberyardProxySetShapeType():
|
||||
##This function is launched when the shape value is changed in the editor
|
||||
|
||||
#get the new value from the menu
|
||||
shapeString = (cmds.optionMenu(proxyCreationSettings.menuDropDownShape, query = True, value = True))
|
||||
|
||||
#store the new value in the class
|
||||
proxyCreationSettings.shape = shapeString
|
||||
|
||||
def LumberyardAddMaterialToProxy(inputProxy):
|
||||
##This function adds a material to a proxy shape object
|
||||
|
||||
#get the material name from the class
|
||||
thisMaterialName = proxyCreationSettings.proxyMaterialName
|
||||
|
||||
#get the shading group
|
||||
shadingGroup = thisMaterialName + 'SG'
|
||||
|
||||
#variable that defines the shader
|
||||
shader = ''
|
||||
|
||||
#if the material does not exist, create a shader group that supports it
|
||||
if cmds.objExists(thisMaterialName) == False:
|
||||
shader = cmds.shadingNode('phong', asShader = True, name = thisMaterialName)
|
||||
#add attribute that will define this proxy material
|
||||
cmds.addAttr(shader, longName = 'lumberyardPhysMaterial', defaultValue = 1)
|
||||
shadingGroup = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = shadingGroup)
|
||||
cmds.connectAttr(shader +'.outColor', shadingGroup + '.surfaceShader')
|
||||
cmds.setAttr(shader + '.color', g_defaultMaterialColor[0], g_defaultMaterialColor[1], g_defaultMaterialColor[2], type = 'double3')
|
||||
else:
|
||||
shader = 'thisMaterialName'
|
||||
#apply the shading group to the proxy object
|
||||
cmds.sets(inputProxy[0], edit = True, forceElement = shadingGroup )
|
||||
|
||||
def CreateProxyPositionFromChildren(jointNode):
|
||||
#get the children. the joint's children define the length of the proxy
|
||||
jointChildren = cmds.listRelatives(jointNode, children = True, path = True, type = 'joint')
|
||||
|
||||
#get the joint node's position in world space
|
||||
jointStartPosition = cmds.xform(jointNode, query = True, worldSpace = True, translation = True)
|
||||
|
||||
#get the average joint position for all of the child joints this will determine the proxy's length
|
||||
sumOfJointPositionX = 0.0
|
||||
sumOfJointPositionY = 0.0
|
||||
sumOfJointPositionZ = 0.0
|
||||
proxyPositionX = jointStartPosition[0]
|
||||
proxyPositionY = jointStartPosition[1]
|
||||
proxyPositionZ = jointStartPosition[2]
|
||||
|
||||
#if a joint has children, find out the length of the average child joints
|
||||
if (jointChildren):
|
||||
for jointChild in jointChildren:
|
||||
jointPositionWorldSpace = cmds.xform( jointChild, query = True, worldSpace = True, translation = True)
|
||||
sumOfJointPositionX = sumOfJointPositionX + jointPositionWorldSpace[0]
|
||||
sumOfJointPositionY = sumOfJointPositionY + jointPositionWorldSpace[1]
|
||||
sumOfJointPositionZ = sumOfJointPositionZ + jointPositionWorldSpace[2]
|
||||
averageJointPositionX = sumOfJointPositionX / len(jointChildren)
|
||||
averageJointPositionY = sumOfJointPositionY / len(jointChildren)
|
||||
averageJointPositionZ = sumOfJointPositionZ / len(jointChildren)
|
||||
#move to the midpoint of joint and averaged child joints
|
||||
proxyPositionX = ((averageJointPositionX + jointStartPosition[0])/2)
|
||||
proxyPositionY = ((averageJointPositionY + jointStartPosition[1])/2)
|
||||
proxyPositionZ = ((averageJointPositionZ + jointStartPosition[2])/2)
|
||||
|
||||
proxyPosition = [proxyPositionX, proxyPositionY, proxyPositionZ]
|
||||
return proxyPosition
|
||||
|
||||
def LumberyardCreateProxies(*args):
|
||||
##This function creates the proxy objects and parents them to joints
|
||||
|
||||
#create display layers for proxy's visibility to easily be toggled
|
||||
LumberyardCreateProxyLayer()
|
||||
|
||||
#variable for the display layer
|
||||
layerPhys = g_nameOfDisplayLayer
|
||||
|
||||
#make a list of all of the selected objects
|
||||
selectedObjects = cmds.ls(selection = True)
|
||||
|
||||
#if nothing is selected throw a warning
|
||||
if (len(selectedObjects) == 0):
|
||||
cmds.warning('No joints selected. Select Joints and press the Add Joints button.')
|
||||
|
||||
else:
|
||||
for selectedObject in selectedObjects:
|
||||
|
||||
if cmds.objectType(selectedObject, isType = 'joint' ) == True:
|
||||
|
||||
shapeOfProxy = proxyCreationSettings.shape
|
||||
|
||||
#get the joint node's position in world space
|
||||
jointStartPosition = cmds.xform(selectedObject, query = True, worldSpace = True, translation = True)
|
||||
proxyPosition = jointStartPosition
|
||||
proxyWidth = float(proxyCreationSettings.width)
|
||||
proxyLength = proxyWidth
|
||||
|
||||
if (g_centerString in proxyCreationSettings.objectOrient) == False:
|
||||
|
||||
proxyPosition = CreateProxyPositionFromChildren(selectedObject)
|
||||
|
||||
#find out the length of the average child joints
|
||||
distanceBetweenPoints = math.sqrt(math.pow((jointStartPosition[0] - proxyPosition[0]), 2) + math.pow((jointStartPosition[1] - proxyPosition[1]) ,2) + math.pow((jointStartPosition[2] - proxyPosition[2]), 2))
|
||||
proxyLength = distanceBetweenPoints * 2
|
||||
|
||||
#create the proxy shape
|
||||
if (shapeOfProxy == g_shapeTypes[g_boxIndex]):
|
||||
proxyShape = cmds.polyCube(height = proxyLength, width = proxyWidth, depth = proxyWidth, createUVs = 1,constructionHistory = True)
|
||||
else:
|
||||
proxyRadius = proxyWidth/2
|
||||
if (shapeOfProxy == g_shapeTypes[g_capsuleIndex]):
|
||||
if (proxyLength > proxyWidth):
|
||||
proxyShape = cmds.polyCylinder(radius = proxyRadius, height = proxyLength - (proxyRadius *2), roundCap = True, subdivisionsCaps = 3)
|
||||
else:
|
||||
proxyShape = cmds.polySphere(radius = proxyRadius * 2, subdivisionsAxis = 16, subdivisionsHeight = 16)
|
||||
else:
|
||||
proxyShape = cmds.polySphere(radius = proxyRadius * 2, subdivisionsAxis = 16, subdivisionsHeight = 16)
|
||||
|
||||
#add object to the phys display layer
|
||||
cmds.editDisplayLayerMembers( layerPhys, proxyShape[0])
|
||||
|
||||
#add an attribute to easily find our created proxy
|
||||
cmds.addAttr(proxyShape, longName = 'lumberyardPhysProxy', defaultValue = 1)
|
||||
|
||||
#add material to proxy
|
||||
if (proxyCreationSettings.proxyMaterialName != 'no material'):
|
||||
|
||||
LumberyardAddMaterialToProxy(proxyShape)
|
||||
|
||||
#add orientation to proxy
|
||||
LumberyardOrientProxy(proxyShape[0])
|
||||
|
||||
#move proxy into place
|
||||
cmds.move(proxyPosition[0], proxyPosition[1], proxyPosition[2], proxyShape, worldSpace = True)
|
||||
|
||||
#orient the proxy so its aiming toward the parent joint. can we do this with vector math instead?
|
||||
aimConsProxy = cmds.aimConstraint(selectedObject, proxyShape)
|
||||
cmds.delete(aimConsProxy)
|
||||
orientConsProxy = cmds.orientConstraint(selectedObject, proxyShape, skip = 'none')
|
||||
cmds.delete(orientConsProxy)
|
||||
|
||||
#if the orient pulldown defines this as a center, center its orient on the joint.
|
||||
if (g_centerString in proxyCreationSettings.objectOrient):
|
||||
cmds.move(jointStartPosition[0], jointStartPosition[1],jointStartPosition[2], proxyShape[0], worldSpace = True)
|
||||
else:
|
||||
cmds.move(jointStartPosition[0], jointStartPosition[1], jointStartPosition[2], proxyShape[0] + ".scalePivot", proxyShape[0] + ".rotatePivot", worldSpace = True)
|
||||
|
||||
#parent it to the joint
|
||||
cmds.parent(proxyShape[0], selectedObject)
|
||||
|
||||
#freeze the proxy. this will zero out its translate values relative to its parent joint
|
||||
cmds.makeIdentity(proxyShape[0], apply = True, scale = 1, rotate = 1, translate = 1, normal = 0)
|
||||
|
||||
#delete construction history
|
||||
cmds.delete(proxyShape[0],constructionHistory=True)
|
||||
|
||||
#rename the proxy with the proper name
|
||||
cmds.rename(proxyShape[0], selectedObject + g_physPostfix)
|
||||
else:
|
||||
cmds.warning(selectedObject + " is not a joint. No proxy created.")
|
||||
|
||||
def LumberyardOrientProxy(proxyObjectInput):
|
||||
##This function orients the proxy based on the settings in the editor ui
|
||||
|
||||
if proxyCreationSettings.objectOrient == g_orientTypes[g_xIndex] or proxyCreationSettings.objectOrient == g_orientTypes[g_xCenterIndex]:
|
||||
cmds.xform(proxyObjectInput, rotateAxis = [0, 90, 90])
|
||||
|
||||
if proxyCreationSettings.objectOrient == g_orientTypes[g_yIndex] or proxyCreationSettings.objectOrient == g_orientTypes[g_yCenterIndex]:
|
||||
cmds.xform(proxyObjectInput, rotateAxis = [0, 0, 0])
|
||||
|
||||
if proxyCreationSettings.objectOrient == g_orientTypes[g_zIndex] or proxyCreationSettings.objectOrient == g_orientTypes[g_zCenterIndex]:
|
||||
cmds.xform(proxyObjectInput, rotateAxis = [90, 0, 0])
|
||||
|
||||
def LumberyardCreateProxyLayer():
|
||||
##This function creates a layer for our proxy objects so visibility may be easily toggled
|
||||
#if there is not already a display layer for the proxies, create one
|
||||
if cmds.objExists(g_nameOfDisplayLayer) == False:
|
||||
cmds.createDisplayLayer(name = g_nameOfDisplayLayer)
|
||||
|
||||
def LumberyardFloatConfirm(inputString):
|
||||
##This function checks to see if the entered string is a float value and returns true or false
|
||||
try:
|
||||
float(inputString)
|
||||
except ValueError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LYExport.mel
|
||||
//
|
||||
// UI code for improved Maya exporter
|
||||
//
|
||||
// Description: this file contains code for creating the new improved Maya exporter (called
|
||||
// as "Lumberyard Tools" with primarily the UI change, plus some underlying functional change),
|
||||
// reference link: https://wiki.labcollab.net/confluence/display/lmbr/Improved+Maya+Exporter
|
||||
// The new Maya exporter consolidates the massive windows existed in the original CryTek
|
||||
// exporter into a unified one. It will improve the efficiency of artist workflow of
|
||||
// exporting asserts from Maya. This file is still under development in parallel with the
|
||||
// CryTek exporter (allow co-exist), and will eventually replace the current CryTek exporter as a
|
||||
// last step.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LumberyardToolLoadDependencies();
|
||||
|
||||
//! Load dependencies for using their global functions
|
||||
/*!
|
||||
\todo Add LumberyardValidator to script dependencies if it is added to the window controls
|
||||
*/
|
||||
global proc LumberyardToolLoadDependencies()
|
||||
{
|
||||
eval("source cryValidate.mel");
|
||||
eval("source cryAnim.mel");
|
||||
eval("source cryMaterial.mel");
|
||||
eval("source cryExport.mel");
|
||||
eval("source cryTools.mel");
|
||||
eval("source cryUDP.mel");
|
||||
eval("source degraded_faces_check.mel");
|
||||
eval("source cryPivot.mel");
|
||||
eval("source cryAlembic.mel");
|
||||
if( !`cryPluginIsLoaded` )
|
||||
{
|
||||
cryLoadPluginQuiet;
|
||||
}
|
||||
|
||||
eval("source LumberyardUIStyle.mel");
|
||||
eval("source LumberyardUtilities.mel");
|
||||
eval("source LumberyardAnimationPane.mel");
|
||||
eval("source LumberyardGeometry.mel");
|
||||
eval("source LumberyardMaterial.mel");
|
||||
//eval("source LumberyardValidator.mel");
|
||||
}
|
||||
|
||||
//! Utility function to call cryPivotRun function with the correct parameters
|
||||
global proc LumberyardToolOriginToPivot()
|
||||
{
|
||||
int $centerPivots = `menuItem -query -checkBox LUMBERYARD_CENTER_PIVOTS_CHECKBOX`;
|
||||
cryPivotRun($centerPivots);
|
||||
}
|
||||
|
||||
//! Creates the top menu bar for the Lumberyard Tools window
|
||||
/*!
|
||||
\param $versionString The version of the plugin mll (used in the Help toolbar menu to display version number)
|
||||
\todo
|
||||
Determine whether Output Attachment Helpers functionality is still valid,
|
||||
and reactivate if it is.
|
||||
*/
|
||||
proc LumberyardToolCreateToolMenuBar(string $versionString)
|
||||
{
|
||||
menuBarLayout;
|
||||
// Tools Menu
|
||||
string $toolsMenu = `menu -label "Tools" LUMBERYARD_TOOLS_MENU`;
|
||||
|
||||
// temporarily remove Auto Add Geometry related to LMBR-13573
|
||||
/*
|
||||
menuItem -label "Auto Add Geometry" -subMenu true;
|
||||
{
|
||||
menuItem -label "Execute" -enable true -command ("LumberyardAutoAddAll");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Include materials" -checkBox true -enable true autoAddMaterialsCheckbox;
|
||||
setParent -menu $toolsMenu;
|
||||
}
|
||||
menuItem -divider true;
|
||||
*/
|
||||
menuItem -label "Add Scene Root" -command ("LumberyardUtilitiesAddSceneRoot");
|
||||
menuItem -label "Move Origin to Pivot" -subMenu true;
|
||||
{
|
||||
menuItem -label "Execute" -command ("LumberyardToolOriginToPivot");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Center Pivots" -checkBox false LUMBERYARD_CENTER_PIVOTS_CHECKBOX;
|
||||
setParent -menu $toolsMenu;
|
||||
}
|
||||
menuItem -label "Zero Joint Rotations" -command ("cryAnimZeroJointRotation");
|
||||
//menuItem -label "Output Attachment Helpers" -command ("cryOutputAttachmentHelpers");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Add Attributes" -command ("cryExportAddAttributes");
|
||||
menuItem -label "User Defined Properties..." -command ("cryUDPWindow");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Polygon Check" -command ("cryCheckFaces");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Prepare Alembic materials" -command ("cryAlembic_prepareMaterials");
|
||||
menuItem -label "Export Selected to Alembic..." -command ("cryAlembic_export");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Joint Proxy Editor (Experimental)..." -command ("LumberyardStartJointProxyEditor");
|
||||
menuItem -divider true;
|
||||
menuItem -label "Validator..." -command ("cryValidateComplete");
|
||||
|
||||
// Options Menu
|
||||
menu -label "Options";
|
||||
menuItem -label "Remove Name Spaces" -checkBox false -enable true
|
||||
-command ("LumberyardToolSetRemoveNamespaces") LUMBERYARD_REMOVE_NAMESPACES_CHECKBOX;
|
||||
|
||||
// Help Menu
|
||||
menu -label "Help" -helpMenu true;
|
||||
menuItem -label "Online Documentation" -enable true
|
||||
-command ("LumberyardToolSetOpenHelp");
|
||||
|
||||
LumberyardToolLoadMenuCheckBoxValues;
|
||||
setParent ..;
|
||||
|
||||
scriptJob -event "NewSceneOpened" "LumberyardToolHandleSceneChange" -parent "LUMBERYARDTOOL_MAIN_LAYOUT";
|
||||
scriptJob -event "PostSceneRead" "LumberyardToolHandleSceneChange" -parent "LUMBERYARDTOOL_MAIN_LAYOUT";
|
||||
|
||||
}
|
||||
|
||||
//! Utility function to call LumberyardAutoDetectGeometry with the correct parameters
|
||||
global proc LumberyardAutoAddAll()
|
||||
{
|
||||
int $includeMaterial = `menuItem -query -checkBox autoAddMaterialsCheckbox`;
|
||||
LumberyardAutoDetectGeometry $includeMaterial;
|
||||
}
|
||||
|
||||
global proc LumberyardStartJointProxyEditor()
|
||||
{
|
||||
//reload() call is used during development so that the python gets recompiled each time it is opened
|
||||
python ("import LumberyardProxyTool; reload(LumberyardProxyTool); LumberyardProxyTool.LumberyardProxyTool()");
|
||||
}
|
||||
|
||||
//! Update Remove Namespaces option value in back-end data with checkBox value.
|
||||
global proc LumberyardToolSetRemoveNamespaces()
|
||||
{
|
||||
int $removeNamespaces = `menuItem -query -checkBox LUMBERYARD_REMOVE_NAMESPACES_CHECKBOX`;
|
||||
cryExportSetExportSettingValue "removeNamespaces" $removeNamespaces;
|
||||
}
|
||||
|
||||
//! Open up the online documentation website at the maya tools section
|
||||
global proc LumberyardToolSetOpenHelp()
|
||||
{
|
||||
launch -webPage "https://docs.aws.amazon.com/console/lumberyard/userguide/lumberyard-maya-tools";
|
||||
}
|
||||
|
||||
//! Find old style export settings node and show dialog to confirm upgrade.
|
||||
global proc int LumberyardToolFindAndUpgradeOldStyleExportSettingsNode()
|
||||
{
|
||||
if (`objExists CRYEXPORTSETTINGS`)
|
||||
{
|
||||
string $dialogMessage = "Detected old export SETTINGS data. Do you wish to upgrade " +
|
||||
"to the new tool format? (This operation will remove old data)";
|
||||
if(`confirmDialog -title "Lumberyard Exporter" -message $dialogMessage
|
||||
-button "Yes" -button "No" -defaultButton "Yes"
|
||||
-cancelButton "No" -dismissString "No"` == "No")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string $exportSettingsNode = LumberyardGetExportSettingNodeName();
|
||||
//there is potential for the new settings node to be generated first by other event handlers
|
||||
//before this code is run to update so delete the new one.
|
||||
//If the CRYEXPORTSETTINGS is there then the newly generated settings has no information in it
|
||||
if (`objExists $exportSettingsNode`)
|
||||
{
|
||||
delete $exportSettingsNode;
|
||||
}
|
||||
if( !`objExists LUMBERYARD_EXPORT_GROUP` )
|
||||
{
|
||||
// Create LUMBERYARD_EXPORT_GROUP
|
||||
group -empty -name LUMBERYARD_EXPORT_GROUP;
|
||||
}
|
||||
rename CRYEXPORTSETTINGS $exportSettingsNode;
|
||||
parent ($exportSettingsNode, "LUMBERYARD_EXPORT_GROUP");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Find old style export settings node and show dialog to confirm upgrade.
|
||||
global proc int LumberyardToolFindAndUpgradeOldStyleExportAnimationNode()
|
||||
{
|
||||
if (`objExists "LUMBERYARD_ANIMATIONEXPORT_GROUP"` )
|
||||
{
|
||||
string $parents[] = `listRelatives -parent "LUMBERYARD_ANIMATIONEXPORT_GROUP"`;
|
||||
if (!stringArrayContains("LUMBERYARD_EXPORT_GROUP", $parents))
|
||||
{
|
||||
string $dialogMessage = "Detected old export Animation data. Do you wish to upgrade " +
|
||||
"to the new tool format? (This operation will move LUMBERYARD_ANIMATIONEXPORT_GROUP under LUMBERYARD_EXPORT_GROUP)";
|
||||
if(`confirmDialog -title "Lumberyard Exporter" -message $dialogMessage
|
||||
-button "Yes" -button "No" -defaultButton "Yes"
|
||||
-cancelButton "No" -dismissString "No"` == "No")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !`objExists "LUMBERYARD_EXPORT_GROUP"` )
|
||||
{
|
||||
//Create LUMBERYARD_EXPORT_GROUP
|
||||
group -empty -name "LUMBERYARD_EXPORT_GROUP";
|
||||
}
|
||||
|
||||
parent ("LUMBERYARD_ANIMATIONEXPORT_GROUP", "LUMBERYARD_EXPORT_GROUP");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
global proc LumberyardToolHandleSceneChange()
|
||||
{
|
||||
if (!LumberyardToolFindAndUpgradeOldStyleExportSettingsNode())
|
||||
{
|
||||
// Close Lumberyard tools window if user choose not to upgrade.
|
||||
if( `window -exists LUMBERYARDTOOL_MAIN_WINDOW` )
|
||||
{
|
||||
deleteUI LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LumberyardToolFindAndUpgradeOldStyleExportAnimationNode())
|
||||
{
|
||||
// Close Lumberyard tools window if user choose not to upgrade.
|
||||
if( `window -exists LUMBERYARDTOOL_MAIN_WINDOW` )
|
||||
{
|
||||
deleteUI LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
}
|
||||
return;
|
||||
}
|
||||
LumberyardToolLoadMenuCheckBoxValues();
|
||||
}
|
||||
|
||||
//! Update the menu checkBox values with saved back-end data.
|
||||
global proc LumberyardToolLoadMenuCheckBoxValues()
|
||||
{
|
||||
if (`cryExportGetExportSettingValue "removeNamespaces"` == "")
|
||||
{
|
||||
cryExportSetExportSettingValue "removeNamespaces" 1;
|
||||
}
|
||||
int $removeNamespaces = `LumberyardGetIntExportSetting "removeNamespaces"`;
|
||||
menuItem -edit -checkBox $removeNamespaces LUMBERYARD_REMOVE_NAMESPACES_CHECKBOX;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Lumberyard Tool Main Window
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Utility function to call the export function for all asset types, ignoring warnings
|
||||
global proc LumberyardToolExportAll()
|
||||
{
|
||||
LumberyardToolExportCheckedGeometryListItems(0);
|
||||
LumberyardToolExportCheckedMaterialGroups(0);
|
||||
LumberyardUtilitiesExportSelectedAnimations(0);
|
||||
}
|
||||
|
||||
//! Resize Lumberyard Tool window with a height change
|
||||
/*!
|
||||
\param $heightDiff The difference of window height for change
|
||||
*/
|
||||
global proc LumberyardToolResizeWindow(int $heightDiff)
|
||||
{
|
||||
int $height = `window -query -height LUMBERYARDTOOL_MAIN_WINDOW` + $heightDiff;
|
||||
window -edit -height $height LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
}
|
||||
|
||||
//! Creates the main UI window for the Lumberyard Tools and call creation for all sub-elements
|
||||
/*!
|
||||
\todo Add validator UI to the main window once it has been hooked to the validation output
|
||||
*/
|
||||
proc LumberyardToolCreateWindow()
|
||||
{
|
||||
global float $g_UIColor[];
|
||||
if (!LumberyardToolFindAndUpgradeOldStyleExportSettingsNode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LumberyardToolFindAndUpgradeOldStyleExportAnimationNode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int $windowExists = `window -exists LUMBERYARDTOOL_MAIN_WINDOW`;
|
||||
if(!$windowExists)
|
||||
{
|
||||
if (!`LumberyardToolAttemptDataUpdates`)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(`windowPref -exists LUMBERYARDTOOL_MAIN_WINDOW`)
|
||||
{
|
||||
windowPref -topLeftCorner `windowPref -query -topEdge LUMBERYARDTOOL_MAIN_WINDOW` `windowPref -query -leftEdge LUMBERYARDTOOL_MAIN_WINDOW` LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
}
|
||||
print("\nGetting plugin info...\n");
|
||||
string $pluginName = `cryGetPluginName`;
|
||||
print("PluginName: " + $pluginName + "\n");
|
||||
string $pluginVersionString = `pluginInfo -query -version $pluginName`;
|
||||
print("PluginVersion: " + $pluginVersionString + "\n");
|
||||
window -titleBar true -title "Lumberyard Tools" -sizeable true -minimizeButton false -maximizeButton false LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
$collayout = `columnLayout -adjustableColumn true -rowSpacing 15 LUMBERYARDTOOL_MAIN_LAYOUT`;
|
||||
|
||||
LumberyardToolCreateToolMenuBar($pluginVersionString);
|
||||
|
||||
LumberyardToolCreateGeometryFrame;
|
||||
|
||||
LumberyardToolCreateMaterialFrame;
|
||||
|
||||
LumberyardAnimationPaneCreate;
|
||||
|
||||
setParent LUMBERYARDTOOL_MAIN_LAYOUT;
|
||||
button -height 44 -label "Export All" -backgroundColor $g_UIColor[0] $g_UIColor[1] $g_UIColor[2]
|
||||
-command ("LumberyardToolExportAll");
|
||||
|
||||
//LumberyardToolCreateValidatorFrame;
|
||||
}
|
||||
showWindow LUMBERYARDTOOL_MAIN_WINDOW;
|
||||
|
||||
if(!$windowExists)
|
||||
{
|
||||
// Collapsing Advance Options has to go after the window is shown, otherwise the
|
||||
// interpreted current window size to based on will not be correct.
|
||||
LumberyardGeometryCollapseAdvanceOptionsFrame;
|
||||
LumberyardMaterialCollapseAdvanceOptionsFrame;
|
||||
}
|
||||
}
|
||||
|
||||
//! Load maya plugin (.mll) file and create the main window of Lumberyard Tools if plugin loads successfully
|
||||
global proc LumberyardToolWindow()
|
||||
{
|
||||
string $pluginName = `cryGetPluginName`;
|
||||
if( catchQuiet( `pluginInfo -query -version $pluginName` ))
|
||||
{
|
||||
error("Plugin `" + $pluginName + "` could not be found.");
|
||||
}
|
||||
|
||||
LumberyardToolLoadGeometryExportNodes;
|
||||
|
||||
if( !`LumberyardToolFindAndUpgradeOldStyleExportNodes` )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( !`LumberyardUtilitiesUpgradeAnimationData` )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LumberyardToolCreateWindow();
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UI property values
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
global int $g_boxWidth = 400; // width of display box (list box, tree view)
|
||||
global int $g_rowItemHeight = 22; // row height of items in display box
|
||||
global int $g_buttonSpace = 4; // space width between two buttons
|
||||
|
||||
global float $g_UIColor[]; // color for UI buttons/option menus
|
||||
global float $g_highLightColor[]; // highlight color of items in display box
|
||||
|
||||
global string $g_warningIconName = "icons/lumberyard_warning.svg";
|
||||
|
||||
global string $g_defaultPathString = "<default>";
|
||||
|
||||
global int $g_geometryHeightDiff = 320; // the height difference of geometry frame between collapse and expand
|
||||
global int $g_advanceOptionHeightDiff = 88; // the height difference of advance option frame between collapse and expand
|
||||
global int $g_materialAdvanceOptionHeightDiff = 42; // the height difference of material advance option frame between collapse and expand
|
||||
global int $g_materialHeightDiff = 354; // the height difference of material frame between collapse and expand
|
||||
global int $g_animationHeightDiff = 180; // the height difference of animation frame between collapse and expand
|
||||
global int $g_instructionRowSpace = 10;
|
||||
|
||||
//values for Geometry List display
|
||||
global int $g_checkColumnWidth = 22;
|
||||
global int $g_nodeNameColumnWidth = 115;
|
||||
global int $g_exportNameColumnWidth = 110;
|
||||
global int $g_exportTypeColumnWidth = 110;
|
||||
global int $g_deleteExportColumnWidth = 15;
|
||||
global int $g_listHeaderHeight = 18;
|
||||
|
||||
LumberyardCalculateUIValues();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Create UI related values
|
||||
global proc LumberyardCalculateUIValues()
|
||||
{
|
||||
global float $g_UIColor[];
|
||||
global float $g_UIInvalidColor[];
|
||||
global float $g_highLightColor[];
|
||||
|
||||
$g_UIColor = {0.165, 0.165, 0.165};
|
||||
$g_UIInvalidColor = {0.89, 0.49, 0.49};
|
||||
$g_highLightColor = {0.11, 0.46, 0.81};
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Common Utility functions for the Lumberyard Tool
|
||||
|
||||
LumberyardUtilitiesLoadDependencies();
|
||||
|
||||
//! Loads the script files that this script is dependent upon
|
||||
global proc LumberyardUtilitiesLoadDependencies()
|
||||
{
|
||||
eval("source LumberyardUIStyle.mel");
|
||||
}
|
||||
|
||||
//! Reset the file path textField to default value.
|
||||
/*!
|
||||
\param $controlName The name of the textFiled to reset value.
|
||||
*/
|
||||
global proc LumberyardUtilitiesSetTextToDefaultPath(string $controlName)
|
||||
{
|
||||
global string $g_defaultPathString;
|
||||
textField -edit -text $g_defaultPathString $controlName;
|
||||
}
|
||||
|
||||
//! Utility script to reverse the order of the strings contained in an array
|
||||
/*!
|
||||
\param $array The array of strings to reverse
|
||||
*/
|
||||
global proc string[] LumberyardUtilitiesReverseStringArray(string $array[])
|
||||
{
|
||||
string $reverseArray[];
|
||||
|
||||
if(size($array) > 0)
|
||||
{
|
||||
int $newCount = 0;
|
||||
|
||||
for($i = size($array) - 1; $i >= 0; $i--)
|
||||
{
|
||||
$reverseArray[$newCount] = $array[$i];
|
||||
$newCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return $reverseArray;
|
||||
}
|
||||
|
||||
//! Adds a SceneRoot entity as a curve displaying the axes
|
||||
global proc LumberyardUtilitiesAddSceneRoot()
|
||||
{
|
||||
if(!`objExists "SceneRoot"`)
|
||||
{
|
||||
string $sceneRootCurve = `curve -degree 1
|
||||
-point 1 0 0 -point 1.049582 0 0.000590718 -point 1.010888 0 0.0685401 -point 1.033656 0 0.0685401
|
||||
-point 1.067513 0 0.0178139 -point 1.10137 0 0.0685401 -point 1.124137 0 0.0685401
|
||||
-point 1.085562 0 0.000590718 -point 1.124255 0 -0.0673587 -point 1.101487 0 -0.0673587
|
||||
-point 1.067631 0 -0.0165146 -point 1.033656 0 -0.0673587 -point 1.010888 0 -0.0673587
|
||||
-point 1.049582 0 0.000590718 -point 1 0 0 -point 0.75 0 -0.25 -point 0.75 0 -0.125 -point 0 0 -0.125
|
||||
-point -0.125 0 0 -point -0.125 0 0.125 -point -0.125 0 0.75 -point -0.25 0 0.75 -point 0 0 1
|
||||
-point 0.000344241 0 1.03654 -point -0.0436663 0 0.99124 -point -0.0723325 0 0.99124
|
||||
-point -0.0723325 0 1.104489 -point -0.0496827 0 1.104489 -point -0.0496827 0 1.015423
|
||||
-point 0.0370236 0 1.104489 -point 0.0635663 0 1.104489 -point 0.0635663 0 0.99879
|
||||
-point 0.0409165 0 0.99879 -point 0.0409165 0 1.0783 -point 0.000344241 0 1.03654 -point 0 0 1
|
||||
-point 0.25 0 0.75 -point 0.125 0 0.75 -point 0.125 0 0.125 -point 0.125 0 0 -point 0.125 0.75 0
|
||||
-point 0.25 0.75 0 -point 0 1 0 -point -0.000470898 1.056641 0 -point 0.0774559 1.005923 0
|
||||
-point 0.0774559 1.026439 0 -point 0.012561 1.065182 0 -point 0.0774559 1.107272 0
|
||||
-point 0.0774559 1.124266 0 -point -0.000470898 1.073547 0 -point -0.0577933 1.073547 0
|
||||
-point -0.0577933 1.056641 0 -point -0.000470898 1.056641 0 -point 0 1 0 -point -0.25 0.75 0
|
||||
-point -0.125 0.75 0 -point -0.125 0 0 -point -0.125 0 0.75 -point -0.25 0 0.75 -point 0 0 1
|
||||
-point 0.25 0 0.75 -point 0.125 0 0.75 -point 0.125 0 0.125 -point 0.75 0 0.125 -point 0.75 0 0.25
|
||||
-point 1 0 0
|
||||
-knot 0 -knot 1 -knot 2 -knot 3 -knot 4 -knot 5 -knot 6 -knot 7 -knot 8 -knot 9 -knot 10 -knot 11 -knot 12 -knot 13 -knot 14
|
||||
-knot 15 -knot 16 -knot 17 -knot 18 -knot 19 -knot 20 -knot 21 -knot 22 -knot 23 -knot 24 -knot 25 -knot 26 -knot 27
|
||||
-knot 28 -knot 29 -knot 30 -knot 31 -knot 32 -knot 33 -knot 34 -knot 35 -knot 36 -knot 37 -knot 38 -knot 39 -knot 40
|
||||
-knot 41 -knot 42 -knot 43 -knot 44 -knot 45 -knot 46 -knot 47 -knot 48 -knot 49 -knot 50 -knot 51 -knot 52 -knot 53
|
||||
-knot 54 -knot 55 -knot 56 -knot 57 -knot 58 -knot 59 -knot 60 -knot 61 -knot 62 -knot 63 -knot 64 -knot 65
|
||||
-name "SceneRoot"`;
|
||||
|
||||
rotate -90 180 0 $sceneRootCurve;
|
||||
}
|
||||
}
|
||||
|
||||
//! Fetches an export setting of integer or boolean type
|
||||
/*!
|
||||
\param $settingName The name of the setting to fetch the value of
|
||||
*/
|
||||
global proc int LumberyardGetIntExportSetting(string $settingName)
|
||||
{
|
||||
string $settingValue = `cryExportGetExportSettingValue $settingName`;
|
||||
if ($settingValue == "")
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return $settingValue;
|
||||
}
|
||||
|
||||
//! Helper function to do path fixup and open a file browser
|
||||
/*!
|
||||
\param $startingFolder The folder to open the file browser at (relative paths will use scene file as basis)
|
||||
\param $caption The caption to display on the file browser window
|
||||
*/
|
||||
global proc string[] LumberyardBrowseForPath(string $startingFolder, string $caption)
|
||||
{
|
||||
// Convert to absolute path expected by fileDialog2
|
||||
string $returnPath[];
|
||||
$startingFolder = `cryExportRelativeToAbsolutePath $startingFolder`;
|
||||
string $result[] = `fileDialog2 -fileMode 3 -startingDirectory $startingFolder -caption $caption
|
||||
-fileFilter ("Directories only (*)")`;
|
||||
if (size($result) == 1)
|
||||
{
|
||||
// Convert back to relative path
|
||||
$returnPath[0] = `cryExportFixupPath $result[0]`;
|
||||
}
|
||||
|
||||
return $returnPath;
|
||||
}
|
||||
|
||||
//! Verify if requested name is valid and return a proper name for the scene object.
|
||||
/*
|
||||
\param $requestedName The desired name of the object.
|
||||
\param $currentName The current name of the object.
|
||||
\param $prefix The prefix that will need to add to the requested name when verify its uniqueness in scene.
|
||||
*/
|
||||
global proc string LumberyardVerifySceneObjectRequestNameWithPrefix(string $requestedName, string $currentName, string $prefix)
|
||||
{
|
||||
if ($requestedName == "" || $requestedName == $currentName)
|
||||
{
|
||||
return $currentName;
|
||||
}
|
||||
|
||||
string $firstLetter = `substring $requestedName 1 1`;
|
||||
string $letterMatch = `match "[A-Z;a-z]" $firstLetter`;
|
||||
if ($letterMatch == "")
|
||||
{
|
||||
return $currentName;
|
||||
}
|
||||
|
||||
string $uniqueName = $requestedName;
|
||||
int $i = 1;
|
||||
while (`objExists ($prefix + $uniqueName)`)
|
||||
{
|
||||
$uniqueName = $requestedName + $i;
|
||||
$i++;
|
||||
}
|
||||
return $uniqueName;
|
||||
}
|
||||
|
||||
//! Verify if requested name is valid and return a proper name for the scene object.
|
||||
/*
|
||||
\param $requestedName The desired name of the object.
|
||||
\param $currentName The current name of the object.
|
||||
*/
|
||||
global proc string LumberyardVerifySceneObjectRequestName(string $requestedName, string $currentName)
|
||||
{
|
||||
return `LumberyardVerifySceneObjectRequestNameWithPrefix $requestedName $currentName ""`;
|
||||
}
|
||||
|
||||
//! Provide the name of the export settings node from a unified source
|
||||
global proc string LumberyardGetExportSettingNodeName()
|
||||
{
|
||||
return "LUMBERYARD_EXPORT_SETTINGS";
|
||||
}
|
||||
|
||||
//! Provide the name of the export settings node from a unified source
|
||||
global proc string LumberyardGetExportNodeNamePrefix()
|
||||
{
|
||||
return "LumberyardExportNode_";
|
||||
}
|
||||
|
||||
//! Provide the name of the export settings node from a unified source
|
||||
global proc string LumberyardGetOldExportNodeNamePrefix()
|
||||
{
|
||||
return "cryExportNode_";
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Validator
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Create a row in the validator list box
|
||||
global proc LumberyardValidatorCreateRow(int $messageType, int $enableFocus, string $messageText)
|
||||
{
|
||||
setParent LUMBERYARDTOOL_VALIDATOR_LISTBOX;
|
||||
rowLayout -numberOfColumns 2 -columnWidth2 240 15 -rowAttach 2 "bottom" 0;
|
||||
{
|
||||
string $text = `text -wordWrap true -backgroundColor .95 .85 .65 -width 240 -align "left"
|
||||
-label $messageText`;
|
||||
string $button = `button -label "<>" -width 15 -backgroundColor 0.5 0.5 0.5
|
||||
-command ("print \"Focus works!\"")`;
|
||||
|
||||
// warning type
|
||||
if ($messageType == 0)
|
||||
{
|
||||
text -edit -backgroundColor .95 .85 .65 $text;
|
||||
}
|
||||
// error type
|
||||
else
|
||||
{
|
||||
text -edit -backgroundColor .95 .65 .65 $text;
|
||||
}
|
||||
|
||||
if ($enableFocus)
|
||||
{
|
||||
button -edit -enable true $button;
|
||||
}
|
||||
else
|
||||
{
|
||||
button -edit -enable false $button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Run the validator to get problem messages
|
||||
global proc LumberyardValidatorValidate()
|
||||
{
|
||||
string $childItems[] = `scrollLayout -query -childArray LUMBERYARDTOOL_VALIDATOR_LISTBOX`;
|
||||
for ($child in $childItems)
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
// give example messages
|
||||
LumberyardValidatorCreateRow 0 0 "This is a warning example. This is a warning example. This is a warning example. This is a warning example.";
|
||||
LumberyardValidatorCreateRow 1 1 "This is an error example. This is an error example. This is an error example. This is an error example.";
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Create validator frame
|
||||
global proc LumberyardToolCreateValidatorFrame()
|
||||
{
|
||||
setParent LUMBERYARDTOOL_MAIN_LAYOUT;
|
||||
frameLayout -collapsable false -borderStyle "etchedOut" -marginHeight 5 -marginWidth 5
|
||||
-label "Validator" LUMBERYARDTOOL_VALIDATOR_FRAME;
|
||||
{
|
||||
columnLayout -adjustableColumn true LUMBERYARDTOOL_VALIDATOR_LAYOUT;
|
||||
{
|
||||
scrollLayout -height 120 -backgroundColor 0 0 0 -visible true LUMBERYARDTOOL_VALIDATOR_LISTBOX;
|
||||
}
|
||||
setParent LUMBERYARDTOOL_VALIDATOR_FRAME;
|
||||
button -label "Validate" -command ("LumberyardValidatorValidate") LUMBERYARDTOOL_VALIDATE_BUTTON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Script to control the options for the Maya Cry Exporter.
|
||||
*/
|
||||
|
||||
global proc int MayaCryExportOpts(string $parent,string $action,string $initialSettings,string $resultCallback )
|
||||
{
|
||||
int $bResult = 0;
|
||||
if($action == "post")
|
||||
{
|
||||
////////////////////////////////////
|
||||
// Create the controls
|
||||
setParent $parent;
|
||||
|
||||
setUITemplate -pushTemplate DefaultTemplate;
|
||||
|
||||
formLayout -e -visible false optionsBoxForm;
|
||||
{
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
////////////////////////////////////
|
||||
// Now set to current settings.
|
||||
|
||||
formLayout -e -visible true optionsBoxForm;
|
||||
|
||||
setUITemplate -popTemplate;
|
||||
|
||||
$bResult = 1;
|
||||
}
|
||||
else if ($action == "query")
|
||||
{
|
||||
/////////////////////////////////////
|
||||
// Build the command string
|
||||
$currentOptions = "";
|
||||
print( "Options: " + $currentOptions + "\n" );
|
||||
|
||||
eval($resultCallback+" \""+$currentOptions+"\"");
|
||||
|
||||
$bResult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bResult = 0;
|
||||
}
|
||||
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
// "Prepare Materials for Alembic Export"
|
||||
// "import cryAlembic\ncryAlembic.renameShadingEngines()\ncryAlembic.enforcePerFaceAssignment()"
|
||||
//
|
||||
// "Export Alembic for Lumberyard"
|
||||
// "from maya import cmds\nimport cryAlembic\n\ncryAlembic.exportAlembicForGeomCache(cmds.ls(sl = 1))"
|
||||
|
||||
proc preparePyEnv()
|
||||
{
|
||||
string $pycmd = "try:\n" +
|
||||
" import cryAlembic\n" +
|
||||
"except:\n" +
|
||||
" import sys\n" +
|
||||
" print('could not import cry maya tools! trying to setup environment...')\n" +
|
||||
" paths = [p for p in os.environ['MAYA_SCRIPT_PATH'].split(';') if p.lower().endswith('/tools/melscript')]\n" +
|
||||
" crypath = ''\n" +
|
||||
" for p in paths:\n" +
|
||||
" if os.path.exists('%s/%s' % (p, 'cryAlembic.py')):\n" +
|
||||
" print('found \"/Tools/melScript\" path')\n" +
|
||||
" crypath = p\n" +
|
||||
" break\n" +
|
||||
" if crypath not in [p.replace('\\\\','/').lower() for p in sys.path]:\n" +
|
||||
" sys.path.append(crypath)\n" +
|
||||
" print('added \"/Tools/melScript\" path to py paths')\n";
|
||||
python($pycmd);
|
||||
}
|
||||
|
||||
global proc cryAlembic_prepareMaterials()
|
||||
{
|
||||
preparePyEnv();
|
||||
python("import cryAlembic\ncryAlembic.renameShadingEngines()\ncryAlembic.enforcePerFaceAssignment()");
|
||||
}
|
||||
|
||||
global proc cryAlembic_export()
|
||||
{
|
||||
preparePyEnv();
|
||||
python("import cryAlembic\ncryAlembic.exportAlembicForGeomCache()");
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
from maya import cmds
|
||||
from time import time
|
||||
import cryDecorators
|
||||
import sys
|
||||
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger(__name__)
|
||||
#log.setLevel(logging.DEBUG)
|
||||
|
||||
standardSGs = set(['initialParticleSE', 'initialShadingGroup'])
|
||||
|
||||
|
||||
def renameShadingEngines(lstShadingEngines=None):
|
||||
'''
|
||||
Renames ShadingEngines, to match their material's name.
|
||||
This is required, because maya exports FaceSets from ShadingEngines
|
||||
and GeomCaches derives material IDs from FaceSets.
|
||||
'''
|
||||
|
||||
if not lstShadingEngines:
|
||||
lstShadingEngines = cmds.ls(type="shadingEngine")
|
||||
elif isinstance(lstShadingEngines, basestring):
|
||||
lstShadingEngines = [lstShadingEngines]
|
||||
|
||||
# can't rename standard shading engines
|
||||
lstShadingEngines = list(set(lstShadingEngines) - standardSGs)
|
||||
|
||||
if not lstShadingEngines:
|
||||
return []
|
||||
|
||||
log.info("Renaming ShadingEngines...")
|
||||
log.debug(" %s" % ', '.join(lstShadingEngines))
|
||||
|
||||
for i in range(len(lstShadingEngines)):
|
||||
lstMaterials = cmds.listConnections("%s.surfaceShader" % lstShadingEngines[i], d=False, s=True, p=False)
|
||||
if lstMaterials:
|
||||
log.debug(" Materials: %s" % ', '.join(lstMaterials))
|
||||
dgMaterial = lstMaterials[0]
|
||||
destName = "%sSG" % dgMaterial
|
||||
if lstShadingEngines[i] == destName:
|
||||
continue
|
||||
|
||||
log.debug("Renaming " + lstShadingEngines[i] + " to " + destName + " ...")
|
||||
try:
|
||||
lstShadingEngines[i] = cmds.rename(lstShadingEngines[i], destName)
|
||||
print('lstShadingEngines[i]: %s' % lstShadingEngines[i])
|
||||
except:
|
||||
log.debug(" !!! FAILED TO RENAME !!!")
|
||||
else:
|
||||
log.debug("No material found for shadingEngine: " + lstShadingEngines[i])
|
||||
return lstShadingEngines
|
||||
|
||||
|
||||
def enforcePerFaceAssignment(lstShadingEngines=None):
|
||||
'''
|
||||
Workaround for Maya 2014/2015 bug.
|
||||
Ensures that ShadingEngines contain only faces, rather than full shapes.
|
||||
Alembic 1.1.5 contains a bug, so that it doesn't export FaceSets
|
||||
for objects where the entire shape is in the ShadingEngine.
|
||||
'''
|
||||
if lstShadingEngines is None:
|
||||
lstShadingEngines = cmds.ls(type="shadingEngine")
|
||||
else:
|
||||
if isinstance(lstShadingEngines, basestring):
|
||||
lstShadingEngines = [lstShadingEngines]
|
||||
|
||||
# cant apply per face assignment on standardSGs
|
||||
lstShadingEngines = set(lstShadingEngines) - standardSGs
|
||||
|
||||
if not lstShadingEngines:
|
||||
return False
|
||||
|
||||
log.info("Enforcing per-face material assignment ...")
|
||||
|
||||
for dgShadingEngine in lstShadingEngines:
|
||||
log.debug(" shadingEngine: " + dgShadingEngine)
|
||||
|
||||
lstSetMembers = cmds.sets(dgShadingEngine, q=True)
|
||||
if not lstSetMembers:
|
||||
continue
|
||||
|
||||
for sSetMember in lstSetMembers:
|
||||
if ".f[" not in sSetMember:
|
||||
log.debug(" Converting shape-assignment to face-assignment: " + sSetMember)
|
||||
# make sure sSetMember is a mesh!
|
||||
meshMember = cmds.ls(cmds.listHistory(sSetMember), type='mesh')
|
||||
if not meshMember:
|
||||
log.debug('SetMember "%s" (from %s) did not yield a mesh!' % sSetMember, dgShadingEngine)
|
||||
continue
|
||||
meshMember = meshMember[0]
|
||||
try:
|
||||
#iFaceCount = cmds.polyEvaluate(meshMember, f=True)
|
||||
#sFaces = meshMember + ".f[0:" + str(iFaceCount - 1) + "]"
|
||||
sFaces = "%s.f[*]" % meshMember
|
||||
# nasty hack: temporarily apply default material
|
||||
# to generate objectGroup datastructures
|
||||
if dgShadingEngine not in standardSGs:
|
||||
cmds.sets("%s.f[0]" % meshMember, e=True, fe="initialShadingGroup")
|
||||
cmds.sets(sFaces, e=1, fe=dgShadingEngine)
|
||||
# remove original member from that we added all faces if still in
|
||||
if cmds.sets(sSetMember, isMember=dgShadingEngine):
|
||||
cmds.sets(sSetMember, rm=dgShadingEngine)
|
||||
except StandardError, error:
|
||||
log.error(error)
|
||||
log.debug("Failed to all faces to material for object: " + sSetMember + "!")
|
||||
log.debug(sys.exc_info())
|
||||
|
||||
# fix for abc import which throws per face warnings if you have
|
||||
# get connected visible shapes
|
||||
connMesh = set(cmds.ls(cmds.listConnections('%s.dagSetMembers' % dgShadingEngine, shapes=True), type='mesh'))
|
||||
connMesh = set([m for m in connMesh if not cmds.getAttr('%s.intermediateObject' % m)])
|
||||
shapeMembers = set(cmds.ls(lstSetMembers, s=True, dag=True, o=True))
|
||||
# find nodes connected to dagSetMembers but are not members
|
||||
nonMemberShapes = list(connMesh - shapeMembers)
|
||||
if nonMemberShapes:
|
||||
log.debug('ShadingEngine "%s" has false member connection to mesh shape: %s'
|
||||
% (dgShadingEngine, ', '.join(nonMemberShapes)))
|
||||
# find out exact connection and disconnect
|
||||
for shape in nonMemberShapes:
|
||||
conns = cmds.listConnections(shape, type='shadingEngine', c=True, p=True)
|
||||
for i in range(1, len(conns), 2):
|
||||
if conns[i].startswith('%s.dagSetMembers' % dgShadingEngine):
|
||||
log.debug('unplugging "%s" from "%s"' % (conns[i - 1], conns[i]))
|
||||
cmds.disconnectAttr(conns[i - 1], conns[i])
|
||||
|
||||
return True
|
||||
|
||||
@cryDecorators.pluginDependency("AbcExport.mll")
|
||||
def exportAlembicForGeomCache(nodes=[]):
|
||||
'''
|
||||
Exports objects to Alembic with settings required for GeomCache pipeline.
|
||||
'''
|
||||
if not nodes:
|
||||
nodes = cmds.ls(sl=True, tr=True)
|
||||
if not nodes:
|
||||
log.error('Select some transforms to export!')
|
||||
return
|
||||
|
||||
selMesh, selSGs = getMeshAndSGs(nodes)
|
||||
if not selMesh:
|
||||
log.error('No meshes found to export!')
|
||||
|
||||
if selSGs.intersection(standardSGs):
|
||||
log.warning('Selected objects have default materials applied! Please replace!')
|
||||
|
||||
#lstFilePath = cmds.fileDialog2(cap="Export Alembic for GeomCache", ff="*.abc", ds=1, fm=0, dir=(cmds.workspace(q=1, rd=1)))
|
||||
lstFilePath = cmds.fileDialog2(cap="Export Alembic for GeomCache", fileFilter="Alembic .abc (*.abc)", fileMode=0)
|
||||
if not lstFilePath:
|
||||
return
|
||||
|
||||
t0 = time()
|
||||
selSGs = renameShadingEngines(selSGs)
|
||||
enforcePerFaceAssignment(selSGs)
|
||||
|
||||
sOptions = "-frameRange %s %s" % (cmds.playbackOptions(q=1, min=1), cmds.playbackOptions(q=1, max=1))
|
||||
sOptions += " -uvWrite -writeColorSets -writeFaceSets -writeVisibility "
|
||||
sOptions += ' '.join(['-root %s' % n for n in nodes])
|
||||
sOptions += ' -file "%s"' % lstFilePath[0]
|
||||
log.debug("AbcExport params:\n\t%s" % sOptions)
|
||||
|
||||
log.info('Exporting file: "%s" ...' % lstFilePath[0])
|
||||
try:
|
||||
cmds.AbcExport(jobArg=sOptions)
|
||||
except StandardError, error:
|
||||
log.error(error)
|
||||
log.debug(sys.exc_info())
|
||||
|
||||
log.info('Export finished! %ssec' % round(time() - t0, 1))
|
||||
|
||||
|
||||
def getMeshAndSGs(nodes=[]):
|
||||
"""
|
||||
filters visible mesh shapes from given or selected nodes and returns
|
||||
them with thier shading groups
|
||||
"""
|
||||
if not nodes:
|
||||
nodes = cmds.ls(sl=True)
|
||||
if not nodes:
|
||||
return None, None
|
||||
selMesh = set(cmds.ls(cmds.listRelatives(nodes, allDescendents=True), type='mesh'))
|
||||
selMesh = [m for m in selMesh if not cmds.getAttr('%s.intermediateObject' % m)]
|
||||
if not selMesh:
|
||||
return None, None
|
||||
selSGs = set(cmds.ls(cmds.listConnections(selMesh), type='shadingEngine'))
|
||||
return selMesh, selSGs
|
||||
|
||||
|
||||
def prepareMaterials(*args):
|
||||
"""inline call for Ui"""
|
||||
mesh, sgs = getMeshAndSGs()
|
||||
sgs= renameShadingEngines(sgs)
|
||||
enforcePerFaceAssignment(sgs)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
from maya import cmds
|
||||
from functools import wraps
|
||||
import inspect
|
||||
|
||||
import logging
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
||||
def pluginDependency(sPlugin, bEnableAutoLoad=False, bErrorOnFailure=False):
|
||||
'''
|
||||
This is a decorator, to be used with functions that expect a certain plugin to be loaded.
|
||||
If the required plugin is not already loaded, it will try to load it, before calling the decorated function.
|
||||
If the plugin cannot be loaded, it will raise an exception and return None without calling the decorated function.
|
||||
|
||||
The plugin's name needs to be supplied as a string, like so:
|
||||
@pluginDepdendency("myPlugin.mll)
|
||||
def myFunction():
|
||||
# do things...
|
||||
'''
|
||||
print('sPlugin: %s' % sPlugin)
|
||||
|
||||
def decorator(fFunction):
|
||||
@wraps(fFunction)
|
||||
def wrapper(*args, **kwargs):
|
||||
# check for plugin and try to load it if necessary
|
||||
bPluginLoaded = False
|
||||
|
||||
if not cmds.pluginInfo(sPlugin, query=True, loaded=True):
|
||||
log.debug("Plugin not loaded. Attempting to load: " + sPlugin)
|
||||
|
||||
try:
|
||||
cmds.loadPlugin(sPlugin)
|
||||
if bEnableAutoLoad:
|
||||
cmds.pluginInfo(sPlugin, edit=True, autoload=True)
|
||||
bPluginLoaded = True
|
||||
except Exception as eException:
|
||||
sModule = (inspect.getmodule(fFunction)).__name__
|
||||
#sFile = inspect.getsourcefile(fFunction)
|
||||
#sLine = (inspect.getsourcelines(fFunction))[-1]
|
||||
sMessage = str(eException) + "Aborting function call: " + sModule + "." + fFunction.__name__
|
||||
|
||||
if bErrorOnFailure:
|
||||
cmds.error(sMessage)
|
||||
else:
|
||||
cmds.warning(sMessage)
|
||||
else:
|
||||
bPluginLoaded = True
|
||||
|
||||
if bPluginLoaded:
|
||||
log.debug("Plugin loaded. Continuing function: " + fFunction.__name__)
|
||||
|
||||
return fFunction(*args, **kwargs)
|
||||
else:
|
||||
return None
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
// By sorting the node names based on the string length we know that a leaf node will always be in the list before it's parent.
|
||||
proc cryFBXSortNodeNamesLeafFirst( string $inNodes[] )
|
||||
{
|
||||
int $numNodes = size($inNodes);
|
||||
string $temp;
|
||||
for( $i = 0;$i<$numNodes-1;$i++ )
|
||||
{
|
||||
int $swap = 0;
|
||||
for( $j = 0;$j<$numNodes-1-$i;$j++ )
|
||||
{
|
||||
int $jLength = size($inNodes[$j]);
|
||||
int $j1Length = size($inNodes[$j+1]);
|
||||
|
||||
if( $j1Length > $jLength )
|
||||
{
|
||||
$temp = $inNodes[$j];
|
||||
$inNodes[$j] = $inNodes[$j+1];
|
||||
$inNodes[$j+1] = $temp;
|
||||
$swap = 1;
|
||||
}
|
||||
}
|
||||
if( $swap == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupDollars( string $node, string $newNodeName )
|
||||
{
|
||||
string $dollarString = "FBXASC036"; // FBX importer replaces `$` with this string.
|
||||
while ( $newNodeName != ( $newNodeName = `substitute $dollarString $newNodeName "_"` ) );
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupHashes( string $node, string $newNodeName )
|
||||
{
|
||||
string $hashString = "FBXASC035"; // FBX importer replaces `#` with this string.
|
||||
while ( $newNodeName != ( $newNodeName = `substitute $hashString $newNodeName "_"` ) );
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupSpaces( string $node, string $newNodeName )
|
||||
{
|
||||
string $spaceString = "FBXASC032"; // FBX importer replaces ` ` with this string.
|
||||
while ( $newNodeName != ( $newNodeName = `substitute $spaceString $newNodeName "__"` ) );
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupParentheses( string $node, string $newNodeName )
|
||||
{
|
||||
string $openBraceString = "FBXASC040"; // FBX importer replaces `(` with this string.
|
||||
string $closeBraceString = "FBXASC041"; // FBX importer replaces `)` with this string.
|
||||
while ( $newNodeName != ( $newNodeName = `substitute $openBraceString $newNodeName "_"` ) );
|
||||
while ( $newNodeName != ( $newNodeName = `substitute $closeBraceString $newNodeName "_"` ) );
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupGroup( string $node, string $newNodeName )
|
||||
{
|
||||
string $pathTokens[];
|
||||
$pathTokens = `stringToStringArray $node "|"`;
|
||||
int $pathLength = `size($pathTokens)`;
|
||||
|
||||
if( $pathLength > 1 && `endsWith $newNodeName "_group"` == 0 && `startsWith $newNodeName "_joint"` == 0 )
|
||||
{
|
||||
$newNodeName = ($newNodeName + "_group");
|
||||
}
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc string cryFBXCleanupExportNode( string $node, string $newNodeName )
|
||||
{
|
||||
string $pathTokens[];
|
||||
$pathTokens = `stringToStringArray $node "|"`;
|
||||
int $pathLength = `size($pathTokens)`;
|
||||
|
||||
if( $pathLength == 1 )
|
||||
{
|
||||
string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix();
|
||||
$newNodeName = $lumberyardExportNodePrefix + $newNodeName;
|
||||
}
|
||||
return $newNodeName;
|
||||
}
|
||||
|
||||
proc cryFBXCleanupAttributes( string $node )
|
||||
{
|
||||
string $attrs[];
|
||||
$attrs = `listAttr -userDefined $node`;
|
||||
|
||||
for( $attr in $attrs )
|
||||
{
|
||||
// Some of the attributes from MAX seem to have a `3DSMAX` suffix...
|
||||
if( `endsWith $attr "3DSMAX"` == 1 )
|
||||
{
|
||||
int $attrNameLength = `size($attr)`;
|
||||
string $newAttrName = `substring $attr 1 ($attrNameLength-6)`;
|
||||
catchQuiet( `renameAttr ($node+"."+$attr) $newAttrName` );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc int cryFBXCleanupIsSelected( string $nodeName )
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `ls -sl $nodeName`;
|
||||
|
||||
if( size($selected) > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check to see if the nodes parent is selected.
|
||||
string $parent = `firstParentOf $nodeName`;
|
||||
if( size($parent) > 0 )
|
||||
{
|
||||
return `cryFBXCleanupIsSelected $parent`;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc cryFBXCleanupProcess( int $renameSelectedRootsOnly )
|
||||
{
|
||||
string $allNodes[];
|
||||
$allNodes = `ls -l -type "transform" -type "mesh"`;
|
||||
|
||||
cryFBXSortNodeNamesLeafFirst $allNodes;
|
||||
|
||||
string $node;
|
||||
for( $node in $allNodes )
|
||||
{
|
||||
string $nodeType = `nodeType $node`;
|
||||
|
||||
string $pathTokens[];
|
||||
$pathTokens = `stringToStringArray $node "|"`;
|
||||
string $nodeName = $pathTokens[size($pathTokens)-1];
|
||||
|
||||
cryFBXCleanupAttributes $node;
|
||||
|
||||
int $renameExportNode = 1;
|
||||
if( $renameSelectedRootsOnly && !`cryFBXCleanupIsSelected $nodeName` )
|
||||
$renameExportNode = 0;
|
||||
|
||||
string $newNodeName = $nodeName;
|
||||
$newNodeName = `cryFBXCleanupDollars $node $newNodeName`;
|
||||
$newNodeName = `cryFBXCleanupHashes $node $newNodeName`;
|
||||
$newNodeName = `cryFBXCleanupSpaces $node $newNodeName`;
|
||||
$newNodeName = `cryFBXCleanupParentheses $node $newNodeName`;
|
||||
|
||||
if( $renameExportNode && `strcmp $nodeType "mesh"` != 0 )
|
||||
{
|
||||
$newNodeName = `cryFBXCleanupExportNode $node $newNodeName`;
|
||||
$newNodeName = `cryFBXCleanupGroup $node $newNodeName`;
|
||||
}
|
||||
|
||||
if( $newNodeName != $nodeName )
|
||||
{
|
||||
catchQuiet( $newNodeName = `rename -ignoreShape $node $newNodeName` );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryFBXCleanupUDP( )
|
||||
{
|
||||
string $udpAttributeName = "UDP";
|
||||
|
||||
string $allNodes[];
|
||||
$allNodes = `ls -l`;
|
||||
for( $node in $allNodes )
|
||||
{
|
||||
if (`attributeExists $udpAttributeName $node`)
|
||||
{
|
||||
string $nodeUDP = `getAttr ($node+"."+$udpAttributeName)`;
|
||||
while( 1 )
|
||||
{
|
||||
string $newUDP = `substitute "&cr;&lf;" $nodeUDP "\n"`;
|
||||
if( `strcmp $newUDP $nodeUDP` == 0 )
|
||||
break;
|
||||
$nodeUDP = $newUDP;
|
||||
}
|
||||
setAttr -type "string" ($node+"."+$udpAttributeName) $nodeUDP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc cryFBXCleanup()
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `ls -sl`;
|
||||
|
||||
int $renameSelectedRootsOnly = 1;
|
||||
string $message = "";
|
||||
if( size($selected) == 0 )
|
||||
{
|
||||
$message = "This will cleanup the node names created when importing an FBX scene from Max.\nAll root nodes will be renamed using the Lumberyard export node prefix.\nIf this is not what you want to do, click Cancel, select the export nodes and rerun this script.";
|
||||
$renameSelectedRootsOnly = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = "This will cleanup the node names created when importing an FBX scene from Max.\nOnly the selected root nodes will be renamed using the Lumberyard export node prefix.";
|
||||
$renameSelectedRootsOnly = 1;
|
||||
}
|
||||
|
||||
string $result = `confirmDialog -title "Lumberyard FBX" -message $message -button "Ok" -button "Cancel" -defaultButton "Ok" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
|
||||
if( $result == "Ok" )
|
||||
{
|
||||
cryFBXCleanupProcess( $renameSelectedRootsOnly );
|
||||
|
||||
cryFBXCleanupUDP;
|
||||
|
||||
string $nodes[];
|
||||
string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix();
|
||||
string $filter = $lumberyardExportNodePrefix + "*";
|
||||
$nodes = `ls $filter`;
|
||||
|
||||
// Add any attributes to the newly renamed nodes.
|
||||
cryExportAddAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
proc cryFBXSourceDependencies()
|
||||
{
|
||||
eval("source cryExport.mel");
|
||||
}
|
||||
|
||||
global proc cryFBX()
|
||||
{
|
||||
cryFBXSourceDependencies;
|
||||
cryFBXCleanup;
|
||||
}
|
||||
@@ -0,0 +1,926 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
global proc string cryMaterialGetPartitionName()
|
||||
{
|
||||
return "cryMaterials";
|
||||
}
|
||||
|
||||
global proc string cryMaterialGetDefaultGroupName()
|
||||
{
|
||||
return "newMaterialGroup1";
|
||||
}
|
||||
|
||||
global proc string cryMaterialCreateGroup( string $name )
|
||||
{
|
||||
string $partitionName = `cryMaterialGetPartitionName`;
|
||||
if( !`objExists $partitionName` )
|
||||
{
|
||||
partition -name $partitionName;
|
||||
}
|
||||
|
||||
int $defaultName = 0;
|
||||
if( `size($name)` == 0 )
|
||||
{
|
||||
$name = `cryMaterialGetDefaultGroupName`;
|
||||
$defaultName = 1;
|
||||
}
|
||||
|
||||
$newSet = `sets -empty -name $name`;
|
||||
if( $defaultName == 0 && $newSet != $name )
|
||||
{
|
||||
confirmDialog -title "Create Group" -message ("The group was renamed from `" + $name + "` to `" + $newSet + "` due to a name clash.") -button "OK";
|
||||
}
|
||||
partition -add $partitionName $newSet;
|
||||
return $newSet;
|
||||
}
|
||||
|
||||
global proc string cryMaterialCreateShader( string $name )
|
||||
{
|
||||
string $newShader;
|
||||
$newShader = `shadingNode -asShader phong`;
|
||||
string $renamed = `rename $newShader $name`;
|
||||
return $renamed;
|
||||
}
|
||||
|
||||
global proc string[] cryMaterialGetMaterialGroups(string $partitionName)
|
||||
{
|
||||
string $materialGroups[];
|
||||
|
||||
if( `objExists $partitionName` )
|
||||
{
|
||||
if( `objectType -isType "partition" $partitionName` )
|
||||
{
|
||||
$materialGroups = `partition -q $partitionName`;
|
||||
}
|
||||
}
|
||||
return $materialGroups;
|
||||
}
|
||||
|
||||
global proc string[] cryMaterialGetGroupShaders( string $group)
|
||||
{
|
||||
// It seems that the sets command dosen't always return the list in the right order.
|
||||
// The shaders should be connected to the dnSetMembers plug.
|
||||
// List connections seems to get them in the right order.
|
||||
string $contents[];
|
||||
$contents = `listConnections ($group+".dnSetMembers")`;
|
||||
//$contents = `sets -q -nodesOnly $group`;
|
||||
return $contents;
|
||||
}
|
||||
|
||||
global proc cryMaterialRebuildGroup( string $group )
|
||||
{
|
||||
// Rebuild the set's connections to remove any gaps in the dnSetMembers array
|
||||
string $contents[];
|
||||
$contents = `cryMaterialGetGroupShaders $group`;
|
||||
|
||||
// Remove all connections
|
||||
for( $shader in $contents )
|
||||
{
|
||||
string $dests[];
|
||||
$dests = `connectionInfo -destinationFromSource ($shader+".message")`;
|
||||
for( $dest in $dests )
|
||||
{
|
||||
if( `gmatch ($dest) ($group+".dnSetMembers*")` )
|
||||
disconnectAttr ($shader+".message") ($dest);
|
||||
}
|
||||
}
|
||||
|
||||
// Recreate connections
|
||||
int $connectionCount = 0;
|
||||
for( $shader in $contents )
|
||||
{
|
||||
connectAttr ($shader+".message") ($group+".dnSetMembers["+$connectionCount+"]");
|
||||
$connectionCount++;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialDeleteGroup( string $group )
|
||||
{
|
||||
delete $group;
|
||||
}
|
||||
|
||||
global proc cryMaterialMoveShaderToGroupWithPartition( string $group, string $shader, string $partitionName )
|
||||
{
|
||||
// If it's already a member of this group just return.
|
||||
if( `sets -isMember $group $shader` )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// The forceElement option on the sets command dosn't seem to be working so we have
|
||||
// to remove the shader from any other groups.
|
||||
string $materialGroups[];
|
||||
$materialGroups = `cryMaterialGetMaterialGroups $partitionName`;
|
||||
int $doAdd = 1;
|
||||
for( $materialGroup in $materialGroups )
|
||||
{
|
||||
if( `sets -isMember $materialGroup $shader` )
|
||||
{
|
||||
string $result = `confirmDialog -title "Move Shader" -message ("Shader `"+$shader+"` is already in group `"+$materialGroup+"`. Do you want to move it to group `"+$group+"`?")
|
||||
-button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`;
|
||||
|
||||
if( $result == "Yes" )
|
||||
{
|
||||
string $shaders[];
|
||||
$shaders[0] = $shader;
|
||||
cryMaterialRemoveShadersFromGroup $materialGroup $shaders;
|
||||
}
|
||||
else
|
||||
{
|
||||
$doAdd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $doAdd == 1 )
|
||||
{
|
||||
print("Add shader to group `"+$shader+"` -> `"+$group+"`\n");
|
||||
sets -forceElement $group $shader;
|
||||
cryMaterialRebuildGroup $group;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialMoveShaderToGroup( string $group, string $shader )
|
||||
{
|
||||
cryMaterialMoveShaderToGroupWithPartition $group $shader `cryMaterialGetPartitionName`;
|
||||
}
|
||||
|
||||
global proc cryMatrialAddSelectedShadersToGroup( string $group )
|
||||
{
|
||||
if( `objExists $group` )
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `ls -sl`;
|
||||
for( $object in $selected )
|
||||
{
|
||||
if( `objectType -isType "lambert" $object` || `objectType -isType "phong" $object` || `objectType -isType "blinn" $object` || `objectType -isAType "hwShader" $object` )
|
||||
{
|
||||
cryMaterialMoveShaderToGroup $group $object;
|
||||
}
|
||||
}
|
||||
cryMaterialRebuildGroup $group;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialAddShadersFromGeomToGroupRecurse( string $group, string $node, string $partitionName )
|
||||
{
|
||||
string $shaderEngines[] = `listConnections -type shadingEngine $node`;
|
||||
for( $se in $shaderEngines )
|
||||
{
|
||||
string $shaders[] = `listConnections -type lambert $se`;
|
||||
for( $shader in $shaders )
|
||||
{
|
||||
cryMaterialMoveShaderToGroupWithPartition $group $shader $partitionName;
|
||||
}
|
||||
string $hwShaders[] = `listConnections -type hwShader $se`;
|
||||
for( $hwShader in $hwShaders )
|
||||
{
|
||||
cryMaterialMoveShaderToGroupWithPartition $group $hwShader $partitionName;
|
||||
}
|
||||
}
|
||||
|
||||
string $children[];
|
||||
string $child;
|
||||
$children = `listRelatives -children -fullPath $node`;
|
||||
for ($child in $children)
|
||||
{
|
||||
cryMaterialAddShadersFromGeomToGroupRecurse $group $child $partitionName;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialAddShadersFromGeomToGroup( string $group )
|
||||
{
|
||||
if( `objExists $group` )
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `ls -sl`;
|
||||
|
||||
for( $rootNode in $selected )
|
||||
{
|
||||
cryMaterialAddShadersFromGeomToGroupRecurse $group $rootNode `cryMaterialGetPartitionName`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialRemoveShadersFromGroup( string $group, string $shaders[] )
|
||||
{
|
||||
if( `objExists $group` )
|
||||
{
|
||||
for( $shader in $shaders )
|
||||
{
|
||||
if( `sets -isMember $group $shader` )
|
||||
{
|
||||
print("Remove shader from group `"+$shader+"` <- `"+$group+"`\n");
|
||||
sets -edit -remove $group $shader;
|
||||
}
|
||||
}
|
||||
cryMaterialRebuildGroup $group;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialMoveShadersUp( string $group, string $inShaders[] )
|
||||
{
|
||||
// Rebuild the group to make sure the content index and the connection index match
|
||||
cryMaterialRebuildGroup $group;
|
||||
string $shaders[];
|
||||
$shaders = `cryMaterialGetGroupShaders $group`;
|
||||
|
||||
// Sort shaders array
|
||||
string $sortedInShaders[];
|
||||
for( $shader in $shaders )
|
||||
{
|
||||
for( $inShader in $inShaders )
|
||||
{
|
||||
if( $inShader == $shader )
|
||||
$sortedInShaders[`size($sortedInShaders)`] = $shader;
|
||||
}
|
||||
}
|
||||
|
||||
if( `size($sortedInShaders)` != `size($inShaders)` )
|
||||
print("Error sorting shaders\n");
|
||||
|
||||
|
||||
int $numInShaders = `size($sortedInShaders)`;
|
||||
int $numShaders = `size($shaders)`;
|
||||
for( $i = 0;$i<$numInShaders;$i++ )
|
||||
{
|
||||
int $swapped = 0;
|
||||
string $inShader = $inShaders[$i];
|
||||
|
||||
for( $j = 1;$j<$numShaders;$j++ )
|
||||
{
|
||||
string $shader = $shaders[$j];
|
||||
if( $inShader == $shader )
|
||||
{
|
||||
string $shaderM1 = $shaders[$j-1];
|
||||
if( !`stringArrayContains $shaderM1 $sortedInShaders` )
|
||||
{
|
||||
// Swap $shader and $shaderM1
|
||||
disconnectAttr ($shader+".message") ($group+".dnSetMembers["+$j+"]");
|
||||
disconnectAttr ($shaderM1+".message") ($group+".dnSetMembers["+($j-1)+"]");
|
||||
connectAttr ($shader+".message") ($group+".dnSetMembers["+($j-1)+"]");
|
||||
connectAttr ($shaderM1+".message") ($group+".dnSetMembers["+$j+"]");
|
||||
$swapped = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( $swapped )
|
||||
{
|
||||
$shaders = `cryMaterialGetGroupShaders $group`;
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild again though it shouldn't be needed
|
||||
cryMaterialRebuildGroup $group;
|
||||
}
|
||||
|
||||
global proc cryMaterialMoveShadersDown( string $group, string $inShaders[] )
|
||||
{
|
||||
// Rebuild the group to make sure the content index and the connection index match
|
||||
cryMaterialRebuildGroup $group;
|
||||
string $shaders[];
|
||||
$shaders = `cryMaterialGetGroupShaders $group`;
|
||||
|
||||
// Sort shaders array
|
||||
string $sortedInShaders[];
|
||||
for( $shader in $shaders )
|
||||
{
|
||||
for( $inShader in $inShaders )
|
||||
{
|
||||
if( $inShader == $shader )
|
||||
$sortedInShaders[`size($sortedInShaders)`] = $shader;
|
||||
}
|
||||
}
|
||||
|
||||
if( `size($sortedInShaders)` != `size($inShaders)` )
|
||||
print("Error sorting shaders\n");
|
||||
|
||||
int $numInShaders = `size($sortedInShaders)`;
|
||||
int $numShaders = `size($shaders)`;
|
||||
for( $i = $numInShaders-1;$i>=0;$i-- )
|
||||
{
|
||||
int $swapped = 0;
|
||||
string $inShader = $inShaders[$i];
|
||||
|
||||
for( $j = $numShaders-2;$j>=0;$j-- )
|
||||
{
|
||||
string $shader = $shaders[$j];
|
||||
if( $inShader == $shader )
|
||||
{
|
||||
string $shaderP1 = $shaders[$j+1];
|
||||
if( !`stringArrayContains $shaderP1 $sortedInShaders` )
|
||||
{
|
||||
// Swap $shader and $shaderM1
|
||||
disconnectAttr ($shader+".message") ($group+".dnSetMembers["+$j+"]");
|
||||
disconnectAttr ($shaderP1+".message") ($group+".dnSetMembers["+($j+1)+"]");
|
||||
connectAttr ($shader+".message") ($group+".dnSetMembers["+($j+1)+"]");
|
||||
connectAttr ($shaderP1+".message") ($group+".dnSetMembers["+$j+"]");
|
||||
$swapped = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( $swapped )
|
||||
{
|
||||
$shaders = `cryMaterialGetGroupShaders $group`;
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild again though it shouldn't be needed
|
||||
cryMaterialRebuildGroup $group;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Cry Material UI
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
global proc cryMaterialUICloseWindow()
|
||||
{
|
||||
deleteUI -window CRYMATERIAL_WINDOW;
|
||||
}
|
||||
|
||||
global proc string cryMaterialUIShaderNameEncode( string $group, string $shader )
|
||||
{
|
||||
string $contents[];
|
||||
$contents = `cryMaterialGetGroupShaders $group`;
|
||||
int $shaderIndex = 0;
|
||||
for( $i = 0;$i<size($contents);$i++ )
|
||||
{
|
||||
if( $shader == $contents[$i] )
|
||||
{
|
||||
$shaderIndex = $i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
string $returnName;
|
||||
if( $shaderIndex < 10 )
|
||||
$returnName = "0";
|
||||
$returnName += ($shaderIndex + " : " + $shader );
|
||||
return $returnName;
|
||||
}
|
||||
|
||||
global proc string cryMaterialUIShaderNameDecode( string $shaderName )
|
||||
{
|
||||
int $length = size($shaderName);
|
||||
// TODO: there is a potential bug that if the number of materials exceeds 99,
|
||||
// then it cannot be exported successfully
|
||||
string $name = `substring $shaderName 6 $length`;
|
||||
return $name;
|
||||
}
|
||||
|
||||
proc string cryMaterialUIGetSelectedGroup()
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `textScrollList -q -selectItem CRYMATERIAL_GROUPLIST`;
|
||||
if( `size($selected)` == 0 )
|
||||
return "";
|
||||
else
|
||||
return $selected[0];
|
||||
}
|
||||
|
||||
proc cryMaterialUIShaderListSelect( string $selected[] )
|
||||
{
|
||||
string $itemList[] = `textScrollList -q -allItems CRYMATERIAL_SHADERLIST`;
|
||||
for( $item in $selected )
|
||||
{
|
||||
for( $listItem in $itemList )
|
||||
{
|
||||
string $listItemDecode = `cryMaterialUIShaderNameDecode $listItem`;
|
||||
if( $listItemDecode == $item )
|
||||
{
|
||||
textScrollList -e -selectItem $listItem CRYMATERIAL_SHADERLIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc string[] cryMaterialUIGetSelectedShaders()
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `textScrollList -q -selectItem CRYMATERIAL_SHADERLIST`;
|
||||
for( $i = 0;$i<size($selected);$i++ )
|
||||
{
|
||||
$selected[$i] = `cryMaterialUIShaderNameDecode $selected[$i]`;
|
||||
}
|
||||
return $selected;
|
||||
}
|
||||
|
||||
global proc cryMaterialUICreateGroup()
|
||||
{
|
||||
string $name = `cryMaterialGetDefaultGroupName`;
|
||||
string $result = `promptDialog -title "Create Group" -message "Enter group name:" -text $name -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
|
||||
if ($result == "OK")
|
||||
{
|
||||
$name = `promptDialog -query -text`;
|
||||
if( `size($name)` == 0 )
|
||||
$name = `cryMaterialGetDefaultGroupName`;
|
||||
cryMaterialCreateGroup $name;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUICreateGroupFromSelection()
|
||||
{
|
||||
string $name = `cryMaterialGetDefaultGroupName`;
|
||||
|
||||
// Get the name of the new group from the Lumberyard export node if there is one selected.
|
||||
string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix();
|
||||
string $selectedNodes[] = `ls -sl`;
|
||||
if( size($selectedNodes) > 0 )
|
||||
{
|
||||
for( $selectedNode in $selectedNodes )
|
||||
{
|
||||
string $lowerNode = tolower( $selectedNode );
|
||||
if( startsWith( $lowerNode, $lumberyardExportNodePrefix ) )
|
||||
{
|
||||
int $start = size($lumberyardExportNodePrefix)+1;
|
||||
int $end = size($selectedNode);
|
||||
$name = `substring $selectedNode $start $end`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string $result = `promptDialog -title "Create Group" -message "Enter group name:" -text $name -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
|
||||
if ($result == "OK")
|
||||
{
|
||||
$name = `promptDialog -query -text`;
|
||||
if( `size($name)` == 0 )
|
||||
$name = `cryMaterialGetDefaultGroupName`;
|
||||
string $newGroup = `cryMaterialCreateGroup $name`;
|
||||
cryMaterialAddShadersFromGeomToGroup $newGroup;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIReadMaterial()
|
||||
{
|
||||
if( `cryPluginIsLoaded` == 0 )
|
||||
{
|
||||
confirmDialog -title "Read Material" -message ("Can't read a material as the Lumberyard plugin isn't loaded.") -button "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
string $currentPath = `file -q -sceneName`;
|
||||
$currentPath = `dirname $currentPath`;
|
||||
string $startingFolder = $currentPath;
|
||||
|
||||
string $absPath = `cryExportRelativeToAbsolutePath $startingFolder`;
|
||||
string $inFiles[] = `fileDialog2 -fileMode 1 -startingDirectory $absPath -fileFilter ("Material Files (*.mtl)")`;
|
||||
if( size($inFiles) > 0 )
|
||||
{
|
||||
string $option1 = "readMaterial";
|
||||
string $option2 = $inFiles[0];
|
||||
|
||||
if( catchQuiet( `cryMayaSupportPlugin $option1 $option2` ) )
|
||||
{
|
||||
confirmDialog -title "Read Material" -message ("Failed to read material file `"+$inFiles[0]+"`.") -button "OK";
|
||||
}
|
||||
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIRenameGroup()
|
||||
{
|
||||
string $currentName = `cryMaterialUIGetSelectedGroup`;
|
||||
string $result = `promptDialog -title "Rename Group" -message "Enter new group name:" -text $currentName -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
|
||||
if ($result == "OK")
|
||||
{
|
||||
string $name = `promptDialog -query -text`;
|
||||
if( `size($name)` != 0 )
|
||||
{
|
||||
string $newName;
|
||||
$newName = `rename $currentName $name`;
|
||||
if( $newName != $name )
|
||||
{
|
||||
confirmDialog -title "Rename Group" -message ("The group was renamed from `" + $name + "` to `" + $newName + "` due to a name clash.") -button "OK";
|
||||
}
|
||||
cryMaterialUIRebuild;
|
||||
textScrollList -e -selectItem $name CRYMATERIAL_GROUPLIST;
|
||||
cryMaterialUIUpdateShaderList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIRenameShader()
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( size($currentShaders) > 0 )
|
||||
{
|
||||
string $currentName = $currentShaders[0];
|
||||
string $result = `promptDialog -title "Rename Shader" -message "Enter new shader name:" -text $currentName -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
|
||||
if ($result == "OK")
|
||||
{
|
||||
string $name = `promptDialog -query -text`;
|
||||
if( `size($name)` != 0 )
|
||||
{
|
||||
rename $currentName $name;
|
||||
int $selectedItems[] = `textScrollList -q -selectIndexedItem CRYMATERIAL_SHADERLIST`;
|
||||
cryMaterialUIRebuild;
|
||||
cryMaterialUIUpdateShaderList;
|
||||
textScrollList -e -selectIndexedItem $selectedItems[0] CRYMATERIAL_SHADERLIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIDeleteGroup( int $deleteAllGroups )
|
||||
{
|
||||
string $answer = "Yes";
|
||||
if( $deleteAllGroups )
|
||||
$answer = `confirmDialog -title "Lumberyard Material" -message ("Delete all material groups?") -button "Yes" -button "No"`;
|
||||
if( $answer == "Yes" )
|
||||
{
|
||||
string $selected[];
|
||||
if( $deleteAllGroups )
|
||||
$selected = `textScrollList -q -allItems CRYMATERIAL_GROUPLIST`;
|
||||
else
|
||||
$selected = `textScrollList -q -selectItem CRYMATERIAL_GROUPLIST`;
|
||||
|
||||
for( $i = 0;$i<size($selected);$i++ )
|
||||
cryMaterialDeleteGroup $selected[$i];
|
||||
|
||||
textScrollList -e -removeAll CRYMATERIAL_SHADERLIST;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIRemoveShaders( )
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
|
||||
string $selected[];
|
||||
$selected = `cryMaterialUIGetSelectedShaders`;
|
||||
cryMaterialRemoveShadersFromGroup $currentGroup $selected;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIAddSelectedShaders( )
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
cryMatrialAddSelectedShadersToGroup $currentGroup;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIAddShadersFromGeom( )
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
cryMaterialAddShadersFromGeomToGroup $currentGroup;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIMoveShadersUp()
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
cryMaterialMoveShadersUp $currentGroup $currentShaders;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIMoveShadersDown()
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
cryMaterialMoveShadersDown $currentGroup $currentShaders;
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIOpenHyperShader()
|
||||
{
|
||||
HypershadeWindow;
|
||||
// FIXME: This relies on the opened hypershade panel being called `hyperShadePanel1`.
|
||||
hyperShadePanelMenuCommand("hyperShadePanel1", "showBottomTabsOnly");
|
||||
evalDeferred("hyperShadePanelGraphCommand(\"hyperShadePanel1\", \"showUpAndDownstream\");");
|
||||
}
|
||||
|
||||
global proc cryMaterialUIOpenShaderInHyperShade( )
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( `size($currentShaders)` > 0 )
|
||||
{
|
||||
select $currentShaders;
|
||||
cryMaterialUIOpenHyperShader;
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No shaders are selected.") -button "OK";
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIOpenGroupInHyperShade( )
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
if( `size($currentGroup)` > 0 )
|
||||
{
|
||||
select -r -ne $currentGroup;
|
||||
cryMaterialUIOpenHyperShader;
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No group is selected.") -button "OK";
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUISelectShader()
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( `size($currentShaders)` == 0 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No shaders are selected.") -button "OK";
|
||||
return;
|
||||
}
|
||||
if( `size($currentShaders)` > 1 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("Too many shaders are selected. Select only 1.") -button "OK";
|
||||
return;
|
||||
}
|
||||
|
||||
select $currentShaders[0];
|
||||
}
|
||||
|
||||
global proc cryMaterialUICreateNewShader()
|
||||
{
|
||||
string $newShader = `cryMaterialCreateShader("newShader")`;
|
||||
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
cryMaterialMoveShaderToGroup $currentGroup $newShader;
|
||||
|
||||
cryMaterialUIRebuild;
|
||||
}
|
||||
|
||||
global proc cryMaterialUISelectObjectsWithMaterialGroup()
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
if( `size($currentGroup)` > 0 )
|
||||
{
|
||||
string $groupShaders[] = `cryMaterialGetGroupShaders $currentGroup`;
|
||||
|
||||
if( `size($groupShaders)` > 0 )
|
||||
{
|
||||
select -r $groupShaders;
|
||||
hyperShade -objects "";
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmDialog -title "Material" -message ("The selected group has no shaders.") -button "OK";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No material group selected.") -button "OK";
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUISelectObjectsWithMaterial()
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( `size($currentShaders)` > 0 )
|
||||
{
|
||||
select -r $currentShaders;
|
||||
hyperShade -objects "";
|
||||
}
|
||||
else
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No shaders are selected.") -button "OK";
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIAssignMaterialToSelection()
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( `size($currentShaders)` == 0 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No shaders are selected.") -button "OK";
|
||||
return;
|
||||
}
|
||||
if( `size($currentShaders)` > 1 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("Too many shaders are selected. Select only 1.") -button "OK";
|
||||
return;
|
||||
}
|
||||
|
||||
hyperShade -assign $currentShaders[0];
|
||||
}
|
||||
|
||||
global proc cryMaterialUIOpenInAttributeEditor( )
|
||||
{
|
||||
string $currentShaders[] = `cryMaterialUIGetSelectedShaders`;
|
||||
if( `size($currentShaders)` == 0 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("No shaders are selected.") -button "OK";
|
||||
return;
|
||||
}
|
||||
if( `size($currentShaders)` > 1 )
|
||||
{
|
||||
confirmDialog -title "Material" -message ("Too many shaders are selected. Select only 1.") -button "OK";
|
||||
return;
|
||||
}
|
||||
|
||||
select $currentShaders[0];
|
||||
autoUpdateAttrEd;
|
||||
openAEWindow;
|
||||
}
|
||||
|
||||
global proc cryMaterialUIUpdateShaderList()
|
||||
{
|
||||
string $currentGroup = `cryMaterialUIGetSelectedGroup`;
|
||||
|
||||
string $selected[];
|
||||
$selected = `cryMaterialUIGetSelectedShaders`;
|
||||
|
||||
textScrollList -e -removeAll CRYMATERIAL_SHADERLIST;
|
||||
if( `objExists $currentGroup` )
|
||||
{
|
||||
string $contents[];
|
||||
$contents = `cryMaterialGetGroupShaders $currentGroup`;
|
||||
|
||||
for( $shader in $contents )
|
||||
{
|
||||
string $shaderName = `cryMaterialUIShaderNameEncode $currentGroup $shader`;
|
||||
textScrollList -e -append $shaderName CRYMATERIAL_SHADERLIST;
|
||||
}
|
||||
|
||||
string $newSelected[];
|
||||
for( $item in $selected )
|
||||
{
|
||||
$newSelected[size($newSelected)] = $item;
|
||||
}
|
||||
cryMaterialUIShaderListSelect $newSelected;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryMaterialUIRebuild()
|
||||
{
|
||||
// Don't clear the shader list is here or the slection will be lost when moving the shaders up and down etc.
|
||||
// It should be cleared in the caller when needed.
|
||||
//textScrollList -e -removeAll CRYMATERIAL_SHADERLIST;
|
||||
|
||||
$partitionName = `cryMaterialGetPartitionName`;
|
||||
|
||||
if( `objExists $partitionName` )
|
||||
{
|
||||
string $materialGroups[];
|
||||
$materialGroups = `partition -q $partitionName`;
|
||||
|
||||
string $selected[];
|
||||
$selected = `textScrollList -q -selectItem CRYMATERIAL_GROUPLIST`;
|
||||
|
||||
textScrollList -e -removeAll CRYMATERIAL_GROUPLIST;
|
||||
|
||||
for( $materialGroup in $materialGroups )
|
||||
{
|
||||
textScrollList -e -append $materialGroup CRYMATERIAL_GROUPLIST;
|
||||
}
|
||||
|
||||
if( `size($materialGroups)` > 0 )
|
||||
{
|
||||
if( `size($selected)` > 0 )
|
||||
{
|
||||
for( $item in $selected )
|
||||
{
|
||||
if( `stringArrayContains $item $materialGroups` )
|
||||
textScrollList -e -selectItem $item CRYMATERIAL_GROUPLIST;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textScrollList -e -selectIndexedItem 1 CRYMATERIAL_GROUPLIST;
|
||||
}
|
||||
}
|
||||
|
||||
cryMaterialUIUpdateShaderList;
|
||||
}
|
||||
}
|
||||
|
||||
proc createCryMaterialWindow()
|
||||
{
|
||||
if(!`window -ex CRYMATERIAL_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYMATERIAL_WINDOW`)
|
||||
{
|
||||
windowPref -wh 500 410 -tlc `windowPref -q -topEdge CRYMATERIAL_WINDOW` `windowPref -q -leftEdge CRYMATERIAL_WINDOW` CRYMATERIAL_WINDOW;
|
||||
//windowPref -remove CRYMATERIAL_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Material Groups" -widthHeight 500 410 -sizeable true -mnb false -mxb false CRYMATERIAL_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
{
|
||||
text -height 30 -font "boldLabelFont" -label "Material Groups" CRYMATERIAL_GROUPSLABEL;
|
||||
textScrollList -allowMultiSelection false -selectCommand "cryMaterialUIUpdateShaderList"
|
||||
-deleteKeyCommand "cryMaterialUIDeleteGroup 0" -doubleClickCommand "cryMaterialUIRenameGroup" -width 20 CRYMATERIAL_GROUPLIST;
|
||||
popupMenu;
|
||||
{
|
||||
menuItem -label "Select Objects With MaterialGroup" -command "cryMaterialUISelectObjectsWithMaterialGroup";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Rename Group" -command "cryMaterialUIRenameGroup";
|
||||
menuItem -label "View in HyperShade" -command "cryMaterialUIOpenGroupInHyperShade";
|
||||
}
|
||||
|
||||
text -height 30 -font "boldLabelFont" -label "Shaders" CRYMATERIAL_SHADERSLABEL;
|
||||
textScrollList -allowMultiSelection true -deleteKeyCommand "cryMaterialUIRemoveShaders"
|
||||
-doubleClickCommand "cryMaterialUIRenameShader" -width 20 CRYMATERIAL_SHADERLIST;
|
||||
popupMenu;
|
||||
{
|
||||
menuItem -label "Select Shader" -command "cryMaterialUISelectShader";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Open Shader In Attribute Editor" -command "cryMaterialUIOpenInAttributeEditor";
|
||||
menuItem -label "Select Objects With Material" -command "cryMaterialUISelectObjectsWithMaterial";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Assign Material To Selection" -command "cryMaterialUIAssignMaterialToSelection";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Create New Shader" -command "cryMaterialUICreateNewShader";
|
||||
}
|
||||
|
||||
columnLayout -adjustableColumn true CRYMATERIAL_GROUPCOL;
|
||||
{
|
||||
button -label "Create Group" -command "cryMaterialUICreateGroup";
|
||||
button -label "Create Group From Selection" -command "cryMaterialUICreateGroupFromSelection";
|
||||
button -label "Rename Selected Group" -command "cryMaterialUIRenameGroup";
|
||||
button -label "Read Material File" -command "cryMaterialUIReadMaterial";
|
||||
button -label "View Selected Group in HyperShade" -command "cryMaterialUIOpenGroupInHyperShade";
|
||||
}
|
||||
setParent ..;
|
||||
columnLayout -adjustableColumn true CRYMATERIAL_SHADERCOL;
|
||||
{
|
||||
button -label "Add Selected Shaders" -command "cryMaterialUIAddSelectedShaders";
|
||||
button -label "Add Shaders From Selected Geom" -command "cryMaterialUIAddShadersFromGeom";
|
||||
button -label "Move Shaders Up" -command "cryMaterialUIMoveShadersUp";
|
||||
button -label "Move Shaders Down" -command "cryMaterialUIMoveShadersDown";
|
||||
button -label "View Selected Shaders in HyperShade" -command "cryMaterialUIOpenShaderInHyperShade";
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
$closebutton = `button -label "Close" -command ("cryMaterialUICloseWindow")`;
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYMATERIAL_GROUPSLABEL "top" 5
|
||||
-attachForm CRYMATERIAL_GROUPSLABEL "left" 5
|
||||
-attachPosition CRYMATERIAL_GROUPSLABEL "right" 5 50
|
||||
-attachNone CRYMATERIAL_GROUPSLABEL "bottom"
|
||||
|
||||
-attachForm CRYMATERIAL_SHADERSLABEL "top" 5
|
||||
-attachPosition CRYMATERIAL_SHADERSLABEL "left" 5 50
|
||||
-attachForm CRYMATERIAL_SHADERSLABEL "right" 5
|
||||
-attachNone CRYMATERIAL_SHADERSLABEL "bottom"
|
||||
|
||||
-attachControl CRYMATERIAL_GROUPLIST "top" 5 CRYMATERIAL_GROUPSLABEL
|
||||
-attachForm CRYMATERIAL_GROUPLIST "left" 5
|
||||
-attachPosition CRYMATERIAL_GROUPLIST "right" 5 50
|
||||
-attachControl CRYMATERIAL_GROUPLIST "bottom" 5 CRYMATERIAL_GROUPCOL
|
||||
|
||||
-attachControl CRYMATERIAL_SHADERLIST "top" 5 CRYMATERIAL_SHADERSLABEL
|
||||
-attachPosition CRYMATERIAL_SHADERLIST "left" 5 50
|
||||
-attachForm CRYMATERIAL_SHADERLIST "right" 5
|
||||
-attachControl CRYMATERIAL_SHADERLIST "bottom" 5 CRYMATERIAL_SHADERCOL
|
||||
|
||||
|
||||
-attachNone CRYMATERIAL_GROUPCOL "top"
|
||||
-attachForm CRYMATERIAL_GROUPCOL "left" 5
|
||||
-attachPosition CRYMATERIAL_GROUPCOL "right" 5 50
|
||||
-attachControl CRYMATERIAL_GROUPCOL "bottom" 5 $closebutton
|
||||
|
||||
-attachNone CRYMATERIAL_SHADERCOL "top"
|
||||
-attachPosition CRYMATERIAL_SHADERCOL "left" 5 50
|
||||
-attachForm CRYMATERIAL_SHADERCOL "right" 5
|
||||
-attachControl CRYMATERIAL_SHADERCOL "bottom" 5 $closebutton
|
||||
|
||||
-attachForm $closebutton "bottom" 5
|
||||
-attachForm $closebutton "left" 5
|
||||
-attachForm $closebutton "right" 5
|
||||
-attachNone $closebutton "top"
|
||||
$layout1;
|
||||
}
|
||||
|
||||
cryMaterialUIRebuild;
|
||||
|
||||
showWindow CRYMATERIAL_WINDOW;
|
||||
}
|
||||
|
||||
proc cryMaterialSourceDependencies()
|
||||
{
|
||||
eval("source cryExport.mel");
|
||||
}
|
||||
|
||||
global proc cryMaterialWin()
|
||||
{
|
||||
cryMaterialSourceDependencies;
|
||||
createCryMaterialWindow();
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
proc int cryPivotTranslationLocked( string $node )
|
||||
{
|
||||
if( `attributeExists "translate" $node` )
|
||||
{
|
||||
if( `getAttr -lock ($node+".translateX")` || `getAttr -lock ($node+".translateY")` || `getAttr -lock ($node+".translateZ")` )
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
global proc int cryPivotRecurseMoveNode(int $centrePivots,string $node,vector $offset)
|
||||
{
|
||||
float $fpivot[];
|
||||
vector $pivot;
|
||||
|
||||
if(`attributeExists "intermediateObject" $node`)
|
||||
{
|
||||
if(`getAttr ($node+".intermediateObject")` == 1 )
|
||||
return 1; // Stop processing this node but carry on with siblings.
|
||||
}
|
||||
|
||||
if( `cryPivotTranslationLocked $node` )
|
||||
{
|
||||
confirmDialog -title "Lumberyard Pivot" -message ("Failure. The node `"+$node+"` has locked transform attributes.") -button "OK" -defaultButton "OK";
|
||||
return 0; // Fail. Exit all the way up the recusion.
|
||||
}
|
||||
|
||||
if(`nodeType $node` == "transform")
|
||||
{
|
||||
if( $centrePivots == 1 )
|
||||
{
|
||||
xform -centerPivots -preserve true $node;
|
||||
}
|
||||
|
||||
$fpivot = `xform -q -os -rotatePivot $node`;
|
||||
xform -r -translation ($fpivot[0] - $offset.x) ($fpivot[1] - $offset.y) ($fpivot[2] - $offset.z) $node;
|
||||
xform -os -pivots (0) (0) (0) $node;
|
||||
$offset = <<$fpivot[0],$fpivot[1],$fpivot[2]>>;
|
||||
}
|
||||
else if(`nodeType $node` == "mesh")
|
||||
{
|
||||
int $eval[] = `polyEvaluate -v $node`;
|
||||
$vertCount = $eval[0];
|
||||
move -r (-$offset.x) (-$offset.y) (-$offset.z) ($node+".vtx[0:"+$vertCount+"]");
|
||||
}
|
||||
|
||||
string $children[];
|
||||
string $child;
|
||||
$children = `listRelatives -children -fullPath $node`;
|
||||
for ($child in $children)
|
||||
{
|
||||
if( `cryPivotRecurseMoveNode $centrePivots $child $offset` == 0 )
|
||||
{
|
||||
return 0; // Fail. Exit all the way up the recursion
|
||||
}
|
||||
}
|
||||
|
||||
return 1; // Success.
|
||||
}
|
||||
|
||||
global proc cryPivotCloseWindow()
|
||||
{
|
||||
if(`window -ex CRYPIVOT_WINDOW`)
|
||||
{
|
||||
deleteUI -window CRYPIVOT_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryPivotClickedRun()
|
||||
{
|
||||
int $centrePivots = 0;
|
||||
if(`window -ex CRYPIVOT_WINDOW`)
|
||||
{
|
||||
$centrePivots = `checkBox -q -v CRYPIVOT_CENTREPIVOTS`;
|
||||
}
|
||||
|
||||
cryPivotRun($centrePivots);
|
||||
}
|
||||
|
||||
global proc cryPivotRun(int $centrePivots)
|
||||
{
|
||||
$sellist = `ls -sl -long`;
|
||||
|
||||
if(size($sellist) != 1)
|
||||
{
|
||||
confirmDialog -title "Lumberyard Pivot" -message "Wrong number of nodes selected, expected 1." -button "OK" -defaultButton "OK";
|
||||
return;
|
||||
}
|
||||
|
||||
cryPivotCloseWindow;
|
||||
|
||||
string $node = $sellist[0];
|
||||
if( `cryPivotRecurseMoveNode $centrePivots $node <<0,0,0>>` == 1 )
|
||||
{
|
||||
confirmDialog -title "Lumberyard Pivot" -message "Origins set sucessfully." -button "OK" -defaultButton "OK";
|
||||
}
|
||||
}
|
||||
|
||||
proc cryPivotOptionWindow()
|
||||
{
|
||||
if(!`window -ex CRYPIVOT_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYPIVOT_WINDOW`)
|
||||
{
|
||||
windowPref -wh 400 110 -tlc `windowPref -q -topEdge CRYPIVOT_WINDOW` `windowPref -q -leftEdge CRYPIVOT_WINDOW` CRYPIVOT_WINDOW;
|
||||
//windowPref -remove CRYPIVOT_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Fixup Node Origins" -widthHeight 400 110 -sizeable true -mnb false -mxb false CRYPIVOT_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
{
|
||||
columnLayout -adjustableColumn true CRYPIVOT_COL;
|
||||
{
|
||||
text -align "left" -label "This will move the origin of the selected node to it's pivot position.\nThe centre pivot option will centre the pivot point before moving the origin.";
|
||||
text -label "";
|
||||
checkBox -label "Centre Pivots" -align "center" CRYPIVOT_CENTREPIVOTS;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
$runbutton = `button -label "Run" -command ("cryPivotClickedRun")`;
|
||||
$cancelbutton = `button -label "Cancel" -command ("cryPivotCloseWindow")`;
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYPIVOT_COL "top" 5
|
||||
-attachForm CRYPIVOT_COL "left" 5
|
||||
-attachForm CRYPIVOT_COL "right" 5
|
||||
-attachControl CRYPIVOT_COL "bottom" 5 $cancelbutton
|
||||
|
||||
-attachForm $runbutton "bottom" 5
|
||||
-attachForm $runbutton "left" 5
|
||||
-attachPosition $runbutton "right" 5 50
|
||||
-attachNone $runbutton "top"
|
||||
|
||||
-attachForm $cancelbutton "bottom" 5
|
||||
-attachPosition $cancelbutton "left" 5 50
|
||||
-attachForm $cancelbutton "right" 5
|
||||
-attachNone $cancelbutton "top"
|
||||
$layout1;
|
||||
}
|
||||
|
||||
showWindow CRYPIVOT_WINDOW;
|
||||
}
|
||||
|
||||
global proc cryPivot()
|
||||
{
|
||||
cryPivotOptionWindow;
|
||||
}
|
||||
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
global proc cryToolsCreateCryExportNodeCloseWindow()
|
||||
{
|
||||
deleteUI -window CRYNEWEXPORTNODE_WINDOW;
|
||||
}
|
||||
|
||||
global proc string cryToolsCreateCryExportNodeCreateCore( string $name, int $fileType, string $contents[] )
|
||||
{
|
||||
// check selection
|
||||
for( $content in $contents )
|
||||
{
|
||||
string $type = `nodeType $content`;
|
||||
if( $type != "transform" && $type != "joint" )
|
||||
{
|
||||
warning( "Selected node " + $content + " is not valid for exporting!" );
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
string $targetName = $contents[0];
|
||||
|
||||
// Create/Adjust group properly
|
||||
// If there are multiple contents, need to create a group
|
||||
string $groupPostfix = "_group";
|
||||
if( size( $contents ) > 1 )
|
||||
{
|
||||
if( `confirmDialog -title "Lumberyard Exporter" -message "A group node will be created for selected nodes. Scene hierarchy will be modified."
|
||||
-button "Confirm" -button "Cancel" -defaultButton "Confirm"
|
||||
-cancelButton "Cancel" -dismissString "Cancel"` == "Confirm" )
|
||||
{
|
||||
$targetName = `group -empty -name ($name + $groupPostfix)`;
|
||||
xform -objectSpace -pivots 0 0 0 $targetName;
|
||||
|
||||
// Add contents to group node
|
||||
for( $item in $contents )
|
||||
{
|
||||
parent $item $targetName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// User cancelled operation, do nothing and return
|
||||
return "";
|
||||
}
|
||||
}
|
||||
// Else if it's a group, attempt to add "_group" postfix if it lacks
|
||||
else if (`nodeType $contents[0]` == "transform" && size(`listRelatives -type "mesh" -children $contents[0]`) == 0)
|
||||
{
|
||||
if ( !endsWith($contents[0], $groupPostfix) && !endsWith($contents[0], "_helper") )
|
||||
{
|
||||
string $message = "Renaming this group node with a `_group` postfix will allow a more predictable export. Would you like to rename this node to `" + $contents[0] + "_group`?";
|
||||
string $action = `confirmDialog -title "Lumberyard Exporter" -message $message
|
||||
-button "Rename" -button "Ignore" -button "Cancel" -defaultButton "Rename"
|
||||
-cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
if ($action == "Rename")
|
||||
{
|
||||
$targetName = `rename $contents[0] ($contents[0] + $groupPostfix)`;
|
||||
}
|
||||
else if ($action == "Cancel")
|
||||
{
|
||||
// User cancels operation, do nothing and return
|
||||
return "";
|
||||
}
|
||||
// If choose "Ignore", keep the original name
|
||||
}
|
||||
}
|
||||
|
||||
// Create LUMBERYARD_EXPORT_GROUP and LUMBERYARD_GEOMETRYEXPORT_GROUP if needed.
|
||||
if( !`objExists LUMBERYARD_EXPORT_GROUP` )
|
||||
{
|
||||
// Create LUMBERYARD_EXPORT_GROUP
|
||||
group -empty -name LUMBERYARD_EXPORT_GROUP;
|
||||
}
|
||||
if( !`objExists LUMBERYARD_GEOMETRYEXPORT_GROUP` )
|
||||
{
|
||||
// Create LUMBERYARD_GEOMETRYEXPORT_GROUP
|
||||
group -empty -parent LUMBERYARD_EXPORT_GROUP -name LUMBERYARD_GEOMETRYEXPORT_GROUP;
|
||||
}
|
||||
|
||||
// Create the new node and make sure it's transforms are zeroed
|
||||
string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix();
|
||||
string $fullName = $lumberyardExportNodePrefix + $name;
|
||||
$newExportNode = `group -empty -name $fullName -parent LUMBERYARD_GEOMETRYEXPORT_GROUP`;
|
||||
xform -objectSpace -pivots 0 0 0 $newExportNode;
|
||||
|
||||
// Add attributes to all nodes
|
||||
cryExportAddAttributes;
|
||||
|
||||
// Set file type
|
||||
setAttr ($newExportNode+".fileType") ($fileType);
|
||||
// Set export target.
|
||||
string $longName[] = `ls -long $targetName`;
|
||||
// Exporter plugin expects leading | stripped from long paths
|
||||
$targetName = `substring $longName[0] 2 (size($longName[0]))`;
|
||||
setAttr ($newExportNode+".exportTarget") -type "string" ($targetName);
|
||||
|
||||
cryExportUpdateExportLists;
|
||||
|
||||
return $newExportNode;
|
||||
}
|
||||
|
||||
global proc cryToolsCreateCryExportNodeCreate()
|
||||
{
|
||||
if(`window -ex CRYNEWEXPORTNODE_WINDOW`)
|
||||
{
|
||||
// Create the new node and make sure it's transforms are zeroed
|
||||
string $name = `textField -q -text CRYTOOLS_NEWEXPORTNODE_NAME`;
|
||||
|
||||
// Set the fileType. Subtract 1 as the optionMenu index is 1 based and the attr is 0 based.
|
||||
int $fileType = `optionMenu -q -select CRYNEWEXPORTNODE_FILETYPE`;
|
||||
$fileType -= 1;
|
||||
|
||||
int $groupSelection = `checkBox -q -value CRYNEWEXPORTNODE_GROUPSELECTION`;
|
||||
|
||||
string $selection[];
|
||||
if( $groupSelection )
|
||||
{
|
||||
$selection = `ls -sl`;
|
||||
}
|
||||
|
||||
cryToolsCreateCryExportNodeCreateCore $name $fileType $selection;
|
||||
|
||||
cryToolsCreateCryExportNodeCloseWindow;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryToolsCreateCryExportNode( int $quietMode )
|
||||
{
|
||||
string $newName = "New";
|
||||
string $selection[] = `ls -sl`;
|
||||
int $hasSelection = size($selection) > 0;
|
||||
if( $hasSelection )
|
||||
{
|
||||
$newName = $selection[0];
|
||||
}
|
||||
|
||||
if( $quietMode )
|
||||
{
|
||||
int $fileType = 0;
|
||||
string $selection[] = `ls -sl`;
|
||||
cryToolsCreateCryExportNodeCreateCore $newName $fileType $selection;
|
||||
}
|
||||
else if(!`window -ex CRYNEWEXPORTNODE_WINDOW`)
|
||||
{
|
||||
int $pluginLoaded = `cryPluginIsLoaded`;
|
||||
if( !$pluginLoaded )
|
||||
{
|
||||
confirmDialog -title "Lumberyard Export" -message "The MayaCryExport plugin is not loaded." -button "OK";
|
||||
return;
|
||||
}
|
||||
|
||||
if(`windowPref -exists CRYNEWEXPORTNODE_WINDOW`)
|
||||
{
|
||||
windowPref -wh 400 150 -tlc `windowPref -q -topEdge CRYNEWEXPORTNODE_WINDOW` `windowPref -q -leftEdge CRYNEWEXPORTNODE_WINDOW` CRYNEWEXPORTNODE_WINDOW;
|
||||
//windowPref -remove CRYNEWEXPORTNODE_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Create CryExportNode" -widthHeight 400 180 -sizeable false -mnb false -mxb false CRYNEWEXPORTNODE_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 10 CRYNEWEXPORTNODE_MAINCOL;
|
||||
{
|
||||
rowLayout -numberOfColumns 2 -columnAttach 1 "right" 5 -columnWidth 1 100 -columnWidth 2 200 CRYNEWEXPORTNODE_NAMEROW;
|
||||
{
|
||||
text -label "Name";
|
||||
textField -text $newName CRYTOOLS_NEWEXPORTNODE_NAME;
|
||||
}
|
||||
setParent ..;
|
||||
rowLayout -numberOfColumns 2 -columnAttach 1 "right" 5 -columnWidth 1 100 -columnWidth 2 200 CRYNEWEXPORTNODE_FILETYPEROW;
|
||||
{
|
||||
text -label "File Type";
|
||||
optionMenu CRYNEWEXPORTNODE_FILETYPE;
|
||||
{
|
||||
string $enumString = `cryExportGetFileTypeEnumString`;
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $enumString ":" $tokens`;
|
||||
for( $i = 0;$i<$numTokens;$i++ )
|
||||
{
|
||||
menuItem -label $tokens[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
setParent ..;
|
||||
rowLayout -numberOfColumns 2 -columnAttach 1 "right" 5 -columnWidth 1 100 -columnWidth 2 200 CRYNEWEXPORTNODE_GROUPSELECTIONROW;
|
||||
{
|
||||
text "";
|
||||
string $annotation = "Moves the currently selected items into the new export node.";
|
||||
checkBox -annotation $annotation -value $hasSelection -label "Group Selection" CRYNEWEXPORTNODE_GROUPSELECTION;
|
||||
}
|
||||
setParent ..;
|
||||
rowLayout -numberOfColumns 2 -columnAttach 1 "right" 5 -columnWidth 1 100 -columnWidth 2 200 CRYNEWEXPORTNODE_CREATEGROUPNODEROW;
|
||||
{
|
||||
text "";
|
||||
string $annotation = "Create a `_group` node and put it under the new export node. If you also have `Group Selection` checked the selected items will be put under the `_group` node.";
|
||||
checkBox -annotation $annotation -value true -label "Create `_group` node" CRYNEWEXPORTNODE_CREATEGROUPNODE;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
$createbutton = `button -label "Create" -command ("cryToolsCreateCryExportNodeCreate")`;
|
||||
$closebutton = `button -label "Close" -command ("cryToolsCreateCryExportNodeCloseWindow")`;
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYNEWEXPORTNODE_MAINCOL "top" 15
|
||||
-attachForm CRYNEWEXPORTNODE_MAINCOL "left" 5
|
||||
-attachForm CRYNEWEXPORTNODE_MAINCOL "right" 5
|
||||
-attachControl CRYNEWEXPORTNODE_MAINCOL "bottom" 5 $closebutton
|
||||
|
||||
-attachForm $createbutton "bottom" 5
|
||||
-attachForm $createbutton "left" 5
|
||||
-attachPosition $createbutton "right" 5 50
|
||||
-attachNone $createbutton "top"
|
||||
-attachForm $closebutton "bottom" 5
|
||||
-attachPosition $closebutton "left" 5 50
|
||||
-attachForm $closebutton "right" 5
|
||||
-attachNone $closebutton "top"
|
||||
$layout1;
|
||||
|
||||
showWindow CRYNEWEXPORTNODE_WINDOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
showWindow CRYNEWEXPORTNODE_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryToolsCreateMultipleCryExportNodes()
|
||||
{
|
||||
string $result = `confirmDialog -title "Lumberyard Tools" -message "Create an export node and group for each of the selected nodes?" -button "Yes" -button "Cancel" -defaultButton "Yes" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
if( $result != "Yes" )
|
||||
return;
|
||||
|
||||
string $newName = "New";
|
||||
int $fileType = 0;
|
||||
string $selection[] = `ls -sl`;
|
||||
|
||||
string $newExportNodes[];
|
||||
for( $item in $selection )
|
||||
{
|
||||
string $itemArray[];
|
||||
$itemArray[0] = $item;
|
||||
string $newName = $item;
|
||||
|
||||
string $newExportNode = `cryToolsCreateCryExportNodeCreateCore $newName $fileType $itemArray`;
|
||||
$newExportNodes[size($newExportNodes)] = $newExportNode;
|
||||
}
|
||||
|
||||
select -cl;
|
||||
for( $node in $newExportNodes )
|
||||
{
|
||||
select -add $node;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryToolsCreateCryHelperNode()
|
||||
{
|
||||
string $newNode = `createNode cryHelperNode`;
|
||||
string $newParent = firstParentOf($newNode);
|
||||
|
||||
rename $newNode "cryHelperShape#";
|
||||
rename $newParent "cryHelper#";
|
||||
}
|
||||
|
||||
global proc cryToolsFixCameraPivots()
|
||||
{
|
||||
string $cameras[] = `ls -l -sl -type camera`;
|
||||
if( size($cameras) == 0 )
|
||||
{
|
||||
string $message = "This will attempt to reset the pivots for all cameras in the scene.";
|
||||
string $result = `confirmDialog -title "Lumberyard Tools" -message $message -button "Ok" -button "Cancel" -defaultButton "Ok" -cancelButton "Cancel" -dismissString "Cancel"`;
|
||||
if( $result != "Ok" )
|
||||
return;
|
||||
|
||||
$cameras = `ls -l -type camera`;
|
||||
}
|
||||
|
||||
for( $camera in $cameras )
|
||||
{
|
||||
string $camParent = firstParentOf($camera);
|
||||
if( `nodeType $camParent` == "transform" )
|
||||
{
|
||||
vector $rotPivTrans = `getAttr ($camParent+".rotatePivotTranslate")`;
|
||||
|
||||
catchQuiet( `setAttr ($camParent+".rotatePivotTranslate") 0 0 0` );
|
||||
catchQuiet( `setAttr ($camParent+".scalePivotTranslate") 0 0 0` );
|
||||
catchQuiet( `setAttr ($camParent+".rotatePivot") 0 0 0` );
|
||||
catchQuiet( `setAttr ($camParent+".scalePivot") 0 0 0` );
|
||||
|
||||
catchQuiet( `xform -r -translation ($rotPivTrans.x) ($rotPivTrans.y) ($rotPivTrans.z) $camParent` );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert units and remove the postfixes.
|
||||
proc float cryToolsConvertUnit( float $inVal, string $from, string $to )
|
||||
{
|
||||
string $floatStr = `convertUnit -f $from -t $to (""+$inVal)`;
|
||||
|
||||
$floatStr = `substitute "m" $floatStr ""`;
|
||||
$floatStr = `substitute "rad" $floatStr ""`;
|
||||
|
||||
float $f = $floatStr;
|
||||
|
||||
return $f;
|
||||
}
|
||||
|
||||
global proc cryOutputAttachmentHelpers()
|
||||
{
|
||||
print("======== Begin Attachment Helpers ========\n");
|
||||
|
||||
string $selected[] = `ls -sl`;
|
||||
for( $item in $selected )
|
||||
{
|
||||
string $useItem = "";
|
||||
if( `objectType $item` == "locator" )
|
||||
{
|
||||
string $parents[] = `listRelatives -parent $item`;
|
||||
if( size($parents) > 0 )
|
||||
{
|
||||
$count = stringArrayContains($parents[0], $selected);
|
||||
if( $count == 0 ) // Dont process this locator if the parent node is alos in the selected list.
|
||||
$useItem = $parents[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string $children[] = `listRelatives -children $item`;
|
||||
for( $child in $children )
|
||||
{
|
||||
if( `objectType $child` == "locator" )
|
||||
{
|
||||
$useItem = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string $currentLinearUnit = `currentUnit -q -fullName -linear`;
|
||||
string $currentAngleUnit = `currentUnit -q -fullName -angle`;
|
||||
|
||||
if( size($useItem) > 0 && `objectType $useItem` == "transform" )
|
||||
{
|
||||
float $trans[] = `xform -q -translation $useItem`;
|
||||
float $rot[] = `xform -q -rotation $useItem`;
|
||||
|
||||
$trans[0] = `cryToolsConvertUnit $trans[0] $currentLinearUnit "meter"`;
|
||||
$trans[1] = `cryToolsConvertUnit $trans[1] $currentLinearUnit "meter"`;
|
||||
$trans[2] = `cryToolsConvertUnit $trans[2] $currentLinearUnit "meter"`;
|
||||
|
||||
$rot[0] = `cryToolsConvertUnit $rot[0] $currentAngleUnit "radian"`;
|
||||
$rot[1] = `cryToolsConvertUnit $rot[1] $currentAngleUnit "radian"`;
|
||||
$rot[2] = `cryToolsConvertUnit $rot[2] $currentAngleUnit "radian"`;
|
||||
|
||||
string $quatStr = `cryMayaSupportPlugin convertToQuat $rot[0] $rot[1] $rot[2]`;
|
||||
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $quatStr " " $tokens`;
|
||||
if( $numTokens == 4 )
|
||||
{
|
||||
float $quat[];
|
||||
|
||||
$quat[0] = $tokens[0];
|
||||
$quat[1] = $tokens[1];
|
||||
$quat[2] = $tokens[2];
|
||||
$quat[3] = $tokens[3];
|
||||
|
||||
string $output = (" <Attachment AName=\"" + $useItem + "\"");
|
||||
$output += (" Type=\"CA_BONE\"");
|
||||
$output += (" Rotation=\"" + $quat[3] + "," + $quat[0] + "," + $quat[1] + "," + $quat[2] + "\"");
|
||||
$output += (" Position=\"" + $trans[0] + "," + $trans[1] + "," + $trans[2] + "\"");
|
||||
$output += (" BoneName=\"bone_" + $useItem + "\"");
|
||||
$output += (" Binding=\"\"");
|
||||
$output += (" Flags=\"0\"/>");
|
||||
|
||||
print ($output + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
print("======== End Attachment Helpers ========\n");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Cry Tools Menu
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
global proc cryToolsRemoveMenu()
|
||||
{
|
||||
if( `control -q -exists CRYTOOLS_MENU` )
|
||||
{
|
||||
deleteUI -menu CRYTOOLS_MENU;
|
||||
}
|
||||
}
|
||||
|
||||
proc createCryToolsMenu()
|
||||
{
|
||||
// Remove the menu first
|
||||
cryToolsRemoveMenu;
|
||||
|
||||
global string $gMainWindow;
|
||||
|
||||
setParent $gMainWindow;
|
||||
menu -l "Lumberyard Tools" -p MayaWindow -to 1 -aob true CRYTOOLS_MENU;
|
||||
|
||||
menuItem -label "Create LumberyardExportNode" -command "cryToolsCreateCryExportNode 0";
|
||||
menuItem -label "Create CryHelperNode" -command "cryToolsCreateCryHelperNode";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Zero Joint Rotations" -command "cryAnimZeroJointRotation";
|
||||
menuItem -label "Anim Manager" -command "cryAnimManagerWin";
|
||||
menuItem -label "Output Attachment Helpers" -command "cryOutputAttachmentHelpers";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Load Plug-in" -command "cryLoadPlugin";
|
||||
menuItem -label "Unload Plug-in" -command "cryUnloadPlugin";
|
||||
menuItem -divider true;
|
||||
menuItem -label "Reset Camera Pivots" -command "cryToolsFixCameraPivots";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Cry Tools UI
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
global proc cryToolsUICloseWindow()
|
||||
{
|
||||
deleteUI -window CRYTOOLS_WINDOW;
|
||||
}
|
||||
|
||||
proc createCryToolsWindow()
|
||||
{
|
||||
if(!`window -ex CRYTOOLS_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYTOOLS_WINDOW`)
|
||||
{
|
||||
windowPref -wh 200 480 -tlc `windowPref -q -topEdge CRYTOOLS_WINDOW` `windowPref -q -leftEdge CRYTOOLS_WINDOW` CRYTOOLS_WINDOW;
|
||||
//windowPref -remove CRYTOOLS_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Lumberyard Tools" -widthHeight 200 480 -sizeable true -mnb false -mxb false CRYTOOLS_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 15 CRYTOOLS_MAINCOL;
|
||||
{
|
||||
frameLayout -label "Node Tools" -borderStyle "out" -collapsable true -marginHeight 5 -marginWidth 5;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 5;
|
||||
{
|
||||
button -label "Create LumberyardExportNode" -command "cryToolsCreateCryExportNode 0";
|
||||
button -label "Create Multiple LumberyardExportNodes" -command "cryToolsCreateMultipleCryExportNodes";
|
||||
button -label "Create CryHelperNode" -command "cryToolsCreateCryHelperNode";
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
frameLayout -label "Animation Tools" -borderStyle "out" -collapsable true -marginHeight 5 -marginWidth 5;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 5;
|
||||
{
|
||||
button -label "Zero Joint Rotations" -command "cryAnimZeroJointRotation";
|
||||
button -label "Anim Manager" -command "cryAnimManagerWin";
|
||||
button -label "Output Attachment Helpers" -command "cryOutputAttachmentHelpers";
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
frameLayout -label "Plug-in Tools" -borderStyle "out" -collapsable true -marginHeight 5 -marginWidth 5;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 5;
|
||||
{
|
||||
button -label "Load Plug-in" -command "cryLoadPlugin";
|
||||
button -label "Unload Plug-in" -command "cryUnloadPlugin";
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
frameLayout -label "Helpers" -borderStyle "out" -collapsable true -marginHeight 5 -marginWidth 5;
|
||||
{
|
||||
columnLayout -adjustableColumn true -rowSpacing 5;
|
||||
{
|
||||
button -label "Reset Camera Pivots" -command "cryToolsFixCameraPivots";
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
$closebutton = `button -label "Close" -command ("cryToolsUICloseWindow")`;
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYTOOLS_MAINCOL "top" 5
|
||||
-attachForm CRYTOOLS_MAINCOL "left" 5
|
||||
-attachForm CRYTOOLS_MAINCOL "right" 5
|
||||
-attachControl CRYTOOLS_MAINCOL "bottom" 5 $closebutton
|
||||
|
||||
-attachForm $closebutton "bottom" 5
|
||||
-attachForm $closebutton "left" 5
|
||||
-attachForm $closebutton "right" 5
|
||||
-attachNone $closebutton "top"
|
||||
$layout1;
|
||||
}
|
||||
|
||||
showWindow CRYTOOLS_WINDOW;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Window and menu creation entry functions.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
proc cryToolsSourceDependencies()
|
||||
{
|
||||
eval("source cryExport.mel");
|
||||
eval("source cryAnim.mel");
|
||||
eval("source LumberyardUtilities.mel");
|
||||
//eval("source cryExportSettings.mel");
|
||||
}
|
||||
|
||||
global proc cryToolsWin()
|
||||
{
|
||||
cryToolsSourceDependencies;
|
||||
createCryToolsWindow;
|
||||
}
|
||||
|
||||
global proc cryToolsMenu()
|
||||
{
|
||||
cryToolsSourceDependencies;
|
||||
createCryToolsMenu;
|
||||
}
|
||||
|
||||
global proc cryToolsMenuRemove()
|
||||
{
|
||||
cryToolsRemoveMenu;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Shelf functions.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
global proc string cryToolsGetShelfNameFromScriptName( string $scriptName )
|
||||
{
|
||||
string $shelfName = $scriptName;
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $scriptName "_." $tokens`;
|
||||
if( $numTokens == 3 )
|
||||
{
|
||||
$shelfName = $tokens[1];
|
||||
}
|
||||
return $shelfName;
|
||||
}
|
||||
|
||||
global proc cryToolsLoadShelf( string $scriptName )
|
||||
{
|
||||
string $shelfName = `cryToolsGetShelfNameFromScriptName $scriptName`;
|
||||
if (`shelfLayout -exists $shelfName`)
|
||||
{
|
||||
deleteUI $shelfName;
|
||||
}
|
||||
evalDeferred( "loadNewShelf "+$scriptName );
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
// This script needs to know its own mel name. If you change the file name, change this.
|
||||
global string $cryUDP_nameOfScript = "cryUDP.mel";
|
||||
|
||||
|
||||
|
||||
|
||||
global proc UDPCloseWindow()
|
||||
{
|
||||
if(`window -ex CRYUDP_WINDOW`)
|
||||
deleteUI -window CRYUDP_WINDOW;
|
||||
}
|
||||
|
||||
global proc UDPSave(string $value)
|
||||
{
|
||||
string $selected[];
|
||||
$selected = `ls -sl`;
|
||||
if( size($selected) > 0 )
|
||||
{
|
||||
string $node = $selected[0];
|
||||
|
||||
// Add the UDP attribute
|
||||
if( !`attributeExists "UDP" $node` )
|
||||
addAttr -ln UDP -dt "string" $node;
|
||||
|
||||
//string $value = `scrollField -q -text UDP_LINES`;
|
||||
setAttr -type "string" ($node+".UDP") $value;
|
||||
|
||||
//button -e -enable false UDP_SAVEBUTTON;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
global proc UDPUpdate()
|
||||
{
|
||||
int $set = 0;
|
||||
string $selected[];
|
||||
$selected = `ls -sl`;
|
||||
string $nodeName = "<None>";
|
||||
if( size($selected) > 0 )
|
||||
{
|
||||
string $node = $selected[0];
|
||||
$nodeName = $node;
|
||||
|
||||
if( `attributeExists "UDP" $node` )
|
||||
{
|
||||
string $value = `getAttr ($node+".UDP")`;
|
||||
scrollField -e -text $value UDP_LINES;
|
||||
$set = 1;
|
||||
}
|
||||
}
|
||||
if( $set == 0 )
|
||||
scrollField -e -text "" UDP_LINES;
|
||||
|
||||
text -e -label (" Node : " + $nodeName) UDP_NODE;
|
||||
|
||||
button -e -enable false UDP_SAVEBUTTON;
|
||||
}
|
||||
|
||||
|
||||
global proc cryPopulatePopup()
|
||||
{
|
||||
string $scriptPath = `whatIs "cryUDP.mel"`;
|
||||
string $path = `match "[^ ]*$" $scriptPath`;
|
||||
$path = dirname($path);
|
||||
string $textFile = $path + "/cryUDP_Values.txt";
|
||||
print $textFile;
|
||||
print "\n";
|
||||
|
||||
$fileId=`fopen $textFile "r"`;
|
||||
|
||||
string $nextLine = `fgetline $fileId`;
|
||||
while ( size( $nextLine ) > 0 )
|
||||
{
|
||||
//$nextLine = ($nextLine + "\n");
|
||||
string $noReturn = `substitute "\n" $nextLine ""`;
|
||||
print ("scrollField -e -it " + $noReturn + " -ip 0 UDP_LINES;\n");
|
||||
menuItem -label $nextLine -c ("scrollField -e -it \"" + $noReturn + "\" -ip 0 UDP_LINES; scrollField -e -it \"\\n\" -ip 0 UDP_LINES;") -parent UDP_OPTIONMENU;
|
||||
$nextLine = `fgetline $fileId`;
|
||||
}
|
||||
|
||||
|
||||
fclose $fileId;
|
||||
}
|
||||
|
||||
|
||||
global proc cryUDPWindow( )
|
||||
{
|
||||
if(!`window -ex CRYUDP_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYUDP_WINDOW`)
|
||||
{
|
||||
windowPref -wh 350 210 -tlc `windowPref -q -topEdge CRYUDP_WINDOW` `windowPref -q -leftEdge CRYUDP_WINDOW` CRYUDP_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "User Defined Properties" -widthHeight 350 210 -sizeable false -mnb false -mxb false CRYUDP_WINDOW;
|
||||
|
||||
$layout1 = `formLayout -numberOfDivisions 100`;
|
||||
|
||||
text -label "Node : <None>" -align "left" -font "boldLabelFont" UDP_NODE;
|
||||
|
||||
scrollField -keyPressCommand ("button -e -enable true UDP_SAVEBUTTON") UDP_LINES;
|
||||
|
||||
popupMenu -parent UDP_LINES UDP_OPTIONMENU;
|
||||
//menuItem -label "test\n" -c "scrollField -e -it test -ip 0 UDP_LINES;" -parent UDP_OPTIONMENU;
|
||||
cryPopulatePopup();
|
||||
|
||||
button -label "Save" -command ("UDPSave(`scrollField -q -text UDP_LINES`); button -e -enable false UDP_SAVEBUTTON;") UDP_SAVEBUTTON;
|
||||
button -label "Close" -command ("UDPCloseWindow") UDP_CLOSEBUTTON;
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm UDP_NODE "top" 5
|
||||
-attachForm UDP_NODE "left" 5
|
||||
-attachForm UDP_NODE "right" 5
|
||||
-attachNone UDP_NODE "bottom"
|
||||
|
||||
//-attachControl UDP_OPTIONMENU "top" 5 UDP_NODE
|
||||
//-attachForm UDP_OPTIONMENU "left" 5
|
||||
//-attachForm UDP_OPTIONMENU "right" 5
|
||||
//-attachControl UDP_OPTIONMENU "bottom" 5 UDP_LINES
|
||||
|
||||
-attachControl UDP_LINES "top" 5 UDP_NODE
|
||||
-attachForm UDP_LINES "left" 5
|
||||
-attachForm UDP_LINES "right" 5
|
||||
-attachControl UDP_LINES "bottom" 5 UDP_SAVEBUTTON
|
||||
|
||||
-attachControl UDP_SAVEBUTTON "bottom" 5 UDP_CLOSEBUTTON
|
||||
-attachForm UDP_SAVEBUTTON "left" 5
|
||||
-attachForm UDP_SAVEBUTTON "right" 5
|
||||
-attachNone UDP_SAVEBUTTON "top"
|
||||
|
||||
-attachForm UDP_CLOSEBUTTON "bottom" 5
|
||||
-attachForm UDP_CLOSEBUTTON "left" 5
|
||||
-attachForm UDP_CLOSEBUTTON "right" 5
|
||||
-attachNone UDP_CLOSEBUTTON "top"
|
||||
$layout1;
|
||||
|
||||
UDPUpdate();
|
||||
|
||||
showWindow CRYUDP_WINDOW;
|
||||
|
||||
scriptJob -event "SelectionChanged" "UDPUpdate" -parent "CRYUDP_WINDOW";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
no_explosion_occlusion
|
||||
other_rendermesh
|
||||
colltype_player
|
||||
box
|
||||
cylinder
|
||||
capsule
|
||||
sphere
|
||||
notaprim
|
||||
no_hit_refinement
|
||||
dynamic
|
||||
entity
|
||||
gameplay_critical
|
||||
player_can_break
|
||||
childof_unbroken
|
||||
mass=
|
||||
density=
|
||||
pieces=
|
||||
limit=
|
||||
bend=
|
||||
twist=
|
||||
pull=
|
||||
push=
|
||||
shift=
|
||||
constraint_limit=
|
||||
constraint_minang=
|
||||
consrtaint_maxang=
|
||||
constraint_damping=
|
||||
consrtaint_collides=
|
||||
stiffness=
|
||||
hardness=
|
||||
max_stretch=
|
||||
max_impulse=
|
||||
skin_dist=
|
||||
thickness=
|
||||
notaprim
|
||||
explosion_scale=
|
||||
@@ -0,0 +1,599 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
global int $g_enableValidateHelpWindow = false;
|
||||
|
||||
proc string cryValidateGetMessageList()
|
||||
{
|
||||
string $s;
|
||||
$s = `cryValidatePlugin messages getMessageList`;
|
||||
return $s;
|
||||
}
|
||||
|
||||
global proc string[] cryValidateDecodeMessageString( string $message )
|
||||
{
|
||||
string $decode[];
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $message "," $tokens`;
|
||||
if( $numTokens == 5 )
|
||||
{
|
||||
$decode[0] = $tokens[0]; // Enable
|
||||
$decode[1] = $tokens[1]; // IsCritical
|
||||
$decode[2] = $tokens[2]; // MessageType
|
||||
$decode[3] = $tokens[3]; // FocusNode
|
||||
$decode[4] = $tokens[4]; // MessageText
|
||||
}
|
||||
|
||||
return $decode;
|
||||
}
|
||||
|
||||
proc int cryValidateAllowExport()
|
||||
{
|
||||
string $s;
|
||||
$s = `cryValidatePlugin messages messageSource`;
|
||||
if( $s == "EXPORT" )
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
proc cryValidateShowIgnoreState()
|
||||
{
|
||||
// Disable the messages in the list
|
||||
string $s;
|
||||
$s = `cryValidateGetMessageList`;
|
||||
|
||||
string $messages[];
|
||||
$messageCount = `tokenize $s ";" $messages`;
|
||||
|
||||
string $childControls[];
|
||||
$childControls = `layout -q -childArray CRYVALIDATE_COLUMNLAYOUT`;
|
||||
|
||||
layout -e -visible 0 CRYVALIDATE_COLUMNLAYOUT;
|
||||
int $allDisabled = 1;
|
||||
if( size($s) > 0 )
|
||||
{
|
||||
int $childNum = 0;
|
||||
for( $message in $messages )
|
||||
{
|
||||
string $decode[];
|
||||
$decode = `cryValidateDecodeMessageString $message`;
|
||||
|
||||
$child = $childControls[$childNum];
|
||||
|
||||
string $rowChildren[];
|
||||
$rowChildren = `layout -q -childArray $child`;
|
||||
|
||||
int $enable = $decode[0];
|
||||
$enable = 1-$enable;
|
||||
int $isCritical = $decode[1];
|
||||
|
||||
float $colG = .85;
|
||||
if( $isCritical )
|
||||
$colG = .65;
|
||||
|
||||
$messageControl = $rowChildren[0];
|
||||
|
||||
if( $enable == 1 )
|
||||
{
|
||||
control -e -enable true -bgc .95 $colG .65 $messageControl;
|
||||
$allDisabled = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
control -e -enable false -bgc .4 .4 .4 $messageControl;
|
||||
}
|
||||
|
||||
$childNum++;
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the export button if all the errors haven't been ignored.
|
||||
if( $allDisabled )
|
||||
{
|
||||
button -e -enable true CRYVALIDATE_EXPORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
button -e -enable false CRYVALIDATE_EXPORT;
|
||||
}
|
||||
|
||||
layout -e -visible 1 CRYVALIDATE_COLUMNLAYOUT;
|
||||
}
|
||||
|
||||
global proc cryValidateCopyMessageText( string $messageText )
|
||||
{
|
||||
cryMayaSupportPlugin copyToClipboard $messageText;
|
||||
}
|
||||
|
||||
proc cryValidatePopulateMessageList()
|
||||
{
|
||||
global int $g_enableValidateHelpWindow;
|
||||
|
||||
setParent CRYVALIDATE_COLUMNLAYOUT;
|
||||
string $childControls[];
|
||||
$childControls = `layout -q -childArray CRYVALIDATE_COLUMNLAYOUT`;
|
||||
|
||||
for( $child in $childControls )
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
|
||||
string $s;
|
||||
$s = `cryValidateGetMessageList`;
|
||||
|
||||
if( size($s) > 0 )
|
||||
{
|
||||
string $messages[];
|
||||
$messageCount = `tokenize $s ";" $messages`;
|
||||
|
||||
int $messageNum = 0;
|
||||
for( $message in $messages )
|
||||
{
|
||||
string $decode[];
|
||||
$decode = `cryValidateDecodeMessageString $message`;
|
||||
string $messageType = $decode[2];
|
||||
|
||||
$rowName = `rowLayout -numberOfColumns 3 -columnWidth3 300 65 65 -adjustableColumn 1 -columnAlign 1 "left"
|
||||
-columnAlign 2 "center" -columnAlign 3 "center"
|
||||
-columnAttach 2 "both" 0 -columnAttach 3 "both" 0 -bgc .4 .4 .4`;
|
||||
{
|
||||
int $isCritical = $decode[1];
|
||||
int $hasFocus = 1;
|
||||
if( size($decode[3]) == 0 || $decode[3] == "*" )
|
||||
$hasFocus = 0;
|
||||
int $allowIgnoreAllType = 1;
|
||||
if( $isCritical )
|
||||
$allowIgnoreAllType = 0;
|
||||
|
||||
int $allowExport = `cryValidateAllowExport`;
|
||||
int $showIgnore = 1;
|
||||
if( $allowExport == 0 )
|
||||
$showIgnore = 0;
|
||||
|
||||
string $messageText = $decode[4];
|
||||
$messageTextControl = `text -h 22 -label (" "+$messageText)`;
|
||||
$ignoreButton = `button -align "center" -label "Ignore" -enable (1-$isCritical) -command ( "cryValidateIgnoreMessage "+$messageNum )`;
|
||||
$focusButton = `button -align "center" -label "Focus" -enable $hasFocus -command ( "cryValidateFocus \""+$decode[3]+"\"" )`;
|
||||
|
||||
if( $showIgnore == 0 )
|
||||
{
|
||||
button -e -visible false $ignoreButton;
|
||||
rowLayout -e -columnWidth 2 1 $rowName;
|
||||
}
|
||||
|
||||
popupMenu -parent $rowName -button 3 CRYVALIDATE_IDMENU;
|
||||
{
|
||||
menuItem -label "Copy message text" -command ( "cryValidateCopyMessageText \""+$messageText+"\"" );
|
||||
menuItem -divider true;
|
||||
if( $showIgnore == 1 )
|
||||
{
|
||||
menuItem -label "Ignore" -enable (1-$isCritical) -command ( "cryValidateIgnoreMessage "+$messageNum );
|
||||
menuItem -label "Ignore all messages of this type" -enable $allowIgnoreAllType -command ( "cryValidateIgnoreMessageType "+$messageNum );
|
||||
menuItem -divider true;
|
||||
}
|
||||
menuItem -label "Focus" -enable $hasFocus -command ( "cryValidateFocus \""+$decode[3]+"\"" );
|
||||
menuItem -divider true;
|
||||
menuItem -label "Validate Message Settings" -command ("cryValidateMessageControl \""+$decode[2]+"\"");
|
||||
if ($g_enableValidateHelpWindow)
|
||||
{
|
||||
menuItem -label "Validate Help" -command ("cryValidateHelpWindow");
|
||||
}
|
||||
if( `cryValidateFixCanFix $messageType` )
|
||||
{
|
||||
menuItem -divider true;
|
||||
menuItem -label "Auto Fix Problem" -command("cryValidateFix " +$messageType+" \""+$decode[3]+"\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
setParent ..;
|
||||
$messageNum++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text -label "No validate messages." -align "center" -bgc .4 .4 .4;
|
||||
}
|
||||
|
||||
cryValidateShowIgnoreState;
|
||||
}
|
||||
|
||||
global proc cryValidateIgnoreMessage( int $messageNum )
|
||||
{
|
||||
cryValidatePlugin messages ignoreMessage $messageNum;
|
||||
cryValidateShowIgnoreState;
|
||||
}
|
||||
|
||||
global proc cryValidateIgnoreMessageType( int $inMessageNum )
|
||||
{
|
||||
string $s;
|
||||
$s = `cryValidateGetMessageList`;
|
||||
if( size($s) > 0 )
|
||||
{
|
||||
string $messages[];
|
||||
$messageCount = `tokenize $s ";" $messages`;
|
||||
|
||||
string $inMessageType = "";
|
||||
if( $inMessageNum < size($messages) )
|
||||
{
|
||||
string $message = $messages[$inMessageNum];
|
||||
string $decode[];
|
||||
$decode = `cryValidateDecodeMessageString $message`;
|
||||
$inMessageType = $decode[2];
|
||||
}
|
||||
|
||||
int $messageNum = 0;
|
||||
for( $message in $messages )
|
||||
{
|
||||
string $decode[];
|
||||
$decode = `cryValidateDecodeMessageString $message`;
|
||||
string $messageType = $decode[2];
|
||||
if( $messageType == $inMessageType )
|
||||
{
|
||||
cryValidatePlugin messages ignoreMessage $messageNum;
|
||||
}
|
||||
$messageNum++;
|
||||
}
|
||||
}
|
||||
cryValidateShowIgnoreState;
|
||||
}
|
||||
|
||||
global proc cryValidateFocus( string $focusNode )
|
||||
{
|
||||
if( `startsWith $focusNode "loc"` )
|
||||
{
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $focusNode ":" $tokens`;
|
||||
|
||||
if( $numTokens == 4 ) // Should be "loc x y z"
|
||||
{
|
||||
string $userUnit = `currentUnit -q -linear`;
|
||||
// It seems that some RC errors give values that are 100 times smaller then meters. TODO: work out whats going on with RC.
|
||||
float $x = (float)(`strip $tokens[1]`) * 100.0;
|
||||
float $y = (float)(`strip $tokens[2]`) * 100.0;
|
||||
float $z = (float)(`strip $tokens[3]`) * 100.0;
|
||||
|
||||
// Convert to the current UI unit.
|
||||
$x = `convertUnit -fromUnit "meter" -toUnit $userUnit (""+$x)`; // Need to concat it to a string as convertUnit will only work with a string
|
||||
$y = `convertUnit -fromUnit "meter" -toUnit $userUnit (""+$y)`;
|
||||
$z = `convertUnit -fromUnit "meter" -toUnit $userUnit (""+$z)`;
|
||||
|
||||
// Swap for y-up if needed
|
||||
if( `upAxis -q -axis` == "y" )
|
||||
{
|
||||
$temp = $y;
|
||||
$y = $z;
|
||||
$z = -$temp;
|
||||
}
|
||||
|
||||
string $focusLocatorName = "CRYFOCUSLOCATOR";
|
||||
if( !`objExists $focusLocatorName` )
|
||||
{
|
||||
spaceLocator -p 0 0 0 -absolute -n $focusLocatorName;
|
||||
xform -absolute -translation $x $y $z $focusLocatorName;
|
||||
}
|
||||
else
|
||||
{
|
||||
spaceLocator -e -p 0 0 0 -absolute $focusLocatorName;
|
||||
xform -absolute -translation $x $y $z $focusLocatorName;
|
||||
}
|
||||
|
||||
select $focusLocatorName;
|
||||
fitPanel -selected;
|
||||
}
|
||||
}
|
||||
else if( $focusNode != "*" )
|
||||
{
|
||||
eval("select -r "+$focusNode);
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryValidateCloseWindow()
|
||||
{
|
||||
if( `window -exists CRYVALIDATE_WINDOW` )
|
||||
{
|
||||
deleteUI -window CRYVALIDATE_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryValidateCloseAndReset()
|
||||
{
|
||||
cryValidateCloseWindow;
|
||||
cryValidatePlugin reset; // Remove all messages and un-mark any ignored ones.
|
||||
}
|
||||
|
||||
global proc cryValidateExport()
|
||||
{
|
||||
// Tell the exporter to use the same options as the last time it was run.
|
||||
string $options = "";
|
||||
$options += "cryExportType=postValidateReexport" + ";";
|
||||
|
||||
file -op $options -typ "MayaCryExport" -pr -ea "dummyExportName";
|
||||
}
|
||||
|
||||
global proc cryValidateRevalidate()
|
||||
{
|
||||
cryValidateCloseWindow;
|
||||
evalDeferred( "cryValidatePlugin recheck" );
|
||||
}
|
||||
|
||||
global proc cryValidateCreateControls( int $selected )
|
||||
{
|
||||
global int $g_enableValidateHelpWindow;
|
||||
// Save the window prefs. We need to do this as the window will move to the location in the prefs when
|
||||
// the main form layout is deleted.
|
||||
windowPref -saveAll;
|
||||
|
||||
if( `layout -exists CRYVALIDATE_FORMLAYOUT` )
|
||||
return;
|
||||
|
||||
formLayout -numberOfDivisions 100 -visible false CRYVALIDATE_FORMLAYOUT;
|
||||
{
|
||||
popupMenu -button 3 CRYVALIDATE_FORMIDMENU;
|
||||
{
|
||||
menuItem -label "Validate Message Settings" -command ("cryValidateMessageControl \"\"");
|
||||
if ($g_enableValidateHelpWindow)
|
||||
{
|
||||
menuItem -label "Validate Help" -command ("cryValidateHelpWindow");
|
||||
}
|
||||
}
|
||||
scrollLayout -childResizable true -hst 0 -vst 15 -bgc .4 .4 .4 CRYVALIDATE_SCROLLLAYOUT;
|
||||
{
|
||||
columnLayout -adjustableColumn true -columnOffset "both" 5 -rowSpacing 5 -bgc .4 .4 .4 CRYVALIDATE_COLUMNLAYOUT;
|
||||
{
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
button -label "Continue Export" -command ("cryValidateExport") CRYVALIDATE_EXPORT;
|
||||
button -label "Re-Validate" -command ("cryValidateRevalidate") CRYVALIDATE_REVALIDATE;
|
||||
button -label "Close" -command ("cryValidateCloseAndReset") CRYVALIDATE_CLOSE;
|
||||
}
|
||||
|
||||
// Show or hide the export button
|
||||
int $enableExport = `cryValidateAllowExport`;
|
||||
int $firstAttach = 0;
|
||||
int $secondAttach = 0;
|
||||
if( $enableExport )
|
||||
{
|
||||
button -e -visible true CRYVALIDATE_EXPORT;
|
||||
$firstAttach = 33;
|
||||
$secondAttach = 66;
|
||||
}
|
||||
else
|
||||
{
|
||||
button -e -visible false CRYVALIDATE_EXPORT;
|
||||
$firstAttach = 0;
|
||||
$secondAttach = 50;
|
||||
}
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYVALIDATE_SCROLLLAYOUT "top" 5
|
||||
-attachForm CRYVALIDATE_SCROLLLAYOUT "left" 5
|
||||
-attachForm CRYVALIDATE_SCROLLLAYOUT "right" 5
|
||||
-attachControl CRYVALIDATE_SCROLLLAYOUT "bottom" 5 CRYVALIDATE_CLOSE
|
||||
|
||||
-attachForm CRYVALIDATE_EXPORT "bottom" 5
|
||||
-attachForm CRYVALIDATE_EXPORT "left" 5
|
||||
-attachPosition CRYVALIDATE_EXPORT "right" 5 $firstAttach
|
||||
-attachNone CRYVALIDATE_EXPORT "top"
|
||||
|
||||
-attachForm CRYVALIDATE_REVALIDATE "bottom" 5
|
||||
-attachPosition CRYVALIDATE_REVALIDATE "left" 5 $firstAttach
|
||||
-attachPosition CRYVALIDATE_REVALIDATE "right" 5 $secondAttach
|
||||
-attachNone CRYVALIDATE_REVALIDATE "top"
|
||||
|
||||
-attachForm CRYVALIDATE_CLOSE "bottom" 5
|
||||
-attachPosition CRYVALIDATE_CLOSE "left" 5 $secondAttach
|
||||
-attachForm CRYVALIDATE_CLOSE "right" 5
|
||||
-attachNone CRYVALIDATE_CLOSE "top"
|
||||
CRYVALIDATE_FORMLAYOUT;
|
||||
|
||||
cryValidatePopulateMessageList;
|
||||
|
||||
formLayout -e -visible true CRYVALIDATE_FORMLAYOUT;
|
||||
}
|
||||
|
||||
proc cryValidateCreateWindow()
|
||||
{
|
||||
global int $g_enableValidateHelpWindow;
|
||||
// If the window exists but is not visible, close it - and reset the messages.
|
||||
if( `window -ex CRYVALIDATE_WINDOW` && !`window -q -vis CRYVALIDATE_WINDOW`)
|
||||
{
|
||||
cryValidateCloseAndReset;
|
||||
}
|
||||
|
||||
if(!`window -ex CRYVALIDATE_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYVALIDATE_WINDOW`)
|
||||
{
|
||||
windowPref -wh 800 400 -tlc `windowPref -q -topEdge CRYVALIDATE_WINDOW` `windowPref -q -leftEdge CRYVALIDATE_WINDOW` CRYVALIDATE_WINDOW;
|
||||
//windowPref -remove CRYVALIDATE_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Lumberyard Validate" -sizeable true -mnb false -mxb false CRYVALIDATE_WINDOW;
|
||||
|
||||
cryValidateCreateControls 0;
|
||||
|
||||
showWindow CRYVALIDATE_WINDOW;
|
||||
|
||||
int $dontShow = `cryValidateHelpLoadDontShow`;
|
||||
if( !$dontShow && $g_enableValidateHelpWindow )
|
||||
{
|
||||
cryValidateHelpWindow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cryValidatePopulateMessageList;
|
||||
}
|
||||
}
|
||||
|
||||
proc cryValidateSourceDependencies()
|
||||
{
|
||||
//eval("source cryExport.mel"); // Removed from here as resourcing the script will it is running is causing heap corruption in OpenMaya.dll
|
||||
eval("source cryValidateFix.mel");
|
||||
|
||||
if( !`cryPluginIsLoaded` )
|
||||
cryLoadPluginQuiet;
|
||||
}
|
||||
|
||||
global proc cryValidate( )
|
||||
{
|
||||
cryValidateSourceDependencies();
|
||||
cryValidateCreateWindow();
|
||||
}
|
||||
|
||||
global proc cryValidateRunBasic( )
|
||||
{
|
||||
cryValidateSourceDependencies();
|
||||
cryValidatePlugin basic silentIfClean;
|
||||
}
|
||||
|
||||
global proc cryValidateRunComplete( )
|
||||
{
|
||||
cryValidateSourceDependencies();
|
||||
cryValidatePlugin complete silentIfClean;
|
||||
}
|
||||
|
||||
global proc string cryValidateIsMessageWindowVisible()
|
||||
{
|
||||
// Window has to be open and visible
|
||||
if( `window -ex CRYVALIDATE_WINDOW` && `window -q -vis CRYVALIDATE_WINDOW`)
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
// Progress window.
|
||||
global proc cryValidateProgressUpdate( string $text, float $amount )
|
||||
{
|
||||
progressWindow -edit -progress $amount -status ("Validating:" + $amount+"%"+" : "+$text);
|
||||
}
|
||||
|
||||
global proc cryValidateProgressCloseWindow()
|
||||
{
|
||||
progressWindow -endProgress;
|
||||
}
|
||||
|
||||
global proc cryValidateProgress( )
|
||||
{
|
||||
int $amount = 0;
|
||||
progressWindow -title "Validating" -progress $amount -status " Validating: 0% " -isInterruptable false;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// Help Window
|
||||
//////////////////////////////////
|
||||
global proc cryValidateHelpSaveDontShow( int $value )
|
||||
{
|
||||
optionVar -iv "cryValidateHelpDontShow" $value;
|
||||
}
|
||||
|
||||
global proc int cryValidateHelpLoadDontShow( )
|
||||
{
|
||||
int $value = 0;
|
||||
if(`optionVar -exists "cryValidateHelpDontShow"` )
|
||||
{
|
||||
$value = `optionVar -q "cryValidateHelpDontShow"`;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
global proc cryValidateHelpCloseWindow()
|
||||
{
|
||||
if( `control -exists CRYVALIDATEHELP_DONTSHOW` )
|
||||
{
|
||||
int $value = `checkBox -q -value CRYVALIDATEHELP_DONTSHOW`;
|
||||
cryValidateHelpSaveDontShow $value;
|
||||
}
|
||||
|
||||
deleteUI -window CRYVALIDATEHELP_WINDOW;
|
||||
}
|
||||
|
||||
global proc cryValidateMessageHelp( string $messageType )
|
||||
{
|
||||
cryMayaSupportPlugin start "http://confluence/display/SNT/Maya+Validate+Message+Help#groupNodeHasNoChildren";
|
||||
}
|
||||
|
||||
global proc cryValidateHelpWindow( )
|
||||
{
|
||||
if(!`window -ex CRYVALIDATEHELP_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYVALIDATEHELP_WINDOW`)
|
||||
{
|
||||
windowPref -remove CRYVALIDATEHELP_WINDOW;
|
||||
}
|
||||
window -widthHeight 750 450 -titleBar true -title "Lumberyard Validate Help" -sizeable true -mnb false -mxb false CRYVALIDATEHELP_WINDOW;
|
||||
|
||||
formLayout -numberOfDivisions 100 -visible false CRYVALIDATEHELP_FORMLAYOUT;
|
||||
{
|
||||
string $helpText = "Export Validation.\n\n";
|
||||
$helpText += "The validation runs before the exporter. If the validation produces any messages the export will be stopped and no files are written. You can also run the validation from the Crytek shelf.\n\n";
|
||||
$helpText += "There are two types of messages produced by the validation, critical and ignorable. If there are any critical messages you can't export until they are fixed. Ignorable messages can be ignored but will come back the next time the validation is run. They really should be fixed as well as it will be annoying to have to ignore them every time for every export.\n\n";
|
||||
$helpText += "\nIgnoring Messages.\n\n";
|
||||
$helpText += "If the scene has ignorable messages, the validate window will pop up when the `Export` button is clicked. If you ignore the messages you can conplete the export by clicking the `Continue Export` at the bottom of the validate window. \nSo the process is:\n - Click `Export`.\n - 'Ignore' messages.\n - Click `Continue Export`.\n - Wait for the export to finish.\n - Close validate window.\nIf there are no messages to display the validate window is not shown and the export happens with the first click of the `Export` button.\n\n";
|
||||
$helpText += "\nFocus Button.\n\n";
|
||||
$helpText += "There is also a `Focus` button. This will select the node or component that caused the message and make it easier the find the problem. The focus button will be grayed out if there is nothing to focus on.\n\n";
|
||||
scrollField -editable false -wordWrap true -text $helpText CRYVALIDATEHELP_HELPTEXT;
|
||||
checkBox -label "Don't show this dialog again." CRYVALIDATEHELP_DONTSHOW;
|
||||
button -label "Close" -command ("cryValidateHelpCloseWindow;") CRYVALIDATEHELP_CLOSE;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYVALIDATEHELP_HELPTEXT "top" 5
|
||||
-attachForm CRYVALIDATEHELP_HELPTEXT "left" 5
|
||||
-attachForm CRYVALIDATEHELP_HELPTEXT "right" 5
|
||||
-attachControl CRYVALIDATEHELP_HELPTEXT "bottom" 5 CRYVALIDATEHELP_DONTSHOW
|
||||
|
||||
-attachNone CRYVALIDATEHELP_DONTSHOW "top"
|
||||
-attachForm CRYVALIDATEHELP_DONTSHOW "left" 5
|
||||
-attachForm CRYVALIDATEHELP_DONTSHOW "right" 5
|
||||
-attachControl CRYVALIDATEHELP_DONTSHOW "bottom" 5 CRYVALIDATEHELP_CLOSE
|
||||
|
||||
-attachNone CRYVALIDATEHELP_CLOSE "top"
|
||||
-attachForm CRYVALIDATEHELP_CLOSE "left" 5
|
||||
-attachForm CRYVALIDATEHELP_CLOSE "right" 5
|
||||
-attachForm CRYVALIDATEHELP_CLOSE "bottom" 5
|
||||
CRYVALIDATEHELP_FORMLAYOUT;
|
||||
|
||||
int $dontShow = `cryValidateHelpLoadDontShow`;
|
||||
checkBox -edit -value $dontShow CRYVALIDATEHELP_DONTSHOW;
|
||||
|
||||
showWindow CRYVALIDATEHELP_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// This function is only here to use as a debug tool.
|
||||
// There is no way to get to this function though the UI.
|
||||
//////////////////////////////////
|
||||
global proc cryValidateDebugIgnoreAll( )
|
||||
{
|
||||
string $s;
|
||||
$s = `cryValidateGetMessageList`;
|
||||
if( size($s) > 0 )
|
||||
{
|
||||
string $messages[];
|
||||
$messageCount = `tokenize $s ";" $messages`;
|
||||
|
||||
for( $i = 0;$i<$messageCount;$i ++ )
|
||||
{
|
||||
cryValidatePlugin messages ignoreMessage $i;
|
||||
}
|
||||
|
||||
}
|
||||
cryValidateShowIgnoreState;
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
global proc int cryValidateFixCanFix(string $messageType)
|
||||
{
|
||||
if( strcmp($messageType, "llShouldNotInheritTrans") == 0 )
|
||||
return 1;
|
||||
else if( strcmp($messageType, "exportNodeNotTopLevel") == 0 )
|
||||
return 0;
|
||||
else if( strcmp($messageType, "InvalidUDPChars") == 0 )
|
||||
return 1;
|
||||
else if( strcmp($messageType, "meshWeightsNot1") == 0 )
|
||||
return 1;
|
||||
else if( strcmp($messageType, "groupNodeNotOnGrid") == 0 )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
global proc cryValidateFix( string $messageType, string $focusNode)
|
||||
{
|
||||
if( `objExists $focusNode` == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( strcmp($messageType, "llShouldNotInheritTrans") == 0 )
|
||||
{
|
||||
cryValidateFixShouldNotInheritTransform $focusNode;
|
||||
}
|
||||
else if( strcmp($messageType, "exportNodeNotTopLevel") == 0 )
|
||||
{
|
||||
cryValidateFixExportNodeNotTopLevel $focusNode;
|
||||
}
|
||||
else if( strcmp($messageType, "InvalidUDPChars") == 0 )
|
||||
{
|
||||
cryValidateFixInvalidUDPChars $focusNode;
|
||||
}
|
||||
else if( strcmp($messageType, "meshWeightsNot1") == 0 )
|
||||
{
|
||||
cryValidateFixWeightsNotNormalised $focusNode;
|
||||
}
|
||||
else if( strcmp($messageType, "groupNodeNotOnGrid") == 0 )
|
||||
{
|
||||
cryValidateFixGroupNodeNotOnGrid $focusNode;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Fix functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Joint node should not inhert the trasform of it's parent. Used for locamotion locators etc.
|
||||
global proc cryValidateFixShouldNotInheritTransform(string $node)
|
||||
{
|
||||
setAttr ($node+".inheritsTransform") 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Export node is not top level
|
||||
global proc cryValidateFixExportNodeNotTopLevel(string $node)
|
||||
{
|
||||
string $pathTokens[];
|
||||
$pathCount = `tokenize $node "|" $pathTokens`;
|
||||
|
||||
print("Path `"+$node+"` :: Count "+$pathCount);
|
||||
if( $pathCount == 2 )
|
||||
{
|
||||
confirmDialog -title "Lumberyard Auto Fix" -message ("Should the node `"+$pathTokens[0]+"` be the scene root node. If so we can rename it to `SceneRoot`.") -button "OK";
|
||||
|
||||
// TODO: Finish this......
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Invalid characters in the UDP
|
||||
global proc cryValidateFixInvalidUDPChars(string $node)
|
||||
{
|
||||
string $udpAttributeName = "UDP";
|
||||
if (`attributeExists $udpAttributeName $node`)
|
||||
{
|
||||
string $nodeUDP = `getAttr ($node+"."+$udpAttributeName)`;
|
||||
|
||||
// Remove both carriage return and linefeed
|
||||
while( 1 )
|
||||
{
|
||||
string $newUDP = `substitute "&cr;&lf;" $nodeUDP "\n"`;
|
||||
if( `strcmp $newUDP $nodeUDP` == 0 )
|
||||
break;
|
||||
$nodeUDP = $newUDP;
|
||||
}
|
||||
|
||||
// Remove carriage return
|
||||
while( 1 )
|
||||
{
|
||||
string $newUDP = `substitute "&cr;" $nodeUDP "\n"`;
|
||||
if( `strcmp $newUDP $nodeUDP` == 0 )
|
||||
break;
|
||||
$nodeUDP = $newUDP;
|
||||
}
|
||||
|
||||
// Remove linefeed
|
||||
while( 1 )
|
||||
{
|
||||
string $newUDP = `substitute "&lf;" $nodeUDP "\n"`;
|
||||
if( `strcmp $newUDP $nodeUDP` == 0 )
|
||||
break;
|
||||
$nodeUDP = $newUDP;
|
||||
}
|
||||
|
||||
setAttr -type "string" ($node+"."+$udpAttributeName) $nodeUDP;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Vertex weights not normalised, dont add up to 1.
|
||||
global proc cryValidateFixWeightsNotNormalised(string $focusNode)
|
||||
{
|
||||
string $currentSelection[] = `ls -sl`;
|
||||
|
||||
eval("select -r "+$focusNode);
|
||||
eval("doNormalizeWeightsArgList 1 {\"4\"}");
|
||||
|
||||
select -r $currentSelection;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Group node is not aligned to the grid
|
||||
global proc cryValidateFixGroupNodeNotOnGrid(string $node)
|
||||
{
|
||||
float $gridSize = 1.0;
|
||||
vector $v = `xform -q -worldSpace -rotatePivot $node`;
|
||||
|
||||
float $xVal = floor($v.x+0.5);
|
||||
float $yVal = floor($v.y+0.5);
|
||||
float $zVal = floor($v.z+0.5);
|
||||
|
||||
xform -worldSpace -rotatePivot $xVal $yVal $zVal $node;
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* 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.
|
||||
|
||||
global proc cryValidateMessageControlClose()
|
||||
{
|
||||
if( `window -exists CRYVALIDATEMESSAGECONTROL_WINDOW` )
|
||||
{
|
||||
deleteUI -window CRYVALIDATEMESSAGECONTROL_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
proc string cryValidateMessageControlGetMessageData()
|
||||
{
|
||||
string $s;
|
||||
// messageType, MessageDesc, ignorable, disabled
|
||||
//$s = "messageType1,Message Description 1,1,1;messageType1,Message Description 2,1,1;messageType1,Message Description 3,1,1;messageType1,Message Description 4,1,1;";
|
||||
|
||||
$s = `cryValidatePlugin messages getMessageData`;
|
||||
return $s;
|
||||
}
|
||||
|
||||
global proc string[] cryValidateMessageControlDecodeMessageDataString( string $messageData )
|
||||
{
|
||||
string $decode[];
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $messageData "," $tokens`;
|
||||
if( $numTokens == 5 )
|
||||
{
|
||||
$decode[0] = $tokens[0]; // Message Type
|
||||
$decode[1] = $tokens[1]; // Message Desc
|
||||
$decode[2] = $tokens[2]; // Editable
|
||||
$decode[3] = $tokens[3]; // Ignorable
|
||||
$decode[4] = $tokens[4]; // Disabled
|
||||
}
|
||||
|
||||
return $decode;
|
||||
}
|
||||
|
||||
global proc cryValidateMessageControlSettingChange()
|
||||
{
|
||||
global int $cryValidateMessageControlSettingsHaveChanged = 0;
|
||||
$cryValidateMessageControlSettingsHaveChanged = 1;
|
||||
|
||||
if( `control -exists CRYVALIDATEMESSAGECONTROL_SAVE` )
|
||||
{
|
||||
button -e -enable true CRYVALIDATEMESSAGECONTROL_SAVE;
|
||||
}
|
||||
}
|
||||
|
||||
proc cryValidateMessageControlPopulateMessageList()
|
||||
{
|
||||
global string $g_validateMessageControlHiLight = "";
|
||||
|
||||
setParent CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT;
|
||||
string $childControls[];
|
||||
$childControls = `layout -q -childArray CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT`;
|
||||
|
||||
for( $child in $childControls )
|
||||
{
|
||||
deleteUI $child;
|
||||
}
|
||||
|
||||
string $s;
|
||||
$s = `cryValidateMessageControlGetMessageData`;
|
||||
|
||||
if( size($s) > 0 )
|
||||
{
|
||||
string $messages[];
|
||||
$messageCount = `tokenize $s ";" $messages`;
|
||||
|
||||
int $messageNum = 0;
|
||||
for( $message in $messages )
|
||||
{
|
||||
string $decode[];
|
||||
$decode = `cryValidateMessageControlDecodeMessageDataString $message`;
|
||||
string $messageType = $decode[0];
|
||||
string $messageDesc = $decode[1];
|
||||
int $editable = $decode[2];
|
||||
int $ignorable = $decode[3];
|
||||
int $disabled = $decode[4];
|
||||
|
||||
setParent CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT;
|
||||
print("Message `"+$message+"` MessageType `"+$messageType+"`\n");
|
||||
$rowName = `rowLayout -numberOfColumns 3 -columnWidth3 200 80 80 -adjustableColumn 1 -columnAlign 1 "left"
|
||||
-columnAlign 2 "center" -columnAlign 3 "center"
|
||||
-columnAttach 2 "both" 0 -columnAttach 3 "both" 0 -bgc .4 .4 .4
|
||||
$messageType`; // Name the rowLayout with the messageType so we know what it's about.
|
||||
|
||||
// If we launched the settings widow using a perticular message, hilight it.
|
||||
if( $g_validateMessageControlHiLight != "" )
|
||||
{
|
||||
if( `strcmp $g_validateMessageControlHiLight $messageType` == 0 )
|
||||
rowLayout -edit -bgc .45 .45 .45 $messageType;
|
||||
}
|
||||
|
||||
{
|
||||
string $messageText = $messageDesc;
|
||||
if( size($messageText) == 0 || $messageText == " " )
|
||||
$messageText = "* Message With No Description *";
|
||||
$messageTextControl = `text -h 22 -label (" " + $messageText)`;
|
||||
|
||||
checkBox -v $ignorable -label "Ignorable" -enable $editable -cc("cryValidateMessageControlSettingChange");
|
||||
checkBox -v $disabled -label "Disabled" -enable $editable -cc("cryValidateMessageControlSettingChange");
|
||||
}
|
||||
setParent ..;
|
||||
$messageNum++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text -label "No validate messages." -align "center" -bgc .4 .4 .4;
|
||||
}
|
||||
}
|
||||
|
||||
proc cryValidateMessageControlCreateWindow()
|
||||
{
|
||||
// If the window exists but is not visible, close it - and reset the messages.
|
||||
if( `window -ex CRYVALIDATEMESSAGECONTROL_WINDOW` && !`window -q -vis CRYVALIDATEMESSAGECONTROL_WINDOW`)
|
||||
{
|
||||
cryValidateCloseAndReset;
|
||||
}
|
||||
|
||||
if(!`window -ex CRYVALIDATEMESSAGECONTROL_WINDOW`)
|
||||
{
|
||||
if(`windowPref -exists CRYVALIDATEMESSAGECONTROL_WINDOW`)
|
||||
{
|
||||
windowPref -wh 800 400 -tlc `windowPref -q -topEdge CRYVALIDATEMESSAGECONTROL_WINDOW` `windowPref -q -leftEdge CRYVALIDATEMESSAGECONTROL_WINDOW` CRYVALIDATEMESSAGECONTROL_WINDOW;
|
||||
//windowPref -remove CRYVALIDATEMESSAGECONTROL_WINDOW;
|
||||
}
|
||||
window -titleBar true -title "Lumberyard Validate Messages" -wh 800 400 -sizeable true -mnb false -mxb false CRYVALIDATEMESSAGECONTROL_WINDOW;
|
||||
|
||||
formLayout -numberOfDivisions 100 -visible false CRYVALIDATEMESSAGECONTROL_FORMLAYOUT;
|
||||
{
|
||||
scrollLayout -childResizable true -hst 0 -vst 15 -bgc .4 .4 .4 CRYVALIDATEMESSAGECONTROL_SCROLLLAYOUT;
|
||||
{
|
||||
columnLayout -adjustableColumn true -columnOffset "both" 5 -rowSpacing 5 -bgc .4 .4 .4 CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT;
|
||||
{
|
||||
}
|
||||
setParent ..;
|
||||
}
|
||||
setParent ..;
|
||||
|
||||
button -label "Reset to Defaults" -command ("cryValidateMessageControlReset") CRYVALIDATEMESSAGECONTROL_RESET;
|
||||
button -label "Save" -enable false -command ("cryValidateMessageControlSave") CRYVALIDATEMESSAGECONTROL_SAVE;
|
||||
button -label "Close" -command ("cryValidateMessageControlClose") CRYVALIDATEMESSAGECONTROL_CLOSE;
|
||||
}
|
||||
|
||||
formLayout -edit
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_SCROLLLAYOUT "top" 5
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_SCROLLLAYOUT "left" 5
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_SCROLLLAYOUT "right" 5
|
||||
-attachControl CRYVALIDATEMESSAGECONTROL_SCROLLLAYOUT "bottom" 5 CRYVALIDATEMESSAGECONTROL_CLOSE
|
||||
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_RESET "bottom" 5
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_RESET "left" 5
|
||||
-attachPosition CRYVALIDATEMESSAGECONTROL_RESET "right" 5 33
|
||||
-attachNone CRYVALIDATEMESSAGECONTROL_RESET "top"
|
||||
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_SAVE "bottom" 5
|
||||
-attachPosition CRYVALIDATEMESSAGECONTROL_SAVE "left" 5 33
|
||||
-attachPosition CRYVALIDATEMESSAGECONTROL_SAVE "right" 5 66
|
||||
-attachNone CRYVALIDATEMESSAGECONTROL_SAVE "top"
|
||||
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_CLOSE "bottom" 5
|
||||
-attachPosition CRYVALIDATEMESSAGECONTROL_CLOSE "left" 5 66
|
||||
-attachForm CRYVALIDATEMESSAGECONTROL_CLOSE "right" 5
|
||||
-attachNone CRYVALIDATEMESSAGECONTROL_CLOSE "top"
|
||||
|
||||
CRYVALIDATEMESSAGECONTROL_FORMLAYOUT;
|
||||
|
||||
// Make sure the latest data is loaded before populating the list.
|
||||
cryValidatePlugin messages loadMessageData;
|
||||
cryValidateMessageControlPopulateMessageList;
|
||||
|
||||
showWindow CRYVALIDATEMESSAGECONTROL_WINDOW;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryValidateMessageControl( string $hilightMessageType )
|
||||
{
|
||||
global string $g_validateMessageControlHiLight = "";
|
||||
$g_validateMessageControlHiLight = $hilightMessageType;
|
||||
|
||||
cryValidateMessageControlCreateWindow( );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Util functions for saving/reseting etc.
|
||||
/////////////////////////////////////////////////////////
|
||||
global proc cryValidateMessageControlReset()
|
||||
{
|
||||
cryValidatePlugin messages resetMessageData;
|
||||
// Populate the list without reloading the data. It will need to be saved before the optionVar string will get changed.
|
||||
cryValidateMessageControlPopulateMessageList;
|
||||
//cryValidateMessageControlSave;
|
||||
|
||||
if( `control -exists CRYVALIDATEMESSAGECONTROL_SAVE` )
|
||||
{
|
||||
button -e -enable true CRYVALIDATEMESSAGECONTROL_SAVE;
|
||||
}
|
||||
}
|
||||
|
||||
global proc cryValidateMessageControlSave()
|
||||
{
|
||||
string $s = "";
|
||||
|
||||
setParent CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT;
|
||||
string $childControls[];
|
||||
$childControls = `layout -q -childArray CRYVALIDATEMESSAGECONTROL_COLUMNLAYOUT`;
|
||||
|
||||
for( $child in $childControls )
|
||||
{
|
||||
string $messageType = "";
|
||||
|
||||
// Get the messageType from the rowLayout name
|
||||
{
|
||||
string $layoutName = `layout -q -fullPathName $child`;
|
||||
string $tokens[];
|
||||
$numTokens = `tokenize $layoutName "|" $tokens`;
|
||||
if( $numTokens > 0 )
|
||||
$messageType = $tokens[$numTokens-1];
|
||||
}
|
||||
|
||||
string $rowChildren[];
|
||||
$rowChildren = `layout -q -childArray $child`;
|
||||
|
||||
int $ignorable = `checkBox -q -v $rowChildren[1]`;
|
||||
int $disabled = `checkBox -q -v $rowChildren[2]`;
|
||||
|
||||
|
||||
if( size($s) > 0 )
|
||||
$s += ";";
|
||||
$s += ($messageType+","+$ignorable+","+$disabled);
|
||||
|
||||
//print ("Type : "+$messageType+","+$ignorable+","+$disabled+"\n");
|
||||
|
||||
}
|
||||
|
||||
optionVar -sv "cryValidateMessageControl" $s;
|
||||
|
||||
if( `control -exists CRYVALIDATEMESSAGECONTROL_SAVE` )
|
||||
{
|
||||
button -e -enable false CRYVALIDATEMESSAGECONTROL_SAVE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
source LumberyardUtilities.mel;
|
||||
|
||||
global proc cryCheckFaces()
|
||||
{
|
||||
string $exportNodes[];
|
||||
string $lumberyardExportNodePrefix = LumberyardGetExportNodeNamePrefix();
|
||||
string $filterString = $lumberyardExportNodePrefix + "*";
|
||||
$exportNodes = `ls $filterString`;
|
||||
cryMayaCheckDegradedFaces($exportNodes[0]);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0fb28ea1ba9b6cb797e3fd43e25f7006f9e17894cf92643dd881e4d46311a2be
|
||||
size 2396
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5e1ca7e844948678fab6facc5649c97f250700ef6a4f86d2033359752ab6102b
|
||||
size 2562
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46da8efc6a474ce1281d244b4ab8cbc6690fc58923a3e23301cfb25736da473b
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7d6600e43df930b7654a91e8b5c859b2e91f13a1f0a2f038d013e20eb9db4ede
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1c95053ff6f1e0754062339945a06d712484b4d071a426b5b43587cb40b6e12d
|
||||
size 4982
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cc709962ee61b6e7a7700c10114f3324357a82c28e20da7cec74a0d30c343a8c
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9cd194c785de0045a5d4c968e01cd5261b24936c5ad02c35cb8da17bd5bc218e
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0a7eaac2b71e39fc7208f8d56b9e93f889c5a8fae014b1ae7c4ef4ede80b0c8b
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:27be4c06bc4f0139e4ccf24ac06d5f8caf4e66b3ff82a31d65bde3b47039ded9
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:83e99647d347fdfae0087c5bbce06379ecbc0a19bcc524a6aa681d787e13758e
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a89f0427e8174ae52137f4e579e730b08adba600f93021080f1cfa2b76d59faf
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f23e4e5af6fac6a9925a99a0dc28b57d95a094eaaff37c31c1c1482bbc0461d7
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ed1f2c8b2e488bc55a40bc7a37131bca01d8001a1e012c038d96265061bdc234
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:919a401ec0751fdc1b66e3434b7eada8f9d7d5f5ec20ed7683d864bba22ef542
|
||||
size 3128
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8ac176b706b8560db1d6ce793ee397ac07d99785d2a93980c663c85daf619db9
|
||||
size 621
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:62e26e0df5c03e6c085d5aba5726d625f4995217d615d5f6c2edb25e68902d27
|
||||
size 18738
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-283 285 32 32"
|
||||
enable-background="new -283 285 32 32" xml:space="preserve">
|
||||
<title></title>
|
||||
<desc></desc>
|
||||
<path fill="#EDAF14" d="M-268.6,290.1c0.9-1.4,2.3-1.4,3.2,0l10.8,17.4c1.2,1.9,0.3,3.4-1.9,3.4h-20.9c-2.2,0-3.1-1.5-1.9-3.4
|
||||
L-268.6,290.1L-268.6,290.1z M-267.6,290.5 M-267,305.9c-0.8,0-1.4,0.6-1.4,1.4s0.6,1.4,1.4,1.4s1.4-0.6,1.4-1.4
|
||||
S-266.2,305.9-267,305.9z M-265.6,303V297c0-0.8-0.6-1.4-1.4-1.4l0,0c-0.8,0-1.4,0.6-1.4,1.4v6.1c0,0.8,0.6,1.4,1.4,1.4l0,0
|
||||
C-266.2,304.4-265.6,303.8-265.6,303z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 936 B |
@@ -0,0 +1,96 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
################################################################################################################
|
||||
#
|
||||
# mayaAnimUtilities.py
|
||||
#
|
||||
# replaces mayaAnimUtilities.cpp
|
||||
#
|
||||
# contains two functons
|
||||
# - AMZN_GetTimeFromFrame
|
||||
# Takes frame number as input
|
||||
# Returns time based on current Maya settings
|
||||
#
|
||||
# - AMZN_DecodeAnimRangeString
|
||||
# Takes string as parameter representing Maya export settings
|
||||
# Returns array with values parced out
|
||||
#
|
||||
################################################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################################################
|
||||
#
|
||||
# PURPOSE: To return the current time from a given frame
|
||||
#
|
||||
# PROCEDURE: Using C++ api calls, create new MTime entity
|
||||
# Set the MTime entity to the current unit of time and current frame
|
||||
# returns the current time in secconds
|
||||
#
|
||||
# PRESUMPTIONS: original c++ used MTime.as, which does not currently seem to be supported in Python
|
||||
# looks like MTime.asUnits is equivalent function
|
||||
#
|
||||
#################################################################################################################
|
||||
import maya.OpenMaya as om
|
||||
|
||||
def AMZN_GetTimeFromFrame(frame):
|
||||
time = om.MTime()
|
||||
|
||||
time.setUnit( time.uiUnit() )
|
||||
time.setValue( frame )
|
||||
|
||||
#original c++ uses MTime.as
|
||||
#as far as I can tell, MTime.asUnits is synonimous
|
||||
return time.asUnits(om.MTime.kSeconds)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################################################
|
||||
#
|
||||
# PURPOSE: To parse out the string containing the animation export options
|
||||
#
|
||||
# PROCEDURE: First we split the string up via it's sentinal value " - ", then we take the first
|
||||
# element, which is the frame range, and pull out the start and end frames. We then
|
||||
# add them all back into one string
|
||||
#
|
||||
# PRESUMPTIONS: 1) the items in the string are seperated by an " - " value
|
||||
# 2) that there are no " - ' values in things lke path names (wasn't my idea for a sentinal value)
|
||||
# 3) that the first element in the string is the time range in the format [startFrame-endFrame]
|
||||
#
|
||||
#################################################################################################################
|
||||
def AMZN_DecodeAnimRangeString(str):
|
||||
|
||||
returnArray = []
|
||||
|
||||
#split the export options by the sentinal value
|
||||
splitBySentinal = str.split(" - ")
|
||||
|
||||
#first item in the array is the time range, need to parce out the numbers from the string
|
||||
timeRange = splitBySentinal[0]
|
||||
timeRange = timeRange.translate(None, '[]')
|
||||
splitTimeRange = timeRange.split("-")
|
||||
|
||||
del splitBySentinal[0]
|
||||
#print splitBySentinal
|
||||
|
||||
returnArray.extend(splitTimeRange)
|
||||
returnArray.extend(splitBySentinal)
|
||||
|
||||
return returnArray
|
||||
#print returnArray
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
global proc shelf_Lumberyard ()
|
||||
{
|
||||
shelfButton
|
||||
-enableCommandRepeat 1
|
||||
-enable 1
|
||||
-width 35
|
||||
-height 35
|
||||
-manage 1
|
||||
-visible 1
|
||||
-preventOverride 0
|
||||
-annotation "Lumberyard Tools"
|
||||
-enableBackground 0
|
||||
-align "center"
|
||||
-label "Lumberyard Tools"
|
||||
-labelOffset 0
|
||||
-font "plainLabelFont"
|
||||
-overlayLabelColor 0.8 0.8 0.8
|
||||
-overlayLabelBackColor 0 0 0 0.2
|
||||
-image "lumberyard_icon.png"
|
||||
-image1 "lumberyard_icon.png"
|
||||
-style "iconOnly"
|
||||
-marginWidth 1
|
||||
-marginHeight 1
|
||||
-command "source LumberyardTool.mel;\r\nLumberyardToolWindow;"
|
||||
-sourceType "mel"
|
||||
-commandRepeatable 1
|
||||
-flat 1
|
||||
;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user