2015-09-09 194 views
0

嘿傢伙我有這個簡單的腳本,正在測試。目前它基本上可以讓你選擇一個位圖,然後將路徑添加到edittext。分配着色器按鈕創建了一個材質並分配它。我正在尋找的是使用用戶路徑來定義一個位圖紋理添加到diffuse插槽。有點卡在那裏。感謝在先進的幫助。這裏是腳本到目前爲止Maxscript文件路徑讀取?

嘗試(DestroyDialog瀏覽)趕上()

首次展示瀏覽 「瀏覽」 寬度:550高度:150

button btn_browse "browse" pos:[430,20] 
button btn_assin "Assign Shader " 
edittext edt_image "ImageFile:" fieldWidth: 350 pos:[5,22] 

on btn_browse pressed do 
(
    imgDir = getOpenFilename caption: "Open File" types: "Jpg (*.jpg)|*.jpg|Exr (*.exr)|*.exr|Tif (*.tif)|*.tif|ALL|*.*|" 
    edt_image.text = imgDir 

) 

on btn_assin pressed do 
     ( 
      if edt_image != undefined do 
      ( 
       for i in selection do 
        (
        i.material = meditmaterials[1].diffuseMap = Bitmaptexture filename: ???????????????????? 
        ) 
      ) 
     ) 

createdialog瀏覽

回答

2
try(DestroyDialog Browse) catch() 
rollout Browse "Browse" width:550 
(
    editText edt_image "Image File:" fieldWidth:400 across:2 
    button btn_browse "Browse" align:#right 
    button btn_assign "Assign Shader" 

    on btn_browse pressed do 
    (
     local imgPath = getOpenFilename caption: "Open File" types: "Jpg (*.jpg)|*.jpg|Exr (*.exr)|*.exr|Tif (*.tif)|*.tif|ALL|*.*|" 
     if imgPath != undefined do edt_image.text = imgPath 
    ) 

    on btn_assign pressed do if isProperty meditMaterials[1] #diffuseMap AND doesFileExist edt_image.text do 
    ( 
     meditMaterials[1].diffuseMap = BitmapTexture filename:edt_image.text 
     selection.material = meditMaterials[1] 
    ) 
) 
createDialog Browse