⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogreexporter.mel

📁 使用stl技术,(还没看,是听说的)
💻 MEL
📖 第 1 页 / 共 3 页
字号:
		}
	}
	
	// tell the exporter that we are previewing and to copy the texture files
	$command += " -p \"" + $dir_text + "\"";
	
	textScrollList -edit -da animDefLst;
	
	string $files[] = `getFileList -fld $dir_text -fs "*.jpg"`;
	int $num_files = size($files);
	
	int $i;
	for($i = 0; $i < $num_files; $i++)
	{
		string $file_to_delete = $dir_text + $files[$i];
		sysFile -delete $file_to_delete;
	}
	
	string $files[] = `getFileList -fld $dir_text -fs "*.bmp"`;
	$num_files = size($files);
	
	for($i = 0; $i < $num_files; $i++)
	{
		string $file_to_delete = $dir_text + $files[$i];
		sysFile -delete $file_to_delete;
	}
	
	string $files[] = `getFileList -fld $dir_text -fs "*.gif"`;
	$num_files = size($files);
	
	for($i = 0; $i < $num_files; $i++)
	{
		string $file_to_delete = $dir_text + $files[$i];
		sysFile -delete $file_to_delete;
	}
	
	string $files[] = `getFileList -fld $dir_text -fs "*.png"`;
	$num_files = size($files);
	
	for($i = 0; $i < $num_files; $i++)
	{
		string $file_to_delete = $dir_text + $files[$i];
		sysFile -delete $file_to_delete;
	}
	
	string $files[] = `getFileList -fld $dir_text -fs "*.tga"`;
	$num_files = size($files);
	
	for($i = 0; $i < $num_files; $i++)
	{
		string $file_to_delete = $dir_text + $files[$i];
		sysFile -delete $file_to_delete;
	}
	
	// call and end command	
	evalEcho($command);
	
	// call the material upgrader
	if($mat_bool == 1)
	{
		system("start " + $dir_text + "OgreMaterialUpgrade.exe " + "\"" + $dir_text + $file_text + ".material\"");
	}
	
	// see whether or not to export to binary
	string $binary = `checkBox -query -v meshBinary`;
	
	if($mesh_bool && $binary)
	{
		//$command += " -bin " + $binary;
		// call the xml convertor	
		system("start " + $dir_text + "OgreXMLConverter.exe " + "\"" + $dir_text + $file_text + ".mesh.xml\"");
	}
	
	// see whether or not to export skeletion to binary
	string $skl_binary = `checkBox -query -v animBinary`;
	
	if($anim_exp && $skl_binary)
	{	
		//$command += " -bsk " + $skl_binary;
		system("start " + $dir_text + "OgreXMLConverter.exe " + "\"" + $dir_text + $file_text + ".skeleton.xml\"");
	}
	
	// call the viewer
	system("start " + $dir_text + "OgreViewerClient.exe " + "\"" + $dir_text + $file_text + ".mesh\"");
}

global proc OgreExporter()
{
	if( `window -exists OgreWindow` )
		deleteUI -window OgreWindow;
		
	if( !`window -exists OgreWindow` )
	{
		// the main window
		string $window = `window -title "Ogre Exporter"
			-iconName "Ogre Exporter"
        		-width 450
			-height 500
			-resizeToFitChildren false
			-minimizeButton false
			-maximizeButton false
			-sizeable false 
			OgreWindow`;
		
		// the main layout for window to aloow for scrolling
		string $mainLayout = `scrollLayout -childResizable false -p $window`;
		
		// the main layout ontop of the scroll layout
		string $mainInsideLayout = `formLayout -numberOfDivisions 100 -width 413 -p $mainLayout`;
		
		// the frame layouts
		string $materialFrame = `frameLayout -collapsable true -label "Materials" -collapse true -width 413 -labelVisible true -p $mainInsideLayout`;
		string $animationFrame = `frameLayout -collapsable true -label "Animation" -collapse true -width 413 -labelVisible true -p $mainInsideLayout`;
		string $meshFrame = `frameLayout -collapsable true -label "Mesh" -collapse true -width 413 -labelVisible true -p $mainInsideLayout`;
		string $advancedFrame = `frameLayout -collapsable true -label "Advanced Options" -collapse true -width 413 -labelVisible true -p $mainInsideLayout`;
		string $exportFrame = `frameLayout -collapsable true -label "Export" -collapse true -width 413 -labelVisible true -p $mainInsideLayout`;
		
		// formlayouts on the framelayouts
		string $exportFormLayout = `formLayout -numberOfDivisions 100 -p $exportFrame`;
		string $advancedFormLayout = `formLayout -numberOfDivisions 100 -p $advancedFrame`;
		string $materialFormLayout = `formLayout -numberOfDivisions 100 -p $materialFrame`;
		string $meshFormLayout = `formLayout -numberOfDivisions 100 -p $meshFrame`;
		string $animationFormLayout = `formLayout -numberOfDivisions 100 -p $animationFrame`;
		
		// mesh controls
		string $meshExportToXML = `checkBox -label "Export mesh to Ogre .xml file format" -cc("UpdateGUI()") -p $meshFormLayout meshExportXML`;
		string $meshBoneAssignment = `checkBox -label "Include vertex bone assignments" -en false -p $meshFormLayout meshBoneAssign`;
		string $meshVertexNormals = `checkBox -label "Include vertex normals" -en false -p $meshFormLayout meshNormals`;
		string $meshDiffuseColor = `checkBox -label "Include diffuse vertex colors" -en false -p $meshFormLayout meshDiffuseColor`;
		string $meshTextureCoords = `checkBox -label "Include texture coordinates" -en false -p $meshFormLayout meshTexCoords`;
		string $meshToBinary = `checkBox -label "Also create binary .mesh file" -en false -p $meshFormLayout meshBinary`;
		string $meshSubmeshNames = `checkBox -label "Include Submesh names" -en false -p $meshFormLayout meshSub`;
		
		// material controls
		string $materialExportToMaterial = `checkBox -label "Export materials to Ogre .material file format" -cc("UpdateGUI()") -p $materialFormLayout materialExport`;
		//string $materialMaterialLabel = `text -label "Material Filename:" -en false -p $materialFormLayout materialLbl`;
		//string $materialMaterialText = `textField -width 300 -en false -p $materialFormLayout materialTxt`;
		
		// animation controls
		string $animationExportToXML = `checkBox -label "Export skeleton to Ogre .xml file format" -cc("UpdateGUI()") -p $animationFormLayout animExport`;
		string $animationToBinary = `checkBox -label "Also create binary .skeleton file" -en false -p $animationFormLayout animBinary`;
		string $animationAnimations = `checkBox -label "Include Animations" -en false -cc("UpdateGUI()") -p $animationFormLayout animAnims`;
				
		string $animationDefsLabel = `text -label "Animation Definitions:" -en false -p $animationFormLayout animDefsLbl`;
		string $animationDefsLst = `textScrollList -allowMultiSelection false -numberOfRows 10 -w 400 -en false -sc("PreRemoveAnim()") -p $animationFormLayout animDefLst`;
		
		string $animationAddLabel = `text -label "Add a new animation:" -en false -p $animationFormLayout animAddLbl`;
		string $animationAddAnimName = `text -label "Name" -en false -p $animationFormLayout animNameLbl`;
		string $animationAddAnimNameTxt = `textField -width 175 -en false -p $animationFormLayout animNameTxt`;
		string $animationAddAnimStart = `text -label "Start Time" -en false -p$animationFormLayout animStart`;
		string $animationAddAnimStartTxt = `textField -width 50 -text "0" -en false -p $animationFormLayout animStartTxt`;
		string $animationAddAnimEnd = `text -label "End Time" -en false -p $animationFormLayout animEnd`;
		string $animationAddAnimEndTxt = `textField -width 50 -text "0" -en false -p $animationFormLayout animEndTxt`;
		string $animationAddAnimSkip = `text -label "Step" -en false -p $animationFormLayout animSkip`;
		string $animationAddAnimSkipTxt = `textField -width 25 -text "1" -en false -p $animationFormLayout animSkipTxt`;
		string $aniamtionAddAnimBttn = `button -label "Add" -w 35 -en false -p $animationFormLayout -command("AddAnim()") animBttn`;
		string $aniamtionRemoveAnimBttn = `button -label "Remove" -w 50 -en false -p $animationFormLayout -command("RemoveAnim()") animRBttn`;
		
		
		// advanced controls
		string $advancedRadioCollection = `radioCollection -p $advancedFormLayout`;
		string $advancedMayaUVs = `radioButton -label "Maya UVs:" -select -cl $advancedRadioCollection -p $advancedFormLayout mayaUVs`;
		string $advancedNormUVs = `radioButton -label "Normal UVs:" -cl $advancedRadioCollection -p $advancedFormLayout normUVs`;
		
		// get the path to the script file for relative paths to the .bmps
		string $file_path = `file -q -loc OgreExporter.mel`;
		string $buffer[];
		int $numTokens = `tokenize $file_path "//" $buffer`;
		int $i;
		$file_path = "";
		for($i = 0; $i < $numTokens-2; $i++)
		{
			$file_path += $buffer[$i] + "/";		
		}
		string $norm_uv_bmp = $file_path + "normalUVs.bmp";
		string $maya_uv_bmp = $file_path + "mayaUVs.bmp";
		
		// advanced control continued....
		string $advancedNormImage = `image -image $norm_uv_bmp -w 32 -h 32 -p $advancedFormLayout`;
		string $advancedMayaImage = `image -image $maya_uv_bmp -w 32 -h 32 -p $advancedFormLayout`;
		//string $advancedMatOptLabel = `text -label "Material Prefix:" -p $advancedFormLayout`;
		//string $advancedMatOptTxt = `textField -width 300 -p $advancedFormLayout`;
		//string $advancedTriangulate = `checkBox -label "Triangulate Geometry" -p $advancedFormLayout advTriangulate`;
		//string $advancedOptimize = `checkBox -label "Optimize Geometry" -p $advancedFormLayout advOptimize`;
		
		// export controls
		string $exportOutLabel = `text -label "Output Directory:" -p $exportFormLayout`;
		string $exportOutTxt = `textField -width 380 -p $exportFormLayout exportOutputTxt`;
		string $exportDirLocation = `button -label "...." -p $exportFormLayout -command("GetOutputDir()")`;
		
		string $exportXMLLabel = `text -label "XML Filename for Mesh and Skeleton(without extension):" -en true -p $exportFormLayout exportXMLLbl`;
		string $exportXMLText = `textField -width 300 -en true -p $exportFormLayout exportXMLTxt`;
		
		string $exportOptionLabel = `text -label "Export Options:" -p $exportFormLayout`;
		
		string $exportRadioCollection = `radioCollection -p $advancedFormLayout`;
		string $radioExportEverything = `radioButton -label "Everything" -recomputeSize true -select -cl $exportRadioCollection -p $exportFormLayout exportEverything`;
		string $radioExportSelected = `radioButton -label "Selected" -recomputeSize true -enable false -cl $exportRadioCollection -p $exportFormLayout exportSelected`;
		
		string $exportViewButton = `button -label "Preview" -p $exportFormLayout -command("Preview()")`;
		string $exportButton = `button -label "Export" -p $exportFormLayout -command("Export()")`;
		
		// edit animation form
		formLayout -edit
			-attachPosition $animationExportToXML "left" 5 0
			-attachPosition $animationExportToXML "top" 5 0
			-attachControl $animationToBinary "top" 1 $animationExportToXML
			-attachPosition $animationToBinary "left" 5 0
						
			-attachControl $animationAnimations "top" 2 $animationToBinary
			-attachPosition $animationAnimations "left" 5 0	
			-attachControl $animationDefsLabel "top" 1 $animationAnimations
			-attachPosition $animationDefsLabel "left" 5 0
			-attachControl $animationDefsLst "top" 1 $animationDefsLabel
			-attachPosition $animationDefsLst "left" 5 0
			-attachControl $animationAddLabel "top" 2 $animationDefsLst
			-attachPosition $animationAddLabel "left" 5 0
			
			-attachControl $animationAddAnimName "top" 2 $animationAddLabel
			-attachPosition $animationAddAnimName "left" 5 0
			-attachControl $animationAddAnimNameTxt "top" 1 $animationAddAnimName
			-attachPosition $animationAddAnimNameTxt "left" 5 0
			-attachControl $animationAddAnimStart "top" 1 $animationAddLabel
			-attachControl $animationAddAnimStart "left" 150 $animationAddAnimName
			-attachControl $animationAddAnimStartTxt "top" 1 $animationAddAnimName
			-attachControl $animationAddAnimStartTxt "left" 5 $animationAddAnimNameTxt
			-attachControl $animationAddAnimEnd "top" 1 $animationAddLabel
			-attachControl $animationAddAnimEnd "left" 5 $animationAddAnimStart
			-attachControl $animationAddAnimEndTxt "top" 1 $animationAddAnimEnd
			-attachControl $animationAddAnimEndTxt "left" 5 $animationAddAnimStartTxt
			-attachControl $animationAddAnimSkip "top" 1 $animationAddLabel
			-attachControl $animationAddAnimSkip "left" 8 $animationAddAnimEnd
			-attachControl $animationAddAnimSkipTxt "top" 1 $animationAddAnimSkip
			-attachControl $animationAddAnimSkipTxt "left" 5 $animationAddAnimEndTxt
			-attachControl $aniamtionAddAnimBttn "top" 1 $animationAddAnimName
			-attachControl $aniamtionAddAnimBttn "left" 1 $animationAddAnimSkipTxt
			-attachControl $aniamtionRemoveAnimBttn "left" 1 $aniamtionAddAnimBttn
			-attachControl $aniamtionRemoveAnimBttn "top" 1 $animationAddAnimName
		$animationFormLayout;
		
		// edit form layout or frames
		formLayout -edit
			-attachPosition $meshFrame "top" 5 0
			-attachPosition $meshFrame "left" 5 0
			-attachPosition $meshFrame "right" 5 100
			-attachControl $materialFrame "top" 1 $meshFrame
			-attachPosition $materialFrame "left" 5 0
			-attachPosition $materialFrame "right" 5 100
			-attachControl $animationFrame "top" 1 $materialFrame
			-attachPosition $animationFrame "left" 5 0
			-attachPosition $animationFrame "right" 5 100
			-attachControl $advancedFrame "top" 1 $animationFrame
			-attachPosition $advancedFrame "left" 5 0
			-attachPosition $advancedFrame "right" 5 100
			-attachControl $exportFrame "top" 1 $advancedFrame
			-attachPosition $exportFrame "left" 5 0
			-attachPosition $exportFrame "right" 5 100
		$mainInsideLayout;
		
		// edit mesh form
		formLayout -edit
			-attachPosition $meshExportToXML "top" 5 0
			-attachPosition $meshExportToXML "left" 5 0
			-attachControl $meshBoneAssignment "top" 1 $meshExportToXML
			-attachPosition $meshBoneAssignment "left" 5 0
			-attachControl $meshVertexNormals "top" 1 $meshBoneAssignment
			-attachPosition $meshVertexNormals "left" 5 0
			-attachControl $meshDiffuseColor "top" 1 $meshVertexNormals
			-attachPosition $meshDiffuseColor "left" 5 0
			-attachControl $meshTextureCoords "top" 1 $meshDiffuseColor
			-attachPosition $meshTextureCoords "left" 5 0
			-attachControl $meshSubmeshNames "top" 1 $meshTextureCoords
			-attachPosition $meshSubmeshNames "left" 5 0
			-attachControl $meshToBinary "top" 1 $meshSubmeshNames
			-attachPosition $meshToBinary "left" 5 0
		$meshFormLayout;
		
		// edit material form
		formLayout -edit
			-attachPosition $materialExportToMaterial "top" 5 0
			-attachPosition $materialExportToMaterial "left" 5 0
		$materialFormLayout;
		
		
		
		// edit advanced form
		formLayout -edit
			-attachPosition $advancedMayaUVs "top" 5 0
			-attachPosition $advancedMayaUVs "left" 5 0
			-attachControl $advancedNormUVs "left" 15 $advancedMayaUVs
			-attachPosition $advancedNormUVs "top" 5 0
			-attachControl $advancedMayaImage "top" 1 $advancedMayaUVs
			-attachPosition $advancedMayaImage "left" 25 0
			-attachControl $advancedNormImage "left" 60 $advancedMayaImage
			-attachControl $advancedNormImage "top" 1 $advancedNormUVs
		$advancedFormLayout;
		
		// edit export form
		formLayout -edit
			-attachPosition $exportOutLabel "top" 5 0
			-attachPosition $exportOutLabel "left" 5 0
			-attachControl $exportOutTxt "top" 1 $exportOutLabel
			-attachPosition $exportOutTxt "left" 5 0
			-attachControl $exportDirLocation "left" 1 $exportOutTxt
			-attachControl $exportDirLocation "top" 1 $exportOutLabel
			
			-attachControl $exportXMLLabel "top" 1 $exportDirLocation
			-attachPosition $exportXMLLabel "left" 5 0
			-attachControl $exportXMLText "top" 1 $exportXMLLabel
			-attachPosition $exportXMLText "left" 5 0
			
			-attachControl $exportOptionLabel "top" 5 $exportXMLText
			-attachPosition $exportOptionLabel "left" 5 0
			-attachControl $radioExportEverything "top" 1 $exportOptionLabel
			-attachPosition $radioExportEverything "left" 5 0
			-attachControl $radioExportSelected "left" 1 $radioExportEverything
			-attachControl $radioExportSelected "top" 1 $exportOptionLabel
			-attachControl $exportViewButton "top" 5 $radioExportEverything
			-attachPosition $exportViewButton "left" 5 0
			-attachPosition $exportViewButton "right" 5 100
			-attachControl $exportButton "top" 5 $exportViewButton
			-attachPosition $exportButton "left" 5 0
			-attachPosition $exportButton "right" 5 100
		$exportFormLayout;
		
		// set parent for main window
    		setParent ..;
    		
    		// script job for deleting window from windowPref
    		scriptJob -uiDeleted $window ("windowPref -remove " + $window);
    		    	
    		showWindow $window;
    		ReadSettings();    		
    	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -