Двойным щелчком можно менять исходные параметры.
Сам код:
---------------------------------------------------------------------------
-- tested in 3DMax 2014
try destroyDialog editBlur catch()
global editBlur
global theListData = #()
--function
fn theAllMat =
(
local allMat = #()
join allMat (getclassinstances CoronaMtl)
join allMat (getclassinstances VRayMtl)
join allMat (getclassinstances Standardmaterial)
return allMat
)
fn matFromObj =
(
local allMat = #()
for i in selection where i.material != undefined do
(
for m in (getclassinstances CoronaMtl target:i) do appendIfUnique allMat m
for m in (getclassinstances VRayMtl target:i) do appendIfUnique allMat m
for m in (getclassinstances Standardmaterial target:i) do appendIfUnique allMat m
)
return allMat
)
fn EditBlurMaps mm slotName typeMAP theBlur typeFiltering =
(
if mm != undefined do
(
numSTM = getNumSubTexmaps mm
if numSTM != 0 do
(
for i = 1 to numSTM do
(
theSlotName = getSubTexmapSlotName mm i
if findString theSlotName slotName == 1 do theMAP = getSubTexmap mm i
if theMAP != undefined do
(
for bt in getclassinstances (execute typeMAP) target:theMAP do
(
bt.coords.blur = theBlur
try(bt.filtering = typeFiltering)catch()
)
--EditBlurMaps theMAP slotName typeMAP theBlur typeFiltering
)
)
)
)
)
rollout editBlur "EditBlurMat"
(
--Interface
dropDownList ddl1 "" items:#("Diffuse", "Reflection", "Refraction", \
"Bump", "Displacement", "Opacity") selection:1 across:2
dropDownList ddl2 "" items:#("BitmapTexture", "Cellular", "Checker", \
"Dent", "Noise", "Bricks") selection:1
dropDownList ddl3 "" items:#("Pyramidal", "Summed Area", "None") selection:1 align:#left across:2
spinner theBlurVal "Blur:" range:[0,40, 0.2] type:#float
button addToList "Add to list" width:90 across:3
button DellFromList "Delete from list" width:90
button Clear_All "Clear All" width:90
listbox ListMap "" height:10
button theGo "Execute" width:125 across:2
checkbox selObj "Selection objects" checked:true align:#right
-------------------
on editBlur open do
(
theListData = #(#("Diffuse", "BitmapTexture", 0.2, 2), #("Reflection", "BitmapTexture", 0.2, 2), \
#("Refraction", "BitmapTexture", 0.2, 2), #("Bump", "BitmapTexture", 0.8, 0), \
#("Displacement", "BitmapTexture", 0.2, 2), #("Opacity", "BitmapTexture", 0.2, 2))
for i in theListData do
(
local tF = case i[4] of (0:"Pyramidal"; 1:"Summed Area"; 2:"None")
ListMap.items = append ListMap.items (i[1] + " " + i[2] + " Blur:"+(i[3] as string) + " Filtering:" + tF)
)
)
on addToList pressed do
(
ListMap.items = append ListMap.items (ddl1.selected + " " + ddl2.selected + " Blur:"+(theBlurVal.value as string) + " Filtering:" + ddl3.selected)
local tF = case ddl3.selected of ("Pyramidal":0; "Summed Area":1; "None":2)
append theListData #(ddl1.selected, ddl2.selected, theBlurVal.value, tF)
)
on DellFromList pressed do
(
if ListMap.selection != 0 do
(
deleteItem theListData ListMap.selection
ListMap.items = #()
for i in theListData do
(
if theListData.count != 0 do local tF = case i[4] of (0:"Pyramidal"; 1:"Summed Area"; 2:"None")
ListMap.items = append ListMap.items (i[1] + " " + i[2] + " Blur:"+(i[3] as string) + " Filtering:" + tF)
)
)
)
on Clear_All pressed do
(
ListMap.items = #()
theListData = #()
)
on theGo pressed do
(
am = if selObj.state then matFromObj() else theAllMat()
numAM = am.count
progressstart "Editing materilas..."
for m = 1 to numAM do
(
for i in theListData do EditBlurMaps am[m] i[1] i[2] i[3] i[4]
progressupdate (m*100.0/numAM)
)
progressend ()
)
)
createDialog editBlur width:300
-- Created Alex Yakushev
---------------------------------------------------------------------------
Сам код:
---------------------------------------------------------------------------
-- tested in 3DMax 2014
try destroyDialog editBlur catch()
global editBlur
global theListData = #()
--function
fn theAllMat =
(
local allMat = #()
join allMat (getclassinstances CoronaMtl)
join allMat (getclassinstances VRayMtl)
join allMat (getclassinstances Standardmaterial)
return allMat
)
fn matFromObj =
(
local allMat = #()
for i in selection where i.material != undefined do
(
for m in (getclassinstances CoronaMtl target:i) do appendIfUnique allMat m
for m in (getclassinstances VRayMtl target:i) do appendIfUnique allMat m
for m in (getclassinstances Standardmaterial target:i) do appendIfUnique allMat m
)
return allMat
)
fn EditBlurMaps mm slotName typeMAP theBlur typeFiltering =
(
if mm != undefined do
(
numSTM = getNumSubTexmaps mm
if numSTM != 0 do
(
for i = 1 to numSTM do
(
theSlotName = getSubTexmapSlotName mm i
if findString theSlotName slotName == 1 do theMAP = getSubTexmap mm i
if theMAP != undefined do
(
for bt in getclassinstances (execute typeMAP) target:theMAP do
(
bt.coords.blur = theBlur
try(bt.filtering = typeFiltering)catch()
)
--EditBlurMaps theMAP slotName typeMAP theBlur typeFiltering
)
)
)
)
)
rollout editBlur "EditBlurMat"
(
--Interface
dropDownList ddl1 "" items:#("Diffuse", "Reflection", "Refraction", \
"Bump", "Displacement", "Opacity") selection:1 across:2
dropDownList ddl2 "" items:#("BitmapTexture", "Cellular", "Checker", \
"Dent", "Noise", "Bricks") selection:1
dropDownList ddl3 "" items:#("Pyramidal", "Summed Area", "None") selection:1 align:#left across:2
spinner theBlurVal "Blur:" range:[0,40, 0.2] type:#float
button addToList "Add to list" width:90 across:3
button DellFromList "Delete from list" width:90
button Clear_All "Clear All" width:90
listbox ListMap "" height:10
button theGo "Execute" width:125 across:2
checkbox selObj "Selection objects" checked:true align:#right
-------------------
on editBlur open do
(
theListData = #(#("Diffuse", "BitmapTexture", 0.2, 2), #("Reflection", "BitmapTexture", 0.2, 2), \
#("Refraction", "BitmapTexture", 0.2, 2), #("Bump", "BitmapTexture", 0.8, 0), \
#("Displacement", "BitmapTexture", 0.2, 2), #("Opacity", "BitmapTexture", 0.2, 2))
for i in theListData do
(
local tF = case i[4] of (0:"Pyramidal"; 1:"Summed Area"; 2:"None")
ListMap.items = append ListMap.items (i[1] + " " + i[2] + " Blur:"+(i[3] as string) + " Filtering:" + tF)
)
)
on addToList pressed do
(
ListMap.items = append ListMap.items (ddl1.selected + " " + ddl2.selected + " Blur:"+(theBlurVal.value as string) + " Filtering:" + ddl3.selected)
local tF = case ddl3.selected of ("Pyramidal":0; "Summed Area":1; "None":2)
append theListData #(ddl1.selected, ddl2.selected, theBlurVal.value, tF)
)
on DellFromList pressed do
(
if ListMap.selection != 0 do
(
deleteItem theListData ListMap.selection
ListMap.items = #()
for i in theListData do
(
if theListData.count != 0 do local tF = case i[4] of (0:"Pyramidal"; 1:"Summed Area"; 2:"None")
ListMap.items = append ListMap.items (i[1] + " " + i[2] + " Blur:"+(i[3] as string) + " Filtering:" + tF)
)
)
)
on Clear_All pressed do
(
ListMap.items = #()
theListData = #()
)
on theGo pressed do
(
am = if selObj.state then matFromObj() else theAllMat()
numAM = am.count
progressstart "Editing materilas..."
for m = 1 to numAM do
(
for i in theListData do EditBlurMaps am[m] i[1] i[2] i[3] i[4]
progressupdate (m*100.0/numAM)
)
progressend ()
)
)
createDialog editBlur width:300
-- Created Alex Yakushev
---------------------------------------------------------------------------
Комментариев нет:
Отправить комментарий