1- import bpy
2- import bmesh
1+ from pathlib import Path
32import os
43import io
5- import mathutils
64import math
7- from pathlib import Path
5+
6+ import bpy
7+ import bmesh
8+ import mathutils
89from . import (pdx_data , utils )
910
1011class PdxFileExporter :
12+ """File Exporter Class"""
1113 def __init__ (self , filename ):
1214 self .filename = filename
1315
1416 def export_mesh (self , name ):
1517 objects = []
16-
18+
1719 objects .append (pdx_data .PdxAsset ())
18-
20+
1921 world = pdx_data .PdxWorld ([])
2022
2123 if name .endswith ("MeshShape" ):
@@ -43,7 +45,7 @@ def export_mesh(self, name):
4345 for i in range (0 , len (bm .verts )):
4446 verts .append (bm .verts [i ].co * bpy .data .objects [name ].matrix_world )
4547 bm .verts [i ].normal_update ()
46- normal_temp = bm .verts [i ].normal
48+ normal_temp = bm .verts [i ].normal * bpy . data . objects [ name ]. matrix_world
4749 normal_temp .normalize ()
4850 normals .append (normal_temp )
4951
@@ -61,7 +63,7 @@ def export_mesh(self, name):
6163
6264 for face in bm .faces :
6365 for loop in face .loops :
64- uv_coords .append ((0 ,0 ))
66+ uv_coords .append ((0 , 0 ))
6567
6668 for face in bm .faces :
6769 for loop in face .loops :
@@ -103,17 +105,17 @@ def export_mesh(self, name):
103105 for mat_slot in bpy .data .objects [name ].material_slots :
104106 for mtex_slot in mat_slot .material .texture_slots :
105107 if mtex_slot :
106- if hasattr (mtex_slot .texture , 'image' ):
108+ if hasattr (mtex_slot .texture , 'image' ):
107109 if mtex_slot .texture .image is None :
108110 bpy .ops .error .message ('INVOKE_SCREEN' ,
109- message = "The Texture Image file is not loaded" )
111+ message = "The Texture Image file is not loaded" )
110112 else :
111113 diff_file = os .path .basename (mtex_slot .texture .image .filepath )
112114 else :
113115 diff_file = os .path .basename (bpy .data .meshes [name ].uv_textures [0 ].data [0 ].image .filepath )
114116
115117 mesh .material .shaders = "PdxMeshShip"
116- mesh .material .diffs = diff_file
118+ mesh .material .diffs = diff_file
117119 mesh .material .specs = "test_spec"
118120 mesh .material .normals = "test_normal"
119121
@@ -131,10 +133,10 @@ def export_mesh(self, name):
131133 world .objects .append (locators )
132134 objects .append (world )
133135
134- f = io .open (self .filename , 'wb' )
136+ result_file = io .open (self .filename , 'wb' )
135137
136- f .write (b'@@b@' )
138+ result_file .write (b'@@b@' )
137139 for i in range (0 , len (objects )):
138- f .write (objects [i ].get_binary_data ())
140+ result_file .write (objects [i ].get_binary_data ())
139141
140- f .close ()
142+ result_file .close ()
0 commit comments