Converting Assets to COLLADA
Use this script to "fix" the asset in 3ds max.
Converts the NeLMaterial into a StandardMaterial
so that the exporter can make sense of it.
fn fix_texture_file_name t =
(
if t == undefined then return "unknown.png"
return "c:/database/textures/" + (getFilenameFile (filenameFromPath t)) + ".png"
)
fn find_nel_bitmap_texture t =
(
-- we should log the textures we skip here
if (t.bitmap1FileName != "") then return t.bitmap1FileName
if (t.bitmap2FileName != "") then return t.bitmap2FileName
if (t.bitmap3FileName != "") then return t.bitmap3FileName
if (t.bitmap4FileName != "") then return t.bitmap4FileName
if (t.bitmap5FileName != "") then return t.bitmap5FileName
if (t.bitmap6FileName != "") then return t.bitmap6FileName
if (t.bitmap7FileName != "") then return t.bitmap7FileName
if (t.bitmap8FileName != "") then return t.bitmap8FileName
return "unknown.png"
)
fn fix_bitmap_texture t =
(
local bt
if classof t == NelBitmapTexture then
(
bt = BitmapTexture()
bt.filename = find_nel_bitmap_texture t
bt.filename = fix_texture_file_name bt.filename
return bt
)
else if classof t == BitmapTexture then
(
t.filename = fix_texture_file_name t.filename
)
return t
)
fn fix_material t =
(
local m
local i
if classof t == NelMaterial then
(
m = StandardMaterial()
m.twoSided = t.bTwoSided
m.ambient = t.cAmbient
m.diffuse = t.cDiffuse
m.opacity = t.pOpacity
m.specular = t.cSpecular
m.specularLevel = t.pSpecularLevel
m.glossiness = t.pGlossiness
m.selfIllumColor = t.cSelfIllumColor
m.selfIllumAmount = t.pSelfIllumAmount
m.useSelfIllumColor = t.bUseSelfIllumColor
-- if t.bAlphaTest then print "alpha-test"
m.diffuseMap = fix_bitmap_texture t.tTexture_1
m.specularMap = fix_bitmap_texture t.tTexture_2
return m
)
else if classof t == MultiMaterial then
(
for i = 1 to t.count do
(
t[i] = fix_material t[i]
)
return t
)
return t
)
fn kill_nel_mats =
(
local g, m
for g in geometry do
(
g.material = fix_material g.material
)
)
fn fix_asset =
(
unfreeze geometry
kill_nel_mats()
actionMan.executeAction 0 "40021" -- Selection: Select All
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
actionMan.executeAction 0 "40043" -- Selection: Select None
)
fix_asset()
For batch conversion, just loop through the max files and use
exportFile "foo.dae" using:OpenCOLLADAExporter