New Addon: Import Autodesk .max #105013

Closed
Sebastian Sille wants to merge 136 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 2bcb045779 - Show all commits

View File

@ -43,6 +43,7 @@ class Import_max(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
"""Import Autodesk MAX""" """Import Autodesk MAX"""
bl_idname = "import_autodesk.max" bl_idname = "import_autodesk.max"
bl_label = "Import Autodesk MAX (.max)" bl_label = "Import Autodesk MAX (.max)"
bl_options = {'PRESET', 'UNDO'}
filename_ext = ".max" filename_ext = ".max"
filter_glob: bpy.props.StringProperty(default="*.max", options={'HIDDEN'},) filter_glob: bpy.props.StringProperty(default="*.max", options={'HIDDEN'},)
@ -825,7 +826,7 @@ class ChunkReader():
long, ofst = get_long(data, ofst) long, ofst = get_long(data, ofst)
if (short == 0x8B1F): if (short == 0x8B1F):
short, ofst = get_long(data, ofst) short, ofst = get_long(data, ofst)
if (short == 0x0B000000): if (short == 0xB000000):
data = zlib.decompress(data, zlib.MAX_WBITS|32) data = zlib.decompress(data, zlib.MAX_WBITS|32)
print(" reading '%s'..."%self.name, len(data)) print(" reading '%s'..."%self.name, len(data))
while offset < len(data): while offset < len(data):
@ -1043,9 +1044,9 @@ def get_position(pos):
uid = get_guid(pos) uid = get_guid(pos)
if (uid == 0xFFEE238A118F7E02): # Position XYZ if (uid == 0xFFEE238A118F7E02): # Position XYZ
position = get_point_3d(pos) position = get_point_3d(pos)
elif (uid == 0x0000000000442312): # TCB Position elif (uid == 0x442312): # TCB Position
position = pos.get_first(0x2503).data position = pos.get_first(0x2503).data
elif (uid == 0x0000000000002008): # Bezier Position elif (uid == 0x2008): # Bezier Position
position = pos.get_first(0x2503).data position = pos.get_first(0x2503).data
if (position): if (position):
mtx = mathutils.Matrix.Translation(position) mtx = mathutils.Matrix.Translation(position)
@ -1060,10 +1061,10 @@ def get_rotation(pos):
if (uid == 0x2012): # Euler XYZ if (uid == 0x2012): # Euler XYZ
rot = get_point_3d(pos) rot = get_point_3d(pos)
rotation = mathutils.Euler((rot[2], rot[1], rot[0])).to_quaternion() rotation = mathutils.Euler((rot[2], rot[1], rot[0])).to_quaternion()
elif (uid == 0x0000000000442313): # TCB Rotation elif (uid == 0x442313): # TCB Rotation
rot = pos.get_first(0x2504).data rot = pos.get_first(0x2504).data
rotation = mathutils.Quaternion((rot[0], rot[1], rot[2], rot[3])) rotation = mathutils.Quaternion((rot[0], rot[1], rot[2], rot[3]))
elif (uid == 0x000000004B4B1003): #'Rotation List elif (uid == 0x4B4B1003): #'Rotation List
refs = get_references(pos) refs = get_references(pos)
if (len(refs) > 3): if (len(refs) > 3):
return get_rotation(refs[0]) return get_rotation(refs[0])
@ -1083,7 +1084,7 @@ def get_scale(pos):
if (scale is None): if (scale is None):
scale = pos.get_first(0x2505) scale = pos.get_first(0x2505)
pos = scale.data pos = scale.data
elif (uid == 0x0000000000442315): # TCB Zoom elif (uid == 0x442315): # TCB Zoom
scale = pos.get_first(0x2501) scale = pos.get_first(0x2501)
if (scale is None): if (scale is None):
scale = pos.get_first(0x2505) scale = pos.get_first(0x2505)
@ -1198,7 +1199,7 @@ def adjust_material(obj, mat):
if (uid == 0x0002): # Standard if (uid == 0x0002): # Standard
refs = get_references(mat) refs = get_references(mat)
material = get_standard_material(refs) material = get_standard_material(refs)
elif (uid == 0x0000000000000200): # Multi/Sub-Object elif (uid == 0x0200): # Multi/Sub-Object
refs = get_references(mat) refs = get_references(mat)
material = adjust_material(obj, refs[-1]) material = adjust_material(obj, refs[-1])
elif (uid == 0x7034695C37BF3F2F): # VRayMtl elif (uid == 0x7034695C37BF3F2F): # VRayMtl
@ -1348,7 +1349,6 @@ def calc_point_3d(chunk):
pointlist.append(pt) pointlist.append(pt)
except Exception as exc: except Exception as exc:
print('ArrayError:\n', "%s: offset = %d\n" %(exc, offset)) print('ArrayError:\n', "%s: offset = %d\n" %(exc, offset))
raise exc
return pointlist return pointlist