Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. //This MEL script imports a bunch of FBXes, rotates and scales them to conform to Y-up coordsys, then resaves them out as FBX
  2. string $directory = "/Users/mbp/Desktop/GameDev/UnityProjects/AFTA/Assets/Models/Game/";
  3. string $outdirectory = "/Users/mbp/Desktop/GameDev/UnityProjects/AFTA/Assets/Models/Temp/";
  4.  
  5. //Find all files ending in .fbx
  6. $fbxfiles = `getFileList -folder $directory -filespec "*.fbx"`;
  7.  
  8. for($f=0; $f<size($fbxfiles); $f++){
  9. //before we begin, create a new empty scene in which to work (clear the previous cruft)
  10. file -rename "temp.mb";
  11. file -f -save;
  12. file -new;
  13.  
  14. //get path to FBX
  15. string $wholename = ($directory + $fbxfiles[$f]);
  16. print ("Importing: " + $wholename + "\n");
  17.  
  18. //import FBX
  19. file -import $wholename;
  20.  
  21. //get a list of all meshes
  22. $meshes = `ls -type "mesh"`;
  23. $parent = "mayaGroup";
  24.  
  25. //if we have more than one mesh
  26. if(size($meshes) > 1){
  27. //group the meshes under a node at 0,0,0
  28. print("Parenting required!" + "\n");
  29. group -n $parent $meshes;
  30. xform -os -piv 0 0 0;
  31. } else {
  32. //select the one and only mesh to work with
  33. $parent = $meshes[0];
  34. }
  35.  
  36. //select the new parent in preparation of the transformations
  37. select -r $parent;
  38.  
  39. //Rotate -90 on the x
  40. rotate -r -90deg 0 0;
  41.  
  42. //Scale -1 on x and y
  43. scale -1 -1 1;
  44.  
  45. //freeze transformation
  46. makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
  47.  
  48. //export FBX to outPath
  49. $outPath = ($outdirectory + $fbxfiles[$f]);
  50. print ("Exporting to: " + $outPath + "\n");
  51. FBXExport -f $outPath;
  52. }
  53.  
  54. //NOTES
  55. //print("Rotation X: " + `getAttr Group000.rotateX` + "\n");
  56. //print("Scale X: " + `getAttr Group000.scaleX` + "\n");
  57. //=======================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement