批量渲染烘焙贴图工具

Global thePath 

Global thePath01 



fn BakeDiffuseAndLighting obj size tempPath tempChannel=

(

    obj.iNodeBakeProperties.removeAllBakeElements() 

    be2 = LightingMap() 

    be2.outputSzX = be2.outputSzY = size

    if thePath01 != undefined do(be2.fileType = ( tempPath + "\\" + obj.name + "_L.tga" ))--定义path为按下button-- lightmap path的路径

    be2.fileName = filenameFromPath be2.fileType

    be2.filterOn = true 

    be2.shadowsOn =true

    be2.enabled = true



    obj.INodeBakeProperties.addBakeElement be2 

    obj.INodeBakeProperties.bakeEnabled = true 

    obj.INodeBakeProperties.bakeChannel = tempChannel

    obj.INodeBakeProperties.nDilations = 1 

    select obj 



    render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[size,size]

)





rollout wht "批量烘焙工具 V 1.00" width:150 height:112

(

    button savePath ".." pos:[379,27] width:17 height:23

    editText edt1 "" pos:[131,28] width:246 height:18 readonly:true

    label lbl1 "烘焙贴图保存路径:" pos:[16,30] width:115 height:22

    button getMaxDir ".." pos:[379,56] width:17 height:23

    editText edt2 "" pos:[131,59] width:246 height:18 readonly:true

    label lbl2 "uv通道:" pos:[74,121] width:54 height:22

    editText edt3 "" pos:[132,90] width:59 height:18 text:"256"

    label lbl3 "指定MAX文件目录:" pos:[18,61] width:110 height:22

    button bakeNow "批量处理" pos:[197,89] width:198 height:50

    groupBox grp1 "批量烘焙" pos:[7,8] width:401 height:139

    label lbl4 "烘焙贴图大小:" pos:[39,94] width:86 height:22

    spinner spn1 "" pos:[136,120] width:56 height:16 type:#integer range:[1,5,1]

    

    on savePath pressed  do 

    (

        thePath01 = getSavePath()

        if thePath01 != undefined do edt1.text = thePath01

    )

    on getMaxDir pressed  do 

    (

        thePath = getSavePath()

        if thePath != undefined do edt2.text = thePath

    )        

     

    on bakeNow pressed  do 

    (

        if edt2.text != "" and edt3.text != "" do 

        (

            theFiles = getFiles (edt2.text+"\\*.max")

            

            for f in theFiles do

            (

                loadMaxFile f quiet:false

                for w in geometry do try((BakeDiffuseAndLighting w (edt3.text as number) edt1.text spn1.value))catch(print (w.name+"烘焙出错")) 

            )

            --resetMaxFile #noPrompt 

        )

    )

)

createDialog wht 417 161 style:#(#style_titlebar,#style_sysmenu,#style_minimizebox);



 



 





 

 

你可能感兴趣的:(工具)