1362 lines
56 KiB
Text
1362 lines
56 KiB
Text
///////////////////////////////////////////////////////////////////////////////////
|
||
// Panda3D Exporter Tool //
|
||
// Carnegie Mellon University ETC (Entertainment Technology Center) Panda3D Team //
|
||
// Author: Shao Zhang //
|
||
// 04/14/2005 //
|
||
// //
|
||
// This tool will allow an artist to export and view assets directly from maya. //
|
||
// //
|
||
// To run this mel script, drag and drop it (the .mel file) into your current //
|
||
// maya workspace. //
|
||
///////////////////////////////////////////////////////////////////////////////////
|
||
//
|
||
// EDIT HISTORY
|
||
//
|
||
// 06/26/06: ynjh_jo - Major edits; described in http://panda3d.net/phpbb2/viewtopic.php?t=2503
|
||
// 07/03/06: Mark Tomczak (fixermark@gmail.com) - Added "Actor" option to export with -a model option
|
||
|
||
global proc pandaExporterUI()
|
||
{
|
||
if ( `window -exists PandaExporter2` )
|
||
deleteUI -window PandaExporter2;
|
||
|
||
string $unit=`currentUnit -q -linear`;
|
||
string $unitFull=`currentUnit -q -linear -fullName`;
|
||
|
||
// Window is locked for image dimensions: 280×575
|
||
// (add a few pixels to compensate for title bar and borders)
|
||
window
|
||
-title "Panda Exporter"
|
||
-width 280
|
||
-height 575
|
||
-sizeable 0
|
||
PandaExporter2;
|
||
|
||
// Use a formLayout so you control the overlap of the controls
|
||
formLayout
|
||
-numberOfDivisions 575
|
||
-width 275
|
||
-height 550
|
||
mainForm;
|
||
|
||
// First add controls
|
||
button
|
||
-label "--- E X P O R T ---"
|
||
-command "exportButton"
|
||
exportButton;
|
||
|
||
button
|
||
-label "Browse"
|
||
-enable 0
|
||
-command ( "browseForFolder \"texPath\"" )
|
||
browseTexPathButton;
|
||
|
||
button
|
||
-label "Browse"
|
||
-enable 0
|
||
-command ( "browseForFolder \"outputPath\"" )
|
||
browseOutputPathButton;
|
||
|
||
button
|
||
-label "..."
|
||
-enable 0
|
||
-command ( "browseForFile \"outputPath\"" )
|
||
browseFilenameButton;
|
||
|
||
button
|
||
-label "Select a file to Pview"
|
||
-command "getFile2Pview"
|
||
pviewButton;
|
||
|
||
button
|
||
-label "Select a file to EGG"
|
||
-command "getFile2Egg"
|
||
eggButton;
|
||
|
||
button
|
||
-label "Select a file to BAM"
|
||
-command "getFile2Bam"
|
||
bamButton;
|
||
|
||
button
|
||
-label "www.panda3d.org"
|
||
-command "openBrowser"
|
||
webButton;
|
||
|
||
checkBox
|
||
-label "Export selected objects"
|
||
-value 0
|
||
selectedCB;
|
||
|
||
checkBox
|
||
-label "Double sided faces"
|
||
-value 0
|
||
bfaceCB;
|
||
|
||
checkBox
|
||
-label "Overwrite if file exists"
|
||
-value 1
|
||
overwriteCB;
|
||
|
||
checkBox
|
||
-label "Run Pview after export"
|
||
-value 0
|
||
pviewCB;
|
||
|
||
radioCollection exportOptionsRC;
|
||
radioButton
|
||
-label "Mesh"
|
||
-select
|
||
-onCommand ( "exportOptionsUI" )
|
||
chooseMeshRB;
|
||
radioButton
|
||
-label "Actor"
|
||
-onCommand ( "exportOptionsUI" )
|
||
chooseActorRB;
|
||
radioButton
|
||
-label "Animation"
|
||
-onCommand ( "exportOptionsUI" )
|
||
chooseAnimationRB;
|
||
radioButton
|
||
-label "Both"
|
||
-onCommand ( "exportOptionsUI" )
|
||
chooseBothRB;
|
||
radioButton
|
||
-label "Pose"
|
||
-onCommand ( "exportOptionsUI" )
|
||
choosePoseRB;
|
||
setParent ..; //drop out of exportOptionsRC
|
||
|
||
radioCollection animationOptionsRC;
|
||
radioButton
|
||
-label "Full Range"
|
||
-enable 0
|
||
-onCommand ( "animationOptionsUI" )
|
||
chooseFullRangeRB;
|
||
radioButton
|
||
-label "Custom Range"
|
||
-enable 0
|
||
-onCommand ( "animationOptionsUI" )
|
||
chooseCustomRangeRB;
|
||
setParent ..; //drop out of animationOptionsRC
|
||
|
||
radioCollection outputFileOptionsRC;
|
||
radioButton
|
||
-label "EGG (ASCII)"
|
||
-select
|
||
chooseEggRB;
|
||
radioButton
|
||
-label "BAM (binary)"
|
||
-enable 0
|
||
chooseBamRB;
|
||
radioButton
|
||
-label "Both"
|
||
chooseEggBamRB;
|
||
setParent ..; //drop out of outputFileOptionsRC
|
||
|
||
radioCollection texPathOptionsRC;
|
||
radioButton
|
||
-label "Reference textures relative to maya file (default)"
|
||
-select
|
||
-onCommand ( "texPathOptionsUI" )
|
||
chooseDefaultTexPathRB;
|
||
radioButton
|
||
-label "Reference textures relative to custom path"
|
||
-onCommand ( "texPathOptionsUI" )
|
||
chooseCustomTexPathRB;
|
||
setParent ..; //drop out of texPathOptionsRC
|
||
|
||
radioCollection outputPathOptionsRC;
|
||
radioButton
|
||
-label "Export to root directory of source file (default)"
|
||
-select
|
||
-onCommand ( "outputPathOptionsUI" )
|
||
chooseDefaultOutputPathRB;
|
||
radioButton
|
||
-label "Export to other directory:"
|
||
-onCommand ( "outputPathOptionsUI" )
|
||
chooseCustomOutputPathRB;
|
||
setParent ..; //drop out of outputPathOptionsRC
|
||
|
||
radioCollection outputFilenameOptionsRC;
|
||
radioButton
|
||
-label "Use original filename"
|
||
-select
|
||
-onCommand ( "outputFilenameOptionsUI" )
|
||
chooseOriginalFilenameRB;
|
||
radioButton
|
||
-label "Use alternate filename"
|
||
-onCommand ( "outputFilenameOptionsUI" )
|
||
chooseCustomFilenameRB;
|
||
setParent ..; //drop out of outputFilenameOptionsRC
|
||
|
||
radioCollection transformModeRC;
|
||
radioButton
|
||
-label "all"
|
||
-select
|
||
-onCommand ( "transformModeUI" )
|
||
chooseTransformAllRB;
|
||
radioButton
|
||
-label "model/DCS flag"
|
||
-onCommand ( "transformModeUI" )
|
||
chooseTransformModelRB;
|
||
setParent ..; //drop out of transformModeRC
|
||
|
||
text
|
||
-label "Maya Panda Exporter v.1.3 CMU/ETC Panda3D Team"
|
||
-font "plainLabelFont"
|
||
titleText;
|
||
|
||
text
|
||
-label "Output File Options:"
|
||
-font "plainLabelFont"
|
||
outputFileOptionsText;
|
||
|
||
text
|
||
-label "Texture Path Options:"
|
||
-font "plainLabelFont"
|
||
texPathOptionsText;
|
||
|
||
text
|
||
-label "Specify alternate directory:"
|
||
-font "plainLabelFont"
|
||
customTexPathText;
|
||
|
||
text
|
||
-label "Output directory Options:"
|
||
-font "plainLabelFont"
|
||
outputPathOptionsText;
|
||
|
||
text
|
||
-label "Specify alternate directory:"
|
||
-font "plainLabelFont"
|
||
customOutputPathText;
|
||
|
||
text
|
||
-label "Output filename Options:"
|
||
-font "plainLabelFont"
|
||
outputFilenameOptionsText;
|
||
|
||
text
|
||
-label "Save transform:"
|
||
-font "plainLabelFont"
|
||
transformModeText;
|
||
|
||
text
|
||
-label ("Convert unit from ( "+$unitFull+" ) to : ")
|
||
-align "right"
|
||
-font "boldLabelFont"
|
||
convertUnitText;
|
||
|
||
textField
|
||
-editable 1
|
||
-enable 0
|
||
customTexPathTF;
|
||
|
||
textField
|
||
-editable 1
|
||
-enable 0
|
||
customOutputPathTF;
|
||
|
||
textField
|
||
-editable 1
|
||
-enable 0
|
||
customFilenameTF;
|
||
|
||
optionMenu
|
||
unitMenu;
|
||
menuItem -label "mm";
|
||
menuItem -label "cm";
|
||
menuItem -label "m";
|
||
menuItem -label "km";
|
||
menuItem -label "in";
|
||
menuItem -label "ft";
|
||
menuItem -label "yd";
|
||
menuItem -label "nmi";
|
||
menuItem -label "mi";
|
||
|
||
|
||
frameLayout
|
||
-label "Export Options:"
|
||
-font "plainLabelFont"
|
||
-labelIndent 2
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedOut"
|
||
leftFrame;
|
||
setParent ..; //drop out of leftFrame
|
||
|
||
frameLayout
|
||
-label ""
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedOut"
|
||
leftMiddleFrame;
|
||
setParent ..; //drop out of leftFrame
|
||
|
||
frameLayout
|
||
-label ""
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedOut"
|
||
leftBottomFrame;
|
||
setParent ..; //drop out of leftFrame
|
||
|
||
frameLayout
|
||
-label "Animation Options:"
|
||
-font "plainLabelFont"
|
||
-labelIndent 2
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedOut"
|
||
rightFrame;
|
||
|
||
columnLayout
|
||
-columnAttach "left" 0
|
||
-rowSpacing 0
|
||
-columnWidth 60
|
||
leftFrameColumn;
|
||
|
||
text -label "\n\n";
|
||
text -label "Start Frame:";
|
||
textField
|
||
-editable 1
|
||
-enable 0
|
||
-width 108
|
||
startFrameTF;
|
||
|
||
text -label "End Frame:";
|
||
textField
|
||
-editable 1
|
||
-enable 0
|
||
-width 108
|
||
endFrameTF;
|
||
|
||
setParent ..; //drop out of leftFrameColumn
|
||
setParent ..; //drop out of rightFrame
|
||
|
||
frameLayout
|
||
-label "Extra Tools"
|
||
-font "plainLabelFont"
|
||
-labelIndent 28
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedOut"
|
||
extraToolsFrame;
|
||
setParent ..; //drop out of extraToolsFrame
|
||
|
||
frameLayout
|
||
-label ""
|
||
-collapsable 0
|
||
-collapse 0
|
||
-borderStyle "etchedIn"
|
||
exportButtonFrame;
|
||
setParent ..; //drop out of extraToolsFrame
|
||
|
||
setParent ..; //drop out of "mainForm"
|
||
|
||
// Now edit the layout of the controls in "mainForm
|
||
formLayout -edit
|
||
|
||
|
||
/* text */
|
||
-ap titleText "top" 0 2
|
||
-ap titleText "left" 0 5
|
||
-ap titleText "right" 0 575
|
||
|
||
-ap outputFileOptionsText "top" 0 188
|
||
-ap outputFileOptionsText "left" 0 10
|
||
-ap outputFileOptionsText "right" 0 210
|
||
|
||
-ap texPathOptionsText "top" 0 226
|
||
-ap texPathOptionsText "left" 0 10
|
||
-ap texPathOptionsText "right" 0 210
|
||
|
||
-ap customTexPathText "top" 0 280
|
||
-ap customTexPathText "left" 0 10
|
||
-ap customTexPathText "right" 0 300
|
||
|
||
-ap outputPathOptionsText "top" 0 324
|
||
-ap outputPathOptionsText "left" 0 10
|
||
-ap outputPathOptionsText "right" 0 300
|
||
|
||
-ap customOutputPathText "top" 0 378
|
||
-ap customOutputPathText "left" 0 10
|
||
-ap customOutputPathText "right" 0 300
|
||
|
||
-ap convertUnitText "top" 0 165
|
||
-ap convertUnitText "left" 0 10
|
||
-ap convertUnitText "right" 0 460
|
||
|
||
-ap outputFilenameOptionsText "top" 0 422
|
||
-ap outputFilenameOptionsText "left" 0 10
|
||
-ap outputFilenameOptionsText "right" 0 290
|
||
|
||
-ap transformModeText "top" 0 505
|
||
-ap transformModeText "left" 0 10
|
||
-ap transformModeText "right" 0 290
|
||
|
||
|
||
/* textfields */
|
||
-ap customTexPathTF "top" 0 298
|
||
-ap customTexPathTF "left" 0 10
|
||
-ap customTexPathTF "right" 0 480
|
||
|
||
-ap customOutputPathTF "top" 0 396
|
||
-ap customOutputPathTF "left" 0 10
|
||
-ap customOutputPathTF "right" 0 480
|
||
|
||
-ap customFilenameTF "top" 0 480
|
||
-ap customFilenameTF "left" 0 10
|
||
-ap customFilenameTF "right" 0 284
|
||
|
||
|
||
-ap unitMenu "top" 0 160
|
||
-ap unitMenu "left" 0 460
|
||
|
||
|
||
/* frames */
|
||
-ap leftFrame "top" 0 20
|
||
-ap leftFrame "bottom" 0 80
|
||
-ap leftFrame "left" 0 4
|
||
-ap leftFrame "right" 0 330
|
||
|
||
-ap leftMiddleFrame "top" 0 80
|
||
-ap leftMiddleFrame "bottom" 0 158
|
||
-ap leftMiddleFrame "left" 0 4
|
||
-ap leftMiddleFrame "right" 0 330
|
||
|
||
-ap leftBottomFrame "top" 0 158
|
||
-ap leftBottomFrame "bottom" 0 188
|
||
-ap leftBottomFrame "left" 0 4
|
||
-ap leftBottomFrame "right" 0 574
|
||
|
||
-ap rightFrame "top" 0 20
|
||
-ap rightFrame "bottom" 0 158
|
||
-ap rightFrame "left" 0 334
|
||
-ap rightFrame "right" 0 574
|
||
|
||
-ap extraToolsFrame "top" 0 425
|
||
-ap extraToolsFrame "bottom" 0 542
|
||
-ap extraToolsFrame "left" 0 335
|
||
-ap extraToolsFrame "right" 0 574
|
||
|
||
-ap exportButtonFrame "top" 0 542
|
||
-ap exportButtonFrame "bottom" 0 573
|
||
-ap exportButtonFrame "left" 0 2
|
||
-ap exportButtonFrame "right" 0 574
|
||
|
||
|
||
|
||
/* checkboxes */
|
||
-ap selectedCB "top" 0 82
|
||
-ap selectedCB "left" 0 12
|
||
|
||
-ap bfaceCB "top" 0 101
|
||
-ap bfaceCB "left" 0 12
|
||
|
||
-ap overwriteCB "top" 0 120
|
||
-ap overwriteCB "left" 0 12
|
||
|
||
-ap pviewCB "top" 0 139
|
||
-ap pviewCB "left" 0 12
|
||
|
||
|
||
|
||
/* exportOptionsRC */
|
||
-ap chooseMeshRB "top" 0 21
|
||
-ap chooseMeshRB "left" 0 170
|
||
|
||
-ap chooseActorRB "top" 0 40
|
||
-ap chooseActorRB "left" 0 20
|
||
|
||
-ap chooseBothRB "top" 0 59
|
||
-ap chooseBothRB "left" 0 20
|
||
|
||
-ap chooseAnimationRB "top" 0 40
|
||
-ap chooseAnimationRB "left" 0 170
|
||
|
||
-ap choosePoseRB "top" 0 59
|
||
-ap choosePoseRB "left" 0 170
|
||
|
||
|
||
|
||
/* animationOptionsRC */
|
||
-ap chooseFullRangeRB "top" 0 40
|
||
-ap chooseFullRangeRB "left" 0 346
|
||
|
||
-ap chooseCustomRangeRB "top" 0 59
|
||
-ap chooseCustomRangeRB "left" 0 346
|
||
|
||
|
||
|
||
/* outputFileOptionsRC */
|
||
-ap chooseEggRB "top" 0 205
|
||
-ap chooseEggRB "left" 0 10
|
||
|
||
-ap chooseBamRB "top" 0 205
|
||
-ap chooseBamRB "left" 0 196
|
||
|
||
-ap chooseEggBamRB "top" 0 205
|
||
-ap chooseEggBamRB "left" 0 380
|
||
|
||
|
||
|
||
/* texPathOptionsRC */
|
||
-ap chooseDefaultTexPathRB "top" 0 244
|
||
-ap chooseDefaultTexPathRB "left" 0 10
|
||
|
||
-ap chooseCustomTexPathRB "top" 0 264
|
||
-ap chooseCustomTexPathRB "left" 0 10
|
||
|
||
|
||
|
||
/* outputPathOptionsRC */
|
||
-ap chooseDefaultOutputPathRB "top" 0 342
|
||
-ap chooseDefaultOutputPathRB "left" 0 10
|
||
|
||
-ap chooseCustomOutputPathRB "top" 0 362
|
||
-ap chooseCustomOutputPathRB "left" 0 10
|
||
|
||
|
||
|
||
/* outputFilenameOptionsRC */
|
||
-ap chooseOriginalFilenameRB "top" 0 440
|
||
-ap chooseOriginalFilenameRB "left" 0 10
|
||
|
||
-ap chooseCustomFilenameRB "top" 0 460
|
||
-ap chooseCustomFilenameRB "left" 0 10
|
||
|
||
/* transformModeRC */
|
||
-ap chooseTransformAllRB "top" 0 525
|
||
-ap chooseTransformAllRB "left" 0 10
|
||
|
||
-ap chooseTransformModelRB "top" 0 525
|
||
-ap chooseTransformModelRB "left" 0 120
|
||
|
||
|
||
/* browseTexPathButton */
|
||
-ap browseTexPathButton "top" 0 298
|
||
-ap browseTexPathButton "left" 0 485
|
||
-ap browseTexPathButton "right" 0 575
|
||
|
||
|
||
/* browseOutputPathButton */
|
||
-ap browseOutputPathButton "top" 0 396
|
||
-ap browseOutputPathButton "left" 0 485
|
||
-ap browseOutputPathButton "right" 0 575
|
||
|
||
|
||
/* browseFilenameButton */
|
||
-ap browseFilenameButton "top" 0 480
|
||
-ap browseFilenameButton "left" 0 285
|
||
-ap browseFilenameButton "right" 0 330
|
||
|
||
|
||
|
||
/* extra buttons */
|
||
-ap pviewButton "top" 0 445
|
||
-ap pviewButton "left" 0 340
|
||
-ap pviewButton "right" 0 565
|
||
|
||
-ap eggButton "top" 0 468
|
||
-ap eggButton "left" 0 340
|
||
-ap eggButton "right" 0 565
|
||
|
||
-ap bamButton "top" 0 492
|
||
-ap bamButton "left" 0 340
|
||
-ap bamButton "right" 0 565
|
||
|
||
-ap webButton "top" 0 515
|
||
-ap webButton "left" 0 340
|
||
-ap webButton "right" 0 565
|
||
|
||
|
||
|
||
/* exportButton */
|
||
-ap exportButton "top" 0 545
|
||
-ap exportButton "bottom" 0 570
|
||
-ap exportButton "left" 0 8
|
||
-ap exportButton "right" 0 565
|
||
|
||
|
||
mainForm; //End of layout
|
||
|
||
// defining the current unit value
|
||
optionMenu -edit -value $unit unitMenu;
|
||
|
||
showWindow PandaExporter2;
|
||
}
|
||
|
||
|
||
//Automatically start the tool
|
||
pandaExporterUI();
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: openBrowser //
|
||
// Opens the default browser at the panda3d url //
|
||
///////////////////////////////////////////////////////////
|
||
global proc openBrowser()
|
||
{
|
||
print "\nGoing to www.panda3d.org...\n";
|
||
|
||
launch -webPage "www.panda3d.org";
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: exportOptionsUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc exportOptionsUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select exportOptionsRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseMeshRB":
|
||
print("Export Mesh Chosen\n");
|
||
textField -edit -enable 0 startFrameTF;
|
||
textField -edit -enable 0 endFrameTF;
|
||
radioButton -edit -enable 0 chooseFullRangeRB;
|
||
radioButton -edit -enable 0 chooseCustomRangeRB;
|
||
break;
|
||
case "chooseActorRB":
|
||
print("Export Actor Chosen\n");
|
||
textField -edit -enable 0 startFrameTF;
|
||
textField -edit -enable 0 endFrameTF;
|
||
radioButton -edit -enable 0 chooseFullRangeRB;
|
||
radioButton -edit -enable 0 chooseCustomRangeRB;
|
||
break;
|
||
case "chooseAnimationRB":
|
||
print("Export Animation Chosen\n");
|
||
radioButton -edit -enable 1 -select chooseFullRangeRB;
|
||
radioButton -edit -enable 1 chooseCustomRangeRB;
|
||
animationOptionsUI();
|
||
break;
|
||
case "chooseBothRB":
|
||
print("Export Meshes and Animation Chosen\n");
|
||
radioButton -edit -enable 1 -select chooseFullRangeRB;
|
||
radioButton -edit -enable 1 chooseCustomRangeRB;
|
||
animationOptionsUI();
|
||
break;
|
||
case "choosePoseRB":
|
||
print("Export Pose Chosen\n");
|
||
textField -edit -enable 1 startFrameTF;
|
||
textField -edit -enable 0 endFrameTF;
|
||
radioButton -edit -enable 0 chooseFullRangeRB;
|
||
radioButton -edit -enable 1 -select chooseCustomRangeRB;
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: animationOptionsUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc animationOptionsUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select animationOptionsRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseFullRangeRB":
|
||
print("Animation Full Range Chosen\n");
|
||
textField -edit -enable 0 startFrameTF;
|
||
textField -edit -enable 0 endFrameTF;
|
||
break;
|
||
case "chooseCustomRangeRB":
|
||
print("Animation Custom Range Chosen\n");
|
||
textField -edit -enable 1 startFrameTF;
|
||
textField -edit -enable 1 endFrameTF;
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: texPathOptionsUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc texPathOptionsUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select texPathOptionsRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseDefaultTexPathRB":
|
||
print("Default Texture Path Chosen\n");
|
||
textField -edit -enable 0 customTexPathTF;
|
||
button -edit -enable 0 browseTexPathButton;
|
||
break;
|
||
case "chooseCustomTexPathRB":
|
||
print("Custom Texture Path Chosen\n");
|
||
textField -edit -enable 1 customTexPathTF;
|
||
button -edit -enable 1 browseTexPathButton;
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: outputPathOptionsUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc outputPathOptionsUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select outputPathOptionsRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseDefaultOutputPathRB":
|
||
print("Default File Path Chosen\n");
|
||
textField -edit -enable 0 customOutputPathTF;
|
||
button -edit -enable 0 browseOutputPathButton;
|
||
break;
|
||
case "chooseCustomOutputPathRB":
|
||
print("Custom File Path Chosen\n");
|
||
textField -edit -enable 1 customOutputPathTF;
|
||
button -edit -enable 1 browseOutputPathButton;
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: outputFilenameOptionsUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc outputFilenameOptionsUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select outputFilenameOptionsRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseOriginalFilenameRB":
|
||
print("Default Filename Chosen\n");
|
||
textField -edit -enable 0 customFilenameTF;
|
||
button -edit -enable 0 browseFilenameButton;
|
||
break;
|
||
case "chooseCustomFilenameRB":
|
||
print("Custom Filename Chosen\n");
|
||
textField -edit -enable 1 customFilenameTF;
|
||
button -edit -enable 1 browseFilenameButton;
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: transformModeUI //
|
||
// Updates the UI when a radio button is chosen //
|
||
///////////////////////////////////////////////////////////
|
||
global proc transformModeUI()
|
||
{
|
||
string $selectedRB = `radioCollection -query -select transformModeRC`;
|
||
|
||
switch ($selectedRB)
|
||
{
|
||
case "chooseTransformModelRB":
|
||
print("Save transform of objects which have model- or DCS-flag only, CLEARS local pivot, orientation, scale, and shear of the other objects (all transform will be frozen to the vertices and will be 0 when loaded into Panda3D)\n");
|
||
break;
|
||
case "chooseTransformAllRB":
|
||
print("Save transform of all objects, PRESERVES local pivot, orientation, scale, and shear (all transform will remain when loaded into Panda3D)\n");
|
||
break;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
// Process: browseForFolder //
|
||
// Browses for a directory and returns the path as a string //
|
||
///////////////////////////////////////////////////////////////
|
||
global proc browseForFolder(string $destination)
|
||
{
|
||
fileBrowserDialog
|
||
-mode 4
|
||
-fileCommand ( "browseForFolderCallback \"" + $destination + "\"" )
|
||
-actionName "Pick a Folder";
|
||
}
|
||
|
||
global proc browseForFolderCallback(string $destination, string $result, string $type )
|
||
{
|
||
// Do whatever you need to with the $result
|
||
print ( "Folder selection: " + $result + "\n" );
|
||
|
||
if ( $destination == "texPath")
|
||
{
|
||
textField -edit -text $result customTexPathTF;
|
||
}
|
||
else
|
||
{
|
||
textField -edit -text $result customOutputPathTF;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
// Process: browseForFile //
|
||
// Browses for a file //
|
||
///////////////////////////////////////////////////////////////
|
||
global proc browseForFile(string $destination)
|
||
{
|
||
fileBrowserDialog
|
||
-mode 0
|
||
-fileType "*.EGG"
|
||
-fileCommand ( "browseForFileCallback \"" + $destination + "\"" )
|
||
-actionName "Pick a file";
|
||
}
|
||
|
||
global proc browseForFileCallback(string $destination, string $result, string $type )
|
||
{
|
||
$result=filePart($result);
|
||
$result=match( "[^.]*", $result );
|
||
print ( "File name: " + $result + "\n" );
|
||
|
||
textField -edit -text $result customFilenameTF;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: filePart //
|
||
// Extracts the file portion of an absolute filepath. //
|
||
// Input: e.g. "D:/projects/default/scenes/myScene.mb" //
|
||
// Result: e.g. "myScene.mb" //
|
||
// Filepath can be delimited with //
|
||
// either slash ("/" or "\") //
|
||
///////////////////////////////////////////////////////////
|
||
global proc string filePart( string $path )
|
||
{
|
||
string $filePart = match( "[^/\\]*$", $path );
|
||
|
||
return $filePart;
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////
|
||
// Process: pathPart //
|
||
// Extracts the path portion of an absolute filepath. //
|
||
// Input: e.g. "D:/projects/default/scenes/myScene.mb" //
|
||
// Result: e.g. "D:/projects/default/scenes" //
|
||
// Note: Requires that the filepath be delimited with //
|
||
// _forward_ slashes ("/") //
|
||
////////////////////////////////////////////////////////////
|
||
global proc string pathPart( string $path )
|
||
{
|
||
string $dir = match( "^.*/", $path );
|
||
|
||
// Strip off trailing '/'
|
||
// int $sz = size( $dir );
|
||
// if ( ( $sz > 1 ) && ( substring( $dir, $sz, $sz ) == "/" ) )
|
||
// {
|
||
// $dir = substring( $dir, 1, ($sz - 1) );
|
||
// }
|
||
return $dir;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
// Process: exportScene //
|
||
// exports the entire scene/selected objects //
|
||
///////////////////////////////////////////////////////////////
|
||
global proc string exportScene( string $selection )
|
||
{
|
||
print "Exporting scene...\n";
|
||
|
||
string $sceneFilePath = `file -q -sceneName`; //get scene filename and path
|
||
|
||
if ( $sceneFilePath == "" )
|
||
{
|
||
error "You have not yet saved this scene.\nPlease save your scene or specify a custom output directory and filename.\n";
|
||
return "failed";
|
||
}
|
||
|
||
string $scenePath = pathPart($sceneFilePath);
|
||
string $sceneFile = filePart($sceneFilePath);
|
||
string $fileName = `match "^[^\.]*" $sceneFile`; //cut off the file extension
|
||
string $tempScenePath = ($scenePath + $fileName + "_temp.mb");
|
||
|
||
if ( $selection == "all")
|
||
{
|
||
file -op "v=1" -typ "mayaBinary" -ea $tempScenePath; //export the whole scene
|
||
print ("Saved entire scene as temporary file: " + $fileName + "_temp.mb\n");
|
||
}
|
||
else
|
||
{
|
||
file -op "v=1" -typ "mayaBinary" -es $tempScenePath; //export only selected objects
|
||
print ("Saved selected objects as temporary file: " + $fileName + "_temp.mb\n");
|
||
}
|
||
|
||
return $tempScenePath;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
// Process: argsBuilder //
|
||
// constructs the arguments to pass to maya2egg //
|
||
///////////////////////////////////////////////////////////////
|
||
global proc string argsBuilder()
|
||
{
|
||
string $args = "maya2egg";
|
||
|
||
//get the version of maya and append it to the maya2egg call
|
||
string $mayaVersionLong = `getApplicationVersionAsFloat`;
|
||
string $mayaVersionShort = substituteAllString($mayaVersionLong, ".", "");
|
||
print ("MAYA VERSION : "+$mayaVersionShort+"\n");
|
||
//only strips the zeroes if the version number is less than 4
|
||
if (`size($mayaVersionShort)`<4)
|
||
{
|
||
$mayaVersionShort = substituteAllString($mayaVersionShort, "0", "");
|
||
}
|
||
|
||
$args += $mayaVersionShort;
|
||
|
||
$args += " ";
|
||
|
||
// We always want polygons, never nurbs.
|
||
$args += "-p ";
|
||
|
||
//check back face culling
|
||
if ( `checkBox -query -value bfaceCB` )
|
||
{
|
||
$args += "-bface ";
|
||
}
|
||
|
||
//check animation options
|
||
string $exportOptionsARGS = `radioCollection -query -select exportOptionsRC`;
|
||
|
||
switch ($exportOptionsARGS)
|
||
{
|
||
case "chooseMeshRB":
|
||
$args += "-a none ";
|
||
break;
|
||
case "chooseActorRB":
|
||
$args += "-a model ";
|
||
break;
|
||
case "chooseAnimationRB":
|
||
$args += "-a chan ";
|
||
|
||
//set the start frames **Does not check if start frame < end frame **Does not support negative values **Does not check if start/end frame is within bounds of the scene
|
||
if ( `radioCollection -query -select animationOptionsRC` == "chooseCustomRangeRB" )
|
||
{
|
||
string $startFrameARGS = `textField -query -text startFrameTF`;
|
||
string $endFrameARGS = `textField -query -text endFrameTF`;
|
||
|
||
//start frame
|
||
if ( `match "[0-9]+" $startFrameARGS` == $startFrameARGS && $startFrameARGS != "")
|
||
{
|
||
$args += ( "-sf " + `match "[0-9]+" $startFrameARGS` + " " );
|
||
}
|
||
else
|
||
{
|
||
error "Start Frame entered data is the wrong format. Should be an integer.\n";
|
||
return "failed";
|
||
}
|
||
|
||
//end frame
|
||
if ( `match "[0-9]+" $endFrameARGS` == $endFrameARGS && $endFrameARGS != "")
|
||
{
|
||
$args += ( "-ef " + `match "[0-9]+" $endFrameARGS` + " " );
|
||
}
|
||
else
|
||
{
|
||
error "End Frame entered data is the wrong format. Should be an integer.\n";
|
||
return "failed";
|
||
}
|
||
}
|
||
break;
|
||
case "chooseBothRB":
|
||
$args += "-a both ";
|
||
|
||
//set the start frames **Does not check if start frame < end frame **Does not support negative values **Does not check if start/end frame is within bounds of the scene
|
||
if ( `radioCollection -query -select animationOptionsRC` == "chooseCustomRangeRB" )
|
||
{
|
||
string $startFrameARGS = `textField -query -text startFrameTF`;
|
||
string $endFrameARGS = `textField -query -text endFrameTF`;
|
||
|
||
//start frame
|
||
if ( `match "[0-9]+" $startFrameARGS` == $startFrameARGS && $startFrameARGS != "")
|
||
{
|
||
$args += ( "-sf " + `match "[0-9]+" $startFrameARGS` + " " );
|
||
}
|
||
else
|
||
{
|
||
error "Start Frame entered data is the wrong format. Should be an integer.\n";
|
||
return "failed";
|
||
}
|
||
|
||
//end frame
|
||
if ( `match "[0-9]+" $endFrameARGS` == $endFrameARGS && $endFrameARGS != "")
|
||
{
|
||
$args += ( "-ef " + `match "[0-9]+" $endFrameARGS` + " " );
|
||
}
|
||
else
|
||
{
|
||
error "End Frame entered data is the wrong format. Should be an integer.\n";
|
||
return "failed";
|
||
}
|
||
}
|
||
|
||
|
||
break;
|
||
case "choosePoseRB":
|
||
$args += "-a pose ";
|
||
|
||
//set the start frames **Does not check if start frame < end frame **Does not support negative values **Does not check if start/end frame is within bounds of the scene
|
||
//start frame
|
||
string $startFrameARGS = `textField -query -text startFrameTF`;
|
||
|
||
if ( `match "[0-9]+" $startFrameARGS` == $startFrameARGS && $startFrameARGS != "")
|
||
{
|
||
$args += ( "-sf " + `match "[0-9]+" $startFrameARGS` + " " );
|
||
}
|
||
else
|
||
{
|
||
error "Start Frame entered data is the wrong format. Should be an integer.\n";
|
||
return "failed";
|
||
}
|
||
break;
|
||
}
|
||
|
||
//Relative path check
|
||
if ( `radioCollection -query -select texPathOptionsRC` == "chooseCustomTexPathRB" )
|
||
{
|
||
$args += ( "-pd " + "\"" + `textField -query -text customTexPathTF` + "\"" + " " );
|
||
}
|
||
|
||
print ( "Using these arguments: " + $args + "[END]\n" );
|
||
|
||
return $args;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: export2Egg //
|
||
///////////////////////////////////////////////////////////
|
||
global proc string export2Egg ( string $mbfile, string $destPath, string $destFilename, string $transformMode, string $ARGS)
|
||
{
|
||
string $pandaEnvSetup = "set PATH=%MAYA_LOCATION%\\bin;%PATH% & ";
|
||
|
||
//Check if there is a valid maya binary file to operate on
|
||
if ( $mbfile == "" )
|
||
{
|
||
error "Not a valid Maya Binary file.";
|
||
|
||
return "failed";
|
||
}
|
||
//Start export process
|
||
else
|
||
{
|
||
//make the final egg path
|
||
string $eggFile = ( $destPath + $destFilename );
|
||
string $up=`upAxis -q -axis`;
|
||
string $unit=`optionMenu -q -value unitMenu`;
|
||
|
||
$ARGS += " -cs " + $up+"-up";
|
||
$ARGS += " -uo " + $unit;
|
||
$ARGS += " -trans " + $transformMode;
|
||
|
||
print ("Your scene will be saved as this egg file: " + $destFilename + "\n" );
|
||
|
||
print ("In this directory: " + $destPath + "\n" );
|
||
|
||
//Check if overwriting is enabled
|
||
if ( `checkBox -query -value overwriteCB` )
|
||
{
|
||
//Overwrite
|
||
print "!!Overwrite enabled!!\n";
|
||
string $result =
|
||
system
|
||
(
|
||
$pandaEnvSetup + $ARGS
|
||
+ " -o "
|
||
+ "\"" + $eggFile + "\""
|
||
+ " "
|
||
+ "\"" + $mbfile + "\""
|
||
);
|
||
|
||
print ($result + "\n");
|
||
}
|
||
else
|
||
{
|
||
//Don't overwrite
|
||
string $result =
|
||
system
|
||
(
|
||
$pandaEnvSetup + $ARGS
|
||
+ "\"" + $mbfile + "\""
|
||
+ " "
|
||
+ "\"" + $eggFile + "\""
|
||
);
|
||
|
||
print ($result + "\n");
|
||
}
|
||
|
||
string $unit=`optionMenu -q -value unitMenu`;
|
||
print ("Finished exporting (.mb -> .egg), unit : "+$unit+"\n");
|
||
return $eggFile;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: exportButton //
|
||
///////////////////////////////////////////////////////////
|
||
global proc int exportButton ()
|
||
{
|
||
//We need to do before calling export2EGG/BAM/Pview:
|
||
//-Export a temporary MB
|
||
//-Get the destination path
|
||
//-Get the filename
|
||
//-Get the custom arguments
|
||
|
||
//Export the scene as a temporary file
|
||
string $tempMBFile = "";
|
||
if ( `checkBox -query -value selectedCB` )
|
||
{
|
||
$tempMBFile = exportScene( "selected" );
|
||
if ( $tempMBFile == "failed" )
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$tempMBFile = exportScene( "all" );
|
||
if ( $tempMBFile == "failed" )
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
//get the original scene name
|
||
string $origFileName = filePart ( `file -q -sceneName` );
|
||
$origFileName = `match "^[^\.]*" $origFileName`; //cut off the file extension
|
||
|
||
//-Get the destination path
|
||
//-Get the filename
|
||
//-Get the custom arguments
|
||
|
||
string $eggFile = exportPrep ( $tempMBFile, $origFileName );
|
||
|
||
if ( $eggFile == "failed" )
|
||
{
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
return 1;
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: send2Pview //
|
||
///////////////////////////////////////////////////////////
|
||
global proc send2Pview( string $file )
|
||
{
|
||
print "\nStarting pview...\n";
|
||
|
||
string $result =
|
||
system
|
||
(
|
||
"shell pview -l -c "
|
||
+ "\"" + $file + "\""
|
||
);
|
||
|
||
print ($result + "\n");
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: getFile2Pview //
|
||
///////////////////////////////////////////////////////////
|
||
global proc getFile2Pview()
|
||
{
|
||
string $selectedFile = `fileDialog -directoryMask "*.egg;*.bam"`;
|
||
|
||
string $origFileName = filePart ( $selectedFile );
|
||
$origFileName = `match "^[^\.]*" $origFileName`; //cut off the file extension
|
||
|
||
if ( $selectedFile == "")
|
||
{
|
||
error ( "No file selected\n" );
|
||
}
|
||
else
|
||
{
|
||
send2Pview ( $selectedFile );
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: getFile2Bam //
|
||
///////////////////////////////////////////////////////////
|
||
global proc getFile2Bam()
|
||
{
|
||
string $selectedFile = `fileDialog -directoryMask "*.egg"`;
|
||
|
||
if ( $selectedFile == "")
|
||
{
|
||
error ( "No file selected\n" );
|
||
}
|
||
else
|
||
{
|
||
export2Bam ( $selectedFile );
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: getFile2Egg //
|
||
///////////////////////////////////////////////////////////
|
||
global proc getFile2Egg()
|
||
{
|
||
string $selectedFile = `fileDialog -directoryMask "*.mb"`;
|
||
|
||
string $fileName = filePart ( $selectedFile );
|
||
$fileName = `match "^[^\.]*" $fileName`; //cut off the file extension
|
||
|
||
if ( $selectedFile == "")
|
||
{
|
||
error ( "No file selected\n" );
|
||
}
|
||
else
|
||
{
|
||
exportPrep ( $selectedFile, $fileName );
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////////
|
||
// Process: exportPrep //
|
||
///////////////////////////////////////////////////////////
|
||
global proc string exportPrep( string $workFile, string $fileName )
|
||
{
|
||
//Get the destination path
|
||
string $destPath = "";
|
||
if ( `radioCollection -query -select outputPathOptionsRC` == "chooseDefaultOutputPathRB" )
|
||
{
|
||
$destPath = pathPart($workFile);
|
||
}
|
||
else
|
||
{
|
||
if ( `textField -query -text customOutputPathTF` == "")
|
||
{
|
||
error "Output directory field is empty";
|
||
return "failed";
|
||
}
|
||
else
|
||
{
|
||
$destPath = `textField -query -text customOutputPathTF` + "/";
|
||
}
|
||
}
|
||
|
||
//Get the filename
|
||
string $destFilename = "";
|
||
if ( `radioCollection -query -select outputFilenameOptionsRC` == "chooseOriginalFilenameRB" )
|
||
{
|
||
$destFilename = $fileName + ".egg";
|
||
}
|
||
else
|
||
{
|
||
if ( `textField -query -text customFilenameTF` == "")
|
||
{
|
||
error "Custom filename field is empty";
|
||
return "failed";
|
||
}
|
||
else
|
||
{
|
||
$destFilename = `textField -query -text customFilenameTF` + ".egg";
|
||
}
|
||
}
|
||
|
||
//Get the transform mode
|
||
string $transformMode = "";
|
||
if ( `radioCollection -query -select transformModeRC` == "chooseTransformModelRB" )
|
||
{
|
||
$transformMode = "model";
|
||
}
|
||
else
|
||
{
|
||
$transformMode = "all";
|
||
}
|
||
|
||
//-Get the custom arguments
|
||
string $ARGS = argsBuilder();
|
||
|
||
if ( $ARGS == "failed" )
|
||
{
|
||
return "failed";
|
||
}
|
||
|
||
//export the egg
|
||
string $eggFile = export2Egg ( $workFile, $destPath, $destFilename, $transformMode, $ARGS);
|
||
|
||
if ( $eggFile == "failed" )
|
||
{
|
||
return "failed";
|
||
}
|
||
|
||
//run pview if option is selected
|
||
if ( `checkBox -query -value pviewCB` )
|
||
{
|
||
send2Pview ( $eggFile );
|
||
}
|
||
|
||
if ( `radioCollection -query -select outputFileOptionsRC` == "chooseEggBamRB" )
|
||
{
|
||
export2Bam ( $eggFile );
|
||
}
|
||
|
||
return $eggFile;
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Process: export2Bam //
|
||
///////////////////////////////////////////////////////////
|
||
global proc export2Bam ( string $eggFile )
|
||
{
|
||
//Check if there is a valid egg file to operate on
|
||
if ( $eggFile == "" )
|
||
{
|
||
//Cannot operate without an egg first
|
||
//throw error if the scene has no associated egg file
|
||
error "Invalid egg file";
|
||
}
|
||
//Call egg2bam
|
||
else
|
||
{
|
||
string $bamFile = "";
|
||
string $fileName = filePart($eggFile);
|
||
string $filePath = pathPart($eggFile);
|
||
|
||
//Use either the original fileName or a new fileName for the output
|
||
if ( `radioCollection -query -select outputFilenameOptionsRC` == "chooseCustomFilenameRB" )
|
||
{
|
||
$bamFile = $filePath + `textField -query -text customFilenameTF` + ".bam";
|
||
}
|
||
else
|
||
{
|
||
$bamFile = $filePath + `match "^[^\.]*" $fileName` + ".bam";
|
||
}
|
||
|
||
print ("Your file is: " + $fileName + "\nFound in path: " + $filePath + "\n\n");
|
||
|
||
print ("Your file will be saved as this bam file: " + $bamFile + "\n");
|
||
|
||
//Check if overwriting is enabled
|
||
if ( `checkBox -query -value overwriteCB` )
|
||
{
|
||
//Overwrite
|
||
string $result =
|
||
system
|
||
(
|
||
"egg2bam -o "
|
||
+ "\"" + $bamFile + "\""
|
||
+ " "
|
||
+ "\"" + $eggFile + "\""
|
||
);
|
||
|
||
print ($result + "\n");
|
||
}
|
||
else
|
||
{
|
||
//Don't overwrite
|
||
string $result =
|
||
system
|
||
(
|
||
"egg2bam "
|
||
+ "\"" + $eggFile + "\""
|
||
+ " "
|
||
+ "\"" + $bamFile + "\""
|
||
);
|
||
|
||
print ($result + "\n");
|
||
}
|
||
}
|
||
|
||
string $unit=`optionMenu -q -value unitMenu`;
|
||
print ("Finished exporting (.egg -> .bam), unit : "+$unit+"\n");
|
||
}
|