def loadObjFile(context, filename): # # remember all objects # oldnames = [] for obj in context.scene.objects: oldnames.append(obj.name) global_matrix = (Matrix.Scale(1.0, 4) @ axis_conversion( from_forward='-Y', to_forward='-Z', from_up='Z', to_up='-Y', ).to_4x4()) import_obj.load(context, filename, use_split_objects=False, use_groups_as_vgroups=True, global_matrix=global_matrix) # # get all objects and figure out the new mesh # for obj in context.scene.objects: if obj.name not in oldnames: context.view_layer.objects.active = obj bpy.ops.object.shade_smooth() bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) return (obj) return (None)
def buildMesh(filepath): import os.path from io_scene_obj import import_obj import bpy (header, materials, indices, vertices) = importSKN(filepath) if header['numMaterials'] > 0 and materials[0]['matIndex'] == 2: print('ERROR: Skins with matIndex = 2 are currently unreadable. Exiting') return {'FINISHED'} objStr = skn2obj(header, materials, indices, vertices) objFile = os.path.splitext(filepath)[0]+'.obj' objFid = open(objFile, 'w') objFid.write(objStr) objFid.close() context = dummyContext() context.scene = bpy.data.scenes[0] import_obj.load(None, context, objFile, CREATE_FGONS=False, CREATE_SMOOTH_GROUPS = False, CREATE_EDGES = False, SPLIT_OBJECTS = False, SPLIT_GROUPS = False, ROTATE_X90 = False, IMAGE_SEARCH=False, POLYGROUPS = False)
def execute(self, context): global_matrix = (Matrix.Scale(1.0, 4) * axis_conversion( from_forward='-Y', to_forward='-Z', from_up='Z', to_up='-Y', ).to_4x4()) return import_obj.load(context, self.properties.filepath, use_split_objects=False, use_split_groups=False, use_groups_as_vgroups=True, global_matrix=global_matrix)