Skip to content
Snippets Groups Projects
Commit 481a8384 authored by Ken Nign's avatar Ken Nign
Browse files

fixed issues caused by last two commits

parent 9656588e
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,7 @@ class _obj_surf(object): ...@@ -114,6 +114,7 @@ class _obj_surf(object):
__slots__ = ( __slots__ = (
"bl_mat", "bl_mat",
"name", "name",
"source_name",
"colr", "colr",
"diff", "diff",
"lumi", "lumi",
...@@ -366,7 +367,9 @@ def read_layr(layr_bytes, object_layers, load_hidden): ...@@ -366,7 +367,9 @@ def read_layr(layr_bytes, object_layers, load_hidden):
print("Reading Object Layer") print("Reading Object Layer")
offset= 4 offset= 4
new_layr.pivot= struct.unpack(">fff", layr_bytes[offset:offset+12]) pivot= struct.unpack(">fff", layr_bytes[offset:offset+12])
# Swap Y and Z to match Blender's pitch.
new_layr.pivot= [pivot[0], pivot[2], pivot[1]]
offset+= 12 offset+= 12
layr_name, name_len = read_lwostring(layr_bytes[offset:]) layr_name, name_len = read_lwostring(layr_bytes[offset:])
offset+= name_len offset+= name_len
...@@ -411,10 +414,11 @@ def read_pnts(pnt_bytes, object_layers): ...@@ -411,10 +414,11 @@ def read_pnts(pnt_bytes, object_layers):
while offset < chunk_len: while offset < chunk_len:
pnts= struct.unpack(">fff", pnt_bytes[offset:offset+12]) pnts= struct.unpack(">fff", pnt_bytes[offset:offset+12])
offset+= 12 offset+= 12
# Re-order the points so that the mesh has the right pitch. # Re-order the points so that the mesh has the right pitch,
# the pivot already has the correct order.
pnts= [pnts[0] - object_layers[-1].pivot[0],\ pnts= [pnts[0] - object_layers[-1].pivot[0],\
pnts[2] - object_layers[-1].pivot[2],\ pnts[2] - object_layers[-1].pivot[1],\
pnts[1] - object_layers[-1].pivot[1]] pnts[1] - object_layers[-1].pivot[2]]
object_layers[-1].pnts.append(pnts) object_layers[-1].pnts.append(pnts)
...@@ -1022,11 +1026,11 @@ def build_objects(object_layers, object_surfs, object_tags, object_name, add_sub ...@@ -1022,11 +1026,11 @@ def build_objects(object_layers, object_surfs, object_tags, object_name, add_sub
# me.vertices[vi].co= layer_data.pnts[vi] # me.vertices[vi].co= layer_data.pnts[vi]
# faster, would be faster again to use an array # faster, would be faster again to use an array
me.vertices.foreach_set("co", [axis co for co in layer_data.pnts for axis in co]) me.vertices.foreach_set("co", [axis for co in layer_data.pnts for axis in co])
ngons= {} # To keep the FaceIdx consistant, handle NGons later. ngons= {} # To keep the FaceIdx consistant, handle NGons later.
edges= [] # Holds the FaceIdx of the 2-point polys. edges= [] # Holds the FaceIdx of the 2-point polys.
for fi, fpol in enumerate(len(layer_data.pols)): for fi, fpol in enumerate(layer_data.pols):
fpol.reverse() # Reversing gives correct normal directions fpol.reverse() # Reversing gives correct normal directions
# PointID 0 in the last element causes Blender to think it's un-used. # PointID 0 in the last element causes Blender to think it's un-used.
if fpol[-1] == 0: if fpol[-1] == 0:
...@@ -1157,8 +1161,8 @@ def build_objects(object_layers, object_surfs, object_tags, object_name, add_sub ...@@ -1157,8 +1161,8 @@ def build_objects(object_layers, object_surfs, object_tags, object_name, add_sub
# Apply the Edge Weighting. # Apply the Edge Weighting.
if len(layer_data.edge_weights) > 0: if len(layer_data.edge_weights) > 0:
for edge in me.edges: for edge in me.edges:
edge_sa= "{0} {1}".format(edge.vertices[0]), edge.vertices[1]) edge_sa= "{0} {1}".format(edge.vertices[0], edge.vertices[1])
edge_sb= "{0} {1}".format(edge.vertices[1]), edge.vertices[0]) edge_sb= "{0} {1}".format(edge.vertices[1], edge.vertices[0])
if edge_sa in layer_data.edge_weights: if edge_sa in layer_data.edge_weights:
edge.crease= layer_data.edge_weights[edge_sa] edge.crease= layer_data.edge_weights[edge_sa]
elif edge_sb in layer_data.edge_weights: elif edge_sb in layer_data.edge_weights:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment