[Bf-extensions-cvs] [6706c91e] blender2.8: glTF: Fix light export + export options refactoring

Julien Duroure noreply at git.blender.org
Sun Dec 2 16:45:35 CET 2018


Commit: 6706c91ecf7dd759293b5a7e0b2b75e3c1d7c2e1
Author: Julien Duroure
Date:   Sun Dec 2 16:44:57 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBA6706c91ecf7dd759293b5a7e0b2b75e3c1d7c2e1

glTF: Fix light export + export options refactoring

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_export.py
M	io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
M	io_scene_gltf2/blender/exp/gltf2_blender_extract.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
M	io_scene_gltf2/io/exp/gltf2_io_export.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 5f226b52..f05e766a 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -72,44 +72,21 @@ class ExportGLTF2_Base:
 
     # TODO: refactor to avoid boilerplate
 
+    export_format: EnumProperty(
+        name='Format',
+        items=(('GLB', 'Binary (.glb)', 'Exports a single file, with all data packed in binary form. Most efficient and portable, but more difficult to edit later'),
+               ('GLTF', 'JSON (.gltf)', 'Exports a single file, with all data packed in JSON. Less efficient than binary, but easier to edit later'),
+               ('GLTF_SEPARATE', 'JSON (.gltf + .bin + textures)', 'Exports multiple files, with separate JSON (.gltf), binary (.bin), and texture data. Easiest to edit later')),
+        description='Output format and embedding options. Binary is most efficient, but JSON (embedded or separate) may be easier to edit later',
+        default='GLB'
+    )
+
     export_copyright: StringProperty(
         name='Copyright',
         description='Legal rights and conditions for the model',
         default=''
     )
 
-    export_embed_buffers: BoolProperty(
-        name='Embed Buffers',
-        description='Buffers (mesh, animation, and optionally image data) are' \
-            ' embedded in the asset, rather than in separate (.bin) files.' \
-            ' Total size will be slightly larger than when embedded within a ' \
-            ' binary glTF (.glb) file',
-        default=False
-    )
-
-    export_embed_images: BoolProperty(
-        name='Embed Images',
-        description='Images are embedded in asset buffers, rather than in' \
-            ' separate image files',
-        default=False
-    )
-
-    export_indices: EnumProperty(
-        name='Maximum Indices Type',
-        items=(('UNSIGNED_BYTE', 'Unsigned Byte', ''),
-               ('UNSIGNED_SHORT', 'Unsigned Short', ''),
-               ('UNSIGNED_INT', 'Unsigned Integer', '')),
-        description='Largest data type allowed for indices',
-        default='UNSIGNED_INT'
-    )
-
-    export_force_indices: BoolProperty(
-        name='Force Maximum Indices',
-        description='Always use the selected indices data type, even if the' \
-            ' size of the mesh does not require it',
-        default=False
-    )
-
     export_texcoords: BoolProperty(
         name='UVs',
         description='Export UVs (texture coordinates) with meshes',
@@ -309,6 +286,11 @@ class ExportGLTF2_Base:
         if self.will_save_settings:
             self.save_settings(context)
 
+        if self.export_format == 'GLB':
+            self.filename_ext = '.glb'
+        else:
+            self.filename_ext = '.gltf'
+
         # All custom export settings are stored in this container.
         export_settings = {}
 
@@ -319,10 +301,6 @@ class ExportGLTF2_Base:
 
         export_settings['gltf_format'] = self.export_format
         export_settings['gltf_copyright'] = self.export_copyright
-        export_settings['gltf_embed_buffers'] = self.export_embed_buffers
-        export_settings['gltf_embed_images'] = self.export_embed_images
-        export_settings['gltf_indices'] = self.export_indices
-        export_settings['gltf_force_indices'] = self.export_force_indices
         export_settings['gltf_texcoords'] = self.export_texcoords
         export_settings['gltf_normals'] = self.export_normals
         export_settings['gltf_tangents'] = self.export_tangents and self.export_normals
@@ -378,27 +356,17 @@ class ExportGLTF2_Base:
         #
 
         col = layout.box().column()
-        col.label(text='Embedding:')  # , icon='PACKAGE')
-        col.prop(self, 'export_copyright')
-        if self.export_format == 'ASCII':
-            col.prop(self, 'export_embed_buffers')
-            col.prop(self, 'export_embed_images')
-
-        col = layout.box().column()
-        col.label(text='Nodes:')  # , icon='OOPS')
+        col.label(text='General:', icon='PREFERENCES')
+        col.prop(self, 'export_format')
         col.prop(self, 'export_selected')
         #col.prop(self, 'export_layers')
-        col.prop(self, 'export_extras')
-        col.prop(self, 'export_yup')
-
-        col = layout.box().column()
-        col.label(text='Meshes:')  # , icon='MESH_DATA')
         col.prop(self, 'export_apply')
-        col.prop(self, 'export_indices')
-        col.prop(self, 'export_force_indices')
+        col.prop(self, 'export_yup')
+        col.prop(self, 'export_extras')
+        col.prop(self, 'export_copyright')
 
         col = layout.box().column()
-        col.label(text='Attributes:')  # , icon='SURFACE_DATA')
+        col.label(text='Meshes:', icon='MESH_DATA')
         col.prop(self, 'export_texcoords')
         col.prop(self, 'export_normals')
         if self.export_normals:
@@ -406,20 +374,17 @@ class ExportGLTF2_Base:
         col.prop(self, 'export_colors')
 
         col = layout.box().column()
-        col.label(text='Objects:')  # , icon='OBJECT_DATA')
+        col.label(text='Objects:', icon='OBJECT_DATA')
         col.prop(self, 'export_cameras')
+        col.prop(self, 'export_lights')
 
         col = layout.box().column()
-        col.label(text='Materials:')  # , icon='MATERIAL_DATA')
+        col.label(text='Materials:', icon='MATERIAL_DATA')
         col.prop(self, 'export_materials')
         col.prop(self, 'export_texture_transform')
 
         col = layout.box().column()
-        col.label(text='Lights:')  # , icon='LIGHT_DATA')
-        col.prop(self, 'export_lights')
-
-        col = layout.box().column()
-        col.label(text='Animation:')  # , icon='OUTLINER_DATA_POSE')
+        col.label(text='Animation:', icon='ARMATURE_DATA')
         col.prop(self, 'export_animations')
         if self.export_animations:
             col.prop(self, 'export_frame_range')
@@ -444,40 +409,26 @@ class ExportGLTF2_Base:
             text=GLTF2ExportSettings.bl_label,
             icon="%s" % "PINNED" if self.will_save_settings else "UNPINNED")
 
-# TODO: refactor operators to single operator for both cases
 
-class ExportGLTF2_GLTF(bpy.types.Operator, ExportGLTF2_Base, ExportHelper):
+class ExportGLTF2(bpy.types.Operator, ExportGLTF2_Base, ExportHelper):
     """Export scene as glTF 2.0 file"""
     bl_idname = 'export_scene.gltf'
-    bl_label = 'Export glTF 2.0'
-
-    filename_ext = '.gltf'
-    filter_glob: StringProperty(default='*.gltf', options={'HIDDEN'})
-
-    export_format = 'ASCII'
-
-
-class ExportGLTF2_GLB(bpy.types.Operator, ExportGLTF2_Base, ExportHelper):
-    """Export scene as binary glTF 2.0 file"""
-    bl_idname = 'export_scene.glb'
-    bl_label = 'Export Binary glTF 2.0'
+    bl_label = 'glTF 2.0 (.glb/.gltf)'
 
-    filename_ext = '.glb'
-    filter_glob: StringProperty(default='*.glb', options={'HIDDEN'})
+    filename_ext = ''
 
-    export_format = 'BINARY'
+    filter_glob: StringProperty(default='*.glb;*.gltf', options={'HIDDEN'})
 
 
 def menu_func_export(self, context):
-    self.layout.operator(ExportGLTF2_GLTF.bl_idname, text='glTF 2.0 (.gltf)')
-    self.layout.operator(ExportGLTF2_GLB.bl_idname, text='Binary glTF 2.0 (.glb)')
+    self.layout.operator(ExportGLTF2.bl_idname, text='glTF 2.0 (.glb/.gltf)')
 
 
-class ImportglTF2(Operator, ImportHelper):
+class ImportGLTF2(Operator, ImportHelper):
     bl_idname = 'import_scene.gltf'
-    bl_label = "glTF 2.0 (.gltf/.glb)"
+    bl_label = 'glTF 2.0 (.glb/.gltf)'
 
-    filter_glob: StringProperty(default="*.gltf;*.glb", options={'HIDDEN'})
+    filter_glob: StringProperty(default="*.glb;*.gltf", options={'HIDDEN'})
 
     loglevel: EnumProperty(items=Log.get_levels(), name="Log Level", default=Log.default())
 
@@ -531,14 +482,13 @@ class ImportglTF2(Operator, ImportHelper):
 
 
 def menu_func_import(self, context):
-    self.layout.operator(ImportglTF2.bl_idname, text=ImportglTF2.bl_label)
+    self.layout.operator(ImportGLTF2.bl_idname, text=ImportGLTF2.bl_label)
 
 
 classes = (
     GLTF2ExportSettings,
-    ExportGLTF2_GLTF,
-    ExportGLTF2_GLB,
-    ImportglTF2
+    ExportGLTF2,
+    ImportGLTF2
 )
 
 
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export.py b/io_scene_gltf2/blender/exp/gltf2_blender_export.py
index ae2db26b..1adbe473 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_export.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_export.py
@@ -43,9 +43,9 @@ def save(operator,
         exporter.add_animation(animation)
 
     buffer = bytes()
-    if export_settings[gltf2_blender_export_keys.FORMAT] == 'ASCII':
+    if export_settings[gltf2_blender_export_keys.FORMAT] != 'GLB':
         # .gltf
-        if export_settings[gltf2_blender_export_keys.EMBED_BUFFERS]:
+        if export_settings[gltf2_blender_export_keys.FORMAT] == 'GLTF':
             exporter.finalize_buffer(export_settings[gltf2_blender_export_keys.FILE_DIRECTORY])
         else:
             exporter.finalize_buffer(export_settings[gltf2_blender_export_keys.FILE_DIRECTORY],
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
index 06271a04..ca9ca139 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
@@ -39,13 +39,11 @@ FILE_DIRECTORY = 'gltf_filedirectory'
 BINARY_FILENAME = 'gltf_binaryfilename'
 YUP = 'gltf_yup'
 MORPH = 'gltf_morph'
-INDICES = 'gltf_indices'
 BAKE_SKINS = 'gltf_bake_skins'
 TEX_COORDS = 'gltf_texcoords'
 COLORS = 'gltf_colors'
 NORMALS = 'gltf_normals'
 TANGENTS = 'gltf_tangents'
-FORCE_INDICES = 'gltf_force_indices'
 MORPH_TANGENT = 'gltf_morph_tangent'
 MORPH_NORMAL = 'gltf_morph_normal'
 MOVE_KEYFRAMES = 'gltf_move_keyframes'
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index a5220129..c26429d3 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -970,10 +970,6 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
         #
 
         range_indices = 65536
-        if export_settings[gltf2_blender_export_keys.INDICES] == 'UNSIGNED_BYT

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list