New Addon: Import Autodesk .max #105013
@ -206,6 +206,7 @@ def _clsid(clsid):
|
|||||||
tuple(map(i8, clsid[8:16]))))
|
tuple(map(i8, clsid[8:16]))))
|
||||||
|
|
||||||
def is_maxfile (filename):
|
def is_maxfile (filename):
|
||||||
|
"""Test if file is a MAX OLE2 container."""
|
||||||
if hasattr(filename, 'read'):
|
if hasattr(filename, 'read'):
|
||||||
header = filename.read(len(MAGIC))
|
header = filename.read(len(MAGIC))
|
||||||
filename.seek(0)
|
filename.seek(0)
|
||||||
@ -221,7 +222,7 @@ def is_maxfile (filename):
|
|||||||
|
|
||||||
|
|
||||||
class MaxStream(io.BytesIO):
|
class MaxStream(io.BytesIO):
|
||||||
|
"""Returns an instance of the BytesIO class as read-only file object."""
|
||||||
def __init__(self, fp, sect, size, offset, sectorsize, fat, filesize):
|
def __init__(self, fp, sect, size, offset, sectorsize, fat, filesize):
|
||||||
unknown_size = False
|
unknown_size = False
|
||||||
if size == UNKNOWN_SIZE:
|
if size == UNKNOWN_SIZE:
|
||||||
@ -251,6 +252,7 @@ class MaxStream(io.BytesIO):
|
|||||||
|
|
||||||
|
|
||||||
class MaxFileDirEntry:
|
class MaxFileDirEntry:
|
||||||
|
"""Directory Entry for a stream or storage."""
|
||||||
STRUCT_DIRENTRY = '<64sHBBIII16sIQQIII'
|
STRUCT_DIRENTRY = '<64sHBBIII16sIQQIII'
|
||||||
DIRENTRY_SIZE = 128
|
DIRENTRY_SIZE = 128
|
||||||
assert struct.calcsize(STRUCT_DIRENTRY) == DIRENTRY_SIZE
|
assert struct.calcsize(STRUCT_DIRENTRY) == DIRENTRY_SIZE
|
||||||
@ -348,7 +350,7 @@ class MaxFileDirEntry:
|
|||||||
|
|
||||||
|
|
||||||
class ImportMaxFile:
|
class ImportMaxFile:
|
||||||
|
"""Representing an interface for importing .max files."""
|
||||||
def __init__(self, filename=None, write_mode=False, debug=False):
|
def __init__(self, filename=None, write_mode=False, debug=False):
|
||||||
self.write_mode = write_mode
|
self.write_mode = write_mode
|
||||||
self._filesize = None
|
self._filesize = None
|
||||||
@ -691,7 +693,7 @@ class ImportMaxFile:
|
|||||||
|
|
||||||
|
|
||||||
class MaxChunk():
|
class MaxChunk():
|
||||||
|
"""Representing a chunk of a .max file."""
|
||||||
def __init__(self, types, size, level, number):
|
def __init__(self, types, size, level, number):
|
||||||
self.number = number
|
self.number = number
|
||||||
self.types = types
|
self.types = types
|
||||||
@ -712,7 +714,7 @@ class MaxChunk():
|
|||||||
|
|
||||||
|
|
||||||
class ByteArrayChunk(MaxChunk):
|
class ByteArrayChunk(MaxChunk):
|
||||||
|
"""A byte array of a .max chunk."""
|
||||||
def __init__(self, types, data, level, number):
|
def __init__(self, types, data, level, number):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
|
|
||||||
@ -761,7 +763,7 @@ class ByteArrayChunk(MaxChunk):
|
|||||||
|
|
||||||
|
|
||||||
class ClassIDChunk(ByteArrayChunk):
|
class ClassIDChunk(ByteArrayChunk):
|
||||||
|
"""The class ID subchunk of a .max chunk."""
|
||||||
def __init__(self, types, data, level, number):
|
def __init__(self, types, data, level, number):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
self.dll = None
|
self.dll = None
|
||||||
@ -777,7 +779,7 @@ class ClassIDChunk(ByteArrayChunk):
|
|||||||
|
|
||||||
|
|
||||||
class DirectoryChunk(ByteArrayChunk):
|
class DirectoryChunk(ByteArrayChunk):
|
||||||
|
"""The directory chunk of a .max file."""
|
||||||
def __init__(self, types, data, level, number):
|
def __init__(self, types, data, level, number):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
|
|
||||||
@ -789,7 +791,7 @@ class DirectoryChunk(ByteArrayChunk):
|
|||||||
|
|
||||||
|
|
||||||
class ContainerChunk(MaxChunk):
|
class ContainerChunk(MaxChunk):
|
||||||
|
"""A container chunk in a .max file wich includes byte arrays."""
|
||||||
def __init__(self, types, data, level, number, primitiveReader=ByteArrayChunk):
|
def __init__(self, types, data, level, number, primitiveReader=ByteArrayChunk):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
self.primitiveReader = primitiveReader
|
self.primitiveReader = primitiveReader
|
||||||
@ -813,7 +815,7 @@ class ContainerChunk(MaxChunk):
|
|||||||
|
|
||||||
|
|
||||||
class SceneChunk(ContainerChunk):
|
class SceneChunk(ContainerChunk):
|
||||||
|
"""The scene chunk of a .max file wich includes the relevant data for blender."""
|
||||||
def __init__(self, types, data, level, number, primitiveReader=ByteArrayChunk):
|
def __init__(self, types, data, level, number, primitiveReader=ByteArrayChunk):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
self.primitiveReader = primitiveReader
|
self.primitiveReader = primitiveReader
|
||||||
@ -833,7 +835,7 @@ class SceneChunk(ContainerChunk):
|
|||||||
|
|
||||||
|
|
||||||
class ChunkReader():
|
class ChunkReader():
|
||||||
|
"""The chunk reader class for decoding the byte arrays."""
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
@ -872,7 +874,7 @@ class ChunkReader():
|
|||||||
|
|
||||||
|
|
||||||
class Point3d():
|
class Point3d():
|
||||||
|
"""Representing a three dimensional vector plus pointflag."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.points = None
|
self.points = None
|
||||||
self.flags = 0
|
self.flags = 0
|
||||||
@ -886,7 +888,7 @@ class Point3d():
|
|||||||
|
|
||||||
|
|
||||||
class Material():
|
class Material():
|
||||||
|
"""Representing a material chunk of a scene chunk."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user