diff --git a/src/io_scene_vrm/exporter/vrm0_exporter.py b/src/io_scene_vrm/exporter/vrm0_exporter.py index 29fe05683..b0303effa 100644 --- a/src/io_scene_vrm/exporter/vrm0_exporter.py +++ b/src/io_scene_vrm/exporter/vrm0_exporter.py @@ -2852,23 +2852,31 @@ def write_mesh_node( parent_node_index = None parent_translation = None - if ( - obj.parent_type in ["ARMATURE", "OBJECT"] - and (parent := self.get_export_parent_object(obj, mesh_convertible_objects)) - and parent in self.export_objects - ): - # TODO: 互換性のためネストしたメッシュを復元しないが、将来的には復元する - # parent_translation = parent.matrix_world.to_translation() - # parent_node_index = object_name_to_node_index.get(parent.name) + if have_skin: + # スキンがある場合はシーンのルートノードになる pass + else: + if ( + obj.parent_type in ["ARMATURE", "OBJECT"] + and ( + parent := self.get_export_parent_object( + obj, mesh_convertible_objects + ) + ) + and parent in self.export_objects + ): + # TODO: 互換性のためネストしたメッシュを復元しないが、将来的には復元する + # parent_translation = parent.matrix_world.to_translation() + # parent_node_index = object_name_to_node_index.get(parent.name) + pass - if obj.parent_type == "BONE" and ( - bone := self.armature.pose.bones.get(obj.parent_bone) - ): - parent_translation = ( - self.armature.matrix_world @ bone.matrix - ).to_translation() - parent_node_index = bone_name_to_node_index.get(obj.parent_bone) + if obj.parent_type == "BONE" and ( + bone := self.armature.pose.bones.get(obj.parent_bone) + ): + parent_translation = ( + self.armature.matrix_world @ bone.matrix + ).to_translation() + parent_node_index = bone_name_to_node_index.get(obj.parent_bone) if parent_node_index is not None and 0 <= parent_node_index < len(node_dicts): parent_node_dict = node_dicts[parent_node_index] diff --git a/tests/resources/blend/skinned_mesh_parent_vrm0.blend b/tests/resources/blend/skinned_mesh_parent_vrm0.blend new file mode 100644 index 000000000..9096b67e9 Binary files /dev/null and b/tests/resources/blend/skinned_mesh_parent_vrm0.blend differ diff --git a/tests/resources/blend/skinned_mesh_parent_vrm1.blend b/tests/resources/blend/skinned_mesh_parent_vrm1.blend new file mode 100644 index 000000000..d41a69896 Binary files /dev/null and b/tests/resources/blend/skinned_mesh_parent_vrm1.blend differ diff --git a/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm0.vrm b/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm0.vrm new file mode 100644 index 000000000..109748e9d Binary files /dev/null and b/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm0.vrm differ diff --git a/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm1.vrm b/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm1.vrm new file mode 100644 index 000000000..35f65eda6 Binary files /dev/null and b/tests/resources/vrm/2.93/out/blend/skinned_mesh_parent_vrm1.vrm differ diff --git a/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm0.vrm b/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm0.vrm new file mode 100644 index 000000000..109748e9d Binary files /dev/null and b/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm0.vrm differ diff --git a/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm1.vrm b/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm1.vrm new file mode 100644 index 000000000..19df8df93 Binary files /dev/null and b/tests/resources/vrm/3.3/out/blend/skinned_mesh_parent_vrm1.vrm differ diff --git a/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm0.vrm b/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm0.vrm new file mode 100644 index 000000000..109748e9d Binary files /dev/null and b/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm0.vrm differ diff --git a/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm1.vrm b/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm1.vrm new file mode 100644 index 000000000..59e7bb090 Binary files /dev/null and b/tests/resources/vrm/3.6/out/blend/skinned_mesh_parent_vrm1.vrm differ diff --git a/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm0.vrm b/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm0.vrm new file mode 100644 index 000000000..109748e9d Binary files /dev/null and b/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm0.vrm differ diff --git a/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm1.vrm b/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm1.vrm new file mode 100644 index 000000000..ed2831eea Binary files /dev/null and b/tests/resources/vrm/4.2/out/blend/skinned_mesh_parent_vrm1.vrm differ