22import bmesh
33import os
44import io
5+ import mathutils
6+ import math
57from pathlib import Path
68from . 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