神,那个MAX批量修改贴图后缀名的脚本能给我不?
发布网友
发布时间:2022-05-31 12:45
我来回答
共1个回答
热心网友
时间:2023-10-15 08:32
好久之前的了,当时为了项目写的,不是完善的,发不出脚本,下面是直接代码,格式的话自己看看改改
rollout Spriter "ChangeExtName v0.1" width:218 height:300
(
GroupBox grp1 "From" pos:[9,3] width:200 height:50
-- dropdownlist dd1 \
--items:#(".tga",".png",".jpg") pos:[15,25] height:6
DropdownList dd \
items:#(".tga",".png",".jpg") pos:[15,75] height:6
CheckBox fromTga ".tga" pos:[27,25] width:57 height:19 checked:false triState:0 tooltip: ".tga" enabled:false
CheckBox fromPng ".png" pos:[84,25] width:57 height:19 checked:false triState:0 tooltip: ".png"
CheckBox fromJpg ".jpg" pos:[141,25] width:57 height:19 checked:false triState:0 tooltip: ".jpg"
GroupBox grp3 "To" pos:[9,53] width:200 height:50
GroupBox grp12 "Change Channel (if have)" pos:[10,120] width:200 height:80
checkbox isDiffuse "Diffuse" pos:[27,145] width:57 height:19 checked:true triState:1
checkbox isOpacity "Opacity" pos:[131,145] width:62 height:19
checkbox isColor "Color" pos:[27,170] width:57 height:19 enabled:false
button apply "Apply" pos:[36,260] width:63 height:24
button cancel "Cancel" pos:[119,260] width:63 height:24
button help "?" pos:[198,280] width:16 height:16 toolTip:"help"
on apply pressed do
(
if (queryBox "是否开始执行?") then
(
if selection.count == 0 then
(
messagebox "请先选择物体..."
)
else
(
if fromTga.checked == false and fromPng.checked == false and fromJpg.checked == false then
(
messagebox "请选择源格式..."
)
else
(
if isDiffuse.checked == false and isOpacity.checked == false and isColor.checked == false then
(
messagebox "请选择要转换的贴图类型..."
)
else--选择了物体 选择了源格式 选择了贴图类型
(
obj=#()
for i in selection do
--for i=1 to scenematerials.count do
(
print i.name
if i.material == undefined then --如果当前物体没有材质
(
print "no material"
continue
)
else
(
cmat = i.material --scenematerials[i]
)
if cmat.diffuseMap == undefined then --如果当前材质没有漫反射贴图
(
print "no diff"
--continue
)
else --if cmat.diffuseMap!=undefined and cmat.diffuseMap.filename!=undefined do
(
if cmat.diffuseMap.filename == undefined then --如果当前漫反射贴图没有有贴图文件
(
print "no diff_filename"
--continue
)
else
(
if fromTga.checked == true dofTga = findString cmat.diffuseMap.filename fromTga.tooltip--".tga"
if fromPng.checked == true dofPng = findString cmat.diffuseMap.filename fromPng.tooltip--".png"
if fromJpg.checked == true dofJpg = findString cmat.diffuseMap.filename fromJpg.tooltip--".jpg"
)
if fTga != undefined dostr1=replace cmat.diffuseMap.filename fTga 4 dd.selected--".png"
if fPng != undefined dostr1=replace cmat.diffuseMap.filename fPng 4 dd.selected--".png"
if fJpg != undefined dostr1=replace cmat.diffuseMap.filename fJpg 4 dd.selected--".png"
if str1 != undefined docmat.diffuseMap.filename = str1
)
-- 透明贴图
if cmat.OpacityMap == undefined then --如果当前材质没有漫反射贴图
(
print "no opac"
--continue
)
else --if cmat.OpacityMap!=undefined and cmat.OpacityMap.filename!=undefined do
(
if cmat.OpacityMap.filename == undefined then --如果当前漫反射贴图有贴图文件
(
print "no opac_filename"
--continue
)
else
(
if fromTga.checked == true dofTga = findString cmat.OpacityMap.filename fromTga.tooltip--".tga"
if fromPng.checked == true dofPng = findString cmat.OpacityMap.filename fromPng.tooltip--".png"
if fromJpg.checked == true dofJpg = findString cmat.OpacityMap.filename fromJpg.tooltip--".jpg"
)
--Ojpg2 = findString cmat.OpacityMap.filename ".jpg"
--Otga2 = findString cmat.OpacityMap.filename ".tga"
if fTga != undefined dostr2=replace cmat.OpacityMap.filename fTga 4 dd.selected--".png"
if fPng != undefined dostr2=replace cmat.OpacityMap.filename fPng 4 dd.selected--".png"
if fJpg != undefined dostr2=replace cmat.OpacityMap.filename fJpg 4 dd.selected--".png"
if str2 != undefined docmat.OpacityMap.filename = str2
)
)
)
)
)
)
)
on cancel pressed do
(
DestroyDialog Spriter
)
on help pressed do
(
messagebox "修改贴图路径的扩展名_v0.1\n\n\n\t\t\tby M_BACK" title: "ChangeExtName v0.1"--"重要的不是选择 而是坚持!!!" title:"just a kidding!!"
)
on dd selected itm do
(
fromTga.enabled=true
fromPng.enabled=true
fromJpg.enabled=true
case itm of
(
1 :
(
fromTga.checked=false
fromTga.enabled=false
)
2 :
(
fromPng.checked=false
fromPng.enabled=false
)
3 :
(
fromJpg.checked=false
fromJpg.enabled=false
)
)
)
)
CreateDialog Spriter来自:求助得到的回答