New addon: Import Autodesk .max #17
@ -1243,14 +1243,21 @@ def create_shape(context, pts, indices, node, key, prc, mat):
|
|||||||
mtx = create_matrix(prc)
|
mtx = create_matrix(prc)
|
||||||
data = []
|
data = []
|
||||||
if (pts):
|
if (pts):
|
||||||
shape.vertices.add(len(pts) // 3)
|
loopstart = []
|
||||||
shape.vertices.foreach_set("co", pts)
|
looplines = loop = 0
|
||||||
nbr_faces = len(indices)
|
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.polygons.add(nbr_faces)
|
||||||
shape.loops.add(nbr_faces * 3)
|
shape.vertices.foreach_set("co", pts)
|
||||||
for vtx in indices:
|
for vtx in indices:
|
||||||
|
loopstart.append(loop)
|
||||||
data.extend(vtx)
|
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)
|
shape.loops.foreach_set("vertex_index", data)
|
||||||
|
|
||||||
if (len(data) > 0):
|
if (len(data) > 0):
|
||||||
@ -1317,23 +1324,6 @@ def get_poly_6p(data):
|
|||||||
return polylist
|
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):
|
def get_poly_data(chunk):
|
||||||
offset = 0
|
offset = 0
|
||||||
polylist = []
|
polylist = []
|
||||||
@ -1345,6 +1335,17 @@ def get_poly_data(chunk):
|
|||||||
return polylist
|
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):
|
def calc_point_3d(chunk):
|
||||||
data = chunk.data
|
data = chunk.data
|
||||||
count, offset = get_long(data, 0)
|
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
|
coords = point3i = point4i = point6i = pointNi = None
|
||||||
name = node.get_first(TYP_NAME).data
|
name = node.get_first(TYP_NAME).data
|
||||||
poly = msh.get_first(0x08FE)
|
poly = msh.get_first(0x08FE)
|
||||||
indexList = []
|
|
||||||
coordListI = []
|
|
||||||
indicesList = []
|
|
||||||
created = False
|
created = False
|
||||||
if (poly):
|
if (poly):
|
||||||
for child in poly.children:
|
for child in poly.children:
|
||||||
@ -1387,8 +1385,6 @@ def create_editable_poly(context, node, msh, mat, mtx):
|
|||||||
point6i = child.data
|
point6i = child.data
|
||||||
elif (child.types == 0x011A):
|
elif (child.types == 0x011A):
|
||||||
point4i = calc_point_3d(child)
|
point4i = calc_point_3d(child)
|
||||||
elif (child.types == 0x0310):
|
|
||||||
pointNi = child.data
|
|
||||||
if (point4i is not None):
|
if (point4i is not None):
|
||||||
vertex = get_poly_4p(point4i)
|
vertex = get_poly_4p(point4i)
|
||||||
if (len(vertex) > 0):
|
if (len(vertex) > 0):
|
||||||
@ -1399,23 +1395,9 @@ def create_editable_poly(context, node, msh, mat, mtx):
|
|||||||
elif (point6i is not None):
|
elif (point6i is not None):
|
||||||
ngons = get_poly_6p(point6i)
|
ngons = get_poly_6p(point6i)
|
||||||
created = create_shape(context, coords, ngons, node, None, mtx, mat)
|
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
|
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):
|
def create_editable_mesh(context, node, msh, mat, mtx):
|
||||||
name = node.get_first(TYP_NAME).data
|
name = node.get_first(TYP_NAME).data
|
||||||
poly = msh.get_first(0x08FE)
|
poly = msh.get_first(0x08FE)
|
||||||
@ -1462,12 +1444,6 @@ def create_shell(context, node, shell, mat, mtx):
|
|||||||
return created
|
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):
|
def create_skipable(context, node, msh, mat, mtx, skip):
|
||||||
name = node.get_first(TYP_NAME).data
|
name = node.get_first(TYP_NAME).data
|
||||||
print(" skipping %s '%s'... " %(skip, name))
|
print(" skipping %s '%s'... " %(skip, name))
|
||||||
|
Reference in New Issue
Block a user