3
11

New Addon: Import Autodesk .max #22

Closed
Sebastian Sille wants to merge 38 commits from (deleted):nrgsille-import_max into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit ba4008a5f4 - Show all commits

View File

@ -223,7 +223,8 @@ SKIPPABLE = {
def get_valid_name(name):
if (INVALID_NAME.match(name)): return "_%s"%(name.encode('utf8'))
if (INVALID_NAME.match(name)):
return "_%s"%(name.encode('utf8'))
return "%s"%(name.encode('utf8'))
def i8(data):
@ -840,7 +841,7 @@ class ClassIDChunk(ByteArrayChunk):
self.set(data, "struct", '<IQI', 0, 16) # DllIndex, ID, SuperID
else:
self.unknown = False
self.data = ":".join("%02x"%(c) for c in data)
self.data = ":".join("%02x"%(c) for c in data)
class DirectoryChunk(ByteArrayChunk):
@ -1047,7 +1048,6 @@ def get_reference(chunk):
references = {}
refs = chunk.get_first(0x2035)
if (refs):
types = refs.data[0]
offset = 1
while offset < len(refs.data):
key = refs.data[offset]
@ -1520,11 +1520,14 @@ def create_editable_mesh(context, node, msh, mat, mtx, umt):
return created
def create_shell(context, node, shell, mat, mtx, umt):
def create_shell(context, node, shell, mat, mtx, umt, uvm):
name = node.get_first(TYP_NAME).data
refs = get_references(shell)
msh = refs[-1]
created = create_editable_mesh(context, node, msh, mat, mtx, umt)
if (get_class_name(msh) == "'Editable Poly'"):
created = create_editable_poly(context, node, msh, mat, mtx, umt, uvm)
else:
created = create_editable_mesh(context, node, msh, mat, mtx, umt)
return created
@ -1543,7 +1546,7 @@ def create_mesh(context, node, msh, mtx, mat, umt, uvm):
elif (uid == 0x192F60981BF8338D):
created = create_editable_poly(context, node, msh, mat, mtx, umt, uvm)
elif (uid in {0x2032, 0x2033}):
created = create_shell(context, node, msh, mat, mtx, umt)
created = create_shell(context, node, msh, mat, mtx, umt, uvm)
else:
skip = SKIPPABLE.get(uid)
if (skip is not None):
@ -1605,6 +1608,7 @@ def load(operator, context, filepath="", scale_objects=1.0, use_material=True,
mscale = mathutils.Matrix.Scale(scale_objects, 4)
if global_matrix is not None:
mscale = global_matrix @ mscale
read(context, filepath, mscale, usemat=use_material, uvmesh=use_uv_mesh, transform=use_apply_matrix)
return {'FINISHED'}