diff options
Diffstat (limited to 'io_scene_gltf2/blender/exp')
4 files changed, 40 insertions, 18 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index 87c9d426..0add794a 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py @@ -662,12 +662,16 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp # - vertex_group_index = group_element.group - vertex_group_name = blender_vertex_groups[vertex_group_index].name + joint_weight = group_element.weight + if joint_weight <= 0.0: + continue # - joint_index = 0 + vertex_group_index = group_element.group + vertex_group_name = blender_vertex_groups[vertex_group_index].name + + joint_index = None if modifiers is not None: modifiers_dict = {m.type: m for m in modifiers} @@ -677,12 +681,12 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp for index, j in enumerate(skin.joints): if j.name == vertex_group_name: joint_index = index - - joint_weight = group_element.weight + break # - joint.append(joint_index) - weight.append(joint_weight) + if joint_index is not None: + joint.append(joint_index) + weight.append(joint_weight) if len(joint) > 0: bone_count += 1 diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py index 217930e1..6a5a9947 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py @@ -32,7 +32,8 @@ def gather_gltf2(export_settings): animations = [] # unfortunately animations in gltf2 are just as 'root' as scenes. for blender_scene in bpy.data.scenes: scenes.append(__gather_scene(blender_scene, export_settings)) - animations += __gather_animations(blender_scene, export_settings) + if export_settings[gltf2_blender_export_keys.ANIMATIONS]: + animations += __gather_animations(blender_scene, export_settings) return scenes, animations 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 b6131a59..a694cac3 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py @@ -115,20 +115,35 @@ def __get_image_data(sockets_or_slots, export_settings): image = None for result, socket in zip(results, sockets_or_slots): # rudimentarily try follow the node tree to find the correct image data. - channel = None + source_channel = None + target_channel = None + source_channels_length = None for elem in result.path: if isinstance(elem.from_node, bpy.types.ShaderNodeSeparateRGB): - channel = { + source_channel = { 'R': 0, 'G': 1, 'B': 2 }[elem.from_socket.name] - if channel is not None: - pixels = [split_pixels_by_channels(result.shader_node.image, export_settings)[channel]] + if source_channel is not None: + pixels = [split_pixels_by_channels(result.shader_node.image, export_settings)[source_channel]] + target_channel = source_channel + source_channel = 0 + source_channels_length = 1 else: pixels = split_pixels_by_channels(result.shader_node.image, export_settings) - channel = 0 + target_channel = 0 + source_channel = 0 + source_channels_length = len(pixels) + + # Change target channel for metallic and roughness. + if elem.to_socket.name == 'Metallic': + target_channel = 2 + source_channels_length = 1 + elif elem.to_socket.name == 'Roughness': + target_channel = 1 + source_channels_length = 1 file_name = os.path.splitext(result.shader_node.image.name)[0] @@ -137,13 +152,15 @@ def __get_image_data(sockets_or_slots, export_settings): result.shader_node.image.filepath, result.shader_node.image.size[0], result.shader_node.image.size[1], - channel, + source_channel, + target_channel, + source_channels_length, pixels) if image is None: image = image_data else: - image.add_to_image(channel, image_data) + image.add_to_image(target_channel, image_data) return image elif __is_slot(sockets_or_slots): @@ -156,6 +173,8 @@ def __get_image_data(sockets_or_slots, export_settings): texture.image.size[0], texture.image.size[1], 0, + 0, + len(pixels), pixels) return image_data else: diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py index 4fa025b2..23d51fa6 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py @@ -73,9 +73,7 @@ def __gather_indices(blender_primitive, blender_mesh, modifiers, export_settings indices = blender_primitive['indices'] max_index = max(indices) - if max_index < (1 << 8): - component_type = gltf2_io_constants.ComponentType.UnsignedByte - elif max_index < (1 << 16): + if max_index < (1 << 16): component_type = gltf2_io_constants.ComponentType.UnsignedShort elif max_index < (1 << 32): component_type = gltf2_io_constants.ComponentType.UnsignedInt |