永发信息网

神,那个MAX批量修改贴图后缀名的脚本能给我不?

答案:1  悬赏:30  手机版
解决时间 2021-04-05 04:01
  • 提问者网友:凉末
  • 2021-04-04 22:54
神,那个MAX批量修改贴图后缀名的脚本能给我不?
最佳答案
  • 五星知识达人网友:低血压的长颈鹿
  • 2021-04-04 23:36
好久之前的了,当时为了项目写的,不是完善的,发不出脚本,下面是直接代码,格式的话自己看看改改

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 do fTga = findString cmat.diffuseMap.filename fromTga.tooltip--".tga"
if fromPng.checked == true do fPng = findString cmat.diffuseMap.filename fromPng.tooltip--".png"
if fromJpg.checked == true do fJpg = findString cmat.diffuseMap.filename fromJpg.tooltip--".jpg"
)

if fTga != undefined do str1=replace cmat.diffuseMap.filename fTga 4 dd.selected--".png"
if fPng != undefined do str1=replace cmat.diffuseMap.filename fPng 4 dd.selected--".png"
if fJpg != undefined do str1=replace cmat.diffuseMap.filename fJpg 4 dd.selected--".png"
if str1 != undefined do cmat.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 do fTga = findString cmat.OpacityMap.filename fromTga.tooltip--".tga"
if fromPng.checked == true do fPng = findString cmat.OpacityMap.filename fromPng.tooltip--".png"
if fromJpg.checked == true do fJpg = findString cmat.OpacityMap.filename fromJpg.tooltip--".jpg"
)
-- Ojpg2 = findString cmat.OpacityMap.filename ".jpg"
-- Otga2 = findString cmat.OpacityMap.filename ".tga"

if fTga != undefined do str2=replace cmat.OpacityMap.filename fTga 4 dd.selected--".png"
if fPng != undefined do str2=replace cmat.OpacityMap.filename fPng 4 dd.selected--".png"
if fJpg != undefined do str2=replace cmat.OpacityMap.filename fJpg 4 dd.selected--".png"
if str2 != undefined do cmat.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
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯