Import/Export fixes after some Blender 2.8 API changes

This commit is contained in:
khreathor 2019-05-29 02:08:37 +02:00 committed by Bill Currie
parent 11e5f39fdc
commit 008b5a4d2c
2 changed files with 10 additions and 5 deletions

View file

@ -344,8 +344,10 @@ def export_mdl(
):
obj = context.active_object
#mesh = obj.to_mesh(context.scene, True, 'PREVIEW') #wysiwyg?
mesh = obj.to_mesh(context.depsgraph, True, calc_undeformed=False)
obj.update_from_editmode()
depsgraph = context.evaluated_depsgraph_get()
ob_eval = obj.evaluated_get(depsgraph)
mesh = ob_eval.to_mesh()
#if not check_faces(mesh):
# operator.report({'ERROR'},
# "Mesh has faces with more than 3 vertices.")
@ -377,7 +379,10 @@ def export_mdl(
if not mdl.frames:
for fno in range(context.scene.frame_start, context.scene.frame_end + 1):
context.scene.frame_set(fno)
mesh = obj.to_mesh(context.depsgraph, True, calc_undeformed=False) #wysiwyg?
obj.update_from_editmode()
depsgraph = context.evaluated_depsgraph_get()
ob_eval = obj.evaluated_get(depsgraph)
mesh = ob_eval.to_mesh()
if xform:
mesh.transform(mdl.obj.matrix_world)
mdl.frames.append(make_frame(mesh, vertmap, fno))

View file

@ -87,7 +87,7 @@ def load_skins(mdl):
p[l + 2] = c[2] / 255.0
p[l + 3] = 1.0
img.pixels[:] = p[:]
img.pack(as_png=True)
img.pack()
img.use_fake_user = True
mdl.images=[]
@ -101,7 +101,7 @@ def load_skins(mdl):
def setup_main_material(mdl):
mat = bpy.data.materials.new(mdl.name)
mat.blend_method = 'OPAQUE'
mat.diffuse_color = (1, 1, 1)
mat.diffuse_color = (1, 1, 1, 1)
mat.metallic = 1
mat.roughness = 1
mat.specular_intensity = 0