Create mesh object for any model with geometry regardless of type + triangle strip winding order bugfix

This commit is contained in:
William Herald Snyder 2022-09-28 14:05:37 -04:00
parent 9bd8479e31
commit aa8f05dd42
2 changed files with 4 additions and 2 deletions

View File

@ -85,9 +85,11 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
if segment.triangles:
segment_polygons = [tuple([ind + polygon_index_offset for ind in tri]) for tri in segment.triangles]
elif segment.triangle_strips:
winding = [0,1,2]
rwinding = [1,0,2]
for strip in segment.triangle_strips:
for i in range(len(strip) - 2):
strip_tri = tuple([polygon_index_offset + strip[j] for j in range(i,i+3)])
strip_tri = tuple([polygon_index_offset + strip[i+j] for j in (winding if i % 2 == 0 else rwinding)])
segment_polygons.append(strip_tri)
elif segment.polygons:
segment_polygons = [tuple([ind + polygon_index_offset for ind in polygon]) for polygon in segment.polygons]

View File

@ -122,7 +122,7 @@ def extract_models(scene: Scene, materials_map : Dict[str, bpy.types.Material])
new_obj = None
if model.model_type == ModelType.STATIC or model.model_type == ModelType.SKIN or model.model_type == ModelType.SHADOWVOLUME:
if model.geometry:
new_obj = model_to_mesh_object(model, scene, materials_map)