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 4db63f4d4d - Show all commits

View File

@ -15,7 +15,7 @@ bl_info = {
"name": "Import Autodesk MAX (.max)", "name": "Import Autodesk MAX (.max)",
"author": "Sebastian Sille, Philippe Lagadec, Jens M. Plonka", "author": "Sebastian Sille, Philippe Lagadec, Jens M. Plonka",
"version": (1, 1, 2), "version": (1, 1, 2),
"blender": (4, 0, 0), "blender": (3, 6, 0),
"location": "File > Import", "location": "File > Import",
"description": "Import 3DSMAX meshes & materials", "description": "Import 3DSMAX meshes & materials",
"warning": "", "warning": "",
@ -451,7 +451,6 @@ class ImportMaxFile:
self.fp = None self.fp = None
self.header_clsid = None self.header_clsid = None
self.header_signature = None self.header_signature = None
self.metadata = None
self.mini_sector_shift = None self.mini_sector_shift = None
self.mini_sector_size = None self.mini_sector_size = None
self.mini_stream_cutoff_size = None self.mini_stream_cutoff_size = None
@ -684,9 +683,7 @@ class ImportMaxFile:
def get_rootentry_name(self): def get_rootentry_name(self):
return self.root.name return self.root.name
def getproperties(self, filename, convert_time=False, no_conversion=None): def getproperties(self, filename):
if no_conversion == None:
no_conversion = []
streampath = filename streampath = filename
if not isinstance(streampath, str): if not isinstance(streampath, str):
streampath = '/'.join(streampath) streampath = '/'.join(streampath)
@ -732,7 +729,7 @@ class ImportMaxFile:
value = self._decode_utf16_str(stream[offset + 8:offset + 8 + count * 2]) value = self._decode_utf16_str(stream[offset + 8:offset + 8 + count * 2])
elif property_type == VT_FILETIME: elif property_type == VT_FILETIME:
value = int(i32(stream, offset + 4)) + (int(i32(stream, offset + 8)) << 32) value = int(i32(stream, offset + 4)) + (int(i32(stream, offset + 8)) << 32)
if convert_time and property_id not in no_conversion: if property_id != 10:
_FILETIME_null_date = datetime.datetime(1601, 1, 1, 0, 0, 0) _FILETIME_null_date = datetime.datetime(1601, 1, 1, 0, 0, 0)
value = _FILETIME_null_date + datetime.timedelta(microseconds=value // 10) value = _FILETIME_null_date + datetime.timedelta(microseconds=value // 10)
else: else:
@ -1290,7 +1287,6 @@ def get_arch_material(ad):
material = Material() material = Material()
try: try:
material.set('diffuse', get_color(ad, 0x1A)) material.set('diffuse', get_color(ad, 0x1A))
material.set('specular', get_color(ad, 0x02))
except: except:
pass pass
return material return material
@ -1593,8 +1589,8 @@ def read_scene(context, maxfile, filename, mscale, usemat, uvmesh, transform):
def read(context, filename, mscale, usemat, uvmesh, transform): def read(context, filename, mscale, usemat, uvmesh, transform):
if (is_maxfile(filename)): if (is_maxfile(filename)):
maxfile = ImportMaxFile(filename) maxfile = ImportMaxFile(filename)
prop = maxfile.getproperties('\x05DocumentSummaryInformation', convert_time=True, no_conversion=[10]) prop = maxfile.getproperties('\x05DocumentSummaryInformation')
prop = maxfile.getproperties('\x05SummaryInformation', convert_time=True, no_conversion=[10]) prop = maxfile.getproperties('\x05SummaryInformation')
read_class_data(maxfile, filename) read_class_data(maxfile, filename)
read_config(maxfile, filename) read_config(maxfile, filename)
read_directory(maxfile, filename) read_directory(maxfile, filename)