zoukankan      html  css  js  c++  java
  • 《generate smooth group in 3ds max》

    (

    local ResetMax
    local GetAllFilesWithPatternInDirectoryRecursively
    local DoedFolderExist
    local DoImportFile
    local DoExportFile
    local DoAutoSmooth
     
    fn StartExecute =
    (
    --Fields
    local rootFolderPath = "D:Source"
    local exportRootFolderPath = "D:Dest"
    local autosmoothThreshold = 50.0
    local exportASCII = true
    --Editable_Poly for some reason gives bad results. false for now
    local useEditablePoly = false
    ResetMax()
     
    openLog(exportRootFolderPath+""+logFileName) mode:"w" outputonly:true
     
    print("Start: "+(timestamp() as string))
    print("SutismoothThreshold: "+ (autosmoothThreshold as string))
     
    local filesInFolder = GetAllFilesWithPatternInDirectoryRecursively rootFolderPath "*.fbx"
     
    print("Files to Process: " + (filesInFolder.count as string))
     
    for filePath in filesInFolder do
    (
    --if filenameFromPath filePath != "__xxx.fbx" then
    --continue
    print "New Object"
    print filePath
     
    DoImportFile(filePath)
     
    DoAutoSmooth autosmoothThreshold useEditablePoly
     
    local exportPath = replace filePath 1 rootFolderPath.count exportRootFolderPath
     
    print exportPath
     
    DoesFolderExist(getFilenamePath exportPath) create:true
     
    DoExportFile exportPath exportASCII
     
    ResetMax()
     
    --Exit()
    )
    )
     
    --Returns an array
    fn GetAllFilesWithPatternInDircetoryRecursively dir pattern =
    (
    local dirArr = GetDirectories(dir+"\*")
    for d in dirArr do
    (
    join dirArr (getDirectories(d+"\*"))
    )
     
    append dirArr (dir+"") -- Need to include the original top level directory
     
    local patternMatchedFile = #()
     
    for f in dirArr do
    (
    join patternMatchedFiles (getFiles(f+pattern))
    )
    return patternMatchedFiles
    )
     
    --Test whether folderPath exists and is a folder; create it if it doesn't and create==true
    fn DoesFolderExist folderPath create:true = 
    (
    local val = if(doesFileExist folderPath) and (getfileattribute folderPath #directory) then true else false
     
    if not val and create then
    (
    val = makeDir folderPath
    )
     
    return val
    )
     
    fn DoImportFile fileName =
    (
    FBXImporterSetParam "ResetImport"
    FBXImporterSetParam "SmoothingGroups" true
    importFile fileName #noPrompt using:FXBIMP
    )
     
    fn DoExportFile fileName exportASCII =
    (
    FBXExporterSetParam "ResetExport"
    FBXExporterSetParam "SmoothingGroups" true
    FBXExporterSetParam "Animation" false
    FBXExporterSetParam "Cameras" false
     
    --Set to true if you want a Human-Readable file.
    if exportAscii then
    (
    FBXExporterSetParam "ASCII" true
    )
     
    if units.SystemType == #Inches then
    (
    print "Converting Units to CM"
     
    --This is completely broken.
    --FBXExporterSetParam "COnvertUnit" "cm"
     
    --Shitty replacement solution
    selectedObject = selection[1]
    print selectedObject.scale
    selectedObject.scale=[1,1,1]
    print selectedObject.scale
    )
    print "Exp Smooth?"
    print ((FBXExporterGetParam "SmoothingGroups") as string)
    exportFile (fileName) #noPrompt selectedOnly:false using:FBXEXP
    )
     
    fn ResetMax=
    (
    --Reset max file silently
    resetMaxFile #noPrompt
    )
     
    fn ExitMan=
    (
    --Exit max
    quitMax #noPrompt
    )
     
    fn DoAutoSmooth autosmoothThreshold useEditablePoly=
    (
    if selection.count == 1 then
    (
    print selection[1]
    selectedObject = selection[1]
    if useEditablePoly then
    (
    convertTo selectedObject Editable_Poly
    )
    select selectedObject
    if useEditablePoly then
    (
    print "converting to Editable Poly"
    polyOp.setFaceSelection selectedObject #{1..polyOp.getNumFaces selectedObject}
     
    --Clear existing smoothing groups
    selectObject.EditablePoly.setSmoothingGroups 0
     
    selectedObject.autosmoothThreshold = autosmoothThreshold
     
    print "[erforming AutoSmooth on Editable Poly"
    selectedObject.EditablePoly.autosmooth()
    )
    else
    (
    print "Performing AutoSmooth on Editable Mesh"
    meshop.autoSmooth selectedObject #{1..selectedObject.numfaces} autosmoothThreshold
    )
    )
    else
    (
    print "Error:Multiple Objects Selected."
    )
    )
     
    --Start at the end?
    StartExecute()
     
    ExitMax()
    )
  • 相关阅读:
    cron表达式详解(转载)
    Swagger 3.0使用教程(转载)
    springboot整合shiro-对密码进行MD5并加盐处理(十五)(转载)
    redis排序
    引用和指针的区别?
    测试策略
    主键、外键的作用,索引的优点与不足?
    您所熟悉的软件测试类型都有哪些?请试着分别比较这些不同的测试类型的区别与联系(如功能测试、性能测试……)
    UI测试测什么
    数据库,数据库管理系统,数据库系统三者的区别和练习?
  • 原文地址:https://www.cnblogs.com/DeanWang/p/7148570.html
Copyright © 2011-2022 走看看