New addon: Import Autodesk .max #17
@ -278,7 +278,7 @@ class MaxFileDirEntry:
|
||||
self.sizeHigh
|
||||
) = struct.unpack(MaxFileDirEntry.STRUCT_DIRENTRY, entry)
|
||||
|
||||
if self.namelength>64:
|
||||
if self.namelength > 64:
|
||||
self.namelength = 64
|
||||
self.name_utf16 = self.name_raw[:(self.namelength - 2)]
|
||||
self.name = maxfile._decode_utf16_str(self.name_utf16)
|
||||
@ -1243,14 +1243,21 @@ def create_shape(context, pts, indices, node, key, prc, mat):
|
||||
mtx = create_matrix(prc)
|
||||
data = []
|
||||
if (pts):
|
||||
shape.vertices.add(len(pts) // 3)
|
||||
shape.vertices.foreach_set("co", pts)
|
||||
loopstart = []
|
||||
looplines = loop = 0
|
||||
nbr_faces = len(indices)
|
||||
for fid in range(nbr_faces):
|
||||
polyface = indices[fid]
|
||||
looplines += len(polyface)
|
||||
shape.vertices.add(len(pts) // 3)
|
||||
shape.loops.add(looplines)
|
||||
shape.polygons.add(nbr_faces)
|
||||
shape.loops.add(nbr_faces * 3)
|
||||
shape.vertices.foreach_set("co", pts)
|
||||
for vtx in indices:
|
||||
loopstart.append(loop)
|
||||
data.extend(vtx)
|
||||
shape.polygons.foreach_set("loop_start", range(0, nbr_faces * 3, 3))
|
||||
loop += len(vtx)
|
||||
shape.polygons.foreach_set("loop_start", loopstart)
|
||||
shape.loops.foreach_set("vertex_index", data)
|
||||
|
||||
if (len(data) > 0):
|
||||
@ -1317,23 +1324,6 @@ def get_poly_6p(data):
|
||||
return polylist
|
||||
|
||||
|
||||
def get_poly_ngon(polys):
|
||||
vertex = []
|
||||
offset = 0
|
||||
while (offset < len(polys)):
|
||||
num = polys[offset]
|
||||
offset += 1
|
||||
ngon = []
|
||||
keys = 0
|
||||
while (keys < num):
|
||||
pt = points[polys[offset]][1]
|
||||
ngon.append(pt)
|
||||
offset += 1
|
||||
keys += 1
|
||||
vertex.extend(ngon)
|
||||
return vertex
|
||||
|
||||
|
||||
def get_poly_data(chunk):
|
||||
offset = 0
|
||||
polylist = []
|
||||
@ -1345,6 +1335,17 @@ def get_poly_data(chunk):
|
||||
return polylist
|
||||
|
||||
|
||||
def get_point_array(values):
|
||||
verts = []
|
||||
if len(values) >= 4:
|
||||
count, offset = get_long(values, 0)
|
||||
while (count > 0):
|
||||
floats, offset = get_floats(values, offset, 3)
|
||||
verts.extend(floats)
|
||||
count -= 1
|
||||
return verts
|
||||
|
||||
|
||||
def calc_point_3d(chunk):
|
||||
data = chunk.data
|
||||
count, offset = get_long(data, 0)
|
||||
@ -1375,9 +1376,6 @@ def create_editable_poly(context, node, msh, mat, mtx):
|
||||
coords = point3i = point4i = point6i = pointNi = None
|
||||
name = node.get_first(TYP_NAME).data
|
||||
poly = msh.get_first(0x08FE)
|
||||
indexList = []
|
||||
coordListI = []
|
||||
indicesList = []
|
||||
created = False
|
||||
if (poly):
|
||||
for child in poly.children:
|
||||
@ -1387,8 +1385,6 @@ def create_editable_poly(context, node, msh, mat, mtx):
|
||||
point6i = child.data
|
||||
elif (child.types == 0x011A):
|
||||
point4i = calc_point_3d(child)
|
||||
elif (child.types == 0x0310):
|
||||
pointNi = child.data
|
||||
if (point4i is not None):
|
||||
vertex = get_poly_4p(point4i)
|
||||
if (len(vertex) > 0):
|
||||
@ -1399,23 +1395,9 @@ def create_editable_poly(context, node, msh, mat, mtx):
|
||||
elif (point6i is not None):
|
||||
ngons = get_poly_6p(point6i)
|
||||
created = create_shape(context, coords, ngons, node, None, mtx, mat)
|
||||
elif (pointNi is not None):
|
||||
ngons = get_poly_ngon(pointNi)
|
||||
created = create_shape(context, coords, ngons, node, None, mtx, mat)
|
||||
return created
|
||||
|
||||
|
||||
def get_point_array(values):
|
||||
verts = []
|
||||
if len(values) >= 4:
|
||||
count, offset = get_long(values, 0)
|
||||
while (count > 0):
|
||||
floats, offset = get_floats(values, offset, 3)
|
||||
verts.extend(floats)
|
||||
count -= 1
|
||||
return verts
|
||||
|
||||
|
||||
def create_editable_mesh(context, node, msh, mat, mtx):
|
||||
name = node.get_first(TYP_NAME).data
|
||||
poly = msh.get_first(0x08FE)
|
||||
@ -1462,12 +1444,6 @@ def create_shell(context, node, shell, mat, mtx):
|
||||
return created
|
||||
|
||||
|
||||
def create_boolean(context, node, pro, mat, mtx):
|
||||
name = node.get_first(TYP_NAME).data
|
||||
pBlocks = get_references(pro)
|
||||
return True
|
||||
|
||||
|
||||
def create_skipable(context, node, msh, mat, mtx, skip):
|
||||
name = node.get_first(TYP_NAME).data
|
||||
print(" skipping %s '%s'... " %(skip, name))
|
||||
|
Reference in New Issue
Block a user