描述:3D角色做完把模型给动作,然后动作做完需要导出fbx到unity,当有大量的动作需要导出的时候,对动作来说是非常痛苦的,所以根据动作max文件的储存路劲与max的命名,做了一个批量导出工具。这里将导出类型分成NPC,body,face,head,可以根据自己的项目进行更改。工具截图如下:
代码如下
macroscript 批量导出category:"批量导出"
toolTip:""
(
rollout Export "动作批量导出插件" width:215 height:296
(
edittext importPath "导入路径" pos:[7,31] width:197 height:19
label Label01 "动作批量导出插件" pos:[60,4] width:107 height:20
button ExportSkin "导出蒙皮" pos:[33,225] width:66 height:34
edittext exportPath "导出路径" pos:[10,130] width:192 height:20
checkbox body "body" pos:[20,62] width:56 height:16 enabled:true checked:false
checkbox head "head" pos:[81,61] width:43 height:15 enabled:true
checkbox NPC "NPC" pos:[21,89] width:60 height:18
checkbox face "face" pos:[139,61] width:41 height:16
button ExportAni "导出动作" pos:[120,226] width:66 height:34
on ExportSkin pressed do
(
body_int=0
head_int =0
face_int=0
NPC_int=0
if importPath.text.count != 0 and exportPath.text.count!=0 and (head.state!=false or body.state!=false or NPC.state!=false or face.state !=false) then
(
importFiles = getFiles(importPath.text+"\\*"+".max")
savefilepath = ()
--如果设置了导出身体
if body.state == true then
(
for f in importFiles do
(
loadMaxFile f quiet:true
arrayExportbody = #()
for i in $*body do
(
if (i.isHidden == false) then
append arrayExportbody i --将以body结尾的所有物体加入数组
)
if arrayExportbody.count != 0 then
(
body_int+=1
for i in geometry do i.isHidden = true --隐藏所有的物体
for i in arrayExportbody do
(
i.isHidden =false -- 先将第一个身体显示,此时应该只有第一个身体还有骨骼 没其他任何物件
max select all
filename = i.name
savefilepath = exportPath.text
exfile = savefilepath +"\\"+ filename
FbxExporterSetParam"Animation" false
FbxExporterSetParam "BakeAnimation"false
Exportfile exfile #noPrompt using:exporterPlugin.classes[8]
i.isHidden =true
)
shellLaunch savefilepath""
)
)
)
--如果设置了导出头部
else if head.state== true then
(
for f in importFiles do
(
loadMaxFile f quiet:true
arrayExporthead = #()
for i in $*head do
(
if (i.isHidden == false) then
append arrayExporthead i --将以body结尾的所有物体加入数组
)
if arrayExporthead.count != 0 then
(
head_int+=1
for i in geometry do i.isHidden = true --隐藏所有的物体
for i in arrayExporthead do
(
i.isHidden =false -- 先将第一个身体显