Created
September 14, 2015 06:13
-
-
Save whatnick/efbf102afd13d16bd9bf to your computer and use it in GitHub Desktop.
MAXScript to load LoD's for use in Unreal Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pluginManager.loadClass FbxImporter | |
findDir = getDir #import + @"\" | |
rootDir = getSavePath initialDir:findDir | |
tileDirs = GetDirectories (rootDir+"\\Tile*") | |
for theDir in tileDirs do | |
( | |
print theDir | |
--theDirStrg = theDir + "\\*.fbx" | |
--theFiles = getFiles theDirStrg | |
theDirStrg15= theDir + "\\*L17.fbx" | |
theFiles = getFiles theDirStrg15 | |
theDirStrg17 = theDir + "\\*L18.fbx" | |
join theFiles (getFiles theDirStrg17) | |
theDirStrg19 = theDir + "\\*L19.fbx" | |
join theFiles (getFiles theDirStrg19) | |
theDirStrg21 = theDir + "\\*L20.fbx" | |
join theFiles (getFiles theDirStrg21) | |
theObjects = #() | |
exportlist = #() | |
for i in theFiles do | |
( | |
thePathStrg = i | |
theName = getFilenameFile thePathStrg | |
importfile (i) #noprompt | |
--add FBX switches here example: FbxImporterSetParam "Lights" false | |
FBXImporterSetParam "Mode" #create | |
append theObjects theName | |
$selection[1].name = theName | |
--LayerManager.newLayerFromName theName | |
--newFBXlayer = layermanager.getLayerFromName theName | |
--for c = 1 to theObjects.count do | |
--( | |
--newFBXlayer.addnode theNodes[c] | |
--theNodes[c].isHidden = false | |
--) | |
) | |
exportlist = for b in theObjects where isValidNode (obj = getNodeByName b) collect obj | |
--Select all meshes from above. | |
select exportlist | |
--group now. | |
thegroup = group exportlist name: ("Lod_Group") | |
select thegroup | |
--Now Level Of Detail, and add set. | |
max utility mode | |
UtilityPanel.OpenUtility Level_of_Detail | |
panel = (windows.getChildHWND #max "Utilities") | |
CreateNewSetButton = (windows.getChildHWND (UIAccessor.GetParentWindow panel[3]) "Create New Set") | |
UIAccessor.PressButton CreateNewSetButton[1] | |
--Also select the UCX_ object, for collision, if it exists. | |
obj = getnodebyname ("UCX_" + exportlist[1].name) | |
if obj != undefined then selectMore obj | |
--Export only selected to FBX. | |
dirname = (filterString (filenameFromPath theDir) "\\") [1] | |
FBXSavePath = (rootDir+"\\"+dirname+"_Lod.fbx") | |
print FBXSavePath | |
FbxExporterSetParam "Animation" True | |
FbxExporterSetParam "EmbedTextures" True | |
FbxExporterSetParam "SmoothingGroups" True | |
exportFile FBXSavePath #noPrompt selectedOnly:true using:FBXEXP | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment