/******************************************************************************
	NINTENDO NITRO-System Maya Plugin

	File:         NNS_ExportOpts.mel
	Description:  export NITRO intermediate file options
	Date:         2004/10/21
	Author:       T.Endo

	Copyright 2003-2006 Nintendo. All rights reserved.
******************************************************************************/

// NNS_ExportOpts
// NNS_ResetExportOpts

/******************************************************************************
	switch
******************************************************************************/
//global int $nnsExport_UseIsa = 0;

/******************************************************************************
	magnify callback
******************************************************************************/
global proc nnsExport_MagnifyCB()
{
	float $magnify = `floatFieldGrp -q -v1 nnsExport_Magnify`;
	//trace ("mag: " + $magnify);
	if ($magnify <= 0.0)
		floatFieldGrp -e -v1 1.0 nnsExport_Magnify;
}

/******************************************************************************
	frame range callback
******************************************************************************/
global proc nnsExport_FrameRangeCB()
{
	int $frame_range = `radioButtonGrp -q -sl nnsExport_FrameRange` - 1;
	int $enable_flag = ($frame_range == 2);
	control -e -en $enable_flag nnsExport_StartFrame;
	control -e -en $enable_flag nnsExport_EndFrame;
}

/******************************************************************************
	frame start end callback
******************************************************************************/
global proc nnsExport_FrameStartEndCB()
{
	int $start = `intField -q -v nnsExport_StartFrame`;
	int $end   = `intField -q -v nnsExport_EndFrame`;
	if ($start > $end) {
		intField -e -v $end nnsExport_StartFrame;
		intField -e -v $start nnsExport_EndFrame;
	}
}

/******************************************************************************
	model file callback
******************************************************************************/
global proc nnsExport_ModelCB()
{
	int $imd = `checkBoxGrp -q -v1 nnsExport_ImdFileOut`;

	control -e -en $imd nnsExport_VertexStyle;
	control -e -en $imd nnsExport_OutAllTex;
	control -e -en $imd nnsExport_ForceFullWeight;
	control -e -en $imd nnsExport_UsePrimitiveStrip;
}

/******************************************************************************
	anime file callback
******************************************************************************/
global proc nnsExport_AnimeCB()
{

//-----------------------------------------------------------------------------
// get out file
	int $ica = `checkBoxGrp -q -v1 nnsExport_IcaFileOut`;
	int $iva = `checkBoxGrp -q -v1 nnsExport_IvaFileOut`;
	int $ima = `checkBoxGrp -q -v1 nnsExport_ImaFileOut`;
	int $itp = `checkBoxGrp -q -v1 nnsExport_ItpFileOut`;
	int $ita = `checkBoxGrp -q -v1 nnsExport_ItaFileOut`;
	//int $isa = `checkBoxGrp -q -v1 nnsExport_IsaFileOut`;
	int $isa = 0;

	int $any_anime = ($ica || $iva || $ima || $itp || $ita || $isa);
	int $linear_anime = ($ica || $ima || $ita || $isa);

//-----------------------------------------------------------------------------
// anime options
	int $anime_interp = `optionMenuGrp -q -sl nnsExport_AnimeInterp` - 1;;

	control -e -en $linear_anime nnsExport_AnimeInterp;
	control -e -en ($linear_anime && $anime_interp == 1)
		nnsExport_LoopInterp;
	control -e -en $linear_anime nnsExport_FrameStepMode;

//-----------------------------------------------------------------------------
// tolerance options
	int $node_rt_tol_flag = ($ica || $isa);
	int $node_s_tol_flag = $ica;
	control -e -en $node_rt_tol_flag nnsExport_AnimeTolT;
	control -e -en $node_rt_tol_flag nnsExport_AnimeTolR;
	control -e -en $node_s_tol_flag nnsExport_AnimeTolS;

	int $uv_srt_tol_flag = $ita;
	control -e -en $uv_srt_tol_flag nnsExport_AnimeTolUvT;
	control -e -en $uv_srt_tol_flag nnsExport_AnimeTolUvR;
	control -e -en $uv_srt_tol_flag nnsExport_AnimeTolUvS;

	int $color_tol_flag = ($ima || $isa);
	control -e -en $color_tol_flag nnsExport_AnimeTolC;
}

/******************************************************************************
	tolerance srt callback
******************************************************************************/
global proc nnsExport_ToleranceSRTCB(string $field)
{
	float $val = eval("floatFieldGrp -q -v1 " + $field);
	if ($val < 0.0)
		eval("floatFieldGrp -e -v1 0.0 " + $field);
}

/******************************************************************************
	tolerance color callback
******************************************************************************/
global proc nnsExport_ToleranceColorCB(string $field)
{
	int $val = eval("intFieldGrp -q -v1 " + $field);
	if ($val < 0)
		$val = 0;
	else if ($val > 31)
		$val = 31;
	eval("intFieldGrp -e -v1 " + $val + " " + $field);
}

/******************************************************************************
	update all control state
******************************************************************************/
global proc nnsExport_UpdateAllControlState()
{
	nnsExport_MagnifyCB();
	nnsExport_FrameRangeCB();
	nnsExport_FrameStartEndCB();
	nnsExport_ModelCB();
	nnsExport_AnimeCB();

	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolT");
	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolR");
	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolS");

	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolUvT");
	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolUvR");
	nnsExport_ToleranceSRTCB("nnsExport_AnimeTolUvS");

	nnsExport_ToleranceColorCB("nnsExport_AnimeTolC");
}

/******************************************************************************
	main
******************************************************************************/
global proc int NNS_ExportOpts(string $parent,
	string $action,	string $initialSettings, string $resultCallback)
{
	int	$int_val;
	float $float_val;
	int	$ret_val;
	string $cur_opts;
	string $opt_list[];
	string $opt_words[];
	int	$iopt;

	if ($action == "post") {
		//-----------------------------------------------------------------------------
		// create UI
		//-----------------------------------------------------------------------------

		setParent $parent;

		setUITemplate -pushTemplate DefaultTemplate;
		
		columnLayout -adj 1;

		//-----------------------------------------------------------------------------
		// general
		frameLayout -l "General Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
			columnLayout -adj 1 -rs 4;
			floatFieldGrp -l "Magnify" -nf 1 -cw 1 95 -cw 2 60
				-v1 1.0 -pre 4
				-cc "nnsExport_MagnifyCB"
				nnsExport_Magnify;
			optionMenuGrp -l "Compress Node" -cw 1 95
				-rat 1 "both" 4
				nnsExport_OptimizeNode;
				menuItem -l "None";
				menuItem -l "Cull Useless Node";
				menuItem -l "Merge Useless Node";
				menuItem -l "Unite";
				menuItem -l "Unite and Combine Polygon";
			optionMenuGrp -l "Compress Material" -cw 1 95
				-rat 1 "both" 4
				nnsExport_CompressMaterial;
				menuItem -l "None";
				menuItem -l "Compress Same Material";
			rowColumnLayout -nc 4 -cw 1 290 -cw 2 50 -cw 3 5 -cw 4 50;
				radioButtonGrp -l "Start / End Frame" -nrb 3
					-cw4 95 50 80 65
					-rat 2 "both" 0
					-rat 3 "both" 0
					-rat 4 "both" 0
					-la3 "All" "Playback" "Range" -sl 1
					-cc "nnsExport_FrameRangeCB"
					nnsExport_FrameRange;
				intField -v 1
					-cc "nnsExport_FrameStartEndCB"
					nnsExport_StartFrame;
				text -l ""; // dummy
				intField -v 9999
					-cc "nnsExport_FrameStartEndCB"
					nnsExport_EndFrame;
			setParent ..; // rowColumnLayout
			setParent ..; // columnLayout
		setParent ..; // frameLayout

		//-----------------------------------------------------------------------------
		// file select
		frameLayout -l "Output File Selection" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
			columnLayout -adj 1 -rs 4;
			checkBoxGrp -l "Model Data" -ncb 1 -l1 "[.imd]" -v1 1
				-cc1 "nnsExport_ModelCB" nnsExport_ImdFileOut;
			checkBoxGrp -l "Character Animation Data" -ncb 1 -l1 "[.ica]" -v1 0
				-cc "nnsExport_AnimeCB" nnsExport_IcaFileOut;
			checkBoxGrp -l "Visibility Animation Data" -ncb 1 -l1 "[.iva]" -v1 0
				-cc "nnsExport_AnimeCB" nnsExport_IvaFileOut;
			checkBoxGrp -l "Material Color Animation Data" -ncb 1 -l1 "[.ima]" -v1 0
				-cc "nnsExport_AnimeCB" nnsExport_ImaFileOut;
			checkBoxGrp -l "Texture Pattern Animation Data" -ncb 1 -l1 "[.itp]" -v1 0
				-cc "nnsExport_AnimeCB" nnsExport_ItpFileOut;
			checkBoxGrp -l "Texture SRT Animation Data" -ncb 1 -l1 "[.ita]" -v1 0
				-cc "nnsExport_AnimeCB" nnsExport_ItaFileOut;
			//checkBoxGrp -l "Scene Animation Data" -ncb 1 -l1 "[.isa]" -v1 0
			//	-cc "nnsExport_AnimeCB" nnsExport_IsaFileOut;
			setParent ..; // columnLayout
		setParent ..; // frameLayout

		//-----------------------------------------------------------------------------
		// imd
		frameLayout -l "Imd Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
			columnLayout -adj 1 -rs 4;
			rowColumnLayout -nc 2 -cw 1 160 -cw 2 200;
				optionMenuGrp -l "Vertex Style" -cw 1 95 -cw 2 62
					nnsExport_VertexStyle;
					menuItem -l "Direct";
					menuItem -l "Index";
				optionMenuGrp -l "Output Texture" -cw 1 100
					nnsExport_OutAllTex;
					menuItem -l "Only Used";
					menuItem -l "All";
			setParent ..; // rowColumnLayout
			rowColumnLayout -nc 2 -cw 1 160 -cw 2 200;
				checkBoxGrp -l "" -ncb 1 -cw 1 32
					-l1 "Force Full Weight" -v1 0
					nnsExport_ForceFullWeight;
				checkBoxGrp -l "" -ncb 1 -cw 1 23 -cw 2 120
					-l1 "Use Primitive Strip" -v1 1
					nnsExport_UsePrimitiveStrip;
			setParent ..; // rowColumnLayout
			setParent ..; // columnLayout
		setParent ..; // frameLayout

		//-----------------------------------------------------------------------------
		// anime
		frameLayout -l "Animation Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
			columnLayout -adj 1 -rs 4;
			rowColumnLayout -nc 2 -cw 1 160 -cw 2 220;
				optionMenuGrp -l "Interpolation" -cw 1 95
					-cc "nnsExport_AnimeCB"
					nnsExport_AnimeInterp;
					menuItem -l "Frame";
					menuItem -l "Linear";
				optionMenuGrp -e -sl 1 nnsExport_AnimeInterp; // Frame
				checkBoxGrp -l "" -ncb 1 -cw 1 24
					-l1 "Interpolate End Frame to Start Frame" -v1 0
					nnsExport_LoopInterp;
			setParent ..; // rowColumnLayout
			rowColumnLayout -nc 2 -cw 1 160 -cw 2 220;
				optionMenuGrp -l "Frame Step Mode" -cw 1 95
					nnsExport_FrameStepMode;
					menuItem -l "Auto  ";
					menuItem -l "1";
					menuItem -l "2";
					menuItem -l "4";
				optionMenuGrp -e -sl 2 nnsExport_FrameStepMode; // 1
				text -l ""; // dummy
			setParent ..; // rowColumnLayout
			setParent ..; // columnLayout
		setParent ..; // frameLayout

		//-----------------------------------------------------------------------------
		// tolerance
		frameLayout -l "Tolerance Options" -cll 1 -cl 0 -bv 1 -bs "etchedIn";
			columnLayout -adj 1 -rs 4;
			string $form = `formLayout -h 75`;
				// create control in tab order
				floatFieldGrp -nf 1 -l "Node Translate" -cw2 95 45
					-pre 4 -v1 0.1
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolT\""
					nnsExport_AnimeTolT;
				floatFieldGrp -nf 1 -l "Node Rotate" -cw2 95 45
					-pre 4 -v1 0.1
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolR\""
					nnsExport_AnimeTolR;
				floatFieldGrp -nf 1 -l "Node Scale" -cw2 95 45
					-pre 4 -v1 0.1
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolS\""
					nnsExport_AnimeTolS;

				floatFieldGrp -nf 1 -l "Texture Translate" -cw2 90 45
					-pre 4 -v1 0.01
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolUvT\""
					nnsExport_AnimeTolUvT;
				floatFieldGrp -nf 1 -l "Texture Rotate" -cw2 90 45
					-pre 4 -v1 0.1
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolUvR\""
					nnsExport_AnimeTolUvR;
				floatFieldGrp -nf 1 -l "Texture Scale" -cw2 90 45
					-pre 4 -v1 0.1
					-cc "nnsExport_ToleranceSRTCB \"nnsExport_AnimeTolUvS\""
					nnsExport_AnimeTolUvS;

				intFieldGrp -nf 1 -l "Color" -cw2 70 45
					-v1 2
					-cc "nnsExport_ToleranceColorCB \"nnsExport_AnimeTolC\""
					nnsExport_AnimeTolC;
			setParent ..; // formLayout
			// layout control
			formLayout -e -w 440
				-af nnsExport_AnimeTolT "left" 0
				-af nnsExport_AnimeTolT "top" 0
				-an nnsExport_AnimeTolT "right"
				-an nnsExport_AnimeTolT "bottom"
				
				-af nnsExport_AnimeTolR "left" 0
				-af nnsExport_AnimeTolR "top" 25
				-an nnsExport_AnimeTolR "right"
				-an nnsExport_AnimeTolR "bottom"

				-af nnsExport_AnimeTolS "left" 0
				-af nnsExport_AnimeTolS "top" 50
				-an nnsExport_AnimeTolS "right"
				-an nnsExport_AnimeTolS "bottom"

				-af nnsExport_AnimeTolUvT "left" 160
				-af nnsExport_AnimeTolUvT "top" 0
				-an nnsExport_AnimeTolUvT "right"
				-an nnsExport_AnimeTolUvT "bottom"
				
				-af nnsExport_AnimeTolUvR "left" 160
				-af nnsExport_AnimeTolUvR "top" 25
				-an nnsExport_AnimeTolUvR "right"
				-an nnsExport_AnimeTolUvR "bottom"

				-af nnsExport_AnimeTolUvS "left" 160
				-af nnsExport_AnimeTolUvS "top" 50
				-an nnsExport_AnimeTolUvS "right"
				-an nnsExport_AnimeTolUvS "bottom"

				-af nnsExport_AnimeTolC "left" 300
				-af nnsExport_AnimeTolC "top" 0
				-an nnsExport_AnimeTolC "right"
				-an nnsExport_AnimeTolC "bottom"
				$form;
			setParent ..; // columnLayout
		setParent ..; // frameLayout

		//-----------------------------------------------------------------------------
		setParent ..; // columnLayout

		//-----------------------------------------------------------------------------
		// set to current settings
		$cur_opts = $initialSettings;
		if (size($cur_opts) > 0) {
			tokenize($cur_opts, ";", $opt_list);
			for ($iopt = 0; $iopt < size($opt_list); ++$iopt) {
				tokenize($opt_list[$iopt], "=", $opt_words);
				//-----------------------------------------------------------------------------
				// general
				if ($opt_words[0] == "magnify") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_Magnify;
				}
				else if ($opt_words[0] == "optimize_node") {
					$int_val = $opt_words[1];
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_OptimizeNode;
				}
				else if ($opt_words[0] == "compress_material") {
					$int_val = $opt_words[1];
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_CompressMaterial;
				}
				else if ($opt_words[0] == "frame_range") {
					$int_val = $opt_words[1];
					radioButtonGrp -e -sl ($int_val + 1) nnsExport_FrameRange;
				}
				else if ($opt_words[0] == "start_frame") {
					$int_val = $opt_words[1];
					intField -e -v $int_val nnsExport_StartFrame;
				}
				else if ($opt_words[0] == "end_frame") {
					$int_val = $opt_words[1];
					intField -e -v $int_val nnsExport_EndFrame;
				}
				//-----------------------------------------------------------------------------
				// file select
				else if ($opt_words[0] == "imd_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_ImdFileOut;
				}
				else if ($opt_words[0] == "ica_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_IcaFileOut;
				}
				else if ($opt_words[0] == "iva_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_IvaFileOut;
				}
				else if ($opt_words[0] == "ima_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_ImaFileOut;
				}
				else if ($opt_words[0] == "itp_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_ItpFileOut;
				}
				else if ($opt_words[0] == "ita_file_out") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_ItaFileOut;
				}
				//else if ($opt_words[0] == "isa_file_out") {
				//	$int_val = ($opt_words[1] == "1");
				//	checkBoxGrp -e -v1 $int_val nnsExport_IsaFileOut;
				//}
				//-----------------------------------------------------------------------------
				// imd
				else if ($opt_words[0] == "vertex_table_flag") {
					$int_val = ($opt_words[1] == "1");
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_VertexStyle;
				}
				else if ($opt_words[0] == "out_all_tex") {
					$int_val = ($opt_words[1] == "1");
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_OutAllTex;
				}
				else if ($opt_words[0] == "force_full_weight") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_ForceFullWeight;
				}
				else if ($opt_words[0] == "use_primitive_strip") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_UsePrimitiveStrip;
				}
				//-----------------------------------------------------------------------------
				// anime
				else if ($opt_words[0] == "anime_interp") {
					$int_val = $opt_words[1];
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_AnimeInterp;
				}
				else if ($opt_words[0] == "loop_interp") {
					$int_val = ($opt_words[1] == "1");
					checkBoxGrp -e -v1 $int_val nnsExport_LoopInterp;
				}
				else if ($opt_words[0] == "frame_step_mode") {
					$int_val = $opt_words[1];
					optionMenuGrp -e -sl ($int_val + 1) nnsExport_FrameStepMode;
				}
				//-----------------------------------------------------------------------------
				// tolerance
				else if ($opt_words[0] == "anime_tol_t") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolT;
				}
				else if ($opt_words[0] == "anime_tol_r") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolR;
				}
				else if ($opt_words[0] == "anime_tol_s") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolS;
				}
				else if ($opt_words[0] == "anime_tol_c") {
					$int_val = $opt_words[1];
					intFieldGrp -e -v1 $int_val nnsExport_AnimeTolC;
				}
				else if ($opt_words[0] == "anime_tol_uv_t") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolUvT;
				}
				else if ($opt_words[0] == "anime_tol_uv_r") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolUvR;
				}
				else if ($opt_words[0] == "anime_tol_uv_s") {
					$float_val = $opt_words[1];
					floatFieldGrp -e -v1 $float_val nnsExport_AnimeTolUvS;
				}
			}
		}

		//-----------------------------------------------------------------------------
		// test
		//global int $nnsExport_UseIsa;
		//if (!$nnsExport_UseIsa) {
		//	checkBoxGrp -e -vis 0 -v1 0 nnsExport_IsaFileOut;
		//}

		//-----------------------------------------------------------------------------
		// update control state
		nnsExport_UpdateAllControlState();

		$ret_val = 1;

		setUITemplate -popTemplate;
	}
	else if ($action == "query") {
		//-----------------------------------------------------------------------------
		// get option string
		//-----------------------------------------------------------------------------

		//-----------------------------------------------------------------------------
		// general
		$float_val = `floatFieldGrp -q -v1 nnsExport_Magnify`;
		$cur_opts += "magnify=" + $float_val + ";";

		$int_val = `optionMenuGrp -q -sl nnsExport_OptimizeNode` - 1;
		$cur_opts += "optimize_node=" + $int_val + ";";

		$int_val = `optionMenuGrp -q -sl nnsExport_CompressMaterial` - 1;
		$cur_opts += "compress_material=" + $int_val + ";";

		$int_val = `radioButtonGrp -q -sl nnsExport_FrameRange` - 1;
		$cur_opts += "frame_range=" + $int_val + ";";

		$int_val = `intField -q -v nnsExport_StartFrame`;
		$cur_opts += "start_frame=" + $int_val + ";";

		$int_val = `intField -q -v nnsExport_EndFrame`;
		$cur_opts += "end_frame=" + $int_val + ";";

		//-----------------------------------------------------------------------------
		// file select
		$int_val = `checkBoxGrp -q -v1 nnsExport_ImdFileOut`;
		$cur_opts += "imd_file_out=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_IcaFileOut`;
		$cur_opts += "ica_file_out=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_IvaFileOut`;
		$cur_opts += "iva_file_out=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_ImaFileOut`;
		$cur_opts += "ima_file_out=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_ItpFileOut`;
		$cur_opts += "itp_file_out=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_ItaFileOut`;
		$cur_opts += "ita_file_out=" + $int_val + ";";

		//$int_val = `checkBoxGrp -q -v1 nnsExport_IsaFileOut`;
		//$cur_opts += "isa_file_out=" + $int_val + ";";

		//-----------------------------------------------------------------------------
		// imd
		$int_val = `optionMenuGrp -q -sl nnsExport_VertexStyle` - 1;
		$cur_opts += "vertex_table_flag=" + $int_val + ";";

		$int_val = `optionMenuGrp -q -sl nnsExport_OutAllTex` - 1;
		$cur_opts += "out_all_tex=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_ForceFullWeight`;
		$cur_opts += "force_full_weight=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_UsePrimitiveStrip`;
		$cur_opts += "use_primitive_strip=" + $int_val + ";";

		//-----------------------------------------------------------------------------
		// anime
		$int_val = `optionMenuGrp -q -sl nnsExport_AnimeInterp` - 1;
		$cur_opts += "anime_interp=" + $int_val + ";";

		$int_val = `checkBoxGrp -q -v1 nnsExport_LoopInterp`;
		$cur_opts += "loop_interp=" + $int_val + ";";

		$int_val = `optionMenuGrp -q -sl nnsExport_FrameStepMode` - 1;
		$cur_opts += "frame_step_mode=" + $int_val + ";";

		//-----------------------------------------------------------------------------
		// tolerance
		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolT`;
		$cur_opts += "anime_tol_t=" + $float_val + ";";

		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolR`;
		$cur_opts += "anime_tol_r=" + $float_val + ";";

		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolS`;
		$cur_opts += "anime_tol_s=" + $float_val + ";";

		$int_val = `intFieldGrp -q -v1 nnsExport_AnimeTolC`;
		$cur_opts += "anime_tol_c=" + $int_val + ";";

		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolUvT`;
		$cur_opts += "anime_tol_uv_t=" + $float_val + ";";

		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolUvR`;
		$cur_opts += "anime_tol_uv_r=" + $float_val + ";";

		$float_val = `floatFieldGrp -q -v1 nnsExport_AnimeTolUvS`;
		$cur_opts += "anime_tol_uv_s=" + $float_val + ";";

		//-----------------------------------------------------------------------------
		// end
		//print $cur_opts;
		eval($resultCallback + " \"" + $cur_opts + "\"");
		$ret_val = 1;
	}
	else {
		$ret_val = 0;
	}
	
	return $ret_val;
}

/******************************************************************************
	reset options
******************************************************************************/
global proc NNS_ResetExportOpts()
{

//-----------------------------------------------------------------------------
// general
	floatFieldGrp -e -v1 1.0 nnsExport_Magnify;
	optionMenuGrp -e -sl 1 nnsExport_OptimizeNode;
	optionMenuGrp -e -sl 1 nnsExport_CompressMaterial;
	radioButtonGrp -e -sl 1 nnsExport_FrameRange;
	intField -e -v 1 nnsExport_StartFrame;
	intField -e -v 9999 nnsExport_EndFrame;
	
//-----------------------------------------------------------------------------
// file select
	checkBoxGrp -e -v1 1 nnsExport_ImdFileOut;
	checkBoxGrp -e -v1 0 nnsExport_IcaFileOut;
	checkBoxGrp -e -v1 0 nnsExport_IvaFileOut;
	checkBoxGrp -e -v1 0 nnsExport_ImaFileOut;
	checkBoxGrp -e -v1 0 nnsExport_ItpFileOut;
	checkBoxGrp -e -v1 0 nnsExport_ItaFileOut;
	//checkBoxGrp -e -v1 0 nnsExport_IsaFileOut;

//-----------------------------------------------------------------------------
// imd
	optionMenuGrp -e -sl 1 nnsExport_VertexStyle;
	optionMenuGrp -e -sl 1 nnsExport_OutAllTex;
	checkBoxGrp -e -v1 0 nnsExport_ForceFullWeight;
	checkBoxGrp -e -v1 1 nnsExport_UsePrimitiveStrip;

//-----------------------------------------------------------------------------
// anime
	optionMenuGrp -e -sl 1 nnsExport_AnimeInterp;
	checkBoxGrp -e -v1 0 nnsExport_LoopInterp;
	optionMenuGrp -e -sl 2 nnsExport_FrameStepMode;

//-----------------------------------------------------------------------------
// tolerance
	floatFieldGrp -e -v1 0.01 nnsExport_AnimeTolT;
	floatFieldGrp -e -v1 0.1 nnsExport_AnimeTolR;
	floatFieldGrp -e -v1 0.1 nnsExport_AnimeTolS;

	floatFieldGrp -e -v1 0.01 nnsExport_AnimeTolUvT;
	floatFieldGrp -e -v1 0.1 nnsExport_AnimeTolUvR;
	floatFieldGrp -e -v1 0.1 nnsExport_AnimeTolUvS;

	intFieldGrp -e -v1 2 nnsExport_AnimeTolC;

//-----------------------------------------------------------------------------
// update control state
	nnsExport_UpdateAllControlState();
}
