Browse Source

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?
pull/6/head
Adam Johnson 10 years ago
parent
commit
cd74bf6d27
  1. 16
      korman/exporter/mesh.py

16
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

Loading…
Cancel
Save