From cd74bf6d2764001f693dd1307443a7f7cdf99136 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 18 Jun 2015 14:08:06 -0400 Subject: [PATCH] Fix exporting objects with multiple materials Previously, it appeared visually that only one material was applied to the mesh. Appearances can be deceiving. We were actually exporting all materials and such correctly. However, because we were using a dyanmic type with class attributes to store per-material data... All materials shared all data. So, all materials rendered all vertices. You saw visually the one last material rendered. Fun, eh? --- korman/exporter/mesh.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index 9b0ce42..db60c0b 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -90,6 +90,13 @@ class _DrawableCriteria: return "Spans" +class _GeoData: + def __init__(self, numVtxs): + self.blender2gs = [{} for i in range(numVtxs)] + self.triangles = [] + self.vertices = [] + + class MeshConverter: def __init__(self, exporter): self._exporter = weakref.ref(exporter) @@ -146,14 +153,7 @@ class MeshConverter: print(" Bounds and SpaceTree in the saddle") def _export_geometry(self, bo, mesh, geospans): - _geodatacls = type("_GeoData", - (object,), - { - "blender2gs": [{} for i in mesh.vertices], - "triangles": [], - "vertices": [] - }) - geodata = [_geodatacls() for i in mesh.materials] + geodata = [_GeoData(len(mesh.vertices)) for i in mesh.materials] # Locate relevant vertex color layers now... color, alpha = None, None