Skip to content

Commit f1712e5

Browse files
Merge pull request #4 from WebsiteDeveloper/tesselate-meshes
Tesselate meshes
2 parents b2e48ae + 68cbb86 commit f1712e5

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
1 KB
Binary file not shown.

import-export-clausewitz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "Clausewitz Import/Export",
99
"category": "Import-Export",
1010
"author": "Bernhard Sirlinger",
11-
"version": (0, 3, 1),
11+
"version": (0, 3, 3),
1212
"blender": (2, 78, 0),
1313
"support": "TESTING",
1414
"wiki_url": "https://github.com/WebsiteDeveloper/ClausewitzBlenderPlugin/wiki",

import-export-clausewitz/exporter.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import bmesh
33
import os
44
import io
5+
import mathutils
6+
import math
57
from pathlib import Path
68
from . import (pdx_data, utils)
79

@@ -28,6 +30,7 @@ def export_mesh(self, name):
2830

2931
bm = bmesh.new()
3032
bm.from_mesh(blender_mesh)
33+
bmesh.ops.triangulate(bm, faces=bm.faces)
3134
bm.verts.ensure_lookup_table()
3235
bm.verts.index_update()
3336
bm.faces.index_update()
@@ -37,8 +40,17 @@ def export_mesh(self, name):
3740
verts = []
3841
tangents = []
3942

43+
transform = mathutils.Matrix()
44+
transform.identity()
45+
transform[0][0] = bpy.data.objects[name].scale[0]
46+
transform[1][1] = bpy.data.objects[name].scale[1]
47+
transform[2][2] = bpy.data.objects[name].scale[2]
48+
print(transform)
49+
#mathutils.Matrix. Vector((1.0, 1.0, 1.0))
50+
51+
4052
for i in range(0, len(bm.verts)):
41-
verts.append(bm.verts[i].co)
53+
verts.append(bm.verts[i].co * transform)
4254
bm.verts[i].normal_update()
4355
bm.verts[i].normal.normalize()
4456
normals.append((0.0, 0.0, 0.0))
@@ -103,7 +115,7 @@ def export_mesh(self, name):
103115
print(mtex_slot.texture.name)
104116
diff_file = os.path.basename(mtex_slot.texture.image.filepath)
105117
else:
106-
diff_file = os.path.basename(bpy.data.meshes['Body'].uv_textures[0].data[0].image.filepath)
118+
diff_file = os.path.basename(bpy.data.meshes[name].uv_textures[0].data[0].image.filepath)
107119

108120
mesh.material.shaders = "PdxMeshShip"
109121
mesh.material.diffs = diff_file

0 commit comments

Comments
 (0)