[Bf-extensions-cvs] [74dbec77] blender2.8: glTF addon: updates from upstream
Julien Duroure
noreply at git.blender.org
Tue Nov 27 21:00:22 CET 2018
Commit: 74dbec774ef5e10f1b3475682efe286da8fed4cc
Author: Julien Duroure
Date: Tue Nov 27 20:59:55 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBA74dbec774ef5e10f1b3475682efe286da8fed4cc
glTF addon: updates from upstream
* invalidate cache for multiple exports
* exporter: support KHR_lights_punctual
* fixed lights
* disable export all layers
* fixed texture slot images stalling export
* option to enable exporting more than 4 influences
from upsteam commit 26699c476211add92d13df0a284b8df2f08acb3e
to upstream commit 7a8f733fc446cfb3880a8c1658bccf94bcfd456c
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
A io_scene_gltf2/blender/exp/gltf2_blender_gather_light_spots.py
A io_scene_gltf2/blender/exp/gltf2_blender_gather_lights.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
M io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py
M io_scene_gltf2/blender/exp/gltf2_blender_search_node_tree.py
A io_scene_gltf2/io/com/gltf2_io_extensions.py
A io_scene_gltf2/io/com/gltf2_io_lights_punctual.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 804d0159..4a5344d8 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -18,6 +18,7 @@
import os
import bpy
+import datetime
from bpy_extras.io_utils import ImportHelper, ExportHelper
from bpy.types import Operator, AddonPreferences
@@ -158,11 +159,11 @@ class ExportGLTF2_Base:
default=False
)
- export_layers: BoolProperty(
- name='Export all layers',
- description='',
- default=True
- )
+ # export_layers: BoolProperty(
+ # name='Export all layers',
+ # description='',
+ # default=True
+ # )
export_extras: BoolProperty(
name='Export extras',
@@ -232,6 +233,12 @@ class ExportGLTF2_Base:
default=False
)
+ export_all_influences: BoolProperty(
+ name='Export all bone influences',
+ description='Export more than four joint vertex influences',
+ default=False
+ )
+
export_morph: BoolProperty(
name='Export morphing',
description='',
@@ -307,6 +314,8 @@ class ExportGLTF2_Base:
# All custom export settings are stored in this container.
export_settings = {}
+ export_settings['timestamp'] = datetime.datetime.now()
+
export_settings['gltf_filepath'] = bpy.path.ensure_ext(self.filepath, self.filename_ext)
export_settings['gltf_filedirectory'] = os.path.dirname(export_settings['gltf_filepath']) + '/'
@@ -328,7 +337,7 @@ class ExportGLTF2_Base:
else:
export_settings['gltf_camera_infinite'] = False
export_settings['gltf_selected'] = self.export_selected
- export_settings['gltf_layers'] = self.export_layers
+ export_settings['gltf_layers'] = True #self.export_layers
export_settings['gltf_extras'] = self.export_extras
export_settings['gltf_yup'] = self.export_yup
export_settings['gltf_apply'] = self.export_apply
@@ -346,8 +355,10 @@ class ExportGLTF2_Base:
export_settings['gltf_skins'] = self.export_skins
if self.export_skins:
export_settings['gltf_bake_skins'] = self.export_bake_skins
+ export_settings['gltf_all_vertex_influences'] = self.export_all_influences
else:
export_settings['gltf_bake_skins'] = False
+ export_settings['gltf_all_vertex_influences'] = False
export_settings['gltf_frame_step'] = self.export_frame_step
export_settings['gltf_morph'] = self.export_morph
if self.export_morph:
@@ -384,7 +395,7 @@ class ExportGLTF2_Base:
col = layout.box().column()
col.label(text='Nodes:') # , icon='OOPS')
col.prop(self, 'export_selected')
- col.prop(self, 'export_layers')
+ #col.prop(self, 'export_layers')
col.prop(self, 'export_extras')
col.prop(self, 'export_yup')
@@ -413,6 +424,10 @@ class ExportGLTF2_Base:
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.prop(self, 'export_animations')
@@ -426,19 +441,13 @@ class ExportGLTF2_Base:
col.prop(self, 'export_skins')
if self.export_skins:
col.prop(self, 'export_bake_skins')
+ col.prop(self, 'export_all_influences')
col.prop(self, 'export_morph')
if self.export_morph:
col.prop(self, 'export_morph_normal')
if self.export_morph_normal:
col.prop(self, 'export_morph_tangent')
- addon_prefs = context.user_preferences.addons[__name__].preferences
- if addon_prefs.experimental:
- col = layout.box().column()
- col.label(text='Experimental:') # , icon='RADIO')
- col.prop(self, 'export_lights')
- col.prop(self, 'export_displacement')
-
row = layout.row()
row.operator(
GLTF2ExportSettings.bl_idname,
@@ -474,16 +483,6 @@ def menu_func_export(self, context):
self.layout.operator(ExportGLTF2_GLB.bl_idname, text='Binary glTF 2.0 (.glb)')
-class ExportGLTF2_AddonPreferences(AddonPreferences):
- bl_idname = __name__
-
- experimental: BoolProperty(name='Enable experimental glTF export settings', default=False)
-
- def draw(self, context):
- layout = self.layout
- layout.prop(self, "experimental")
-
-
class ImportglTF2(Operator, ImportHelper):
bl_idname = 'import_scene.gltf'
bl_label = "glTF 2.0 (.gltf/.glb)"
@@ -549,7 +548,6 @@ classes = (
GLTF2ExportSettings,
ExportGLTF2_GLTF,
ExportGLTF2_GLB,
- ExportGLTF2_AddonPreferences,
ImportglTF2
)
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
index 4941ffe2..b89f51d7 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
@@ -98,7 +98,7 @@ def __get_image_data(sockets_or_slots):
# For shared ressources, such as images, we just store the portion of data that is needed in the glTF property
# in a helper class. During generation of the glTF in the exporter these will then be combined to actual binary
# ressources.
- def split_pixels_by_channels(image: bpy.types.Image) -> typing.Iterable[typing.Iterable[float]]:
+ def split_pixels_by_channels(image: bpy.types.Image) -> typing.List[typing.List[float]]:
pixels = np.array(image.pixels)
pixels = pixels.reshape((pixels.shape[0] // image.channels, image.channels))
channels = np.split(pixels, pixels.shape[1], axis=1)
@@ -139,7 +139,7 @@ def __get_image_data(sockets_or_slots):
return image
elif __is_slot(sockets_or_slots):
texture = __get_tex_from_slot(sockets_or_slots[0])
- pixels = texture.image.pixels
+ pixels = split_pixels_by_channels(texture.image)
image_data = gltf2_io_image_data.ImageData(
texture.name,
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_light_spots.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_light_spots.py
new file mode 100644
index 00000000..6b1f95e2
--- /dev/null
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_light_spots.py
@@ -0,0 +1,50 @@
+# Copyright 2018 The glTF-Blender-IO authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import bpy
+from typing import Optional, List, Any
+
+from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached
+
+from io_scene_gltf2.io.com import gltf2_io_lights_punctual
+from io_scene_gltf2.io.com import gltf2_io_debug
+
+
+def gather_light_spot(blender_lamp, export_settings) -> Optional[gltf2_io_lights_punctual.LightSpot]:
+
+ if not __filter_light_spot(blender_lamp, export_settings):
+ return None
+
+ spot = gltf2_io_lights_punctual.LightSpot(
+ inner_cone_angle=__gather_inner_cone_angle(blender_lamp, export_settings),
+ outer_cone_angle=__gather_outer_cone_angle(blender_lamp, export_settings)
+ )
+ return spot
+
+
+def __filter_light_spot(blender_lamp, _) -> bool:
+ if blender_lamp.type != "SPOT":
+ return False
+
+ return True
+
+
+def __gather_inner_cone_angle(blender_lamp, _) -> Optional[float]:
+ angle = blender_lamp.spot_size * 0.5
+ return angle - angle * blender_lamp.spot_blend
+
+
+def __gather_outer_cone_angle(blender_lamp, _) -> Optional[float]:
+ return blender_lamp.spot_size * 0.5
+
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_lights.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_lights.py
new file mode 100644
index 00000000..5cc3dc62
--- /dev/null
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_lights.py
@@ -0,0 +1,131 @@
+# Copyright 2018 The glTF-Blender-IO authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import bpy
+import math
+from typing import Optional, List, Dict, Any
+
+from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached
+
+from io_scene_gltf2.io.com import gltf2_io_lights_punctual
+from io_scene_gltf2.io.com import gltf2_io_debug
+
+from io_scene_gltf2.blender.exp import gltf2_blender_gather_light_spots
+from io_scene_gltf2.blender.exp import gltf2_blender_search_node_tree
+
+ at cached
+def gather_lights_punctual(blender_lamp, export_settings) -> Optional[Dict[str, Any]]:
+ if not __filter_lights_punctual(blender_lamp, export_settings):
+ return None
+
+ light = gltf2_io_lights_punctual.Light(
+ color=__gather_color(blender_lamp, export_settings),
+ intensity=__gather_intensity(blender_lamp, export_settings),
+ spot=__gather_spot(blender_lamp, export_settings),
+ type=__gather_type(blender_lamp, export_settings),
+ range=__gather_range(blender_lamp, export_settings),
+ name=__gather_name(blender_lamp, export_settings),
+ extensions=__gather_extensions(blender_lamp, export_settings),
+ extr
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list