You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
7.2 KiB
Plaintext
182 lines
7.2 KiB
Plaintext
/*
|
|
* 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_";
|
|
} |