Add "empty" skin during export for models with no materials or texture nodes

This commit is contained in:
khreathor 2019-01-16 21:40:34 +01:00 committed by Bill Currie
parent 3913febace
commit ff5f9f1831

View file

@ -98,30 +98,35 @@ def make_skin(operator, mdl, mesh):
materials = bpy.context.object.data.materials materials = bpy.context.object.data.materials
for mat in materials: if len(materials) > 0:
allNodes = list(filter(lambda node: node.type == "TEX_IMAGE", mat.node_tree.nodes)) for mat in materials:
if len(allNodes) > 1: allTextureNodes = list(filter(lambda node: node.type == "TEX_IMAGE", mat.node_tree.nodes))
skingroup = MDL.Skin() if len(allTextureNodes) > 1: #=== skingroup
skingroup.type = 1 skingroup = MDL.Skin()
skingroup.skins = [] skingroup.type = 1
skingroup.times = [] skingroup.skins = []
sortedNodes = list(allNodes) skingroup.times = []
sortedNodes.sort(key=lambda x: x.location[1], reverse=True) sortedNodes = list(allTextureNodes)
for node in sortedNodes: sortedNodes.sort(key=lambda x: x.location[1], reverse=True)
if node.type == "TEX_IMAGE": for node in sortedNodes:
image = node.image if node.type == "TEX_IMAGE":
mdl.skinwidth, mdl.skinheight = image.size image = node.image
skin = convert_image(image) mdl.skinwidth, mdl.skinheight = image.size
skingroup.skins.append(skin) skin = convert_image(image)
skingroup.times.append(0.1) # hardcoded at the moment skingroup.skins.append(skin)
mdl.skins.append(skingroup) skingroup.times.append(0.1) # hardcoded at the moment
else: mdl.skins.append(skingroup)
for node in allNodes: elif len(allTextureNodes) == 1: #=== single skin
if node.type == "TEX_IMAGE": for node in allTextureNodes:
image = node.image if node.type == "TEX_IMAGE":
mdl.skinwidth, mdl.skinheight = image.size image = node.image
skin = convert_image(image) mdl.skinwidth, mdl.skinheight = image.size
mdl.skins.append(skin) skin = convert_image(image)
mdl.skins.append(skin)
else:
mdl.skins.append(skin) # add empty skin - no texture nodes
else:
mdl.skins.append(skin) # add empty skin - no materials
''' '''
if (uvt and uvt.data and uvt.data[0].image): if (uvt and uvt.data and uvt.data[0].image):