diff options
Diffstat (limited to 'io_scene_gltf2/__init__.py')
-rwxr-xr-x | io_scene_gltf2/__init__.py | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 2d44644b..8b7439e0 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (1, 0, 5), + "version": (1, 1, 0), 'blender': (2, 81, 6), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -57,7 +57,8 @@ import bpy from bpy.props import (StringProperty, BoolProperty, EnumProperty, - IntProperty) + IntProperty, + CollectionProperty) from bpy.types import Operator from bpy_extras.io_utils import ImportHelper, ExportHelper @@ -256,6 +257,12 @@ class ExportGLTF2_Base: default=True ) + export_def_bones: BoolProperty( + name='Export Deformation bones only', + description='Export Deformation bones only (and needed bones for hierarchy)', + default=False + ) + export_current_frame: BoolProperty( name='Use Current Frame', description='Export the scene in the current animation frame', @@ -389,11 +396,16 @@ class ExportGLTF2_Base: if self.export_animations: export_settings['gltf_frame_range'] = self.export_frame_range export_settings['gltf_force_sampling'] = self.export_force_sampling + if self.export_force_sampling: + export_settings['gltf_def_bones'] = self.export_def_bones + else: + export_settings['gltf_def_bones'] = False export_settings['gltf_nla_strips'] = self.export_nla_strips else: export_settings['gltf_frame_range'] = False export_settings['gltf_move_keyframes'] = False export_settings['gltf_force_sampling'] = False + export_settings['gltf_def_bones'] = False export_settings['gltf_skins'] = self.export_skins if self.export_skins: export_settings['gltf_all_vertex_influences'] = self.export_all_influences @@ -642,6 +654,10 @@ class GLTF_PT_export_animation_export(bpy.types.Panel): layout.prop(operator, 'export_force_sampling') layout.prop(operator, 'export_nla_strips') + row = layout.row() + row.active = operator.export_force_sampling + row.prop(operator, 'export_def_bones') + class GLTF_PT_export_animation_shapekeys(bpy.types.Panel): bl_space_type = 'FILE_BROWSER' @@ -730,6 +746,11 @@ class ImportGLTF2(Operator, ImportHelper): filter_glob: StringProperty(default="*.glb;*.gltf", options={'HIDDEN'}) + files: CollectionProperty( + name="File Path", + type=bpy.types.OperatorFileListElement, + ) + loglevel: IntProperty( name='Log Level', description="Log Level") @@ -758,14 +779,30 @@ class ImportGLTF2(Operator, ImportHelper): return self.import_gltf2(context) def import_gltf2(self, context): - import time - from .io.imp.gltf2_io_gltf import glTFImporter - from .blender.imp.gltf2_blender_gltf import BlenderGlTF + import os self.set_debug_log() import_settings = self.as_keywords() - self.gltf_importer = glTFImporter(self.filepath, import_settings) + if self.files: + # Multiple file import + ret = {'CANCELLED'} + dirname = os.path.dirname(self.filepath) + for file in self.files: + path = os.path.join(dirname, file.name) + if self.unit_import(path, import_settings) == {'FINISHED'}: + ret = {'FINISHED'} + return ret + else: + # Single file import + return self.unit_import(self.filepath, import_settings) + + def unit_import(self, filename, import_settings): + import time + from .io.imp.gltf2_io_gltf import glTFImporter + from .blender.imp.gltf2_blender_gltf import BlenderGlTF + + self.gltf_importer = glTFImporter(filename, import_settings) success, txt = self.gltf_importer.read() if not success: self.report({'ERROR'}, txt) |