-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMayaPandaTool.mel
1357 lines (1133 loc) · 55.3 KB
/
MayaPandaTool.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
///////////////////////////////////////////////////////////////////////////////////
// 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. //
///////////////////////////////////////////////////////////////////////////////////
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: 280x575
// (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";