diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2018-12-05 23:41:39 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2018-12-05 23:41:39 +0300 |
commit | 3087c4e458dc4e9fd016d2f17e37e0473ce5dce2 (patch) | |
tree | 32bbbf5c7f048f8e548cbe25958f81e43d72113b /io_scene_gltf2/blender/exp | |
parent | 0c494907cf799747fcd33171d1532839001dd729 (diff) |
glTF exporter: Options tweaks, image merging fixes
Diffstat (limited to 'io_scene_gltf2/blender/exp')
4 files changed, 19 insertions, 8 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py index ad9e7619..217930e1 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py @@ -18,6 +18,8 @@ from io_scene_gltf2.io.com import gltf2_io from io_scene_gltf2.blender.exp import gltf2_blender_gather_nodes from io_scene_gltf2.blender.exp import gltf2_blender_gather_animations from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached +from io_scene_gltf2.blender.exp import gltf2_blender_generate_extras +from io_scene_gltf2.blender.exp import gltf2_blender_export_keys def gather_gltf2(export_settings): @@ -39,7 +41,7 @@ def gather_gltf2(export_settings): def __gather_scene(blender_scene, export_settings): scene = gltf2_io.Scene( extensions=None, - extras=None, + extras=__gather_extras(blender_scene, export_settings), name=blender_scene.name, nodes=[] ) @@ -59,3 +61,9 @@ def __gather_animations(blender_scene, export_settings): animations += gltf2_blender_gather_animations.gather_animations(blender_object, export_settings) return animations + +def __gather_extras(blender_object, export_settings): + if export_settings[gltf2_blender_export_keys.EXTRAS]: + return gltf2_blender_generate_extras.generate_extras(blender_object) + return None + 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 d9cc17dc..d9583d08 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py @@ -48,7 +48,7 @@ def __filter_image(sockets_or_slots, export_settings): def __gather_buffer_view(sockets_or_slots, export_settings): - if export_settings[gltf2_blender_export_keys.FORMAT] != 'GLTF': + if export_settings[gltf2_blender_export_keys.FORMAT] != 'GLTF_SEPARATE': image = __get_image_data(sockets_or_slots) return gltf2_io_binary_data.BinaryData( data=image.to_image_data(__gather_mime_type(sockets_or_slots, export_settings))) @@ -79,7 +79,7 @@ def __gather_name(sockets_or_slots, export_settings): def __gather_uri(sockets_or_slots, export_settings): - if export_settings[gltf2_blender_export_keys.FORMAT] == 'GLTF': + if export_settings[gltf2_blender_export_keys.FORMAT] == 'GLTF_SEPARATE': # as usual we just store the data in place instead of already resolving the references return __get_image_data(sockets_or_slots) return None @@ -121,6 +121,7 @@ def __get_image_data(sockets_or_slots): pixels = [split_pixels_by_channels(result.shader_node.image)[channel]] else: pixels = split_pixels_by_channels(result.shader_node.image) + channel = 0 file_name = os.path.splitext(result.shader_node.image.name)[0] @@ -128,12 +129,13 @@ def __get_image_data(sockets_or_slots): file_name, result.shader_node.image.size[0], result.shader_node.image.size[1], + channel, pixels) if image is None: image = image_data else: - image.add_to_image(image_data) + image.add_to_image(channel, image_data) return image elif __is_slot(sockets_or_slots): @@ -144,6 +146,7 @@ def __get_image_data(sockets_or_slots): texture.name, texture.image.size[0], texture.image.size[1], + 0, pixels) return image_data else: diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py index 4e97f3a9..04b67da9 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py @@ -96,7 +96,7 @@ def __gather_double_sided(blender_material, export_settings): def __gather_emmissive_factor(blender_material, export_settings): emissive_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Emissive") - if isinstance(emissive_socket, bpy.types.NodeSocket): + if isinstance(emissive_socket, bpy.types.NodeSocket) and not emissive_socket.is_linked: return list(emissive_socket.default_value)[0:3] return None diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py index 7a567bc3..16b991f0 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py @@ -46,7 +46,7 @@ def __gather_base_color_factor(blender_material, export_settings): base_color_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Base Color") if base_color_socket is None: base_color_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "BaseColor") - if isinstance(base_color_socket, bpy.types.NodeSocket): + if isinstance(base_color_socket, bpy.types.NodeSocket) and not base_color_socket.is_linked: return list(base_color_socket.default_value) return None @@ -67,7 +67,7 @@ def __gather_extras(blender_material, export_settings): def __gather_metallic_factor(blender_material, export_settings): metallic_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Metallic") - if isinstance(metallic_socket, bpy.types.NodeSocket): + if isinstance(metallic_socket, bpy.types.NodeSocket) and not metallic_socket.is_linked: return metallic_socket.default_value return None @@ -87,7 +87,7 @@ def __gather_metallic_roughness_texture(blender_material, export_settings): def __gather_roughness_factor(blender_material, export_settings): roughness_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Roughness") - if isinstance(roughness_socket, bpy.types.NodeSocket): + if isinstance(roughness_socket, bpy.types.NodeSocket) and not roughness_socket.is_linked: return roughness_socket.default_value return None |