Create mesh object for any model with geometry regardless of type + triangle strip winding order bugfix
This commit is contained in:
parent
9bd8479e31
commit
aa8f05dd42
|
@ -85,9 +85,11 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
||||||
if segment.triangles:
|
if segment.triangles:
|
||||||
segment_polygons = [tuple([ind + polygon_index_offset for ind in tri]) for tri in segment.triangles]
|
segment_polygons = [tuple([ind + polygon_index_offset for ind in tri]) for tri in segment.triangles]
|
||||||
elif segment.triangle_strips:
|
elif segment.triangle_strips:
|
||||||
|
winding = [0,1,2]
|
||||||
|
rwinding = [1,0,2]
|
||||||
for strip in segment.triangle_strips:
|
for strip in segment.triangle_strips:
|
||||||
for i in range(len(strip) - 2):
|
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)
|
segment_polygons.append(strip_tri)
|
||||||
elif segment.polygons:
|
elif segment.polygons:
|
||||||
segment_polygons = [tuple([ind + polygon_index_offset for ind in polygon]) for polygon in segment.polygons]
|
segment_polygons = [tuple([ind + polygon_index_offset for ind in polygon]) for polygon in segment.polygons]
|
||||||
|
|
|
@ -122,7 +122,7 @@ def extract_models(scene: Scene, materials_map : Dict[str, bpy.types.Material])
|
||||||
|
|
||||||
new_obj = None
|
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)
|
new_obj = model_to_mesh_object(model, scene, materials_map)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue