|
|
@ -255,19 +255,27 @@ class MeshConverter: |
|
|
|
drawables = self._export_mesh(bo) |
|
|
|
drawables = self._export_mesh(bo) |
|
|
|
|
|
|
|
|
|
|
|
# Create the DrawInterface |
|
|
|
# Create the DrawInterface |
|
|
|
|
|
|
|
if drawables: |
|
|
|
diface = self._mgr.add_object(pl=plDrawInterface, bl=bo) |
|
|
|
diface = self._mgr.add_object(pl=plDrawInterface, bl=bo) |
|
|
|
for dspan_key, idx in drawables: |
|
|
|
for dspan_key, idx in drawables: |
|
|
|
diface.addDrawable(dspan_key, idx) |
|
|
|
diface.addDrawable(dspan_key, idx) |
|
|
|
|
|
|
|
|
|
|
|
def _export_mesh(self, bo): |
|
|
|
def _export_mesh(self, bo): |
|
|
|
# Step 0.8: If this mesh wants to be lit, we need to go ahead and generate it. |
|
|
|
# Step 0.7: Update the mesh such that we can do things and schtuff... |
|
|
|
|
|
|
|
mesh = bo.to_mesh(bpy.context.scene, True, "RENDER", calc_tessface=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Step 0.8: Figure out which materials are attached to this object. Because Blender is backwards, |
|
|
|
|
|
|
|
# we can actually have materials that are None. gotdawgit!!! |
|
|
|
|
|
|
|
materials = [i for i in mesh.materials if i is not None] |
|
|
|
|
|
|
|
if not materials: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Step 0.9: If this mesh wants to be lit, we need to go ahead and generate it. |
|
|
|
self._export_static_lighting(bo) |
|
|
|
self._export_static_lighting(bo) |
|
|
|
|
|
|
|
|
|
|
|
# Step 0.9: Update the mesh such that we can do things and schtuff... |
|
|
|
|
|
|
|
mesh = bo.to_mesh(bpy.context.scene, True, "RENDER", calc_tessface=True) |
|
|
|
|
|
|
|
with helpers.TemporaryObject(mesh, bpy.data.meshes.remove): |
|
|
|
with helpers.TemporaryObject(mesh, bpy.data.meshes.remove): |
|
|
|
# Step 1: Export all of the doggone materials. |
|
|
|
# Step 1: Export all of the doggone materials. |
|
|
|
geospans = self._export_material_spans(bo, mesh) |
|
|
|
geospans = self._export_material_spans(bo, mesh, materials) |
|
|
|
|
|
|
|
|
|
|
|
# Step 2: Export Blender mesh data to Plasma GeometrySpans |
|
|
|
# Step 2: Export Blender mesh data to Plasma GeometrySpans |
|
|
|
self._export_geometry(bo, mesh, geospans) |
|
|
|
self._export_geometry(bo, mesh, geospans) |
|
|
@ -292,10 +300,10 @@ class MeshConverter: |
|
|
|
drawables.append((dspan.key, idx)) |
|
|
|
drawables.append((dspan.key, idx)) |
|
|
|
return drawables |
|
|
|
return drawables |
|
|
|
|
|
|
|
|
|
|
|
def _export_material_spans(self, bo, mesh): |
|
|
|
def _export_material_spans(self, bo, mesh, materials): |
|
|
|
"""Exports all Materials and creates plGeometrySpans""" |
|
|
|
"""Exports all Materials and creates plGeometrySpans""" |
|
|
|
geospans = [None] * len(mesh.materials) |
|
|
|
geospans = [None] * len(materials) |
|
|
|
for i, blmat in enumerate(mesh.materials): |
|
|
|
for i, blmat in enumerate(materials): |
|
|
|
matKey = self.material.export_material(bo, blmat) |
|
|
|
matKey = self.material.export_material(bo, blmat) |
|
|
|
geospans[i] = (self._create_geospan(bo, mesh, blmat, matKey), blmat.pass_index) |
|
|
|
geospans[i] = (self._create_geospan(bo, mesh, blmat, matKey), blmat.pass_index) |
|
|
|
return geospans |
|
|
|
return geospans |
|
|
|