Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This MEL script imports a bunch of FBXes, rotates and scales them to conform to Y-up coordsys, then resaves them out as FBX
- string $directory = "/Users/mbp/Desktop/GameDev/UnityProjects/AFTA/Assets/Models/Game/";
- string $outdirectory = "/Users/mbp/Desktop/GameDev/UnityProjects/AFTA/Assets/Models/Temp/";
- //Find all files ending in .fbx
- $fbxfiles = `getFileList -folder $directory -filespec "*.fbx"`;
- for($f=0; $f<size($fbxfiles); $f++){
- //before we begin, create a new empty scene in which to work (clear the previous cruft)
- file -rename "temp.mb";
- file -f -save;
- file -new;
- //get path to FBX
- string $wholename = ($directory + $fbxfiles[$f]);
- print ("Importing: " + $wholename + "\n");
- //import FBX
- file -import $wholename;
- //get a list of all meshes
- $meshes = `ls -type "mesh"`;
- $parent = "mayaGroup";
- //if we have more than one mesh
- if(size($meshes) > 1){
- //group the meshes under a node at 0,0,0
- print("Parenting required!" + "\n");
- group -n $parent $meshes;
- xform -os -piv 0 0 0;
- } else {
- //select the one and only mesh to work with
- $parent = $meshes[0];
- }
- //select the new parent in preparation of the transformations
- select -r $parent;
- //Rotate -90 on the x
- rotate -r -90deg 0 0;
- //Scale -1 on x and y
- scale -1 -1 1;
- //freeze transformation
- makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
- //export FBX to outPath
- $outPath = ($outdirectory + $fbxfiles[$f]);
- print ("Exporting to: " + $outPath + "\n");
- FBXExport -f $outPath;
- }
- //NOTES
- //print("Rotation X: " + `getAttr Group000.rotateX` + "\n");
- //print("Scale X: " + `getAttr Group000.scaleX` + "\n");
- //=======================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement