1/******************************************************************************
2	NintendoWare for CTR Maya Plugin
3
4	File:         NW4C_ExpDialog.mel
5	Description:  create export dialog
6	Date:         2010/10/07
7	Author:       Takashi Endo
8
9	Copyright (C)2009-2010 Nintendo Co., Ltd. / HAL Laboratory, Inc. All rights reserved.
10******************************************************************************/
11
12// NW4C_ExpDirect
13// OpenOptionWindow CreateSettingMenu
14// SetOptionVariable SetOptionControl UpdateOptionVariableT ResetOptionVariable
15// ExportCB DoExportCmd CheckOptionValue
16// SetConsistentCallback
17// SaveSettingToScene LoadSettingFromScene DeleteUselessSettingNode
18// SaveSettingToFile LoadSettingFromFile GetOptionStringFromC3es
19// SearchAnim
20
21/******************************************************************************
22	variables
23******************************************************************************/
24global int $nw4cExpDialog_SettingLatestVer = 13;
25global string $nw4cExpDialog_c3esLatestVer = "1.3.0";
26global int $nw4cExpDialog_LoadSettingJob = -1;
27
28/******************************************************************************
29	load plugin
30******************************************************************************/
31proc LoadPlugin()
32{
33	if (!`pluginInfo -q -l "NW4C_Export.mll"`)
34	{
35		loadPlugin("NW4C_Export.mll");
36	}
37}
38
39/******************************************************************************
40	show error & stop
41******************************************************************************/
42proc ShowError(string $msg)
43{
44	if (!`about -batch`)
45	{
46		trace ("Error: " + $msg + "\n");
47	}
48	error $msg;
49}
50
51/******************************************************************************
52	use custom ui
53******************************************************************************/
54proc int UseCustomUI()
55{
56	// �J�X�^�� UI �̎g�p�ݒ���‹��ϐ� NW4C_MAYA_CUSTOM_UI ����擾����B
57	// �‹��ϐ��̐ݒ�l�� "0" �̎��̓J�X�^�� UI ���g�p�����A�T�t�B�b�N�X���w�肳��Ă��鎞��
58	// �J�X�^�� UI ���g�p����B�‹��ϐ�����`����Ă��Ȃ��ꍇ�� "0" ���ݒ肳��Ă���Ƃ݂Ȃ��B
59	string $val = `getenv "NW4C_MAYA_CUSTOM_UI"`;
60	if ($val == "")
61	{
62		$val = "0";
63	}
64	else
65	{
66		$val = "1";
67	}
68	return int($val);
69}
70
71/******************************************************************************
72	use 3DEditor
73******************************************************************************/
74proc int Use3DEditor()
75{
76	// 3DEditor �����݂��Ă��邩�m�F����B
77	int $exist = 0;
78	string $nw4cRoot = `getenv "NW4C_ROOT"`;
79	if ($nw4cRoot != "")
80	{
81		string $editorPath = ($nw4cRoot + "/tools/3DEditor/3DEditor.exe");
82		if (`filetest -e $editorPath`)
83		{
84			$exist = 1;
85		}
86	}
87	return $exist;
88}
89
90/******************************************************************************
91	find string in array
92******************************************************************************/
93proc int FindStringInArray(string $array[], string $value)
94{
95	int $size = size($array);
96	int $idx;
97	for ($idx = 0; $idx < $size; ++$idx)
98	{
99		if ($array[$idx] == $value)
100		{
101			return $idx;
102		}
103	}
104	return -1;
105}
106
107/******************************************************************************
108	does save load scene setting
109******************************************************************************/
110proc int DoesSaveLoadSceneSetting()
111{
112	if (!`optionVar -ex nw4cExpDialog_SaveLoadSceneSetting`)
113	{
114		return 1; // default
115	}
116	//trace ("save load scene setting: " + `optionVar -q nw4cExpDialog_SaveLoadSceneSetting` + "\n");
117	return `optionVar -q nw4cExpDialog_SaveLoadSceneSetting`;
118}
119
120/******************************************************************************
121	load setting from option string
122******************************************************************************/
123proc LoadSettingFromOptionString(int $version, string $opts)
124{
125	print ("load NW4C export settings from scene (ver "
126		+ ($version / 10) + "." + ($version % 10) + ")\n");
127
128	//-----------------------------------------------------------------------------
129	// set option variable
130	optionVar -sv nw4cExport_Options $opts;
131
132	//-----------------------------------------------------------------------------
133	// refresh option box
134	if (`scrollLayout -ex nw4cExpDialog_ScrollLayout`)
135	{
136		if (`columnLayout -ex nw4cExpDialog_MainColumn`)
137		{
138			NW4C_ExpDialog;
139		}
140	}
141}
142
143/******************************************************************************
144	load setting from scene (called when scene is opened)
145******************************************************************************/
146global proc nw4cExpDialog_LoadSettingFromScene()
147{
148	global int $nw4cExpDialog_SettingVer;
149	global string $nw4cExpDialog_SettingExportOptions;
150
151	//-----------------------------------------------------------------------------
152	// check save / load scene setting is enabled
153	if (!DoesSaveLoadSceneSetting())
154	{
155		return;
156	}
157
158	//-----------------------------------------------------------------------------
159	// evaluate setting node
160	string $node = "nw4cExpDialog_Setting1";
161	if (!`objExists $node`)
162	{
163		return;
164	}
165	if (nodeType($node) != "script")
166	{
167		return;
168	}
169	string $cmd = `getAttr ($node + ".b")`;
170	if (!size($cmd))
171	{
172		return;
173	}
174	eval($cmd);
175	int $version = $nw4cExpDialog_SettingVer;
176	string $opts = $nw4cExpDialog_SettingExportOptions;
177
178	//-----------------------------------------------------------------------------
179	// load setting
180	if (size($opts))
181	{
182		LoadSettingFromOptionString($version, $opts);
183	}
184}
185
186/******************************************************************************
187	setting node function (called from script node) (do nothing now)
188******************************************************************************/
189global proc nw4cExpDialog_SettingNodeFunc()
190{
191
192}
193
194/******************************************************************************
195	set consistent callback
196******************************************************************************/
197global proc nw4cExpDialog_SetConsistentCallback()
198{
199	// set load setting job at scene opened
200	global int $nw4cExpDialog_LoadSettingJob = -1;
201	$nw4cExpDialog_LoadSettingJob = `scriptJob -e "SceneOpened"
202		"if (`exists nw4cExpDialog_LoadSettingFromScene`) nw4cExpDialog_LoadSettingFromScene;"`;
203}
204
205/******************************************************************************
206	delete useless setting node
207******************************************************************************/
208proc DeleteUselessSettingNode()
209{
210	string $nodes[] = `ls -typ script`;
211	string $node;
212	for ($node in $nodes)
213	{
214		if (gmatch($node, "*_nw4cExpDialog_Setting*") ||
215			gmatch($node, "*:nw4cExpDialog_Setting*"))
216		{
217			if (`referenceQuery -inr $node`) // if referenced
218			{
219				print ("disable settings: " + $node + "\n");
220				if (`getAttr -l ($node + ".st")`)
221				{
222					print "(locked)\n";
223				}
224				else
225				{
226					catch(`setAttr ($node + ".st") 0`); // Demand
227				}
228			}
229			else
230			{
231				print ("delete settings: " + $node + "\n");
232				catch(`delete $node`);
233			}
234		}
235	}
236}
237
238/******************************************************************************
239	get setting node command
240******************************************************************************/
241proc string GetSettingNodeCommand()
242{
243	string $cmd = "";
244
245	//-----------------------------------------------------------------------------
246	// setting version
247	global int $nw4cExpDialog_SettingLatestVer;
248	$cmd += "global int $nw4cExpDialog_SettingVer = " + $nw4cExpDialog_SettingLatestVer + ";\n";
249
250	//-----------------------------------------------------------------------------
251	// export options
252	$cmd += "global string $nw4cExpDialog_SettingExportOptions = \""
253		+ `optionVar -q nw4cExport_Options` + "\";\n";
254
255	//-----------------------------------------------------------------------------
256	// setting node function
257	$cmd += "if (`exists nw4cExpDialog_SettingNodeFunc`) "
258		+ "nw4cExpDialog_SettingNodeFunc();\n";
259
260	return $cmd;
261}
262
263/******************************************************************************
264	save setting to scene
265******************************************************************************/
266proc SaveSettingToScene(int $checkSceneSettingFlag)
267{
268	//return; // never save (debug)
269
270	//-----------------------------------------------------------------------------
271	// check save / load flag
272	if ($checkSceneSettingFlag && !DoesSaveLoadSceneSetting())
273	{
274		return;
275	}
276
277	//-----------------------------------------------------------------------------
278	// delete useless setting node
279	DeleteUselessSettingNode();
280
281	//-----------------------------------------------------------------------------
282	// create setting node
283	string $node = "nw4cExpDialog_Setting1";
284	if (!`objExists $node`)
285	{
286		string $selBak[] = `ls -sl`;
287		createNode script -n $node;
288		select $selBak;
289	}
290
291	//-----------------------------------------------------------------------------
292	// set setting node command & attr
293	if (`getAttr -l ($node + ".b")`)
294	{
295		print "NW4C export settings node is locked\n";
296		return;
297	}
298
299	string $cmd = GetSettingNodeCommand();
300	catch(`setAttr ($node + ".b") -type "string" $cmd`);
301	catch(`setAttr ($node + ".st") 1`); // Open/Close
302}
303
304/******************************************************************************
305	save setting file folder
306******************************************************************************/
307proc SaveSettingFileFolder(string $filePath)
308{
309	string $settingFolder = substitute("[^/]*$", $filePath, "");
310	optionVar -sv nw4cExpDialog_SettingFileFolder $settingFolder;
311}
312
313/******************************************************************************
314	set setting file folder to currnet
315******************************************************************************/
316proc SetSettingFileFolderToCurrent()
317{
318	string $settingFolder = "";
319	if (`optionVar -ex nw4cExpDialog_SettingFileFolder`)
320	{
321		$settingFolder = `optionVar -q nw4cExpDialog_SettingFileFolder`;
322	}
323	if (size($settingFolder) > 0 && `filetest -d $settingFolder`)
324	{
325		workspace -dir $settingFolder;
326	}
327}
328
329/******************************************************************************
330	get float string for setting file
331******************************************************************************/
332proc string GetFloatStringForSettingFile(float $val)
333{
334	string $str = $val;
335	if (match("\\.", $str) == "")
336	{
337		$str += ".0";
338	}
339	return $str;
340}
341
342/******************************************************************************
343	save setting to file (do)
344******************************************************************************/
345global proc nw4cExpDialog_SaveSettingToFileDo(string $filePath)
346{
347	global string $nw4cExpDialog_c3esLatestVer;
348
349	string $boolNames[2] = { "false", "true" };
350
351	//-----------------------------------------------------------------------------
352	// add extension
353	if (match("\\.c3es$", $filePath) == "")
354	{
355		$filePath += ".c3es";
356	}
357
358	//-----------------------------------------------------------------------------
359	// update option variable
360	nw4cExpDialog_UpdateOptionVariable(0); // no save setting to scene
361
362	//-----------------------------------------------------------------------------
363	// get generator version
364	string $generatorVersion = "?";
365	if (`pluginInfo -q -l "NW4C_Export.mll"`)
366	{
367		$generatorVersion = eval("NW4C_ExportInfoCmd -p");
368	}
369
370	//-----------------------------------------------------------------------------
371	// get date & time
372	if (size(match("^//", `pwd`)) != 0)
373	{
374		// if the current folder is on network drive
375		// change it on local drive for getting date & time properly
376		string $localFolder = getenv("TEMP");
377		if (size($localFolder) > 0 && `filetest -d $localFolder`)
378		{
379			chdir($localFolder);
380			//trace ("change cur folder to " + $localFolder);
381		}
382	}
383
384	string $date = `system "echo %DATE%"`;
385	$date = match("[0-9/]+", $date);
386	$date = substituteAllString($date, "/", "-");
387	string $time = `system "echo %TIME%"`;
388	$time = match("[0-9:]+", $time);
389
390	//-----------------------------------------------------------------------------
391	// parse export options
392	//-----------------------------------------------------------------------------
393
394	//-----------------------------------------------------------------------------
395	// init
396	string $processMode = "Single";
397	string $exportTarget = "All";
398	string $outputFileName = "";
399	string $outputMode = "File";
400	string $outputFolder = "";
401	int $mergeCmdl = 0;
402	string $mergeCmdlPath = "";
403	int $copyRelatedFiles = 0;
404	//int $mergeCmdlAuto = 1;
405
406	float $magnify = 1.0;
407	string $frameRange = "All";
408	int $startFrame = 1;
409	int $endFrame = 100;
410	//string $texMatrixMode = "Maya";
411	int $removeNamespace = 0;
412
413	int $outputCmdl = 1;
414	int $outputCtex = 1;
415	int $outputCmdla = 0;
416	int $outputCskla = 0;
417	int $outputCmata = 0;
418	int $outputCmcla = 0;
419	int $outputCmtpa = 0;
420	int $outputCmtsa = 0;
421	int $outputCcam = 0;
422	int $outputClgt = 0;
423	int $outputCenv = 0;
424
425	string $compressNode = "None";
426	//int $combinePolygon = 0;
427	int $compressMaterial = 0;
428	int $optimizePrimitive = 1;
429	int $convertToModel = 0;
430	//int $delUselessVtxData = 0;
431
432	string $quantizePos = "Float";
433	string $quantizeNrm = "Float";
434	string $quantizeTex = "Float";
435	int $frameFormat = 0;
436	int $scaleQuantizeQuality = 9;
437	int $rotateQuantizeQuality = 9;
438	int $translateQuantizeQuality = 9;
439
440	string $adjustSkinning = "None";
441	string $meshVisibilityMode = "BindByIndex";
442	int $nonUniformScale = 0;
443	int $maxReservedUniformRegisters = 0;
444
445	int $bakeAllAnim = 1;
446	float $framePrecision = 1.0;
447	int $loopAnim = 0;
448
449	float $toleranceScale     = 0.1;
450	float $toleranceRotate    = 0.1;
451	float $toleranceTranslate = 0.01;
452	float $toleranceTexScale     = 0.1;
453	float $toleranceTexRotate    = 0.1;
454	float $toleranceTexTranslate = 0.01;
455	float $toleranceColor = 0.001;
456
457	//-----------------------------------------------------------------------------
458	// get option var
459	string $optStr = "";
460	if (`optionVar -ex nw4cExport_Options`)
461	{
462		$optStr = `optionVar -q nw4cExport_Options`;
463	}
464
465	//-----------------------------------------------------------------------------
466	// parse option var
467	string $opts[], $words[];
468	tokenize($optStr, ";", $opts);
469	int $optSize = size($opts);
470	int $iopt;
471	for ($iopt = 0; $iopt < $optSize; ++$iopt)
472	{
473		tokenize($opts[$iopt], "=", $words);
474		string $tag = $words[0];
475		string $val = $words[1];
476		int $boolVal = ($val == "true" || $val == "On" || $val == "1");
477
478		//-----------------------------------------------------------------------------
479		// output
480		if ($tag == "ProcessMode")
481		{
482			$processMode = $val;
483		}
484		else if ($tag == "ExportTarget")
485		{
486			$exportTarget = $val;
487		}
488		else if ($tag == "OutputFileName")
489		{
490			$outputFileName = $val;
491		}
492		else if ($tag == "OutputMode")
493		{
494			$outputMode = $val;
495		}
496		else if ($tag == "OutputFolder")
497		{
498			$outputFolder = $val;
499		}
500		else if ($tag == "MergeCmdl")
501		{
502			$mergeCmdl = $boolVal;
503		}
504		else if ($tag == "MergeCmdlPath")
505		{
506			$mergeCmdlPath = $val;
507		}
508		else if ($tag == "CopyRelatedFiles")
509		{
510			$copyRelatedFiles = $boolVal;
511		}
512		//else if ($tag == "MergeCmdlAuto")
513		//{
514		//	$mergeCmdlAuto = $boolVal;
515		//}
516
517		//-----------------------------------------------------------------------------
518		// general
519		else if ($tag == "Magnify")
520		{
521			$magnify = $val;
522		}
523		else if ($tag == "FrameRange")
524		{
525			$frameRange = $val;
526		}
527		else if ($tag == "StartFrame")
528		{
529			$startFrame = $val;
530		}
531		else if ($tag == "EndFrame")
532		{
533			$endFrame = $val;
534		}
535		//else if ($tag == "TexMatrixMode")
536		//{
537		//	$texMatrixMode = $val;
538		//}
539		else if ($tag == "RemoveNamespace")
540		{
541			$removeNamespace = $boolVal;
542		}
543
544		//-----------------------------------------------------------------------------
545		// file selection
546		else if ($tag == "OutputCmdl")
547		{
548			$outputCmdl = $boolVal;
549		}
550		else if ($tag == "OutputCtex")
551		{
552			$outputCtex = $boolVal;
553		}
554		else if ($tag == "OutputCmdla")
555		{
556			$outputCmdla = $boolVal;
557		}
558		else if ($tag == "OutputCskla")
559		{
560			$outputCskla = $boolVal;
561		}
562		else if ($tag == "OutputCmata")
563		{
564			$outputCmata = $boolVal;
565		}
566		else if ($tag == "OutputCmcla")
567		{
568			$outputCmcla = $boolVal;
569		}
570		else if ($tag == "OutputCmtpa")
571		{
572			$outputCmtpa = $boolVal;
573		}
574		else if ($tag == "OutputCmtsa")
575		{
576			$outputCmtsa = $boolVal;
577		}
578		else if ($tag == "OutputCcam")
579		{
580			$outputCcam = $boolVal;
581		}
582		else if ($tag == "OutputClgt")
583		{
584			$outputClgt = $boolVal;
585		}
586		else if ($tag == "OutputCenv")
587		{
588			$outputCenv = $boolVal;
589		}
590
591		//-----------------------------------------------------------------------------
592		// optimization
593		else if ($tag == "CompressNode")
594		{
595			$compressNode = $val;
596		}
597		//else if ($tag == "CombinePolygon")
598		//{
599		//	$combinePolygon = $boolVal;
600		//}
601		else if ($tag == "CompressMaterial")
602		{
603			$compressMaterial = $boolVal;
604		}
605		else if ($tag == "OptimizePrimitive")
606		{
607			$optimizePrimitive = $boolVal;
608		}
609		else if ($tag == "ConvertToModel")
610		{
611			$convertToModel = $boolVal;
612		}
613
614		//else if ($tag == "DelUselessVtxData")
615		//{
616		//	$delUselessVtxData = $boolVal;
617		//}
618
619		//-----------------------------------------------------------------------------
620		// quantization
621		else if ($tag == "QuantizePos")
622		{
623			$quantizePos = $val;
624		}
625		else if ($tag == "QuantizeNrm")
626		{
627			$quantizeNrm = $val;
628		}
629		else if ($tag == "QuantizeTex")
630		{
631			$quantizeTex = $val;
632		}
633		else if ($tag == "FrameFormat")
634		{
635			$frameFormat = $boolVal;
636		}
637		else if ($tag == "ScaleQuantizeQuality")
638		{
639			$scaleQuantizeQuality = $val;
640		}
641		else if ($tag == "RotateQuantizeQuality")
642		{
643			$rotateQuantizeQuality = $val;
644		}
645		else if ($tag == "TranslateQuantizeQuality")
646		{
647			$translateQuantizeQuality = $val;
648		}
649
650		//-----------------------------------------------------------------------------
651		// model
652		else if ($tag == "AdjustSkinning")
653		{
654			$adjustSkinning = $val;
655		}
656		else if ($tag == "MeshVisibilityMode")
657		{
658			$meshVisibilityMode = $val;
659		}
660		else if ($tag == "NonUniformScale")
661		{
662			$nonUniformScale = $boolVal;
663		}
664		else if ($tag == "MaxReservedUniformRegisters")
665		{
666			$maxReservedUniformRegisters = $val;
667		}
668
669		//-----------------------------------------------------------------------------
670		// animation
671		else if ($tag == "BakeAllAnim")
672		{
673			$bakeAllAnim = $boolVal;
674		}
675		else if ($tag == "FramePrecision")
676		{
677			if ($val == "2")
678			{
679				$framePrecision = 0.5;
680			}
681			else if ($val == "5")
682			{
683				$framePrecision = 0.2;
684			}
685			else if ($val == "10")
686			{
687				$framePrecision = 0.1;
688			}
689		}
690		else if ($tag == "LoopAnim")
691		{
692			$loopAnim = $boolVal;
693		}
694
695		//-----------------------------------------------------------------------------
696		// tolerance
697		else if ($tag == "ToleranceScale")
698		{
699			$toleranceScale = $val;
700		}
701		else if ($tag == "ToleranceRotate")
702		{
703			$toleranceRotate = $val;
704		}
705		else if ($tag == "ToleranceTranslate")
706		{
707			$toleranceTranslate = $val;
708		}
709		else if ($tag == "ToleranceTexScale")
710		{
711			$toleranceTexScale = $val;
712		}
713		else if ($tag == "ToleranceTexRotate")
714		{
715			$toleranceTexRotate = $val;
716		}
717		else if ($tag == "ToleranceTexTranslate")
718		{
719			$toleranceTexTranslate = $val;
720		}
721		else if ($tag == "ToleranceColor")
722		{
723			$toleranceColor = $val;
724		}
725	}
726
727	//-----------------------------------------------------------------------------
728	// open file
729	int $fid = fopen($filePath, "w");
730	if ($fid == 0)
731	{
732		ShowError("Can't open file: " + $filePath);
733	}
734
735	//-----------------------------------------------------------------------------
736	// header
737	fprint($fid, "# NW4C_Export settings\r\n");
738	fprint($fid, "SettingsVersion=\"" + $nw4cExpDialog_c3esLatestVer + "\"\r\n");
739	fprint($fid, "GeneratorName=\"Maya " + `about -v` + " NW4C_Export\"\r\n");
740	fprint($fid, "GeneratorVersion=\"" + $generatorVersion + "\"\r\n");
741	fprint($fid, "Date=\"" + $date + "T" + $time + "\"\r\n");
742	fprint($fid, "\r\n");
743
744	//-----------------------------------------------------------------------------
745	// output options
746	fprint($fid, "# Output Options\r\n");
747	fprint($fid, "ProcessMode=\"" + $processMode + "\"\r\n");
748	fprint($fid, "ExportTarget=\"" + $exportTarget + "\"\r\n");
749	fprint($fid, "OutputFileName=\"" + $outputFileName + "\"\r\n");
750	fprint($fid, "OutputMode=\"" + $outputMode + "\"\r\n");
751	fprint($fid, "OutputFolder=\"" + $outputFolder + "\"\r\n");
752	fprint($fid, "MergeCmdl=\"" + $boolNames[$mergeCmdl] + "\"\r\n");
753	fprint($fid, "MergeCmdlPath=\"" + $mergeCmdlPath + "\"\r\n");
754	fprint($fid, "CopyRelatedFiles=\"" + $boolNames[$copyRelatedFiles] + "\"\r\n");
755	//fprint($fid, "MergeCmdlAuto=\"" + $boolNames[$mergeCmdlAuto] + "\"\r\n");
756	fprint($fid, "\r\n");
757
758	//-----------------------------------------------------------------------------
759	// general options
760	fprint($fid, "# General Options\r\n");
761	fprint($fid, "Magnify=\"" + GetFloatStringForSettingFile($magnify) + "\"\r\n");
762	fprint($fid, "FrameRange=\"" + $frameRange + "\"\r\n");
763	fprint($fid, "StartFrame=\"" + $startFrame + "\"\r\n");
764	fprint($fid, "EndFrame=\"" + $endFrame + "\"\r\n");
765	//fprint($fid, "TexMatrixMode=\"" + $texMatrixMode + "\"\r\n");
766	fprint($fid, "RemoveNamespace=\"" + $boolNames[$removeNamespace] + "\"\r\n");
767	fprint($fid, "\r\n");
768
769	//-----------------------------------------------------------------------------
770	// output file selection
771	fprint($fid, "# Output File Selection\r\n");
772	fprint($fid, "OutputCmdl=\"" + $boolNames[$outputCmdl] + "\"\r\n");
773	fprint($fid, "OutputCtex=\"" + $boolNames[$outputCtex] + "\"\r\n");
774	fprint($fid, "OutputCmdla=\"" + $boolNames[$outputCmdla] + "\"\r\n");
775	fprint($fid, "OutputCskla=\"" + $boolNames[$outputCskla] + "\"\r\n");
776	fprint($fid, "OutputCmata=\"" + $boolNames[$outputCmata] + "\"\r\n");
777	fprint($fid, "OutputCmcla=\"" + $boolNames[$outputCmcla] + "\"\r\n");
778	fprint($fid, "OutputCmtpa=\"" + $boolNames[$outputCmtpa] + "\"\r\n");
779	fprint($fid, "OutputCmtsa=\"" + $boolNames[$outputCmtsa] + "\"\r\n");
780	fprint($fid, "OutputCcam=\"" + $boolNames[$outputCcam] + "\"\r\n");
781	fprint($fid, "OutputClgt=\"" + $boolNames[$outputClgt] + "\"\r\n");
782	fprint($fid, "OutputCenv=\"" + $boolNames[$outputCenv] + "\"\r\n");
783	fprint($fid, "\r\n");
784
785	//-----------------------------------------------------------------------------
786	// optimization options
787	fprint($fid, "# Optimization Options\r\n");
788	fprint($fid, "CompressNode=\"" + $compressNode + "\"\r\n");
789	//fprint($fid, "CombinePolygon=\"" + $boolNames[$combinePolygon] + "\"\r\n");
790	fprint($fid, "CompressMaterial=\"" + $boolNames[$compressMaterial] + "\"\r\n");
791	fprint($fid, "OptimizePrimitive=\"" + $boolNames[$optimizePrimitive] + "\"\r\n");
792	fprint($fid, "ConvertToModel=\"" + $boolNames[$convertToModel] + "\"\r\n");
793	//fprint($fid, "DelUselessVtxData=\"" + $boolNames[$delUselessVtxData] + "\"\r\n");
794	fprint($fid, "\r\n");
795
796	//-----------------------------------------------------------------------------
797	// quantization options
798	fprint($fid, "# Quantization Options\r\n");
799	fprint($fid, "QuantizePos=\"" + $quantizePos + "\"\r\n");
800	fprint($fid, "QuantizeNrm=\"" + $quantizeNrm + "\"\r\n");
801	fprint($fid, "QuantizeTex=\"" + $quantizeTex + "\"\r\n");
802	fprint($fid, "\r\n");
803
804	//-----------------------------------------------------------------------------
805	// model options
806	fprint($fid, "# Model Options\r\n");
807	fprint($fid, "AdjustSkinning=\"" + $adjustSkinning + "\"\r\n");
808	fprint($fid, "MeshVisibilityMode=\"" + $meshVisibilityMode + "\"\r\n");
809	fprint($fid, "NonUniformScale=\"" + $boolNames[$nonUniformScale] + "\"\r\n");
810	fprint($fid, "MaxReservedUniformRegisters=\"" + $maxReservedUniformRegisters + "\"\r\n");
811
812
813	fprint($fid, "\r\n");
814
815	//-----------------------------------------------------------------------------
816	// animation options
817	fprint($fid, "# Animation Options\r\n");
818	fprint($fid, "BakeAllAnim=\"" + $boolNames[$bakeAllAnim] + "\"\r\n");
819	fprint($fid, "FramePrecision=\"" + GetFloatStringForSettingFile($framePrecision) + "\"\r\n");
820	fprint($fid, "LoopAnim=\"" + $boolNames[$loopAnim] + "\"\r\n");
821	fprint($fid, "FrameFormat=\"" + $boolNames[$frameFormat] + "\"\r\n");
822	fprint($fid, "ScaleQuantizeQuality=\"" + $scaleQuantizeQuality + "\"\r\n");
823	fprint($fid, "RotateQuantizeQuality=\"" + $rotateQuantizeQuality + "\"\r\n");
824	fprint($fid, "TranslateQuantizeQuality=\"" + $translateQuantizeQuality + "\"\r\n");
825	fprint($fid, "\r\n");
826
827	//-----------------------------------------------------------------------------
828	// tolerance options
829	fprint($fid, "# Tolerance Options\r\n");
830	fprint($fid, "ToleranceScale=\"" + GetFloatStringForSettingFile($toleranceScale) + "\"\r\n");
831	fprint($fid, "ToleranceRotate=\"" + GetFloatStringForSettingFile($toleranceRotate) + "\"\r\n");
832	fprint($fid, "ToleranceTranslate=\"" + GetFloatStringForSettingFile($toleranceTranslate) + "\"\r\n");
833	fprint($fid, "ToleranceTexScale=\"" + GetFloatStringForSettingFile($toleranceTexScale) + "\"\r\n");
834	fprint($fid, "ToleranceTexRotate=\"" + GetFloatStringForSettingFile($toleranceTexRotate) + "\"\r\n");
835	fprint($fid, "ToleranceTexTranslate=\"" + GetFloatStringForSettingFile($toleranceTexTranslate) + "\"\r\n");
836	fprint($fid, "ToleranceColor=\"" + GetFloatStringForSettingFile($toleranceColor) + "\"\r\n");
837	fprint($fid, "\r\n");
838
839	//-----------------------------------------------------------------------------
840	// close file
841	fclose($fid);
842
843	//-----------------------------------------------------------------------------
844	// end
845	print ("Saved to " + $filePath + "\n");
846}
847
848/******************************************************************************
849	save setting to file (file command)
850******************************************************************************/
851global proc nw4cExpDialog_SaveSettingToFileFC(string $filePath, string $fileType)
852{
853	//-----------------------------------------------------------------------------
854	// save setting file folder
855	SaveSettingFileFolder($filePath);
856
857	//-----------------------------------------------------------------------------
858	// do
859	nw4cExpDialog_SaveSettingToFileDo($filePath);
860}
861
862/******************************************************************************
863	save setting to file (main)
864******************************************************************************/
865global proc nw4cExpDialog_SaveSettingToFile()
866{
867	//-----------------------------------------------------------------------------
868	// set setting file folder to currnet
869	SetSettingFileFolderToCurrent();
870
871	//-----------------------------------------------------------------------------
872	// open file dialog
873	fileBrowserDialog -m 1 -an "Save" -in "c3es"
874		-ft "Best Guess"
875		-fc "nw4cExpDialog_SaveSettingToFileFC";
876}
877
878/******************************************************************************
879	get option string from c3es
880******************************************************************************/
881global proc string nw4cExpDialog_GetOptionStringFromC3es(string $filePath)
882{
883	global string $nw4cExpDialog_c3esLatestVer;
884
885	string $boolNames[2] = { "false", "true" };
886
887	//-----------------------------------------------------------------------------
888	// init
889	string $settingsVersion = "";
890
891	string $processMode = "Single";
892	string $exportTarget = "All";
893	string $outputFileName = "";
894	string $outputMode = "File";
895	string $outputFolder = "";
896	int $mergeCmdl = 0;
897	string $mergeCmdlPath = "";
898	int $copyRelatedFiles = 0;
899	//int $mergeCmdlAuto = 1;
900
901	float $magnify = 1.0;
902	string $frameRange = "All";
903	int $startFrame = 1;
904	int $endFrame = 100;
905	//string $texMatrixMode = "Maya";
906	int $removeNamespace = 0;
907
908	int $outputCmdl = 1;
909	int $outputCtex = 1;
910	int $outputCmdla = 0;
911	int $outputCskla = 0;
912	int $outputCmata = 0;
913	int $outputCmcla = 0;
914	int $outputCmtpa = 0;
915	int $outputCmtsa = 0;
916	int $outputCcam = 0;
917	int $outputClgt = 0;
918	int $outputCenv = 0;
919
920	string $compressNode = "None";
921	//int $combinePolygon = 0;
922	int $compressMaterial = 0;
923	int $optimizePrimitive = 1;
924	int $convertToModel = 0;
925	//int $delUselessVtxData = 0;
926
927	string $quantizePos = "Float";
928	string $quantizeNrm = "Float";
929	string $quantizeTex = "Float";
930	int $frameFormat = 0;
931	int $scaleQuantizeQuality = 9;
932	int $rotateQuantizeQuality = 9;
933	int $translateQuantizeQuality = 9;
934
935	string $adjustSkinning = "None";
936	string $meshVisibilityMode = "IndexMode";
937	int $nonUniformScale = 0;
938	int $maxReservedUniformRegisters = 0;
939
940	int $bakeAllAnim = 1;
941	int $framePrecision = 1;
942	int $loopAnim = 0;
943
944	float $toleranceScale     = 0.1;
945	float $toleranceRotate    = 0.1;
946	float $toleranceTranslate = 0.01;
947	float $toleranceTexScale     = 0.1;
948	float $toleranceTexRotate    = 0.1;
949	float $toleranceTexTranslate = 0.01;
950	float $toleranceColor = 0.001;
951
952	//-----------------------------------------------------------------------------
953	// open file
954	int $fid = fopen($filePath, "r");
955	if ($fid == 0)
956	{
957		ShowError("Can't open file: " + $filePath);
958	}
959
960	//-----------------------------------------------------------------------------
961	// check header
962	string $line = fgetline($fid);
963	if (size(match("^# NW4C_Export settings", $line)) == 0)
964	{
965		fclose($fid);
966		ShowError("c3es file is wrong: " + $filePath);
967	}
968
969	//-----------------------------------------------------------------------------
970	// parse
971	string $words[];
972	while (!feof($fid))
973	{
974		string $line = fgetline($fid);
975		$line = substitute("\r*\n$", $line, ""); // cut [CR+LF] or [LF]
976		// skip empty line & comment line
977		if (size($line) == 0 || substring($line, 1, 1) == "#")
978		{
979			continue;
980		}
981
982		tokenize($line, "=", $words);
983		if (size($words) < 2)
984		{
985			continue;
986		}
987		string $tag = $words[0];
988		string $val = $words[1];
989		$val = substitute("^\"", $val, ""); // cut first double quote
990		$val = substitute("\".*$", $val, ""); // cut last double quote
991		int $boolVal = ($val == "true" || $val == "On" || $val == "1");
992		//print ($tag + ": " + $val + "\n");
993
994		//-----------------------------------------------------------------------------
995		// header
996		if ($tag == "SettingsVersion")
997		{
998			$settingsVersion = $val;
999			//if ($settingsVersion != $nw4cExpDialog_c3esLatestVer)
1000			//{
1001			//	fclose($fid);
1002			//	ShowError("c3es file version is wrong: " + $settingsVersion);
1003			//}
1004		}
1005
1006		//-----------------------------------------------------------------------------
1007		// output
1008		else if ($tag == "ProcessMode")
1009		{
1010			$processMode = $val;
1011		}
1012		else if ($tag == "ExportTarget")
1013		{
1014			$exportTarget = $val;
1015		}
1016		else if ($tag == "OutputFileName")
1017		{
1018			$outputFileName = $val;
1019		}
1020		else if ($tag == "OutputMode")
1021		{
1022			$outputMode = $val;
1023		}
1024		else if ($tag == "OutputFolder")
1025		{
1026			$outputFolder = NW4C_GetUnixFilePath($val);
1027		}
1028		else if ($tag == "MergeCmdl")
1029		{
1030			$mergeCmdl = $boolVal;
1031		}
1032		else if ($tag == "MergeCmdlPath")
1033		{
1034			$mergeCmdlPath = NW4C_GetUnixFilePath($val);
1035		}
1036		else if ($tag == "CopyRelatedFiles")
1037		{
1038			$copyRelatedFiles = $boolVal;
1039		}
1040		//else if ($tag == "MergeCmdlAuto")
1041		//{
1042		//	$mergeCmdlAuto = $boolVal;
1043		//}
1044
1045		//-----------------------------------------------------------------------------
1046		// general
1047		else if ($tag == "Magnify")
1048		{
1049			$magnify = $val;
1050		}
1051		else if ($tag == "FrameRange")
1052		{
1053			$frameRange = $val;
1054		}
1055		else if ($tag == "StartFrame")
1056		{
1057			$startFrame = $val;
1058		}
1059		else if ($tag == "EndFrame")
1060		{
1061			$endFrame = $val;
1062		}
1063		//else if ($tag == "TexMatrixMode")
1064		//{
1065		//	$texMatrixMode = $val;
1066		//}
1067		else if ($tag == "RemoveNamespace")
1068		{
1069			$removeNamespace = $boolVal;
1070		}
1071
1072		//-----------------------------------------------------------------------------
1073		// file selection
1074		else if ($tag == "OutputCmdl")
1075		{
1076			$outputCmdl = $boolVal;
1077		}
1078		else if ($tag == "OutputCtex")
1079		{
1080			$outputCtex = $boolVal;
1081		}
1082		else if ($tag == "OutputCmdla")
1083		{
1084			$outputCmdla = $boolVal;
1085		}
1086		else if ($tag == "OutputCskla")
1087		{
1088			$outputCskla = $boolVal;
1089		}
1090		else if ($tag == "OutputCmata")
1091		{
1092			$outputCmata = $boolVal;
1093		}
1094		else if ($tag == "OutputCmcla")
1095		{
1096			$outputCmcla = $boolVal;
1097		}
1098		else if ($tag == "OutputCmtpa")
1099		{
1100			$outputCmtpa = $boolVal;
1101		}
1102		else if ($tag == "OutputCmtsa")
1103		{
1104			$outputCmtsa = $boolVal;
1105		}
1106		else if ($tag == "OutputCcam")
1107		{
1108			$outputCcam = $boolVal;
1109		}
1110		else if ($tag == "OutputClgt")
1111		{
1112			$outputClgt = $boolVal;
1113		}
1114		else if ($tag == "OutputCenv")
1115		{
1116			$outputCenv = $boolVal;
1117		}
1118
1119		//-----------------------------------------------------------------------------
1120		// optimization
1121		else if ($tag == "CompressNode")
1122		{
1123			$compressNode = $val;
1124		}
1125		//else if ($tag == "CombinePolygon")
1126		//{
1127		//	$combinePolygon = $boolVal;
1128		//}
1129		else if ($tag == "CompressMaterial")
1130		{
1131			$compressMaterial = $boolVal;
1132		}
1133		else if ($tag == "OptimizePrimitive")
1134		{
1135			$optimizePrimitive = $boolVal;
1136		}
1137		else if ($tag == "ConvertToModel")
1138		{
1139			// ConvertToModel �͉��ʌ݊����Ȃ����߁A1.3.0 �����O�ɏo�͂��ꂽ c3es
1140			// ���烍�[�h���鎞�͖�������
1141			if (strcmp($settingsVersion, "1.3.0") >= 0)
1142			{
1143				$convertToModel = $boolVal;
1144			}
1145		}
1146		//else if ($tag == "DelUselessVtxData")
1147		//{
1148		//	$delUselessVtxData = $boolVal;
1149		//}
1150
1151		//-----------------------------------------------------------------------------
1152		// quantization
1153		else if ($tag == "QuantizePos")
1154		{
1155			$quantizePos = $val;
1156		}
1157		else if ($tag == "QuantizeNrm")
1158		{
1159			$quantizeNrm = $val;
1160		}
1161		else if ($tag == "QuantizeTex")
1162		{
1163			$quantizeTex = $val;
1164		}
1165		else if ($tag == "FrameFormat")
1166		{
1167			$frameFormat = $boolVal;
1168		}
1169		else if ($tag == "ScaleQuantizeQuality")
1170		{
1171			$scaleQuantizeQuality = $val;
1172		}
1173		else if ($tag == "RotateQuantizeQuality")
1174		{
1175			$rotateQuantizeQuality = $val;
1176		}
1177		else if ($tag == "TranslateQuantizeQuality")
1178		{
1179			$translateQuantizeQuality = $val;
1180		}
1181
1182		//-----------------------------------------------------------------------------
1183		// model
1184		else if ($tag == "AdjustSkinning")
1185		{
1186			$adjustSkinning = $val;
1187		}
1188		else if ($tag == "MeshVisibilityMode")
1189		{
1190			$meshVisibilityMode = $val;
1191		}
1192		else if ($tag == "NonUniformScale")
1193		{
1194			$nonUniformScale = $boolVal;
1195		}
1196		else if ($tag == "MaxReservedUniformRegisters")
1197		{
1198			$maxReservedUniformRegisters = $val;
1199		}
1200
1201		//-----------------------------------------------------------------------------
1202		// anim
1203		else if ($tag == "BakeAllAnim")
1204		{
1205			$bakeAllAnim = $boolVal;
1206		}
1207		else if ($tag == "FramePrecision")
1208		{
1209			float $floatVal = $val;
1210			if ($floatVal == 0.5)
1211			{
1212				$framePrecision = 2;
1213			}
1214			else if ($floatVal == 0.2)
1215			{
1216				$framePrecision = 5;
1217			}
1218			else if ($floatVal == 0.1)
1219			{
1220				$framePrecision = 10;
1221			}
1222		}
1223		else if ($tag == "LoopAnim")
1224		{
1225			$loopAnim = $boolVal;
1226		}
1227
1228		//-----------------------------------------------------------------------------
1229		// tolerance
1230		else if ($tag == "ToleranceScale")
1231		{
1232			$toleranceScale = $val;
1233		}
1234		else if ($tag == "ToleranceRotate")
1235		{
1236			$toleranceRotate = $val;
1237		}
1238		else if ($tag == "ToleranceTranslate")
1239		{
1240			$toleranceTranslate = $val;
1241		}
1242		else if ($tag == "ToleranceTexScale")
1243		{
1244			$toleranceTexScale = $val;
1245		}
1246		else if ($tag == "ToleranceTexRotate")
1247		{
1248			$toleranceTexRotate = $val;
1249		}
1250		else if ($tag == "ToleranceTexTranslate")
1251		{
1252			$toleranceTexTranslate = $val;
1253		}
1254		else if ($tag == "ToleranceColor")
1255		{
1256			$toleranceColor = $val;
1257		}
1258	}
1259
1260	//-----------------------------------------------------------------------------
1261	// close file
1262	fclose($fid);
1263
1264	//-----------------------------------------------------------------------------
1265	// set option var
1266	string $optStr = "";
1267
1268	$optStr += "ProcessMode=" + $processMode + ";";
1269	$optStr += "ExportTarget=" + $exportTarget + ";";
1270	$optStr += "OutputFileName=" + $outputFileName + ";";
1271	$optStr += "OutputMode=" + $outputMode + ";";
1272	$optStr += "OutputFolder=" + $outputFolder + ";";
1273	$optStr += "MergeCmdl=" + $boolNames[$mergeCmdl] + ";";
1274	$optStr += "MergeCmdlPath=" + $mergeCmdlPath + ";";
1275	$optStr += "CopyRelatedFiles=" + $boolNames[$copyRelatedFiles] + ";";
1276	//$optStr += "MergeCmdlAuto=" + $boolNames[$mergeCmdlAuto] + ";";
1277
1278	$optStr += "Magnify=" + $magnify + ";";
1279	$optStr += "FrameRange=" + $frameRange + ";";
1280	$optStr += "StartFrame=" + $startFrame + ";";
1281	$optStr += "EndFrame=" + $endFrame + ";";
1282	//$optStr += "TexMatrixMode=" + $texMatrixMode + ";";
1283	$optStr += "RemoveNamespace=" + $boolNames[$removeNamespace] + ";";
1284
1285	$optStr += "OutputCmdl=" + $boolNames[$outputCmdl] + ";";
1286	$optStr += "OutputCtex=" + $boolNames[$outputCtex] + ";";
1287	$optStr += "OutputCmdla=" + $boolNames[$outputCmdla] + ";";
1288	$optStr += "OutputCskla=" + $boolNames[$outputCskla] + ";";
1289	$optStr += "OutputCmata=" + $boolNames[$outputCmata] + ";";
1290	$optStr += "OutputCmcla=" + $boolNames[$outputCmcla] + ";";
1291	$optStr += "OutputCmtpa=" + $boolNames[$outputCmtpa] + ";";
1292	$optStr += "OutputCmtsa=" + $boolNames[$outputCmtsa] + ";";
1293	$optStr += "OutputCcam=" + $boolNames[$outputCcam] + ";";
1294	$optStr += "OutputClgt=" + $boolNames[$outputClgt] + ";";
1295	$optStr += "OutputCenv=" + $boolNames[$outputCenv] + ";";
1296
1297	$optStr += "CompressNode=" + $compressNode + ";";
1298	//$optStr += "CombinePolygon=" + $boolNames[$combinePolygon] + ";";
1299	$optStr += "CompressMaterial=" + $boolNames[$compressMaterial] + ";";
1300	$optStr += "OptimizePrimitive=" + $boolNames[$optimizePrimitive] + ";";
1301	$optStr += "ConvertToModel=" + $boolNames[$convertToModel] + ";";
1302	//$optStr += "DelUselessVtxData=" + $boolNames[$delUselessVtxData] + ";";
1303
1304	$optStr += "QuantizePos=" + $quantizePos + ";";
1305	$optStr += "QuantizeNrm=" + $quantizeNrm + ";";
1306	$optStr += "QuantizeTex=" + $quantizeTex + ";";
1307	$optStr += "FrameFormat=" + $boolNames[$frameFormat] + ";";
1308	$optStr += "ScaleQuantizeQuality=" + $scaleQuantizeQuality + ";";
1309	$optStr += "RotateQuantizeQuality=" + $rotateQuantizeQuality + ";";
1310	$optStr += "TranslateQuantizeQuality=" + $translateQuantizeQuality + ";";
1311
1312	$optStr += "AdjustSkinning=" + $adjustSkinning + ";";
1313	$optStr += "MeshVisibilityMode=" + $meshVisibilityMode + ";";
1314	$optStr += "NonUniformScale=" + $boolNames[$nonUniformScale] + ";";
1315	$optStr += "MaxReservedUniformRegisters=" + $maxReservedUniformRegisters + ";";
1316
1317	$optStr += "BakeAllAnim=" + $boolNames[$bakeAllAnim] + ";";
1318	$optStr += "FramePrecision=" + $framePrecision + ";";
1319	$optStr += "LoopAnim=" + $boolNames[$loopAnim] + ";";
1320
1321
1322	$optStr += "ToleranceScale=" + $toleranceScale + ";";
1323	$optStr += "ToleranceRotate=" + $toleranceRotate + ";";
1324	$optStr += "ToleranceTranslate=" + $toleranceTranslate + ";";
1325	$optStr += "ToleranceTexScale=" + $toleranceTexScale + ";";
1326	$optStr += "ToleranceTexRotate=" + $toleranceTexRotate + ";";
1327	$optStr += "ToleranceTexTranslate=" + $toleranceTexTranslate + ";";
1328	$optStr += "ToleranceColor=" + $toleranceColor + ";";
1329
1330	return $optStr;
1331}
1332
1333/******************************************************************************
1334	load setting from file (do)
1335******************************************************************************/
1336global proc nw4cExpDialog_LoadSettingFromFileDo(string $filePath)
1337{
1338	//-----------------------------------------------------------------------------
1339	// get option string from c3es
1340	$optStr = nw4cExpDialog_GetOptionStringFromC3es($filePath);
1341	optionVar -sv nw4cExport_Options $optStr;
1342
1343	//-----------------------------------------------------------------------------
1344	// update setting node
1345	SaveSettingToScene(1);
1346
1347	//-----------------------------------------------------------------------------
1348	// refresh option box
1349	if (`scrollLayout -ex nw4cExpDialog_ScrollLayout`)
1350	{
1351		if (`columnLayout -ex nw4cExpDialog_MainColumn`)
1352		{
1353			NW4C_ExpDialog;
1354		}
1355	}
1356
1357	//-----------------------------------------------------------------------------
1358	// end
1359	print ("Loaded from " + $filePath + "\n");
1360}
1361
1362/******************************************************************************
1363	load setting from file (file command)
1364******************************************************************************/
1365global proc nw4cExpDialog_LoadSettingFromFileFC(string $filePath, string $fileType)
1366{
1367	//-----------------------------------------------------------------------------
1368	// save setting file folder
1369	SaveSettingFileFolder($filePath);
1370
1371	//-----------------------------------------------------------------------------
1372	// do
1373	nw4cExpDialog_LoadSettingFromFileDo($filePath);
1374}
1375
1376/******************************************************************************
1377	load setting from file (main)
1378******************************************************************************/
1379global proc nw4cExpDialog_LoadSettingFromFile()
1380{
1381	//-----------------------------------------------------------------------------
1382	// set setting file folder to currnet
1383	//SetSettingFileFolderToCurrent();
1384
1385	//-----------------------------------------------------------------------------
1386	// open file dialog
1387	//fileBrowserDialog -m 0 -an "Load" -in "c3es"
1388	//	  -fc "nw4cExpDialog_LoadSettingFromFileFC";
1389
1390	string $dirMask = "*.c3es"; // fileDialog can use mask
1391	string $settingFolder = "";
1392	if (`optionVar -ex nw4cExpDialog_SettingFileFolder`)
1393	{
1394		$settingFolder = `optionVar -q nw4cExpDialog_SettingFileFolder`;
1395	}
1396	if (size($settingFolder) > 0 && `filetest -d $settingFolder`)
1397	{
1398		$dirMask = $settingFolder + $dirMask;
1399	}
1400	//trace ("dirMask: " + $dirMask);
1401
1402	string $filePath = `fileDialog -dm $dirMask`;
1403	if (size($filePath) > 0)
1404	{
1405		nw4cExpDialog_LoadSettingFromFileFC($filePath, "");
1406	}
1407}
1408
1409/******************************************************************************
1410	process mode callback
1411******************************************************************************/
1412global proc nw4cExpDialog_ProcessModeCB()
1413{
1414	if (!`control -q -vis nw4cExpDialog_ProcessMode`)
1415	{
1416		return;
1417	}
1418	int $animRangeFlag = (`radioButtonGrp -q -sl nw4cExpDialog_ProcessMode` == 2);
1419	int $useNWCS = (`radioButtonGrp -q -sl nw4cExpDialog_UseCreativeStudio` == 1);
1420	int $cmata = `checkBoxGrp -q -v1 nw4cExpDialog_CmataFileOut`;
1421	int $cmcla = 0;
1422	int $cmtpa = 0;
1423	int $cmtsa = 0;
1424	int $ccam = `checkBoxGrp -q -v1 nw4cExpDialog_CcamFileOut`;
1425	int $clgt = `checkBoxGrp -q -v1 nw4cExpDialog_ClgtFileOut`;
1426	int $cenv = `checkBoxGrp -q -v1 nw4cExpDialog_CenvFileOut`;
1427	int $fileNameFlag;
1428
1429	if (`UseCustomUI` == 1)
1430	{
1431		$cmcla = `checkBoxGrp -q -v1 nw4cExpDialog_CmclaFileOut`;
1432		$cmtpa = `checkBoxGrp -q -v1 nw4cExpDialog_CmtpaFileOut`;
1433		$cmtsa = `checkBoxGrp -q -v1 nw4cExpDialog_CmtsaFileOut`;
1434	}
1435
1436	$fileNameFlag =
1437		(!$animRangeFlag || $cmata || $cmcla || $cmtpa || $cmtsa || $ccam || $clgt || $cenv);
1438
1439	control -e -en $fileNameFlag nw4cExpDialog_OutFileName;
1440	control -e -en $fileNameFlag nw4cExpDialog_SceneToOutFileName;
1441	control -e -en $fileNameFlag nw4cExpDialog_NodeToOutFileName;
1442	control -e -en ($animRangeFlag==0) nw4cExpDialog_UseCreativeStudio;
1443	if ($animRangeFlag && $useNWCS)
1444	{
1445		radioButtonGrp -e -sl 1 nw4cExpDialog_OutInterFile;
1446		radioButtonGrp -e -sl 0 nw4cExpDialog_UseCreativeStudio;
1447		nw4cExpDialog_OutInterFileCB();
1448	}
1449
1450	string $selectionStr = (!$animRangeFlag) ?
1451		"Selection  ( Below )" : "Selection  ( Tree )";
1452	radioButtonGrp -e -l2 $selectionStr	nw4cExpDialog_ExportTarget;
1453}
1454
1455/******************************************************************************
1456	out inter file callback
1457******************************************************************************/
1458global proc nw4cExpDialog_OutInterFileCB()
1459{
1460	int $outInterFile = (`radioButtonGrp -q -sl nw4cExpDialog_OutInterFile` == 1);
1461	control -e -en $outInterFile nw4cExpDialog_OutFolder;
1462	control -e -en $outInterFile nw4cExpDialog_OutFolderBrowser;
1463
1464	int $useCs = (`radioButtonGrp -q -sl nw4cExpDialog_UseCreativeStudio` == 1);
1465	int $cmdl = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlFileOut`;
1466	int $mergeCmdl = `checkBoxGrp -q -v1 nw4cExpDialog_MergeCmdlFlag`;
1467	int $cmdlPathEnable = $cmdl && $mergeCmdl;
1468	control -e -en $cmdl nw4cExpDialog_MergeCmdlFlag;
1469	control -e -en $cmdlPathEnable nw4cExpDialog_MergeCmdlPath;
1470	control -e -en $cmdlPathEnable nw4cExpDialog_MergeCmdlBrowser;
1471	control -e -en $cmdlPathEnable nw4cExpDialog_CopyRelatedFiles;
1472	//control -e -en ($cmdlPathEnable && $useCs) nw4cExpDialog_MergeCmdlAuto;
1473}
1474
1475/******************************************************************************
1476	set node name to file name
1477******************************************************************************/
1478global proc nw4cExpDialog_SetNodeNameToFileName()
1479{
1480	// get selection
1481	// ��ŊK�w�̐[�����ׂ�̂� -l ���K�v
1482	string $xforms[] = `ls -l -sl -typ transform`;
1483	if (size($xforms) == 0)
1484	{
1485		$xforms = `ls -l -v -typ transform`;
1486	}
1487	if (size($xforms) == 0)
1488	{
1489		error "No transform node";
1490	}
1491
1492	// find top level node
1493	string $name, $buf[];
1494	int $depthMin = 10000;
1495	for ($xform in $xforms)
1496	{
1497		int $depth = tokenize($xform, "|", $buf);
1498		if ($depth < $depthMin)
1499		{
1500			$name = $xform;
1501			$depthMin = $depth;
1502		}
1503	}
1504
1505	// set name
1506	$name = substitute(".*|", $name, ""); // to short path
1507	textFieldGrp -e -tx $name nw4cExpDialog_OutFileName;
1508}
1509
1510/******************************************************************************
1511	out folder browser callback
1512******************************************************************************/
1513global proc nw4cExpDialog_OutFolderBrowserFC(string $filePath, string $fileType)
1514{
1515	textFieldGrp -e -tx $filePath nw4cExpDialog_OutFolder;
1516}
1517
1518global proc nw4cExpDialog_OutFolderBrowserCB()
1519{
1520	NW4C_SetCurDirFromFile(`textFieldGrp -q -tx nw4cExpDialog_OutFolder`);
1521
1522	eval("NW4C_FileDialog -m 4 -an \"Select\" -in \"Output Folder\" " +
1523		"-fc \"nw4cExpDialog_OutFolderBrowserFC\"");
1524	//fileBrowserDialog -m 4 -an "Select" -in "Output Folder"
1525	//	  -fc "nw4cExpDialog_OutFolderBrowserFC";
1526}
1527
1528/******************************************************************************
1529	merge cmdl browser callback
1530******************************************************************************/
1531global proc nw4cExpDialog_MergeCmdlBrowserCB()
1532{
1533	string $curPath = `textField -q -tx nw4cExpDialog_MergeCmdlPath`;
1534	if (size($curPath) > 0)
1535	{
1536		$curPath = dirname($curPath);
1537		$curPath = (`filetest -d $curPath`) ? ($curPath + "/") : "";
1538	}
1539	string $newPath = `fileDialog -dm ($curPath + "*.cmdl")`;
1540	if (size($newPath) > 0)
1541	{
1542 		textField -e -tx $newPath nw4cExpDialog_MergeCmdlPath;
1543 	}
1544}
1545
1546/******************************************************************************
1547	magnify callback
1548******************************************************************************/
1549global proc nw4cExpDialog_MagnifyCB()
1550{
1551	float $magnify = `floatFieldGrp -q -v1 nw4cExpDialog_Magnify`;
1552	if ($magnify < 0.001)
1553	{
1554		floatFieldGrp -e -v1 0.001 nw4cExpDialog_Magnify;
1555	}
1556	else if ($magnify > 1000.0)
1557	{
1558		floatFieldGrp -e -v1 1000.0 nw4cExpDialog_Magnify;
1559	}
1560}
1561
1562/******************************************************************************
1563	frame range callback
1564******************************************************************************/
1565global proc nw4cExpDialog_FrameRangeCB()
1566{
1567	int $frameRange = `radioButtonGrp -q -sl nw4cExpDialog_FrameRange` - 1;
1568	int $enableFlag = ($frameRange == 2);
1569	control -e -en $enableFlag nw4cExpDialog_StartFrame;
1570	control -e -en $enableFlag nw4cExpDialog_EndFrame;
1571}
1572
1573/******************************************************************************
1574	frame start end callback
1575******************************************************************************/
1576global proc nw4cExpDialog_FrameStartEndCB()
1577{
1578	int $start = `intField -q -v nw4cExpDialog_StartFrame`;
1579	int $end   = `intField -q -v nw4cExpDialog_EndFrame`;
1580	if ($start > $end)
1581	{
1582		intField -e -v $end nw4cExpDialog_StartFrame;
1583		intField -e -v $start nw4cExpDialog_EndFrame;
1584	}
1585}
1586
1587/******************************************************************************
1588	convert to model callback
1589******************************************************************************/
1590global proc nw4cExpDialog_ConvertToModelCB()
1591{
1592	int $convertToModel = `checkBoxGrp -q -v1 nw4cExpDialog_ConvertToModel`;
1593	control -e -en ($convertToModel == 0) nw4cExpDialog_CompressNode;
1594}
1595
1596/******************************************************************************
1597	max reserved uniform registers callback
1598******************************************************************************/
1599global proc nw4cExpDialog_MaxReservedUniformRegistersCB()
1600{
1601	int $val = `intFieldGrp -q -v1 nw4cExpDialog_MaxReservedUniformRegisters`;
1602	if ($val < 0 || $val > 57)
1603	{
1604		if ($val < 0 ) $val = 0;
1605		if ($val > 57 ) $val = 57;
1606		intFieldGrp -e -v1 $val nw4cExpDialog_MaxReservedUniformRegisters;
1607	}
1608}
1609
1610/******************************************************************************
1611	model file callback
1612******************************************************************************/
1613global proc nw4cExpDialog_ModelCB()
1614{
1615	int $cmdl = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlFileOut`;
1616	int $cmdla = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlaFileOut`;
1617
1618	int $visAnim = ($cmdl || $cmdla);
1619
1620	control -e -en $cmdl nw4cExpDialog_CompressMaterial;
1621	control -e -en $cmdl nw4cExpDialog_OptimizePrimitive;
1622	//control -e -en $cmdl nw4cExpDialog_DelUselessVtxData;
1623
1624	control -e -en $cmdl nw4cExpDialog_QuantPos;
1625	control -e -en $cmdl nw4cExpDialog_QuantNrm;
1626	control -e -en $cmdl nw4cExpDialog_QuantTex;
1627
1628	control -e -en $cmdl nw4cExpDialog_AdjustSkinning;
1629	control -e -en $visAnim nw4cExpDialog_MeshVisibilityMode;
1630	control -e -en $cmdl nw4cExpDialog_NonUniformScale;
1631	control -e -en $cmdl nw4cExpDialog_MaxReservedUniformRegisters;
1632
1633
1634	nw4cExpDialog_OutInterFileCB(); // update merge cmdl file
1635}
1636
1637/******************************************************************************
1638	anim file callback
1639******************************************************************************/
1640global proc nw4cExpDialog_AnimCB()
1641{
1642	//-----------------------------------------------------------------------------
1643	// get out file
1644	int $cmdl = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlFileOut`;
1645	int $cmdla = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlaFileOut`;
1646	int $cskla = `checkBoxGrp -q -v1 nw4cExpDialog_CsklaFileOut`;
1647	int $ccam = `checkBoxGrp -q -v1 nw4cExpDialog_CcamFileOut`;
1648	int $clgt = `checkBoxGrp -q -v1 nw4cExpDialog_ClgtFileOut`;
1649	int $cmata = `checkBoxGrp -q -v1 nw4cExpDialog_CmataFileOut`;
1650	int $cmcla = 0;
1651	int $cmtpa = 0;
1652	int $cmtsa = 0;
1653	int $anyAnim;
1654	int $visAnim;
1655
1656	if (`UseCustomUI` == 1)
1657	{
1658		$cmcla = `checkBoxGrp -q -v1 nw4cExpDialog_CmclaFileOut`;
1659		$cmtpa = `checkBoxGrp -q -v1 nw4cExpDialog_CmtpaFileOut`;
1660		$cmtsa = `checkBoxGrp -q -v1 nw4cExpDialog_CmtsaFileOut`;
1661	}
1662
1663	$anyAnim = ($cmdla || $cskla || $cmata || $cmcla || $cmtpa || $cmtsa || $ccam || $clgt);
1664	$visAnim = ($cmdl || $cmdla);
1665
1666	//-----------------------------------------------------------------------------
1667	// get frame format
1668	int $frameFmt = `checkBoxGrp -q -v1 nw4cExpDialog_FrameFormat`;
1669
1670	//-----------------------------------------------------------------------------
1671	// process mode callback (enable/disable out file name)
1672	nw4cExpDialog_ProcessModeCB();
1673
1674	//-----------------------------------------------------------------------------
1675	// quantization options
1676	control -e -en $cskla nw4cExpDialog_FrameFormat;
1677	control -e -en ($cskla && !$frameFmt) nw4cExpDialog_ScaleQuantizeQuality;
1678	control -e -en ($cskla && !$frameFmt) nw4cExpDialog_RotateQuantizeQuality;
1679	control -e -en ($cskla && !$frameFmt) nw4cExpDialog_TranslateQuantizeQuality;
1680
1681	//-----------------------------------------------------------------------------
1682	// model options
1683	control -e -en $visAnim nw4cExpDialog_MeshVisibilityMode;
1684
1685	//-----------------------------------------------------------------------------
1686	// animation options
1687	control -e -en $anyAnim nw4cExpDialog_BakeAll;
1688	control -e -en $anyAnim nw4cExpDialog_FramePrecision;
1689	control -e -en $anyAnim nw4cExpDialog_LoopAnim;
1690
1691	//-----------------------------------------------------------------------------
1692	// tolerance options
1693	int $nodeTolFlagRT = $cskla || $ccam || $clgt;
1694	int $nodeTolFlagS = $cskla;
1695	control -e -en $nodeTolFlagRT nw4cExpDialog_TolT;
1696	control -e -en $nodeTolFlagRT nw4cExpDialog_TolR;
1697	control -e -en $nodeTolFlagS nw4cExpDialog_TolS;
1698
1699	int $texTolFlagSRT = $cmata || $cmtsa;
1700	control -e -en $texTolFlagSRT nw4cExpDialog_TolTexT;
1701	control -e -en $texTolFlagSRT nw4cExpDialog_TolTexR;
1702	control -e -en $texTolFlagSRT nw4cExpDialog_TolTexS;
1703
1704	int $colorTolFlag = $cmata || $cmcla || $clgt;
1705	control -e -en $colorTolFlag nw4cExpDialog_TolC;
1706}
1707
1708/******************************************************************************
1709	tolerance srt callback
1710******************************************************************************/
1711global proc nw4cExpDialog_ToleranceSRTCB(string $field)
1712{
1713	float $val = eval("floatFieldGrp -q -v1 " + $field);
1714	if ($val < 0.0)
1715	{
1716		eval("floatFieldGrp -e -v1 0.0 " + $field);
1717	}
1718}
1719
1720/******************************************************************************
1721	tolerance color callback
1722******************************************************************************/
1723global proc nw4cExpDialog_ToleranceColorCB(string $field)
1724{
1725	float $val = eval("floatFieldGrp -q -v1 " + $field);
1726	if ($val < 0.0)
1727	{
1728		eval("floatFieldGrp -e -v1 0.0 " + $field);
1729	}
1730}
1731
1732/******************************************************************************
1733	update all control state
1734******************************************************************************/
1735proc nw4cExpDialog_UpdateAllControlState()
1736{
1737	nw4cExpDialog_ProcessModeCB();
1738	nw4cExpDialog_OutInterFileCB();
1739
1740	nw4cExpDialog_MagnifyCB();
1741	nw4cExpDialog_FrameRangeCB();
1742	nw4cExpDialog_FrameStartEndCB();
1743
1744	nw4cExpDialog_ConvertToModelCB();
1745
1746	nw4cExpDialog_ModelCB();
1747	nw4cExpDialog_AnimCB();
1748
1749	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolT");
1750	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolR");
1751	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolS");
1752
1753	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolTexT");
1754	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolTexR");
1755	nw4cExpDialog_ToleranceSRTCB("nw4cExpDialog_TolTexS");
1756
1757	nw4cExpDialog_ToleranceColorCB("nw4cExpDialog_TolC");
1758}
1759
1760/******************************************************************************
1761	set option variable
1762******************************************************************************/
1763proc SetOptionVariable(int $resetFlag)
1764{
1765	if ($resetFlag || !`optionVar -ex nw4cExport_Options`)
1766	{
1767		string $optStr =
1768			"ProcessMode=Single;" +
1769			"ExportTarget=All;" +
1770			"OutputFileName=" + `file -q -namespace` + ";" +
1771			"OutputMode=File;" +
1772			"OutputFolder=" + `workspace -q -rd` + ";" +
1773			"MergeCmdl=false;" +
1774			"MergeCmdlPath=" + "" + ";" +
1775			"CopyRelatedFiles=false;" +
1776			//"MergeCmdlAuto=true;" +
1777
1778			"Magnify=1.0;" +
1779			"FrameRange=All;" +
1780			"StartFrame=1;" +
1781			"EndFrame=100;" +
1782			//"TexMatrixMode=Maya;" +
1783			"RemoveNamespace=false;" +
1784
1785			"OutputCmdl=true;" +
1786			"OutputCtex=true;" +
1787			"OutputCmdla=false;" +
1788			"OutputCskla=false;" +
1789			"OutputCmata=false;" +
1790			"OutputCmcla=false;" +
1791			"OutputCmtpa=false;" +
1792			"OutputCmtsa=false;" +
1793			"OutputCcam=false;" +
1794			"OutputClgt=false;" +
1795			"OutputCenv=false;" +
1796
1797			"CompressNode=None;" +
1798			//"CombinePolygon=true;" +
1799			"CompressMaterial=false;" +
1800			"OptimizePrimitive=true;" +
1801			"ConvertToModel=false;" +
1802			//"DelUselessVtxData=false;" +
1803
1804			"QuantizePos=Float;" +
1805			"QuantizeNrm=Float;" +
1806			"QuantizeTex=Float;" +
1807			"FrameFormat=false;" +
1808			"ScaleQuantizeQuality=9;" +
1809			"RotateQuantizeQuality=9;" +
1810			"TranslateQuantizeQuality=9;" +
1811
1812			"AdjustSkinning=None;" +
1813			"MeshVisibilityMode=BindByIndex;" +
1814			"NonUniformScale=false;" +
1815			"MaxReservedUniformRegisters=0;" +
1816
1817			"BakeAllAnim=true;" +
1818			"FramePrecision=1;" +
1819			"LoopAnim=false;" +
1820
1821			"ToleranceScale=0.1;" +
1822			"ToleranceRotate=0.1;" +
1823			"ToleranceTranslate=0.01;" +
1824			"ToleranceTexScale=0.1;" +
1825			"ToleranceTexRotate=0.1;" +
1826			"ToleranceTexTranslate=0.01;" +
1827			"ToleranceColor=0.001;" +
1828
1829			"";
1830		optionVar -sv nw4cExport_Options $optStr;
1831	}
1832}
1833
1834/******************************************************************************
1835	set option control
1836******************************************************************************/
1837proc SetOptionControl()
1838{
1839	global int $nw4cExpDialog_SettingVer;
1840	global int $nw4cExpDialog_SettingLatestVer;
1841	int $useCustomUI = UseCustomUI();
1842	int $use3DEditor = Use3DEditor();
1843
1844	if (`optionVar -ex nw4cExport_Options`)
1845	{
1846		string $optStr = `optionVar -q nw4cExport_Options`;
1847		if (size($optStr) > 0)
1848		{
1849			string $optList[];
1850			tokenize($optStr, ";", $optList);
1851			int $iopt;
1852			for ($iopt = 0; $iopt < size($optList); ++$iopt)
1853			{
1854				string $words[];
1855				tokenize($optList[$iopt], "=", $words);
1856				int	$intVal;
1857				float $floatVal;
1858				int $boolVal = ($words[1] == "true" || $words[1] == "On" || $words[1] == "1");
1859
1860				//-----------------------------------------------------------------------------
1861				// output
1862				if ($words[0] == "ProcessMode")
1863				{
1864					$intVal = ($words[1] == "AnimationRange");
1865					radioButtonGrp -e -sl ($intVal + 1) nw4cExpDialog_ProcessMode;
1866				}
1867				else if ($words[0] == "ExportTarget")
1868				{
1869					$intVal = ($words[1] == "Selection");
1870					radioButtonGrp -e -sl ($intVal + 1) nw4cExpDialog_ExportTarget;
1871				}
1872				else if ($words[0] == "OutputFileName")
1873				{
1874					textFieldGrp -e -tx $words[1] nw4cExpDialog_OutFileName;
1875				}
1876				else if ($words[0] == "OutputMode")
1877				{
1878					if ($words[1] == "File")
1879					{
1880						radioButtonGrp -e -sl 1 nw4cExpDialog_OutInterFile;
1881					}
1882					else if ($words[1] == "CreativeStudio")
1883					{
1884						radioButtonGrp -e -sl 1 nw4cExpDialog_UseCreativeStudio;
1885					}
1886					else if ($use3DEditor)
1887					{
1888						radioButtonGrp -e -sl 1 nw4cExpDialog_Use3DEditor;
1889					}
1890				}
1891				else if ($words[0] == "OutputFolder")
1892				{
1893					textFieldGrp -e -tx $words[1] nw4cExpDialog_OutFolder;
1894				}
1895				else if ($words[0] == "MergeCmdl")
1896				{
1897					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_MergeCmdlFlag;
1898				}
1899				else if ($words[0] == "MergeCmdlPath")
1900				{
1901					textField -e -tx $words[1] nw4cExpDialog_MergeCmdlPath;
1902				}
1903				else if ($words[0] == "CopyRelatedFiles")
1904				{
1905					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CopyRelatedFiles;
1906				}
1907				//else if ($words[0] == "MergeCmdlAuto")
1908				//{
1909				//	checkBoxGrp -e -v1 $boolVal nw4cExpDialog_MergeCmdlAuto;
1910				//}
1911
1912				//-----------------------------------------------------------------------------
1913				// general
1914				else if ($words[0] == "Magnify")
1915				{
1916					$floatVal = $words[1];
1917					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_Magnify;
1918				}
1919				else if ($words[0] == "FrameRange")
1920				{
1921					int $sel = 1; // All
1922					if ($words[1] == "Playback")
1923					{
1924						$sel = 2;
1925					}
1926					else if ($words[1] == "Range")
1927					{
1928						$sel = 3;
1929					}
1930					radioButtonGrp -e -sl $sel nw4cExpDialog_FrameRange;
1931				}
1932				else if ($words[0] == "StartFrame")
1933				{
1934					$intVal = $words[1];
1935					intField -e -v $intVal nw4cExpDialog_StartFrame;
1936				}
1937				else if ($words[0] == "EndFrame")
1938				{
1939					$intVal = $words[1];
1940					intField -e -v $intVal nw4cExpDialog_EndFrame;
1941				}
1942				//else if ($words[0] == "TexMatrixMode")
1943				//{
1944				//	int $sel = 1; // maya
1945				//	if ($words[1] == "3dsmax")
1946				//	{
1947				//		$sel = 2;
1948				//	}
1949				//	optionMenuGrp -e -sl $sel nw4cExpDialog_TexMatrixMode;
1950				//}
1951				else if ($words[0] == "RemoveNamespace")
1952				{
1953					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_RemoveNamespace;
1954				}
1955
1956				//-----------------------------------------------------------------------------
1957				// file select
1958				else if ($words[0] == "OutputCmdl")
1959				{
1960					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmdlFileOut;
1961				}
1962				else if ($words[0] == "OutputCtex")
1963				{
1964					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CtexFileOut;
1965				}
1966				else if ($words[0] == "OutputCmdla")
1967				{
1968					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmdlaFileOut;
1969				}
1970				else if ($words[0] == "OutputCskla")
1971				{
1972					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CsklaFileOut;
1973				}
1974				else if ($words[0] == "OutputCmata")
1975				{
1976					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmataFileOut;
1977				}
1978				else if ($words[0] == "OutputCmcla")
1979				{
1980					if ($useCustomUI == 1)
1981					{
1982						checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmclaFileOut;
1983					}
1984				}
1985				else if ($words[0] == "OutputCmtpa")
1986				{
1987					if ($useCustomUI == 1)
1988					{
1989						checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmtpaFileOut;
1990					}
1991				}
1992				else if ($words[0] == "OutputCmtsa")
1993				{
1994					if ($useCustomUI == 1)
1995					{
1996						checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CmtsaFileOut;
1997					}
1998				}
1999				else if ($words[0] == "OutputCcam")
2000				{
2001					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CcamFileOut;
2002				}
2003				else if ($words[0] == "OutputClgt")
2004				{
2005					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_ClgtFileOut;
2006				}
2007				else if ($words[0] == "OutputCenv")
2008				{
2009					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_CenvFileOut;
2010				}
2011
2012				//-----------------------------------------------------------------------------
2013				// optimization
2014				else if ($words[0] == "CompressNode")
2015				{
2016					int $sel = 1; // None
2017					if ($words[1] == "Cull")
2018					{
2019						$sel = 2;
2020					}
2021					else if ($words[1] == "CullUninfluential")
2022					{
2023						$sel = 3;
2024					}
2025					else if ($words[1] == "UniteCompressible")
2026					{
2027						$sel = 4;
2028					}
2029					else if ($words[1] == "UniteAll")
2030					{
2031						$sel = 5;
2032					}
2033					optionMenuGrp -e -sl $sel nw4cExpDialog_CompressNode;
2034				}
2035				//else if ($words[0] == "CombinePolygon")
2036				//{
2037				//	checkBox -e -v $boolVal nw4cExpDialog_CombinePolygon;
2038				//}
2039				else if ($words[0] == "CompressMaterial")
2040				{
2041					optionMenuGrp -e -sl ($boolVal + 1) nw4cExpDialog_CompressMaterial;
2042				}
2043				else if ($words[0] == "OptimizePrimitive")
2044				{
2045					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_OptimizePrimitive;
2046				}
2047				else if ($words[0] == "ConvertToModel")
2048				{
2049					// ConvertToModel �͉��ʌ݊����Ȃ����߁A1.3.0 �����O�ɐݒ肳�ꂽ�o�̓I�v�V����
2050					// ���烍�[�h���鎞�͖�������
2051					if ($nw4cExpDialog_SettingVer >= 13)
2052					{
2053						checkBoxGrp -e -v1 $boolVal nw4cExpDialog_ConvertToModel;
2054					}
2055				}
2056				//else if ($words[0] == "DelUselessVtxData")
2057				//{
2058				//	checkBoxGrp -e -v1 $boolVal nw4cExpDialog_DelUselessVtxData;
2059				//}
2060
2061				//-----------------------------------------------------------------------------
2062				// quantization
2063				else if ($words[0] == "QuantizePos")
2064				{
2065					int $sel = 1; // Float
2066					if ($words[1] == "Float")
2067					{
2068						$sel = 1;
2069					}
2070					else if ($words[1] == "Short")
2071					{
2072						$sel = 2;
2073					}
2074					else if ($words[1] == "Byte")
2075					{
2076						$sel = 3;
2077					}
2078					optionMenuGrp -e -sl $sel nw4cExpDialog_QuantPos;
2079				}
2080				else if ($words[0] == "QuantizeNrm")
2081				{
2082					int $sel = 1; // Float
2083					if ($words[1] == "Float")
2084					{
2085						$sel = 1;
2086					}
2087					else if ($words[1] == "Short")
2088					{
2089						$sel = 2;
2090					}
2091					else if ($words[1] == "Byte")
2092					{
2093						$sel = 3;
2094					}
2095					optionMenuGrp -e -sl $sel nw4cExpDialog_QuantNrm;
2096				}
2097				else if ($words[0] == "QuantizeTex")
2098				{
2099					int $sel = 1; // Float
2100					if ($words[1] == "Float")
2101					{
2102						$sel = 1;
2103					}
2104					else if ($words[1] == "Short")
2105					{
2106						$sel = 2;
2107					}
2108					else if ($words[1] == "Byte")
2109					{
2110						$sel = 3;
2111					}
2112					optionMenuGrp -e -sl $sel nw4cExpDialog_QuantTex;
2113				}
2114				else if ($words[0] == "FrameFormat")
2115				{
2116					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_FrameFormat;
2117				}
2118				else if ($words[0] == "ScaleQuantizeQuality")
2119				{
2120					$intVal = $words[1];
2121					intSliderGrp -e -v $intVal nw4cExpDialog_ScaleQuantizeQuality;
2122				}
2123				else if ($words[0] == "RotateQuantizeQuality")
2124				{
2125					$intVal = $words[1];
2126					intSliderGrp -e -v $intVal nw4cExpDialog_RotateQuantizeQuality;
2127				}
2128				else if ($words[0] == "TranslateQuantizeQuality")
2129				{
2130					$intVal = $words[1];
2131					intSliderGrp -e -v $intVal nw4cExpDialog_TranslateQuantizeQuality;
2132				}
2133				//-----------------------------------------------------------------------------
2134				// model
2135				else if ($words[0] == "AdjustSkinning")
2136				{
2137					int $sel = 1; // None
2138					if ($words[1] == "None")
2139					{
2140						$sel = 1;
2141					}
2142					else if ($words[1] == "RigidSkinning")
2143					{
2144						$sel = 2;
2145					}
2146					optionMenuGrp -e -sl $sel nw4cExpDialog_AdjustSkinning;
2147				}
2148				else if ($words[0] == "MeshVisibilityMode")
2149				{
2150					int $sel = 1; // BindByIndex
2151					if ($words[1] == "BindByIndex")
2152					{
2153						$sel = 1;
2154					}
2155					else if ($words[1] == "BindByName")
2156					{
2157						$sel = 2;
2158					}
2159					optionMenuGrp -e -sl $sel nw4cExpDialog_MeshVisibilityMode;
2160				}
2161				else if ($words[0] == "NonUniformScale")
2162				{
2163					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_NonUniformScale;
2164				}
2165				else if ($words[0] == "MaxReservedUniformRegisters")
2166				{
2167					$intVal = $words[1];
2168					intFieldGrp -e -v1 $intVal nw4cExpDialog_MaxReservedUniformRegisters;
2169				}
2170
2171				//-----------------------------------------------------------------------------
2172				// anim
2173				else if ($words[0] == "BakeAllAnim")
2174				{
2175					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_BakeAll;
2176				}
2177				else if ($words[0] == "FramePrecision")
2178				{
2179					$intVal = $words[1];
2180					int $sel = 1;				// 1.0
2181					if ($intVal == "2")			// 0.5
2182					{
2183						$sel = 2;
2184					}
2185					else if ($intVal == "5")	// 0.2
2186					{
2187						$sel = 3;
2188					}
2189					else if ($intVal == "10")	// 0.1
2190					{
2191						$sel = 4;
2192					}
2193					optionMenuGrp -e -sl $sel nw4cExpDialog_FramePrecision;
2194				}
2195				else if ($words[0] == "LoopAnim")
2196				{
2197					checkBoxGrp -e -v1 $boolVal nw4cExpDialog_LoopAnim;
2198				}
2199
2200				//-----------------------------------------------------------------------------
2201				// tolerance
2202				else if ($words[0] == "ToleranceScale")
2203				{
2204					$floatVal = $words[1];
2205					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolS;
2206				}
2207				else if ($words[0] == "ToleranceRotate")
2208				{
2209					$floatVal = $words[1];
2210					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolR;
2211				}
2212				else if ($words[0] == "ToleranceTranslate")
2213				{
2214					$floatVal = $words[1];
2215					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolT;
2216				}
2217				else if ($words[0] == "ToleranceTexScale")
2218				{
2219					$floatVal = $words[1];
2220					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolTexS;
2221				}
2222				else if ($words[0] == "ToleranceTexRotate")
2223				{
2224					$floatVal = $words[1];
2225					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolTexR;
2226				}
2227				else if ($words[0] == "ToleranceTexTranslate")
2228				{
2229					$floatVal = $words[1];
2230					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolTexT;
2231				}
2232				else if ($words[0] == "ToleranceColor")
2233				{
2234					$floatVal = $words[1];
2235					floatFieldGrp -e -v1 $floatVal nw4cExpDialog_TolC;
2236				}
2237			}
2238		}
2239	}
2240
2241	//-----------------------------------------------------------------------------
2242	// update control state
2243	nw4cExpDialog_UpdateAllControlState();
2244
2245	//-----------------------------------------------------------------------------
2246	// ConvertToModel ���o�[�W�����ɂ���ē��삪�قȂ邽�߂̏����B
2247	// ��x���[�h����������̃o�[�W�������グ�āA�ȍ~�� ConvertToModel ��ǂݍ��ނ悤�ɂ���B
2248	$nw4cExpDialog_SettingVer = $nw4cExpDialog_SettingLatestVer;
2249}
2250
2251/******************************************************************************
2252	check option value
2253******************************************************************************/
2254proc CheckOptionValue()
2255{
2256	int $use3DEditor = Use3DEditor();
2257	int $animRangeFlag = (`radioButtonGrp -q -sl nw4cExpDialog_ProcessMode` == 2);
2258
2259	//int $cscaFlag = `checkBoxGrp -q -v1 nw4cExpDialog_CscaFileOut`;
2260	int $cscaFlag = 0;
2261
2262	if (!$animRangeFlag || $cscaFlag)
2263	{
2264		string $outputFileName = `textFieldGrp -q -tx nw4cExpDialog_OutFileName`;
2265		if (size($outputFileName) == 0)
2266		{
2267			ShowError("Output File Name is wrong");
2268		}
2269		if (size(match("[=;:/*?<>|\"]", $outputFileName)) > 0 ||
2270			NW4C_GetUnixFilePath($outputFileName) != $outputFileName) // check "\"
2271		{
2272			ShowError("Output File Name is wrong (please don't use [=] [;] [:] [/] [\\] [*] [?] [<] [>] [|] [double quote])");
2273		}
2274	}
2275
2276	int $useCs = (`radioButtonGrp -q -sl nw4cExpDialog_UseCreativeStudio` == 1);
2277	int $use3DE = 0;
2278	if ($use3DEditor)
2279	{
2280		$use3DE = (`radioButtonGrp -q -sl nw4cExpDialog_Use3DEditor` == 1);
2281	}
2282	if (!$useCs && !$use3DE)
2283	{
2284		string $outputFolder = `textFieldGrp -q -tx nw4cExpDialog_OutFolder`;
2285		if (size($outputFolder) == 0)
2286		{
2287			ShowError("Output Folder is wrong");
2288		}
2289		if (size(match("[=;*?<>|\"]", $outputFolder)) > 0)
2290		{
2291			ShowError("Output Folder is wrong (please don't use [=] [;] [*] [?] [<] [>] [|] [double quote])");
2292		}
2293	}
2294
2295	int $mergeCmdl = `checkBoxGrp -q -v1 nw4cExpDialog_MergeCmdlFlag`;
2296	if ($mergeCmdl)
2297	{
2298		string $mergeCmdlPath = `textField -q -tx nw4cExpDialog_MergeCmdlPath`;
2299		if (size($mergeCmdlPath) == 0)
2300		{
2301			ShowError("Path of cmdl file to merge is wrong");
2302		}
2303		if (size(match("[=;*?<>|\"]", $mergeCmdlPath)) > 0)
2304		{
2305			ShowError("Path of cmdl file to merge is wrong (please don't use [=] [;] [*] [?] [<] [>] [|] [double quote])");
2306		}
2307	}
2308}
2309
2310/******************************************************************************
2311	update option variable (UpdateOptionVariableT)
2312******************************************************************************/
2313global proc nw4cExpDialog_UpdateOptionVariable(int $saveSettingToScene)
2314{
2315	int $use3DEditor = Use3DEditor();
2316	int $intVal;
2317	float $floatVal;
2318	string $optStr = "", $path;
2319
2320	string $boolNames[2] = { "false", "true" };
2321
2322	//-----------------------------------------------------------------------------
2323	// output
2324	$intVal = `radioButtonGrp -q -sl nw4cExpDialog_ProcessMode` - 1;
2325	string $processModeNames[] = { "Single", "AnimationRange" };
2326	$optStr += "ProcessMode=" + $processModeNames[$intVal] + ";";
2327
2328	$intVal = `radioButtonGrp -q -sl nw4cExpDialog_ExportTarget` - 1;
2329	string $exportTargetNames[] = { "All", "Selection" };
2330	$optStr += "ExportTarget=" + $exportTargetNames[$intVal] + ";";
2331
2332	$optStr += "OutputFileName=" + `textFieldGrp -q -tx nw4cExpDialog_OutFileName` + ";";
2333
2334	$intVal = (`radioButtonGrp -q -sl nw4cExpDialog_UseCreativeStudio` == 1);
2335	if ($use3DEditor)
2336	{
2337		if (`radioButtonGrp -q -sl nw4cExpDialog_Use3DEditor` == 1) $intVal = 2;
2338	}
2339	string $outputTargetNames[] = { "File", "CreativeStudio", "3DEditor" };
2340	$optStr += "OutputMode=" + $outputTargetNames[$intVal] + ";";
2341
2342	$path = `textFieldGrp -q -tx nw4cExpDialog_OutFolder`;
2343	$optStr += "OutputFolder=" + NW4C_GetUnixFilePath($path) + ";";
2344
2345	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_MergeCmdlFlag`;
2346	$optStr += "MergeCmdl=" + $boolNames[$intVal] + ";";
2347	$path = `textField -q -tx nw4cExpDialog_MergeCmdlPath`;
2348	$optStr += "MergeCmdlPath=" + NW4C_GetUnixFilePath($path) + ";";
2349	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CopyRelatedFiles`;
2350	$optStr += "CopyRelatedFiles=" + $boolNames[$intVal] + ";";
2351//	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_MergeCmdlAuto`;
2352//	$optStr += "MergeCmdlAuto=" + $boolNames[$intVal] + ";";
2353
2354	//-----------------------------------------------------------------------------
2355	// general
2356	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_Magnify`;
2357	$optStr += "Magnify=" + $floatVal + ";";
2358
2359	$intVal = `radioButtonGrp -q -sl nw4cExpDialog_FrameRange` - 1;
2360	string $frameRangeNames[] = { "All", "Playback", "Range" };
2361	$optStr += "FrameRange=" + $frameRangeNames[$intVal] + ";";
2362
2363	$intVal = `intField -q -v nw4cExpDialog_StartFrame`;
2364	$optStr += "StartFrame=" + $intVal + ";";
2365
2366	$intVal = `intField -q -v nw4cExpDialog_EndFrame`;
2367	$optStr += "EndFrame=" + $intVal + ";";
2368
2369//	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_TexMatrixMode` - 1;
2370//	string $texMatrixModeNames[] = { "Maya", "3dsMax" };
2371//	$optStr += "TexMatrixMode=" + $texMatrixModeNames[$intVal] + ";";
2372
2373	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_RemoveNamespace`;
2374	$optStr += "RemoveNamespace=" + $boolNames[$intVal] + ";";
2375
2376	//-----------------------------------------------------------------------------
2377	// file selection
2378	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlFileOut`;
2379	$optStr += "OutputCmdl=" + $boolNames[$intVal] + ";";
2380
2381	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CtexFileOut`;
2382	$optStr += "OutputCtex=" + $boolNames[$intVal] + ";";
2383
2384	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmdlaFileOut`;
2385	$optStr += "OutputCmdla=" + $boolNames[$intVal] + ";";
2386
2387	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CsklaFileOut`;
2388	$optStr += "OutputCskla=" + $boolNames[$intVal] + ";";
2389
2390	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmataFileOut`;
2391	$optStr += "OutputCmata=" + $boolNames[$intVal] + ";";
2392
2393	if (`UseCustomUI` == 1)
2394	{
2395		$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmclaFileOut`;
2396		$optStr += "OutputCmcla=" + $boolNames[$intVal] + ";";
2397
2398		$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmtpaFileOut`;
2399		$optStr += "OutputCmtpa=" + $boolNames[$intVal] + ";";
2400
2401		$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CmtsaFileOut`;
2402		$optStr += "OutputCmtsa=" + $boolNames[$intVal] + ";";
2403	}
2404	else
2405	{
2406		// CustomUI ���g�p���Ȃ����� cmcla, cmtpa, cmtsa ���o�͂��Ȃ��悤�ɂ���B
2407		$optStr += "OutputCmcla=" + $boolNames[0] + ";";
2408		$optStr += "OutputCmtpa=" + $boolNames[0] + ";";
2409		$optStr += "OutputCmtsa=" + $boolNames[0] + ";";
2410	}
2411
2412	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CcamFileOut`;
2413	$optStr += "OutputCcam=" + $boolNames[$intVal] + ";";
2414
2415	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_ClgtFileOut`;
2416	$optStr += "OutputClgt=" + $boolNames[$intVal] + ";";
2417
2418	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_CenvFileOut`;
2419	$optStr += "OutputCenv=" + $boolNames[$intVal] + ";";
2420
2421	//-----------------------------------------------------------------------------
2422	// optimization
2423	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_CompressNode` - 1;
2424	string $compressNodeNames[] = {
2425		"None", "Cull", "CullUninfluential", "UniteCompressible", "UniteAll" };
2426	$optStr += "CompressNode=" + $compressNodeNames[$intVal] + ";";
2427
2428//	$intVal = `checkBox -q -v nw4cExpDialog_CombinePolygon`;
2429//	$optStr += "CombinePolygon=" + $boolNames[$intVal] + ";";
2430
2431	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_CompressMaterial` - 1;
2432	$optStr += "CompressMaterial=" + $boolNames[$intVal] + ";";
2433
2434	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_OptimizePrimitive`;
2435	$optStr += "OptimizePrimitive=" + $boolNames[$intVal] + ";";
2436
2437	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_ConvertToModel`;
2438	$optStr += "ConvertToModel=" + $boolNames[$intVal] + ";";
2439
2440//	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_DelUselessVtxData`;
2441//	$optStr += "DelUselessVtxData=" + $boolNames[$intVal] + ";";
2442
2443	//-----------------------------------------------------------------------------
2444	// quantization
2445	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_QuantPos` - 1;
2446	string $quantPosNames[] = { "Float", "Short", "Byte", "Auto" };
2447	$optStr += "QuantizePos=" + $quantPosNames[$intVal] + ";";
2448
2449	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_QuantNrm` - 1;
2450	string $quantNrmNames[] = { "Float", "Short", "Byte", "Auto" };
2451	$optStr += "QuantizeNrm=" + $quantNrmNames[$intVal] + ";";
2452
2453	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_QuantTex` - 1;
2454	string $quantTexNames[] = { "Float", "Short", "Byte", "Auto" };
2455	$optStr += "QuantizeTex=" + $quantTexNames[$intVal] + ";";
2456
2457	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_FrameFormat`;
2458	$optStr += "FrameFormat=" + $boolNames[$intVal] + ";";
2459
2460	$intVal = `intSliderGrp -q -v nw4cExpDialog_ScaleQuantizeQuality`;
2461	$optStr += "ScaleQuantizeQuality=" + $intVal + ";";
2462
2463	$intVal = `intSliderGrp -q -v nw4cExpDialog_RotateQuantizeQuality`;
2464	$optStr += "RotateQuantizeQuality=" + $intVal + ";";
2465
2466	$intVal = `intSliderGrp -q -v nw4cExpDialog_TranslateQuantizeQuality`;
2467	$optStr += "TranslateQuantizeQuality=" + $intVal + ";";
2468
2469	//-----------------------------------------------------------------------------
2470	// model
2471	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_AdjustSkinning` - 1;
2472	string $adjustSkinningNames[] = {
2473		"None", "RigidSkinning" };
2474	$optStr += "AdjustSkinning=" + $adjustSkinningNames[$intVal] + ";";
2475	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_MeshVisibilityMode` - 1;
2476	string $meshVisibilityModeNames[] = {
2477		"BindByIndex", "BindByName" };
2478	$optStr += "MeshVisibilityMode=" + $meshVisibilityModeNames[$intVal] + ";";
2479
2480	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_NonUniformScale`;
2481	$optStr += "NonUniformScale=" + $boolNames[$intVal] + ";";
2482	$intVal = `intFieldGrp -q -v1 nw4cExpDialog_MaxReservedUniformRegisters`;
2483	$optStr += "MaxReservedUniformRegisters=" + $intVal + ";";
2484
2485	//-----------------------------------------------------------------------------
2486	// animation
2487	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_BakeAll`;
2488	$optStr += "BakeAllAnim=" + $boolNames[$intVal] + ";";
2489
2490	$intVal = `optionMenuGrp -q -sl nw4cExpDialog_FramePrecision`;
2491	int $framePrecision = 1;
2492	if ($intVal == 2)		// 0.5
2493	{
2494		$framePrecision = 2;
2495	}
2496	else if ($intVal == 3)	// 0.2
2497	{
2498		$framePrecision = 5;
2499	}
2500	else if ($intVal == 4)	// 0.1
2501	{
2502		$framePrecision = 10;
2503	}
2504	$optStr += "FramePrecision=" + $framePrecision + ";";
2505
2506	$intVal = `checkBoxGrp -q -v1 nw4cExpDialog_LoopAnim`;
2507	$optStr += "LoopAnim=" + $boolNames[$intVal] + ";";
2508
2509	//-----------------------------------------------------------------------------
2510	// tolerance
2511	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolS`;
2512	$optStr += "ToleranceScale=" + $floatVal + ";";
2513
2514	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolR`;
2515	$optStr += "ToleranceRotate=" + $floatVal + ";";
2516
2517	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolT`;
2518	$optStr += "ToleranceTranslate=" + $floatVal + ";";
2519
2520	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolTexT`;
2521	$optStr += "ToleranceTexTranslate=" + $floatVal + ";";
2522
2523	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolTexR`;
2524	$optStr += "ToleranceTexRotate=" + $floatVal + ";";
2525
2526	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolTexS`;
2527	$optStr += "ToleranceTexScale=" + $floatVal + ";";
2528
2529	$floatVal = `floatFieldGrp -q -v1 nw4cExpDialog_TolC`;
2530	$optStr += "ToleranceColor=" + $floatVal + ";";
2531
2532	//-----------------------------------------------------------------------------
2533	// set option var
2534	optionVar -sv nw4cExport_Options $optStr;
2535
2536	//-----------------------------------------------------------------------------
2537	// save setting to scene
2538	if ($saveSettingToScene)
2539	{
2540		SaveSettingToScene(1);
2541	}
2542}
2543
2544/******************************************************************************
2545	reset option variable
2546******************************************************************************/
2547global proc nw4cExpDialog_ResetOptionVariable()
2548{
2549	//-----------------------------------------------------------------------------
2550	// reset export dialog options
2551	SetOptionVariable(1);
2552	SetOptionControl();
2553
2554	//-----------------------------------------------------------------------------
2555	// save setting to scene
2556	SaveSettingToScene(1);
2557}
2558
2559/******************************************************************************
2560	do export command
2561******************************************************************************/
2562proc DoExportCmd(int $forceOverwrite)
2563{
2564	//-----------------------------------------------------------------------------
2565	// load plugin
2566	LoadPlugin();
2567
2568	//-----------------------------------------------------------------------------
2569	// get options
2570	string $optStr = "";
2571	if (`optionVar -ex nw4cExport_Options`)
2572	{
2573		$optStr = `optionVar -q nw4cExport_Options`;
2574	}
2575
2576	//-----------------------------------------------------------------------------
2577	// export
2578	string $cmd = "NW4C_ExportCmd ";
2579	if ($forceOverwrite)
2580	{
2581		$cmd += "-f ";
2582	}
2583	$cmd += "-op \"" + $optStr + "\"";
2584	//trace ("cmd: " + $cmd);
2585	if (catch(eval($cmd)))
2586	{
2587		//error "NW4C_Export Failed";
2588	}
2589}
2590
2591/******************************************************************************
2592	export callback
2593******************************************************************************/
2594global proc nw4cExpDialog_ExportCB()
2595{
2596	CheckOptionValue();
2597	nw4cExpDialog_UpdateOptionVariable(1);
2598	DoExportCmd(0);
2599}
2600
2601/******************************************************************************
2602	save settings callback
2603******************************************************************************/
2604global proc nw4cExpDialog_SaveSettingsCB()
2605{
2606	CheckOptionValue();
2607	nw4cExpDialog_UpdateOptionVariable(1);
2608}
2609
2610/******************************************************************************
2611	setting menu command (post menu command)
2612******************************************************************************/
2613global proc nw4cExpDialog_SettingMenuCmd()
2614{
2615	int $sceneSettingFlag = DoesSaveLoadSceneSetting();
2616	int $settingNodeFlag = `objExists nw4cExpDialog_Setting1`;
2617	menuItem -e -cb $sceneSettingFlag nw4cExpDialog_SaveLoadSceneSettingMenu;
2618	menuItem -e -en $settingNodeFlag nw4cExpDialog_DeleteSceneSettingMenu;
2619}
2620
2621/******************************************************************************
2622	save load scene setting menu command
2623******************************************************************************/
2624global proc nw4cExpDialog_SaveLoadSceneSettingMenuCmd()
2625{
2626	int $sceneSettingFlag = DoesSaveLoadSceneSetting();
2627	$sceneSettingFlag = !$sceneSettingFlag;
2628	optionVar -iv nw4cExpDialog_SaveLoadSceneSetting $sceneSettingFlag;
2629	menuItem -e -cb $sceneSettingFlag nw4cExpDialog_SaveLoadSceneSettingMenu;
2630}
2631
2632/******************************************************************************
2633	delete scene setting menu command
2634******************************************************************************/
2635global proc nw4cExpDialog_DeleteSceneSettingMenuCmd()
2636{
2637	DeleteUselessSettingNode();
2638
2639	string $node = "nw4cExpDialog_Setting1";
2640	if (`referenceQuery -inr $node`)
2641	{
2642		print "NW4C export settings node is referenced\n";
2643	}
2644	else
2645	{
2646		catch(`delete $node`);
2647	}
2648}
2649
2650/******************************************************************************
2651	create setting menu
2652******************************************************************************/
2653proc CreateSettingMenu(string $parent)
2654{
2655	//-----------------------------------------------------------------------------
2656	// get option box
2657	global string $gOptionBox;
2658	if (!`window -ex $gOptionBox`)
2659	{
2660		return;
2661	}
2662
2663	//-----------------------------------------------------------------------------
2664	// delete previous menu
2665	if (`menu -q -ex nw4cExpDialog_SettingMenu`)
2666	{
2667		deleteUI nw4cExpDialog_SettingMenu;
2668	}
2669
2670	//-----------------------------------------------------------------------------
2671	// create menu
2672	int $sceneSettingFlag = DoesSaveLoadSceneSetting();
2673	menu -l "NW4C Settings" -p $gOptionBox
2674		-pmc "nw4cExpDialog_SettingMenuCmd"
2675		nw4cExpDialog_SettingMenu;
2676
2677		menuItem -l "Save / Load Scene Settings" -cb $sceneSettingFlag
2678			-ann "Save settings to scene when exporting & Load settings from scene when opening scene"
2679			-c "nw4cExpDialog_SaveLoadSceneSettingMenuCmd"
2680			nw4cExpDialog_SaveLoadSceneSettingMenu;
2681		menuItem -l "Delete Scene Settings"
2682			-ann "Delete script node for settings"
2683			-c "nw4cExpDialog_DeleteSceneSettingMenuCmd"
2684			nw4cExpDialog_DeleteSceneSettingMenu;
2685
2686		menuItem -d 1;
2687
2688		menuItem -l "Load Settings from c3es File"
2689			-ann "Load settings from \".c3es\" file"
2690			-c "nw4cExpDialog_LoadSettingFromFile"
2691			nw4cExpDialog_LoadSettingFromFileMenu;
2692		menuItem -l "Save Settings to c3es File"
2693			-ann "Save settings to \".c3es\" file"
2694			-c "nw4cExpDialog_SaveSettingToFile"
2695			nw4cExpDialog_SaveSettingToMenu;
2696
2697	//-----------------------------------------------------------------------------
2698	// set script job to delete menu
2699	scriptJob -p $gOptionBox -uid nw4cExpDialog_ScrollLayout
2700		"if (!`scrollLayout -ex nw4cExpDialog_ScrollLayout`) { deleteUI nw4cExpDialog_SettingMenu; }";
2701}
2702
2703/******************************************************************************
2704	is no compress node
2705******************************************************************************/
2706proc int IsNoCompressNode(string $node)
2707{
2708	return (`attributeQuery -n $node -ex "nw4cNoCompressNode"`) ?
2709		`getAttr ($node + ".nw4cNoCompressNode")` : 0;
2710}
2711
2712/******************************************************************************
2713	is scene anim object
2714******************************************************************************/
2715proc int IsSceneAnimObject(string $node)
2716{
2717	string $type = nodeType($node);
2718	string $childs[] = `listRelatives -pa -s $node`;
2719	if (size(`ls -cameras -lights -typ environmentFog $childs`) > 0 ||
2720		$type == "lookAt")
2721	{
2722		return true;
2723	}
2724	return false;
2725}
2726
2727/******************************************************************************
2728	is constraint node
2729******************************************************************************/
2730proc int IsConstraintNode(string $node)
2731{
2732	return (size(`ls -typ constraint $node`) != 0);
2733}
2734
2735/******************************************************************************
2736	is needless locator or group
2737******************************************************************************/
2738proc int IsNeedlessLocatorOrGroup(string $node)
2739{
2740	if (nodeType($node) == "transform")
2741	{
2742		string $childs[] = `listRelatives -pa -ni $node`;
2743		if (size($childs) == 0) // empty group
2744		{
2745			return true;
2746		}
2747		else if (size($childs) == 1)
2748		{
2749			string $childType = nodeType($childs[0]);
2750			if ($childType == "locator") // locator without child
2751			{
2752				return true;
2753			}
2754		}
2755	}
2756	return false;
2757}
2758
2759/******************************************************************************
2760	is blend shape target
2761******************************************************************************/
2762proc int IsBlendShapeTarget(string $node)
2763{
2764	string $shapes[] = `listRelatives -pa -ni -s $node`;
2765	if (size($shapes) && nodeType($shapes[0]) == "mesh")
2766	{
2767		string $cons[] = `listConnections -s 0 -d 1 ($shapes[0] + ".worldMesh")`;
2768		if (size($cons) && nodeType($cons[0]) == "blendShape")
2769		{
2770			return true;
2771		}
2772	}
2773	return false;
2774}
2775
2776/******************************************************************************
2777	is animation range control node
2778******************************************************************************/
2779proc int IsAnimRangeControlNode(string $node)
2780{
2781	return `attributeQuery -n $node -ex "nw4c_AnimRangeEnable"`;
2782}
2783
2784/******************************************************************************
2785	is effective node
2786******************************************************************************/
2787proc int IsEffectiveNode(string $node)
2788{
2789	if (IsNoCompressNode($node))
2790	{
2791		return true;
2792	}
2793
2794	string $type = nodeType($node);
2795	if ($type == "ikHandle" ||
2796		$type == "ikEffector" ||
2797		IsConstraintNode($node) ||
2798		IsNeedlessLocatorOrGroup($node) ||
2799		IsBlendShapeTarget($node) ||
2800		IsAnimRangeControlNode($node))
2801	{
2802		return false;
2803	}
2804
2805	if (`getAttr ($node + ".template")`)
2806	{
2807		return false;
2808	}
2809	if (`getAttr ($node + ".overrideEnabled")`)
2810	{
2811		if (!`getAttr ($node + ".overrideVisibility")` ||
2812			!`getAttr ($node + ".overrideShading")` ||
2813			`getAttr ($node + ".overrideDisplayType")` == 1) // Template
2814		{
2815			return false;
2816		}
2817	}
2818
2819	return true;
2820}
2821
2822/******************************************************************************
2823	remove no output child (both argments must be long path)
2824******************************************************************************/
2825proc RemoveNoOutputChild(string $xforms[], string $noOutputs[])
2826{
2827	string $dsts[];
2828	for ($xform in $xforms)
2829	{
2830		int $enable = true;
2831		for ($noOutput in $noOutputs)
2832		{
2833			if (gmatch($xform, $noOutput + "|*"))
2834			{
2835				$enable = false;
2836				//print ("remove by parent: " + $xform + " (" + $noOutput + ")\n");
2837			}
2838		}
2839		if ($enable)
2840		{
2841			$dsts[size($dsts)] = $xform;
2842		}
2843	}
2844	$xforms = $dsts;
2845}
2846
2847/******************************************************************************
2848	get animation range target nodes
2849******************************************************************************/
2850proc GetAnimRangeTargetNodes(string $xforms[])
2851{
2852	string $roots[];
2853	string $sels[] = `ls -l -sl -typ transform`;
2854	for ($sel in $sels)
2855	{
2856		string $root = match("|[^|]+", $sel);
2857		$roots[size($roots)] = $root;
2858	}
2859	$xforms = `ls -l -dag -typ transform $roots`;
2860}
2861
2862/******************************************************************************
2863	get node parent list
2864******************************************************************************/
2865proc GetNodeParentList(string $list[], string $node)
2866{
2867	clear($list);
2868	while (1)
2869	{
2870		$list[size($list)] = $node;
2871		string $parents[] = `listRelatives -pa -p $node`;
2872		if (!size($parents))
2873		{
2874			break;
2875		}
2876		$node = $parents[0];
2877	}
2878}
2879
2880/******************************************************************************
2881	is attr animated
2882******************************************************************************/
2883proc int IsAttrAnimated(string $plug)
2884{
2885	string $ins[] = `listConnections -s 1 -d 0 $plug`;
2886	if (size($ins))
2887	{
2888		string $hists[] = `listHistory $ins[0]`;
2889		if (size(`ls -typ animCurve -typ expression $hists`))
2890		{
2891			return true;
2892		}
2893	}
2894	return false;
2895}
2896
2897/******************************************************************************
2898	is xform node animated
2899******************************************************************************/
2900proc int IsXformNodeAnimated(string $xform, int $depth)
2901{
2902	string $attrs[] = { "tx", "ty", "tz", "rx", "ry", "rz", "sx", "sy", "sz" };
2903	string $compAttrs[] = { "t", "r", "s" };
2904
2905	//-----------------------------------------------------------------------------
2906	// check search depth
2907	//print ("ixna: " + $xform + ", " + $depth + "\n");
2908	if ($depth >= 3)
2909	{
2910		return false;
2911	}
2912
2913	//-----------------------------------------------------------------------------
2914	// child attr
2915	string $checkedCons[];
2916	for ($attr in $attrs)
2917	{
2918		string $plug = $xform + "." + $attr;
2919		string $ins[] = `listConnections -s 1 -d 0 $plug`;
2920		if (size($ins))
2921		{
2922			string $inNode = $ins[0];
2923			string $inType = nodeType($inNode);
2924			string $hists[];
2925			if (gmatch($inType, "animBlendNode*"))
2926				$hists = `listHistory $inNode`;
2927			else
2928				$hists = `listHistory $plug`;
2929
2930			//-----------------------------------------------------------------------------
2931			// curve & expression & rigid body
2932			if (size(`ls -typ animCurve -typ expression -typ rigidBody $hists`))
2933			{
2934				return true;
2935			}
2936
2937			//-----------------------------------------------------------------------------
2938			// xform attr connection (node1.attr -> node2.attr)
2939			if ($inNode != $xform &&
2940				size(`ls -et transform -et joint $inNode`))
2941			{
2942				if (IsXformNodeAnimated($inNode, $depth + 1))
2943				{
2944					return true;
2945				}
2946			}
2947
2948			//-----------------------------------------------------------------------------
2949			// constraint
2950			string $cons[] = `ls -typ constraint $hists`;
2951			if (size($cons))
2952			{
2953				//return true;
2954				string $con = $cons[0];
2955				if (FindStringInArray($checkedCons, $con) == -1)
2956				{
2957					string $targets[] =
2958						`listConnections -s 1 -d  0 -type transform ($con + ".tg")`;
2959					$targets = stringArrayRemoveDuplicates($targets);
2960					//print "tar:\n"; print $targets;
2961					for ($target in $targets)
2962					{
2963						if ($target != $xform && $target != $con)
2964						{
2965							string $list[];
2966							GetNodeParentList($list, $target);
2967							for ($n in $list)
2968							{
2969								if (IsXformNodeAnimated($n, $depth + 1))
2970								{
2971									return true;
2972								}
2973							}
2974						}
2975					}
2976					$checkedCons[size($checkedCons)] = $con;
2977				}
2978			}
2979		}
2980	}
2981
2982	//-----------------------------------------------------------------------------
2983	// compound attr
2984	for ($attr in $compAttrs)
2985	{
2986		string $plug = $xform + "." + $attr;
2987		string $ins[] = `listConnections -s 1 -d 0 $plug`;
2988		if (size($ins))
2989		{
2990			string $inNode = $ins[0];
2991			//-----------------------------------------------------------------------------
2992			// xform (curve -> node1.t -> node2.t)
2993			if (size(`ls -et transform -et joint $inNode`) &&
2994				$inNode != $xform)
2995			{
2996				if (IsXformNodeAnimated($inNode, $depth + 1))
2997				{
2998					return true;
2999				}
3000			}
3001		}
3002	}
3003
3004	return false;
3005}
3006
3007/******************************************************************************
3008	is pole vector animated
3009******************************************************************************/
3010proc int IsPoleVectorAnimated(string $ik)
3011{
3012	string $attrs[] = { "pvx", "pvy", "pvz" };
3013
3014	string $checkedCons[];
3015	for ($attr in $attrs)
3016	{
3017		string $plug = $ik + "." + $attr;
3018		string $ins[] = `listConnections -s 1 -d 0 $plug`;
3019		if (size($ins))
3020		{
3021			string $inNode = $ins[0];
3022			//string $hists[] = `listHistory $inNode`;
3023			string $hists[] = `listHistory $plug`;
3024
3025			if (size(`ls -typ animCurve -typ expression $hists`))
3026			{
3027				return true;
3028			}
3029
3030			if (nodeType($inNode) == "poleVectorConstraint")
3031			{
3032				string $con = $inNode;
3033				if (FindStringInArray($checkedCons, $con) == -1)
3034				{
3035					string $targets[] =
3036						`listConnections -s 1 -d  0 -type transform ($con + ".tg")`;
3037					$targets = stringArrayRemoveDuplicates($targets);
3038					//print "pole tar:\n"; print $targets;
3039					for ($target in $targets)
3040					{
3041						if ($target != $ik && $target != $con)
3042						{
3043							string $list[];
3044							GetNodeParentList($list, $target);
3045							for ($n in $list)
3046							{
3047								if (IsXformNodeAnimated($n, 0))
3048								{
3049									return true;
3050								}
3051							}
3052						}
3053					}
3054					$checkedCons[size($checkedCons)] = $con;
3055				}
3056			}
3057		}
3058	}
3059
3060	return false;
3061}
3062
3063/******************************************************************************
3064	does ik controlled xform exist
3065******************************************************************************/
3066proc int DoesIkControlledXformExist(string $xforms[], string $ik)
3067{
3068	string $sjs[] = `listConnections -s 1 -d 0 ($ik + ".startJoint")`;
3069	string $efs[] = `listConnections -s 1 -d 0 ($ik + ".endEffector")`;
3070	if (size($sjs) && size($efs))
3071	{
3072		string $node = $efs[0];
3073		while ($node != $sjs[0])
3074		{
3075			string $parents[] = `listRelatives -pa -p $node`;
3076			if (!size($parents))
3077			{
3078				break;
3079			}
3080			$node = $parents[0];
3081			if (FindStringInArray($xforms, $node) != -1)
3082			{
3083				return true;
3084			}
3085		}
3086	}
3087	return false;
3088}
3089
3090/******************************************************************************
3091	does chara exist
3092******************************************************************************/
3093proc int DoesCharaAnimExist(string $xforms[])
3094{
3095	//-----------------------------------------------------------------------------
3096	// check size
3097	if (!size($xforms))
3098	{
3099		return false;
3100	}
3101
3102	//-----------------------------------------------------------------------------
3103	// check curve / expression / constraint / rigid body
3104	for ($xform in $xforms)
3105	{
3106		if (IsXformNodeAnimated($xform, 0))
3107		{
3108			return true;
3109		}
3110	}
3111
3112	//-----------------------------------------------------------------------------
3113	// check IK
3114	string $iks[] = `ls -typ ikHandle`;
3115	for ($ik in $iks)
3116	{
3117		if (DoesIkControlledXformExist($xforms, $ik))
3118		{
3119			if (IsXformNodeAnimated($ik, 0) ||
3120				IsPoleVectorAnimated($ik))
3121			{
3122				return true;
3123			}
3124		}
3125	}
3126
3127	return false;
3128}
3129
3130/******************************************************************************
3131	does vis anim exist
3132******************************************************************************/
3133proc int DoesVisAnimExist(string $xforms[], string $meshs[])
3134{
3135	for ($xform in $xforms)
3136	{
3137		if (IsAttrAnimated($xform + ".v"))
3138		{
3139			return true;
3140		}
3141	}
3142
3143	for ($mesh in $meshs)
3144	{
3145		if (IsAttrAnimated($mesh + ".v"))
3146		{
3147			return true;
3148		}
3149	}
3150
3151	return false;
3152}
3153
3154/******************************************************************************
3155	get first file node
3156******************************************************************************/
3157proc string GetFirstFileNode(string $plug)
3158{
3159	string $ins[] = `listConnections -s 1 -d 0 $plug`;
3160	if (size($ins))
3161	{
3162		string $file = $ins[0];
3163		if (nodeType($file) == "layeredTexture")
3164		{
3165			$ins = `listConnections -s 1 -d 0 -type file ($file + ".cs")`;
3166			if (!size($ins))
3167			{
3168				return "";
3169			}
3170			$file = $ins[0];
3171		}
3172		if (nodeType($file) == "file")
3173		{
3174			return $file;
3175		}
3176	}
3177	return "";
3178}
3179
3180/******************************************************************************
3181	does color anim exist
3182******************************************************************************/
3183proc int DoesColorAnimExist(string $mats[])
3184{
3185	string $attrs[] = { "cr", "cg", "cb", "itr", "acr", "acg", "acb", "sr", "sg", "sb" };
3186	string $colorGains[] = { "cgr", "cgg", "cgb" };
3187
3188	for ($mat in $mats)
3189	{
3190		//-----------------------------------------------------------------------------
3191		// direct anim
3192		for ($attr in $attrs)
3193		{
3194			if (!`attributeQuery -n $mat -ex $attr`)
3195			{
3196				break;
3197			}
3198			if (IsAttrAnimated($mat + "." + $attr))
3199			{
3200				return true;
3201			}
3202		}
3203
3204		//-----------------------------------------------------------------------------
3205		// color gain anim
3206		string $file = GetFirstFileNode($mat + ".c");
3207		if (size($file))
3208		{
3209			for ($attr in $colorGains)
3210			{
3211				if (IsAttrAnimated($file + "." + $attr))
3212				{
3213					return true;
3214				}
3215			}
3216		}
3217
3218		//-----------------------------------------------------------------------------
3219		// alpha gain anim
3220		string $file = GetFirstFileNode($mat + ".it");
3221		if (size($file))
3222		{
3223			if (IsAttrAnimated($file + ".ag"))
3224			{
3225				return true;
3226			}
3227		}
3228	}
3229
3230	return false;
3231}
3232
3233/******************************************************************************
3234	does tex pat anim exist
3235******************************************************************************/
3236proc int DoesTexPatAnimExist(string $files[])
3237{
3238	for ($file in $files)
3239	{
3240		if (`getAttr ($file + ".ufe")`)
3241		{
3242			if (IsAttrAnimated($file + ".fe"))
3243			{
3244				return true;
3245			}
3246			//string $ins[] = `listConnections -s 1 -d 0 ($file + ".fe")`;
3247			//if (size($ins))
3248			//{
3249			//	string $hists[] = `listHistory $ins[0]`;
3250			//	if (size(`ls -typ animCurve $hists`)) // curve only
3251			//	{
3252			//		return true;
3253			//	}
3254			//}
3255		}
3256	}
3257
3258	return false;
3259}
3260
3261/******************************************************************************
3262	does tex srt anim exist
3263******************************************************************************/
3264proc int DoesTexSrtAnimExist(string $files[])
3265{
3266	string $attrs[] = { "tfu", "tfv", "rf", "reu", "rev" };
3267
3268	for ($file in $files)
3269	{
3270		string $ins[] = `listConnections -s 1 -d 0 -type place2dTexture ($file + ".uv")`;
3271		if (size($ins))
3272		{
3273			string $place = $ins[0];
3274			for ($attr in $attrs)
3275			{
3276				if (IsAttrAnimated($place + "." + $attr))
3277				{
3278					return true;
3279				}
3280			}
3281		}
3282	}
3283
3284	return false;
3285}
3286
3287/******************************************************************************
3288	does shape anim exist
3289******************************************************************************/
3290proc int DoesShapeAnimExist(string $meshs[])
3291{
3292	if (!size(`ls -typ blendShape`)) // check blend shape exists in scene first
3293	{
3294		return false;
3295	}
3296
3297	for ($mesh in $meshs)
3298	{
3299		string $ins[] = `listConnections -s 1 -d 0 ($mesh + ".i")`;
3300		if (size($ins))
3301		{
3302			string $hists[] = `listHistory $ins[0]`;
3303			string $bss[] = `ls -typ blendShape $hists`;
3304			for ($bs in $bss)
3305			{
3306				if (`getAttr ($bs + ".nds")` == 0)
3307				{
3308					return true;
3309				}
3310			}
3311		}
3312	}
3313
3314	return false;
3315}
3316
3317/******************************************************************************
3318	get file node for attr
3319******************************************************************************/
3320proc GetFileNodeForAttr(string $files[], string $plug)
3321{
3322	string $ins[] = `listConnections -s 1 -d 0 $plug`;
3323	if (size($ins))
3324	{
3325		string $hists[] = `listHistory $ins[0]`;
3326		string $fins[] = `ls -typ file $hists`;
3327		for ($file in $fins)
3328		{
3329			if (FindStringInArray($files, $file) == -1)
3330			{
3331				$files[size($files)] = $file; // append
3332			}
3333		}
3334	}
3335}
3336
3337/******************************************************************************
3338	search anim
3339******************************************************************************/
3340global proc nw4cExpDialog_SearchAnim()
3341{
3342	//-----------------------------------------------------------------------------
3343	// get mode
3344	int $animRangeFlag = (`radioButtonGrp -q -sl nw4cExpDialog_ProcessMode` == 2);
3345
3346	int $selFlag = (`radioButtonGrp -q -sl nw4cExpDialog_ExportTarget` == 2);
3347
3348	//-----------------------------------------------------------------------------
3349	// begin wait cursor
3350	//waitCursor -st 1;
3351
3352	//-----------------------------------------------------------------------------
3353	// get target transform
3354	string $tarXforms[];
3355	if (!$selFlag)		// all
3356	{
3357		$tarXforms = `ls -l -typ transform`;
3358	}
3359	else if (!$animRangeFlag)	// sel (below)
3360	{
3361		$tarXforms = `ls -l -sl -dag -typ transform`;
3362	}
3363	else				// sel (tree)
3364	{
3365		GetAnimRangeTargetNodes($tarXforms);
3366	}
3367
3368	//-----------------------------------------------------------------------------
3369	// get effective transform
3370	string $xforms[];
3371	string $noOutputs[];
3372	for ($xform in $tarXforms)
3373	{
3374		if (!IsSceneAnimObject($xform))
3375		{
3376			if (IsEffectiveNode($xform))
3377			{
3378				$xforms[size($xforms)] = $xform;
3379			}
3380			else
3381			{
3382				$noOutputs[size($noOutputs)] = $xform;
3383			}
3384		}
3385	}
3386	RemoveNoOutputChild($xforms, $noOutputs);
3387
3388	//print "-- xforms --\n"; print $xforms;
3389	if (size($xforms) == 0)
3390	{
3391		if (!$selFlag)
3392		{
3393			warning "No effective node";
3394		}
3395		else
3396		{
3397			warning "Effective node is not selected";
3398		}
3399	}
3400
3401	//-----------------------------------------------------------------------------
3402	// get mesh
3403	string $meshs[];
3404	for ($xform in $xforms)
3405	{
3406		string $shapes[] = `listRelatives -pa -ni -s $xform`;
3407		if (size($shapes) && nodeType($shapes[0]) == "mesh" &&
3408			!`getAttr ($shapes[0] + ".template")`)
3409		{
3410			$meshs[size($meshs)] = $shapes[0];
3411		}
3412	}
3413
3414	//-----------------------------------------------------------------------------
3415	// get material & file
3416	string $mats[];
3417	string $files[];
3418	for ($mesh in $meshs)
3419	{
3420		string $sgs[] = `listSets -t 1 -o $mesh`;
3421		for ($sg in $sgs)
3422		{
3423			string $ins[] = `listConnections -s 1 -d 0 -type lambert ($sg + ".ss")`;
3424			if (size($ins))
3425			{
3426				string $mat = $ins[0];
3427				if (FindStringInArray($mats, $mat) == -1)
3428				{
3429					$mats[size($mats)] = $mat;
3430					GetFileNodeForAttr($files, $mat + ".c");
3431					GetFileNodeForAttr($files, $mat + ".n"); // for nrm map
3432				}
3433			}
3434		}
3435	}
3436
3437	//-----------------------------------------------------------------------------
3438	// search & check
3439	//checkBoxGrp -e -v1 (DoesCharaAnimExist($xforms)) nw4cExpDialog_CsklaFileOut;
3440	//checkBoxGrp -e -v1 (DoesVisAnimExist($xforms, $meshs)) nw4cExpDialog_CviaFileOut;
3441	//checkBoxGrp -e -v1 (DoesColorAnimExist($mats)) nw4cExpDialog_CclaFileOut;
3442	//checkBoxGrp -e -v1 (DoesTexPatAnimExist($files)) nw4cExpDialog_CtpaFileOut;
3443	//checkBoxGrp -e -v1 (DoesTexSrtAnimExist($files)) nw4cExpDialog_CtsaFileOut;
3444	//checkBoxGrp -e -v1 (DoesShapeAnimExist($meshs)) nw4cExpDialog_CshaFileOut;
3445
3446	//-----------------------------------------------------------------------------
3447	// update control
3448	nw4cExpDialog_AnimCB();
3449
3450	//-----------------------------------------------------------------------------
3451	// end wait cursor
3452	//waitCursor -st 0;
3453}
3454
3455/******************************************************************************
3456	open option window
3457
3458		return 1 if success, 0 otherwise
3459******************************************************************************/
3460proc int OpenOptionWindow()
3461{
3462	int $adjustSpace = 20; // Don't zero it !
3463	int $useCustomUI = UseCustomUI();
3464	int $use3DEditor = Use3DEditor();
3465	int $afterMaya2011Adjust = 0;
3466	if (getApplicationVersionAsFloat() >= 2011)
3467		$afterMaya2011Adjust = 1;
3468
3469	//-----------------------------------------------------------------------------
3470	// init option variable
3471	SetOptionVariable(0);
3472
3473	//-----------------------------------------------------------------------------
3474	// get option box
3475	string $optionBox = getOptionBox();
3476	if (size($optionBox) == 0)
3477	{
3478		return 0;
3479	}
3480	setParent $optionBox;
3481
3482	setOptionBoxTitle("NW4C Export Options");
3483
3484	//-----------------------------------------------------------------------------
3485	// create control
3486	//-----------------------------------------------------------------------------
3487
3488	//-----------------------------------------------------------------------------
3489	// begin
3490	setUITemplate -pst DefaultTemplate;
3491	waitCursor -st 1;
3492
3493	//-----------------------------------------------------------------------------
3494	// create layout
3495	scrollLayout -childResizable 1 -minChildWidth 508 nw4cExpDialog_ScrollLayout;
3496		// horizontal scroll bar is appear if layout width < minChildWidth
3497	string $parent = `columnLayout -adj 1 -cat "both" 5 -co "both" 5
3498		nw4cExpDialog_MainColumn`;
3499	$parent = substitute(".*|", $parent, ""); // to short name
3500	setParent $parent;
3501
3502	//-----------------------------------------------------------------------------
3503	// output options
3504	frameLayout -l "Output Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
3505		string $outForm = `formLayout -nd 100`;
3506			radioButtonGrp -l "Process Mode" -vis 1 -nrb 2 -cw 1 (103+$adjustSpace) -cw 2 95
3507				-la2 "Single" "Animation Range" -sl 1
3508				-cc "nw4cExpDialog_ProcessModeCB"
3509				nw4cExpDialog_ProcessMode;
3510			string $sep1 = `separator -vis 1 -st "in" -h 3`;
3511
3512			radioButtonGrp -l "Export Target" -nrb 2 -cw 1 (103+$adjustSpace) -cw 2 95
3513				-la2 "All" "Selection" -sl 1
3514				nw4cExpDialog_ExportTarget;
3515
3516			textFieldGrp -l "Output File Name" -cw2 (103+$adjustSpace) 160
3517				nw4cExpDialog_OutFileName;
3518			button -l "Scene" -w 50
3519				-c "textFieldGrp -e -tx `file -q -ns` nw4cExpDialog_OutFileName"
3520				nw4cExpDialog_SceneToOutFileName;
3521			button -l "Node" -w 50 -c "nw4cExpDialog_SetNodeNameToFileName"
3522				nw4cExpDialog_NodeToOutFileName;
3523
3524			//-----------------------------------------------------------------------------
3525			// out intermediate file
3526			string $sep2 = `separator -st "in" -h 3`;
3527			radioButtonGrp -l "" -nrb 1 -cw 1 (0+$adjustSpace) -cw 2 200
3528				-l1 "Output 3D Intermediate Files" -sl 1
3529				-cc "nw4cExpDialog_OutInterFileCB"
3530				nw4cExpDialog_OutInterFile;
3531
3532			textFieldGrp -l "Output Folder" -cw2 (104+$adjustSpace) 290 -adj 2 -rat 1 "both" 2
3533				nw4cExpDialog_OutFolder;
3534			symbolButton -i "navButtonBrowse.xpm" -w 25 -h 22
3535				-c "nw4cExpDialog_OutFolderBrowserCB"
3536				nw4cExpDialog_OutFolderBrowser;
3537
3538			//-----------------------------------------------------------------------------
3539			// use CreativeStudio
3540			radioButtonGrp -l "" -nrb 1 -cw 1 (0+$adjustSpace) -cw 2 200
3541				-l1 "Use CreativeStudio"
3542				-scl nw4cExpDialog_OutInterFile
3543				-cc "nw4cExpDialog_OutInterFileCB"
3544				nw4cExpDialog_UseCreativeStudio;
3545
3546			//-----------------------------------------------------------------------------
3547			// use 3DEditor
3548			if ($use3DEditor == 1)
3549			{
3550				radioButtonGrp -l "" -nrb 1 -cw 1 (0+$adjustSpace) -cw 2 200
3551					-l1 "Use 3DEditor"
3552					-scl nw4cExpDialog_OutInterFile
3553					-cc "nw4cExpDialog_OutInterFileCB"
3554					nw4cExpDialog_Use3DEditor;
3555			}
3556
3557			//-----------------------------------------------------------------------------
3558			// merge cmdl file
3559			string $sep3 = `separator -st "in" -h 3`;
3560			checkBoxGrp -l "" -ncb 1 -cw 1 (0+$adjustSpace) -cw 2 103
3561				-l1 "Merge cmdl File" -v1 0
3562				-cc "nw4cExpDialog_OutInterFileCB"
3563				nw4cExpDialog_MergeCmdlFlag;
3564			textField -w 290
3565				nw4cExpDialog_MergeCmdlPath;
3566			symbolButton -i "navButtonBrowse.xpm" -w 25 -h 22
3567				-c "nw4cExpDialog_MergeCmdlBrowserCB"
3568				nw4cExpDialog_MergeCmdlBrowser;
3569			checkBoxGrp -l "" -ncb 1 -cw 1 (0+$adjustSpace) -cw 2 103
3570				-l1 "Copy Related Files" -v1 0
3571				nw4cExpDialog_CopyRelatedFiles;
3572
3573			//checkBoxGrp -l "" -ncb 1 -cw 1 28 -cw 2 50
3574			//	-l1 "Auto" -v1 1
3575			//	nw4cExpDialog_MergeCmdlAuto;
3576
3577			if ($use3DEditor == 1)
3578			{
3579				formLayout -e
3580					-af nw4cExpDialog_ProcessMode "left" 0
3581					-af nw4cExpDialog_ProcessMode "top" 4
3582					-an nw4cExpDialog_ProcessMode "right"
3583					-an nw4cExpDialog_ProcessMode "bottom"
3584					-af $sep1 "left" 0
3585					-ac $sep1 "top" 4 nw4cExpDialog_ProcessMode
3586					-af $sep1 "right" 0
3587					-an $sep1 "bottom"
3588
3589					-af nw4cExpDialog_ExportTarget "left" 0
3590					-ac nw4cExpDialog_ExportTarget "top" 4 $sep1
3591					-an nw4cExpDialog_ExportTarget "right"
3592					-an nw4cExpDialog_ExportTarget "bottom"
3593
3594					-af nw4cExpDialog_OutFileName "left" 0
3595					-ac nw4cExpDialog_OutFileName "top" 4 nw4cExpDialog_ExportTarget
3596					-an nw4cExpDialog_OutFileName "right"
3597					-an nw4cExpDialog_OutFileName "bottom"
3598					-ac nw4cExpDialog_SceneToOutFileName "left" 5 nw4cExpDialog_OutFileName
3599					-ac nw4cExpDialog_SceneToOutFileName "top" 4 nw4cExpDialog_ExportTarget
3600					-an nw4cExpDialog_SceneToOutFileName "right"
3601					-an nw4cExpDialog_SceneToOutFileName "bottom"
3602					-ac nw4cExpDialog_NodeToOutFileName "left" 5 nw4cExpDialog_SceneToOutFileName
3603					-ac nw4cExpDialog_NodeToOutFileName "top" 4 nw4cExpDialog_ExportTarget
3604					-an nw4cExpDialog_NodeToOutFileName "right"
3605					-an nw4cExpDialog_NodeToOutFileName "bottom"
3606					-af $sep2 "left" 0
3607					-ac $sep2 "top" 4 nw4cExpDialog_OutFileName
3608					-af $sep2 "right" 0
3609					-an $sep2 "bottom"
3610
3611					-af nw4cExpDialog_OutInterFile "left" 0
3612					-ac nw4cExpDialog_OutInterFile "top" 4 $sep2
3613					-an nw4cExpDialog_OutInterFile "right"
3614					-an nw4cExpDialog_OutInterFile "bottom"
3615
3616					-af nw4cExpDialog_OutFolder "left" 0
3617					-ac nw4cExpDialog_OutFolder "top" 4 nw4cExpDialog_OutInterFile
3618					-ac nw4cExpDialog_OutFolder "right" 5 nw4cExpDialog_OutFolderBrowser
3619					-an nw4cExpDialog_OutFolder "bottom"
3620					-an nw4cExpDialog_OutFolderBrowser "left"
3621					-ac nw4cExpDialog_OutFolderBrowser "top" 4 nw4cExpDialog_OutInterFile
3622					-af nw4cExpDialog_OutFolderBrowser "right" 46
3623					-an nw4cExpDialog_OutFolderBrowser "bottom"
3624
3625					-af nw4cExpDialog_UseCreativeStudio "left" 0
3626					-ac nw4cExpDialog_UseCreativeStudio "top" 4 nw4cExpDialog_OutFolder
3627					-an nw4cExpDialog_UseCreativeStudio "right"
3628					-an nw4cExpDialog_UseCreativeStudio "bottom"
3629
3630					-af nw4cExpDialog_Use3DEditor "left" 0
3631					-ac nw4cExpDialog_Use3DEditor "top" 4 nw4cExpDialog_UseCreativeStudio
3632					-an nw4cExpDialog_Use3DEditor "right"
3633					-an nw4cExpDialog_Use3DEditor "bottom"
3634
3635					-af $sep3 "left" 0
3636					-ac $sep3 "top" 4 nw4cExpDialog_Use3DEditor
3637					-af $sep3 "right" 0
3638					-an $sep3 "bottom"
3639
3640
3641					-af nw4cExpDialog_MergeCmdlFlag "left" 0
3642					-ac nw4cExpDialog_MergeCmdlFlag "top" (4+3) $sep3
3643					-an nw4cExpDialog_MergeCmdlFlag "right"
3644					-an nw4cExpDialog_MergeCmdlFlag "bottom"
3645					-ac nw4cExpDialog_MergeCmdlPath "left" 2 nw4cExpDialog_MergeCmdlFlag
3646					-ac nw4cExpDialog_MergeCmdlPath "top" 4 $sep3
3647					-ac nw4cExpDialog_MergeCmdlPath "right" 5 nw4cExpDialog_MergeCmdlBrowser
3648					-an nw4cExpDialog_MergeCmdlPath "bottom"
3649					-an nw4cExpDialog_MergeCmdlBrowser "left"
3650					-ac nw4cExpDialog_MergeCmdlBrowser "top" 4 $sep3
3651					-af nw4cExpDialog_MergeCmdlBrowser "right" 46
3652					-an nw4cExpDialog_MergeCmdlBrowser "bottom"
3653
3654					-af nw4cExpDialog_CopyRelatedFiles "left" 0
3655					-ac nw4cExpDialog_CopyRelatedFiles "top" 4 nw4cExpDialog_MergeCmdlFlag
3656					-an nw4cExpDialog_CopyRelatedFiles "right"
3657					-an nw4cExpDialog_CopyRelatedFiles "bottom"
3658
3659					//-af nw4cExpDialog_MergeCmdlAuto "left" 0
3660					//-ac nw4cExpDialog_MergeCmdlAuto "top" 4 nw4cExpDialog_MergeCmdlPath
3661					//-an nw4cExpDialog_MergeCmdlAuto "right"
3662					//-af nw4cExpDialog_MergeCmdlAuto "bottom" 4
3663				$outForm;
3664			}
3665			else
3666			{
3667				formLayout -e
3668					-af nw4cExpDialog_ProcessMode "left" 0
3669					-af nw4cExpDialog_ProcessMode "top" 4
3670					-an nw4cExpDialog_ProcessMode "right"
3671					-an nw4cExpDialog_ProcessMode "bottom"
3672					-af $sep1 "left" 0
3673					-ac $sep1 "top" 4 nw4cExpDialog_ProcessMode
3674					-af $sep1 "right" 0
3675					-an $sep1 "bottom"
3676
3677					-af nw4cExpDialog_ExportTarget "left" 0
3678					-ac nw4cExpDialog_ExportTarget "top" 4 $sep1
3679					-an nw4cExpDialog_ExportTarget "right"
3680					-an nw4cExpDialog_ExportTarget "bottom"
3681
3682					-af nw4cExpDialog_OutFileName "left" 0
3683					-ac nw4cExpDialog_OutFileName "top" 4 nw4cExpDialog_ExportTarget
3684					-an nw4cExpDialog_OutFileName "right"
3685					-an nw4cExpDialog_OutFileName "bottom"
3686					-ac nw4cExpDialog_SceneToOutFileName "left" 5 nw4cExpDialog_OutFileName
3687					-ac nw4cExpDialog_SceneToOutFileName "top" 4 nw4cExpDialog_ExportTarget
3688					-an nw4cExpDialog_SceneToOutFileName "right"
3689					-an nw4cExpDialog_SceneToOutFileName "bottom"
3690					-ac nw4cExpDialog_NodeToOutFileName "left" 5 nw4cExpDialog_SceneToOutFileName
3691					-ac nw4cExpDialog_NodeToOutFileName "top" 4 nw4cExpDialog_ExportTarget
3692					-an nw4cExpDialog_NodeToOutFileName "right"
3693					-an nw4cExpDialog_NodeToOutFileName "bottom"
3694					-af $sep2 "left" 0
3695					-ac $sep2 "top" 4 nw4cExpDialog_OutFileName
3696					-af $sep2 "right" 0
3697					-an $sep2 "bottom"
3698
3699					-af nw4cExpDialog_OutInterFile "left" 0
3700					-ac nw4cExpDialog_OutInterFile "top" 4 $sep2
3701					-an nw4cExpDialog_OutInterFile "right"
3702					-an nw4cExpDialog_OutInterFile "bottom"
3703
3704					-af nw4cExpDialog_OutFolder "left" 0
3705					-ac nw4cExpDialog_OutFolder "top" 4 nw4cExpDialog_OutInterFile
3706					-ac nw4cExpDialog_OutFolder "right" 5 nw4cExpDialog_OutFolderBrowser
3707					-an nw4cExpDialog_OutFolder "bottom"
3708					-an nw4cExpDialog_OutFolderBrowser "left"
3709					-ac nw4cExpDialog_OutFolderBrowser "top" 4 nw4cExpDialog_OutInterFile
3710					-af nw4cExpDialog_OutFolderBrowser "right" 46
3711					-an nw4cExpDialog_OutFolderBrowser "bottom"
3712
3713					-af nw4cExpDialog_UseCreativeStudio "left" 0
3714					-ac nw4cExpDialog_UseCreativeStudio "top" 4 nw4cExpDialog_OutFolder
3715					-an nw4cExpDialog_UseCreativeStudio "right"
3716					-an nw4cExpDialog_UseCreativeStudio "bottom"
3717					-af $sep3 "left" 0
3718					-ac $sep3 "top" 4 nw4cExpDialog_UseCreativeStudio
3719					-af $sep3 "right" 0
3720					-an $sep3 "bottom"
3721
3722					-af nw4cExpDialog_MergeCmdlFlag "left" 0
3723					-ac nw4cExpDialog_MergeCmdlFlag "top" (4+3) $sep3
3724					-an nw4cExpDialog_MergeCmdlFlag "right"
3725					-an nw4cExpDialog_MergeCmdlFlag "bottom"
3726					-ac nw4cExpDialog_MergeCmdlPath "left" 2 nw4cExpDialog_MergeCmdlFlag
3727					-ac nw4cExpDialog_MergeCmdlPath "top" 4 $sep3
3728					-ac nw4cExpDialog_MergeCmdlPath "right" 5 nw4cExpDialog_MergeCmdlBrowser
3729					-an nw4cExpDialog_MergeCmdlPath "bottom"
3730					-an nw4cExpDialog_MergeCmdlBrowser "left"
3731					-ac nw4cExpDialog_MergeCmdlBrowser "top" 4 $sep3
3732					-af nw4cExpDialog_MergeCmdlBrowser "right" 46
3733					-an nw4cExpDialog_MergeCmdlBrowser "bottom"
3734
3735					-af nw4cExpDialog_CopyRelatedFiles "left" 0
3736					-ac nw4cExpDialog_CopyRelatedFiles "top" 4 nw4cExpDialog_MergeCmdlFlag
3737					-an nw4cExpDialog_CopyRelatedFiles "right"
3738					-an nw4cExpDialog_CopyRelatedFiles "bottom"
3739
3740					//-af nw4cExpDialog_MergeCmdlAuto "left" 0
3741					//-ac nw4cExpDialog_MergeCmdlAuto "top" 4 nw4cExpDialog_MergeCmdlPath
3742					//-an nw4cExpDialog_MergeCmdlAuto "right"
3743					//-af nw4cExpDialog_MergeCmdlAuto "bottom" 4
3744				$outForm;
3745			}
3746		setParent ..; // formLayout
3747	setParent ..; // frameLayout
3748
3749	//-----------------------------------------------------------------------------
3750	// general
3751	frameLayout -l "General Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
3752		columnLayout -adj 1 -rs 4;
3753		rowColumnLayout -nc 2 -cw 1 (215 + $adjustSpace) -cw 2 190;
3754			floatFieldGrp -l "Magnify" -nf 1 -cw 1 (140 + $adjustSpace) -cw 2 60
3755				-v1 1.0 -pre 4
3756				-cc "nw4cExpDialog_MagnifyCB"
3757				nw4cExpDialog_Magnify;
3758			text -l ""; // dummy
3759			//optionMenuGrp -l "Texture Matrix" -cw 1 120 -rat 1 "both" 4
3760			//	nw4cExpDialog_TexMatrixMode;
3761			//	menuItem -l "Maya";
3762			//	menuItem -l "3dsmax";
3763		setParent ..; // rowColumnLayout
3764		rowColumnLayout -nc 4 -cw 1 (325 + $adjustSpace + $afterMaya2011Adjust * 25) -cw 2 50 -cw 3 5 -cw 4 50;
3765			radioButtonGrp -l "Start / End Frame" -nrb 3
3766				-cw4 160 50 80 65
3767				-rat 2 "both" 0
3768				-rat 3 "both" 0
3769				-rat 4 "both" 0
3770				-la3 "All" "Playback" "Range" -sl 1
3771				-cc "nw4cExpDialog_FrameRangeCB"
3772				nw4cExpDialog_FrameRange;
3773			intField -v 1
3774				-cc "nw4cExpDialog_FrameStartEndCB"
3775				nw4cExpDialog_StartFrame;
3776			text -l ""; // dummy
3777			intField -v 100
3778				-cc "nw4cExpDialog_FrameStartEndCB"
3779				nw4cExpDialog_EndFrame;
3780		setParent ..; // rowColumnLayout
3781		checkBoxGrp -l "" -ncb 1 -cw 1 (140+$adjustSpace) -cw 2 120
3782			-l1 "Remove Namespace" -v1 0
3783			nw4cExpDialog_RemoveNamespace;
3784		setParent ..; // columnLayout
3785	setParent ..; // frameLayout
3786
3787	//-----------------------------------------------------------------------------
3788	// file selection
3789	frameLayout -l "Output File Selection" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
3790		string $form = `formLayout`;
3791			checkBoxGrp -l "Model Data" -ncb 1 -l1 "[.cmdl]" -v1 1
3792				-cw 1 140 -cw 2 60
3793				-cc1 "nw4cExpDialog_ModelCB" nw4cExpDialog_CmdlFileOut;
3794			checkBoxGrp -l "Texture Data" -ncb 1 -l1 "[.ctex]" -v1 1
3795				-cw 1 140 -cw 2 60
3796				nw4cExpDialog_CtexFileOut;
3797			checkBoxGrp -l "Model Animation Data" -ncb 1 -l1 "[.cmdla]" -v1 0
3798				-cw 1 140 -cw 2 60
3799				-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CmdlaFileOut;
3800			checkBoxGrp -l "Skeletal Animation Data" -ncb 1 -l1 "[.cskla]" -v1 0
3801				-cw 1 140 -cw 2 60
3802				-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CsklaFileOut;
3803			checkBoxGrp -l "Material Animation Data" -ncb 1 -l1 "[.cmata]" -v1 0
3804				-cw 1 (140) -cw 2 60
3805				-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CmataFileOut;
3806			if ($useCustomUI == 1)
3807			{
3808				// �J�X�^�� UI ���g�p����ꍇ�̓}�e���A���A�j���[�V������v�f�i�J���[�A
3809				// �e�N�X�`���p�^�[���A�e�N�X�`��SRT�j���ɏo�͐ݒ���s���B
3810				checkBoxGrp -l "Material Color Animation Data" -ncb 1 -l1 "[.cmata]" -v1 0
3811					-cw 1 (170 + $afterMaya2011Adjust * 20)  -cw 2 60
3812					-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CmclaFileOut;
3813				checkBoxGrp -l "Texture Pattern Animation Data" -ncb 1 -l1 "[.cmata]" -v1 0
3814					-cw 1 (170 + $afterMaya2011Adjust * 20) -cw 2 60
3815					-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CmtpaFileOut;
3816				checkBoxGrp -l "Texture SRT Animation Data" -ncb 1 -l1 "[.cmata]" -v1 0
3817					-cw 1 (170 + $afterMaya2011Adjust * 20) -cw 2 60
3818					-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CmtsaFileOut;
3819			}
3820			checkBoxGrp -l "Camera Data" -ncb 1 -l1 "[.ccam]" -v1 0
3821				-cw 1 140 -cw 2 60
3822				-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_CcamFileOut;
3823			checkBoxGrp -l "Light Data" -ncb 1 -l1 "[.clgt]" -v1 0
3824				-cw 1 140 -cw 2 60
3825				-cc "nw4cExpDialog_AnimCB" nw4cExpDialog_ClgtFileOut;
3826			checkBoxGrp -l "Environment Data" -ncb 1 -l1 "[.cenv]" -v1 0
3827				-cw 1 (140) -cw 2 60
3828				-cc "nw4cExpDialog_ProcessModeCB" nw4cExpDialog_CenvFileOut;
3829			button -l "Search Animation" -w 104
3830				-c "nw4cExpDialog_SearchAnim"
3831				nw4cExpDialog_SearchAnimBtn;
3832		setParent ..; // formLayout
3833		if ($useCustomUI == 1)
3834		{
3835			// �}�e���A���A�j���[�V�����������ďo�͂���J�X�^�� UI ���g�p����ꍇ��
3836			// �o�̓t�@�C���ݒ�̔z�u���s���B
3837			formLayout -e
3838				-af nw4cExpDialog_CmdlFileOut "left" $adjustSpace
3839				-af nw4cExpDialog_CmdlFileOut "top" 4
3840				-an nw4cExpDialog_CmdlFileOut "right"
3841				-an nw4cExpDialog_CmdlFileOut "bottom"
3842
3843				-af nw4cExpDialog_CtexFileOut "left" $adjustSpace
3844				-ac nw4cExpDialog_CtexFileOut "top" 4 nw4cExpDialog_CmdlFileOut
3845				-an nw4cExpDialog_CtexFileOut "right"
3846				-an nw4cExpDialog_CtexFileOut "bottom"
3847
3848				-af nw4cExpDialog_CmdlaFileOut "left" $adjustSpace
3849				-ac nw4cExpDialog_CmdlaFileOut "top" 4 nw4cExpDialog_CtexFileOut
3850				-an nw4cExpDialog_CmdlaFileOut "right"
3851				-an nw4cExpDialog_CmdlaFileOut "bottom"
3852
3853				-af nw4cExpDialog_CsklaFileOut "left" $adjustSpace
3854				-ac nw4cExpDialog_CsklaFileOut "top" 4 nw4cExpDialog_CmdlaFileOut
3855				-an nw4cExpDialog_CsklaFileOut "right"
3856				-an nw4cExpDialog_CsklaFileOut "bottom"
3857
3858				-af nw4cExpDialog_CcamFileOut "left" $adjustSpace
3859				-ac nw4cExpDialog_CcamFileOut "top" 4 nw4cExpDialog_CsklaFileOut
3860				-an nw4cExpDialog_CcamFileOut "right"
3861				-an nw4cExpDialog_CcamFileOut "bottom"
3862
3863				-af nw4cExpDialog_ClgtFileOut "left" $adjustSpace
3864				-ac nw4cExpDialog_ClgtFileOut "top" 4 nw4cExpDialog_CcamFileOut
3865				-an nw4cExpDialog_ClgtFileOut "right"
3866				-an nw4cExpDialog_ClgtFileOut "bottom"
3867
3868				-af nw4cExpDialog_CmataFileOut "left" (270 + $adjustSpace + $afterMaya2011Adjust * 20)
3869				-af nw4cExpDialog_CmataFileOut "top" 4
3870				-an nw4cExpDialog_CmataFileOut "right"
3871				-an nw4cExpDialog_CmataFileOut "bottom"
3872
3873				-af nw4cExpDialog_CmclaFileOut "left" (240 + $adjustSpace + $afterMaya2011Adjust * 0)
3874				-ac nw4cExpDialog_CmclaFileOut "top" 4 nw4cExpDialog_CmataFileOut
3875				-an nw4cExpDialog_CmclaFileOut "right"
3876				-an nw4cExpDialog_CmclaFileOut "bottom"
3877
3878				-af nw4cExpDialog_CmtpaFileOut "left" (240 + $adjustSpace + $afterMaya2011Adjust * 0)
3879				-ac nw4cExpDialog_CmtpaFileOut "top" 4 nw4cExpDialog_CmclaFileOut
3880				-an nw4cExpDialog_CmtpaFileOut "right"
3881				-an nw4cExpDialog_CmtpaFileOut "bottom"
3882
3883				-af nw4cExpDialog_CmtsaFileOut "left" (240 + $adjustSpace + $afterMaya2011Adjust * 0)
3884				-ac nw4cExpDialog_CmtsaFileOut "top" 4 nw4cExpDialog_CmtpaFileOut
3885				-an nw4cExpDialog_CmtsaFileOut "right"
3886				-an nw4cExpDialog_CmtsaFileOut "bottom"
3887
3888				-af nw4cExpDialog_CenvFileOut "left" (270 + $adjustSpace + $afterMaya2011Adjust * 20)
3889				-ac nw4cExpDialog_CenvFileOut "top" 4 nw4cExpDialog_CmtsaFileOut
3890				-an nw4cExpDialog_CenvFileOut "right"
3891				-an nw4cExpDialog_CenvFileOut "bottom"
3892
3893				-ac nw4cExpDialog_SearchAnimBtn "left" 32 nw4cExpDialog_CenvFileOut
3894				-af nw4cExpDialog_SearchAnimBtn "top" 4
3895				-an nw4cExpDialog_SearchAnimBtn "right"
3896				-an nw4cExpDialog_SearchAnimBtn "bottom"
3897				$form;
3898		}
3899		else
3900		{
3901			// �J�X�^�� UI ���g�p�����Ƀ}�e���A���A�j���[�V������ .cmata �t�@�C���ɂ܂Ƃ߂ďo�͂���
3902			// �ꍇ�̏o�̓t�@�C���ݒ�̔z�u���s���B
3903			formLayout -e
3904				-af nw4cExpDialog_CmdlFileOut "left" $adjustSpace
3905				-af nw4cExpDialog_CmdlFileOut "top" 4
3906				-an nw4cExpDialog_CmdlFileOut "right"
3907				-an nw4cExpDialog_CmdlFileOut "bottom"
3908
3909				-af nw4cExpDialog_CtexFileOut "left" $adjustSpace
3910				-ac nw4cExpDialog_CtexFileOut "top" 4 nw4cExpDialog_CmdlFileOut
3911				-an nw4cExpDialog_CtexFileOut "right"
3912				-an nw4cExpDialog_CtexFileOut "bottom"
3913
3914				-af nw4cExpDialog_CmdlaFileOut "left" $adjustSpace
3915				-ac nw4cExpDialog_CmdlaFileOut "top" 4 nw4cExpDialog_CtexFileOut
3916				-an nw4cExpDialog_CmdlaFileOut "right"
3917				-an nw4cExpDialog_CmdlaFileOut "bottom"
3918
3919				-af nw4cExpDialog_CsklaFileOut "left" ($adjustSpace)
3920				-ac nw4cExpDialog_CsklaFileOut "top" 4 nw4cExpDialog_CmdlaFileOut
3921				-an nw4cExpDialog_CsklaFileOut "right"
3922				-an nw4cExpDialog_CsklaFileOut "bottom"
3923
3924				-af nw4cExpDialog_CmataFileOut "left" (220 + $adjustSpace + $afterMaya2011Adjust * 20)
3925				-af nw4cExpDialog_CmataFileOut "top" 4
3926				-an nw4cExpDialog_CmataFileOut "right"
3927				-an nw4cExpDialog_CmataFileOut "bottom"
3928
3929				-af nw4cExpDialog_CcamFileOut "left" (220 + $adjustSpace + $afterMaya2011Adjust * 20)
3930				-ac nw4cExpDialog_CcamFileOut "top" 4 nw4cExpDialog_CmataFileOut
3931				-an nw4cExpDialog_CcamFileOut "right"
3932				-an nw4cExpDialog_CcamFileOut "bottom"
3933
3934				-af nw4cExpDialog_ClgtFileOut "left" (220 + $adjustSpace + $afterMaya2011Adjust * 20)
3935				-ac nw4cExpDialog_ClgtFileOut "top" 4 nw4cExpDialog_CcamFileOut
3936				-an nw4cExpDialog_ClgtFileOut "right"
3937				-an nw4cExpDialog_ClgtFileOut "bottom"
3938
3939				-af nw4cExpDialog_CenvFileOut "left" (220 + $adjustSpace + $afterMaya2011Adjust * 20)
3940				-ac nw4cExpDialog_CenvFileOut "top" 4 nw4cExpDialog_ClgtFileOut
3941				-an nw4cExpDialog_CenvFileOut "right"
3942				-af nw4cExpDialog_CenvFileOut "bottom" 4
3943
3944				-ac nw4cExpDialog_SearchAnimBtn "left" 32 nw4cExpDialog_CenvFileOut
3945				-af nw4cExpDialog_SearchAnimBtn "top" 4
3946				-an nw4cExpDialog_SearchAnimBtn "right"
3947				-an nw4cExpDialog_SearchAnimBtn "bottom"
3948				$form;
3949		}
3950	setParent ..; // frameLayout
3951	control -e -vis 0 nw4cExpDialog_SearchAnimBtn; // (debug)
3952
3953	//-----------------------------------------------------------------------------
3954	// optimization
3955	frameLayout -l "Optimization Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
3956		columnLayout -adj 1 -rs 4;
3957
3958		optionMenuGrp -l "Compress Node" -cw 1 120
3959			-rat 1 "both" 4 -cw 1 (140 + $adjustSpace) -cw 2 150
3960			nw4cExpDialog_CompressNode;
3961			menuItem -l "None";
3962			menuItem -l "Cull Useless Node";
3963			menuItem -l "Cull Uninfluential Node";
3964			menuItem -l "Unite Compressible Node";
3965			menuItem -l "Unite All Node";
3966			//menuItem -l "Merge Useless Node";
3967
3968		optionMenuGrp -l "Compress Material" -cw 1 110
3969			-rat 1 "both" 4 -cw 1 (140 + $adjustSpace) -cw 2 150
3970			nw4cExpDialog_CompressMaterial;
3971			menuItem -l "None";
3972			menuItem -l "Compress Same Material";
3973			//checkBox -l "Combine Polygon" -v 0
3974			//	nw4cExpDialog_CombinePolygon;
3975		rowColumnLayout -nc 2 -cw 1 (250 + $adjustSpace + $afterMaya2011Adjust * 30) -cw 2 300;
3976			checkBoxGrp -l "" -ncb 1 -cw 1 (140 + $adjustSpace) -cw 2 120
3977				-l1 "Optimize Primitive" -v1 1
3978				nw4cExpDialog_OptimizePrimitive;
3979
3980			checkBoxGrp -l "" -ncb 1 -cw 1 (34 - $afterMaya2011Adjust * 20) -cw 2 220
3981				-l1 "Convert To Model" -v1 0
3982				-cc "nw4cExpDialog_ConvertToModelCB"
3983				nw4cExpDialog_ConvertToModel;
3984		setParent ..; // rowColumnLayout
3985
3986		//checkBoxGrp -l "" -ncb 1 -cw 1 100 -cw 2 160
3987		//	-l1 "Delete Useless Vertex Data" -v1 0
3988		//	nw4cExpDialog_DelUselessVtxData;
3989
3990		setParent ..; // columnLayout
3991	setParent ..; // frameLayout
3992
3993	//-----------------------------------------------------------------------------
3994	// quantization
3995	frameLayout -l "Quantization Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
3996		columnLayout -adj 1 -rs 4;
3997		rowColumnLayout -nc 3 -cw 1 (200+$adjustSpace + $afterMaya2011Adjust * 10)
3998			-cw 2 (164 + $afterMaya2011Adjust * 10) -cw 3 (164 + $afterMaya2011Adjust * 10);
3999			optionMenuGrp -l "Position" -cw 1 (140 + $adjustSpace)
4000				nw4cExpDialog_QuantPos;
4001				menuItem -l "Float";
4002				menuItem -l "Short";
4003				menuItem -l "Byte";
4004			optionMenuGrp -l "Normal" -cw 1 92
4005				nw4cExpDialog_QuantNrm;
4006				menuItem -l "Float";
4007				menuItem -l "Short";
4008				menuItem -l "Byte";
4009			optionMenuGrp -l "Tex Coord" -cw 1 78
4010				nw4cExpDialog_QuantTex;
4011				menuItem -l "Float";
4012				menuItem -l "Short";
4013				menuItem -l "Byte";
4014		setParent ..; // rowColumnLayout
4015		setParent ..; // columnLayout
4016	setParent ..; // frameLayout
4017
4018	//-----------------------------------------------------------------------------
4019	// model
4020	frameLayout -l "Model Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
4021		columnLayout -adj 1 -rs 4;
4022			rowColumnLayout -nc 2 -cw 1 (282+$adjustSpace + $afterMaya2011Adjust * 25) -cw 2 270;
4023				optionMenuGrp -l "Adjust Skinning" -cw 1 (140 + $adjustSpace)
4024					-rat 1 "both" 4
4025					nw4cExpDialog_AdjustSkinning;
4026					menuItem -l "None If Possible";
4027					menuItem -l "Rigid Skinning";
4028
4029				optionMenuGrp -l "Mesh Visibility Mode" -cw 1 120
4030					-rat 1 "both" 4
4031					nw4cExpDialog_MeshVisibilityMode;
4032					menuItem -l "Bind By Index";
4033					menuItem -l "Bind By Name";
4034			setParent ..; // rowColumnLayout
4035
4036			rowColumnLayout -nc 2 -cw 1 (285+$adjustSpace + $afterMaya2011Adjust * 29) -cw 2 240;
4037				checkBoxGrp -l "" -ncb 1 -cw 1 (140 + $adjustSpace)
4038					-l1 "Non-Uniform Scale" -v1 0
4039					nw4cExpDialog_NonUniformScale;
4040
4041				intFieldGrp -nf 1 -l "Max Reserved Uniform Registers" -cw2 180 45
4042					-v1 0 -cc "nw4cExpDialog_MaxReservedUniformRegistersCB"
4043					nw4cExpDialog_MaxReservedUniformRegisters;
4044			setParent ..; // rowColumnLayout
4045		setParent ..; // columnLayout
4046	setParent ..; // frameLayout
4047
4048	//-----------------------------------------------------------------------------
4049	// anim
4050	frameLayout -l "Animation Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
4051		columnLayout -adj 1 -rs 4;
4052		rowColumnLayout -nc 3 -cw 1 (283+$adjustSpace + $afterMaya2011Adjust * 21) -cw 2 160 -cw 3 100;
4053			checkBoxGrp -l "" -ncb 1 -cw 1 (140+$adjustSpace)
4054				-l1 "Bake All Animation" -v1 1
4055				nw4cExpDialog_BakeAll;
4056			optionMenuGrp -l "Frame Precision" -cw 1 100
4057				nw4cExpDialog_FramePrecision;
4058				menuItem -l "1.0";
4059				menuItem -l "0.5";
4060				menuItem -l "0.2";
4061				menuItem -l "0.1";
4062			checkBoxGrp -l "" -ncb 1 -cw 1 44 -cw 2 100
4063				-l1 "Loop" -v1 0
4064				nw4cExpDialog_LoopAnim;
4065		setParent ..; // rowColumnLayout
4066		rowColumnLayout -nc 2 -cw 1 (270+$adjustSpace) -cw 2 200;
4067			checkBoxGrp -l "" -ncb 1 -cw 1 (140+$adjustSpace) -cw 2 120
4068				-l1 "Frame Format" -v1 0
4069				-cc "nw4cExpDialog_AnimCB"
4070				nw4cExpDialog_FrameFormat;
4071			text -l ""; // dummy
4072		setParent ..; // rowColumnLayout
4073
4074		intSliderGrp -l "Scale Quantize Quality"
4075			-cw 1 (140+$adjustSpace) -cw 2 45 -cw 3 300
4076			-min 0 -max 9 -v 9 -adj 0
4077			nw4cExpDialog_ScaleQuantizeQuality;
4078
4079		intSliderGrp -l "Rotate Quantize Quality"
4080			-cw 1 (140+$adjustSpace) -cw 2 45 -cw 3 300
4081			-min 0 -max 9 -v 9 -adj 0
4082			nw4cExpDialog_RotateQuantizeQuality;
4083
4084		intSliderGrp -l "Translate Quantize Quality"
4085			-cw 1 (140+$adjustSpace) -cw 2 45 -cw 3 300
4086			-min 0 -max 9 -v 9 -adj 0
4087			nw4cExpDialog_TranslateQuantizeQuality;
4088
4089		setParent ..; // columnLayout
4090	setParent ..; // frameLayout
4091
4092	//-----------------------------------------------------------------------------
4093	// tolerance
4094	frameLayout -l "Tolerance Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
4095		columnLayout -adj 1 -rs 4;
4096		string $form = `formLayout -h 75`;
4097			// create control in tab order
4098			floatFieldGrp -nf 1 -l "Node Translate" -cw2 140 45
4099				-pre 4 -v1 0.01
4100				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolT\""
4101				nw4cExpDialog_TolT;
4102			floatFieldGrp -nf 1 -l "Node Rotate" -cw2 140 45
4103				-pre 4 -v1 0.1
4104				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolR\""
4105				nw4cExpDialog_TolR;
4106			floatFieldGrp -nf 1 -l "Node Scale" -cw2 140 45
4107				-pre 4 -v1 0.1
4108				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolS\""
4109				nw4cExpDialog_TolS;
4110
4111			floatFieldGrp -nf 1 -l "Texture Translate" -cw2 100 45
4112				-pre 4 -v1 0.01
4113				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolTexT\""
4114				nw4cExpDialog_TolTexT;
4115			floatFieldGrp -nf 1 -l "Texture Rotate" -cw2 100 45
4116				-pre 4 -v1 0.1
4117				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolTexR\""
4118				nw4cExpDialog_TolTexR;
4119			floatFieldGrp -nf 1 -l "Texture Scale" -cw2 100 45
4120				-pre 4 -v1 0.1
4121				-cc "nw4cExpDialog_ToleranceSRTCB \"nw4cExpDialog_TolTexS\""
4122				nw4cExpDialog_TolTexS;
4123
4124			floatFieldGrp -nf 1 -l "Color" -cw2 60 45
4125				-pre 4 -v1 0.001
4126				-cc "nw4cExpDialog_ToleranceColorCB \"nw4cExpDialog_TolC\""
4127				nw4cExpDialog_TolC;
4128		setParent ..; // formLayout
4129		// layout control
4130		formLayout -e -w 440
4131			-af nw4cExpDialog_TolT "left" (0+$adjustSpace)
4132			-af nw4cExpDialog_TolT "top" 0
4133			-an nw4cExpDialog_TolT "right"
4134			-an nw4cExpDialog_TolT "bottom"
4135
4136			-af nw4cExpDialog_TolR "left" (0+$adjustSpace)
4137			-af nw4cExpDialog_TolR "top" 25
4138			-an nw4cExpDialog_TolR "right"
4139			-an nw4cExpDialog_TolR "bottom"
4140
4141			-af nw4cExpDialog_TolS "left" (0+$adjustSpace)
4142			-af nw4cExpDialog_TolS "top" 50
4143			-an nw4cExpDialog_TolS "right"
4144			-an nw4cExpDialog_TolS "bottom"
4145
4146			-af nw4cExpDialog_TolTexT "left" (210+$adjustSpace)
4147			-af nw4cExpDialog_TolTexT "top" 0
4148			-an nw4cExpDialog_TolTexT "right"
4149			-an nw4cExpDialog_TolTexT "bottom"
4150
4151			-af nw4cExpDialog_TolTexR "left" (210+$adjustSpace)
4152			-af nw4cExpDialog_TolTexR "top" 25
4153			-an nw4cExpDialog_TolTexR "right"
4154			-an nw4cExpDialog_TolTexR "bottom"
4155
4156			-af nw4cExpDialog_TolTexS "left" (210+$adjustSpace)
4157			-af nw4cExpDialog_TolTexS "top" 50
4158			-an nw4cExpDialog_TolTexS "right"
4159			-an nw4cExpDialog_TolTexS "bottom"
4160
4161			-af nw4cExpDialog_TolC "left" (420+$adjustSpace)
4162			-af nw4cExpDialog_TolC "top" 0
4163			-an nw4cExpDialog_TolC "right"
4164			-an nw4cExpDialog_TolC "bottom"
4165			$form;
4166		setParent ..; // columnLayout
4167	setParent ..; // frameLayout
4168
4169	//-----------------------------------------------------------------------------
4170	// close layout
4171	setParent ..;	// columnLayout
4172	setParent ..;	// scrollLayout
4173
4174	//-----------------------------------------------------------------------------
4175	// setting menu
4176	CreateSettingMenu($parent);
4177
4178	//-----------------------------------------------------------------------------
4179	// end
4180	waitCursor -st 0;
4181	setUITemplate -ppt;
4182
4183	//-----------------------------------------------------------------------------
4184	// set help tag to save window size
4185	setOptionBoxHelpTag("nw4cExpDialog");
4186
4187	//-----------------------------------------------------------------------------
4188	// set button & menu command
4189	string $applyBtn = getOptionBoxApplyBtn();
4190	button -e -l "Export" -c "nw4cExpDialog_ExportCB" $applyBtn;
4191
4192	string $saveBtn = getOptionBoxSaveBtn();
4193	button -e -c "nw4cExpDialog_SaveSettingsCB" $saveBtn;
4194
4195	string $resetBtn = getOptionBoxResetBtn();
4196	button -e -c "nw4cExpDialog_ResetOptionVariable" $resetBtn;
4197
4198	string $helpMenu = getOptionBoxHelpItem();
4199	menuItem -e -l "Help on NW4C Export..."
4200		-c "NW4C_ShowHelp \"html/export.html\" \"\"" $helpMenu;
4201
4202	//-----------------------------------------------------------------------------
4203	// set option cotrol
4204	SetOptionControl();
4205
4206	//-----------------------------------------------------------------------------
4207	// show option box
4208	setFocus(getOptionBoxApplyAndCloseBtn());
4209	showOptionBox();
4210
4211	return 1;
4212}
4213
4214/******************************************************************************
4215	main
4216******************************************************************************/
4217global proc NW4C_ExpDialog()
4218{
4219	//-----------------------------------------------------------------------------
4220	// load plugin
4221	LoadPlugin();
4222
4223	//-----------------------------------------------------------------------------
4224	// open option window
4225	OpenOptionWindow();
4226}
4227
4228/******************************************************************************
4229	export direct
4230******************************************************************************/
4231global proc NW4C_ExpDirect()
4232{
4233	//-----------------------------------------------------------------------------
4234	// load plugin
4235	LoadPlugin();
4236
4237	//-----------------------------------------------------------------------------
4238	// init option variable
4239	SetOptionVariable(0);
4240
4241	//-----------------------------------------------------------------------------
4242	// export
4243	DoExportCmd(0);
4244}
4245
4246/******************************************************************************
4247	export direct force (no overwrite check)
4248******************************************************************************/
4249global proc NW4C_ExpDirectForce()
4250{
4251	//-----------------------------------------------------------------------------
4252	// load plugin
4253	LoadPlugin();
4254
4255	//-----------------------------------------------------------------------------
4256	// init option variable
4257	SetOptionVariable(0);
4258
4259	//-----------------------------------------------------------------------------
4260	// export
4261	DoExportCmd(1);
4262}
4263