From 21a459846e204c76bd463a6e46baf059bd394565 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Tue, 12 Nov 2019 16:50:43 -0500 Subject: [PATCH] Fix bones that parent no children on dae export --- .../FileFormats/GFBMDL/GFBMDL.cs | 2 +- .../FileFormats/Assimp/AssimpSaver.cs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs b/File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs index 0117ba6f..d669a157 100644 --- a/File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs +++ b/File_Format_Library/FileFormats/GFBMDL/GFBMDL.cs @@ -327,7 +327,7 @@ namespace FirstPlugin if (Buffer.BoneIndex.Count > 0) vertex.boneIds = new List(Buffer.BoneIndex[v]); // if (Buffer.Colors1.Count > 0) - // vertex.col = Buffer.Colors1[v] / 255f; + // vertex.col = Buffer.Colors1[v] / 255f; if (Buffer.Binormals.Count > 0) vertex.bitan = Buffer.Binormals[v]; diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs index 34421caf..bf797572 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs @@ -616,14 +616,23 @@ namespace Toolbox.Library Node root = new Node("skeleton_root"); parentNode.Children.Add(root); + Console.WriteLine($"bones {skeleton.bones.Count}"); + if (skeleton.bones.Count > 0) { - Node boneNode = new Node(skeleton.bones[0].Text); - boneNode.Transform = AssimpHelper.GetBoneMatrix(skeleton.bones[0]); - root.Children.Add(boneNode); + foreach (var bone in skeleton.bones) + { + //Get each root bone and find children + if (bone.parentIndex == -1) + { + Node boneNode = new Node(bone.Text); + boneNode.Transform = AssimpHelper.GetBoneMatrix(bone); + root.Children.Add(boneNode); - foreach (STBone child in skeleton.bones[0].GetChildren()) - SaveBones(boneNode, child, skeleton); + foreach (STBone child in bone.GetChildren()) + SaveBones(boneNode, child, skeleton); + } + } } } private void SaveBones(Node parentBone, STBone bone, STSkeleton skeleton)