1
0
mirror of synced 2025-02-25 22:38:07 +01:00

Fix dae importing having unmapped bones

This commit is contained in:
KillzXGaming 2019-06-23 09:00:36 -04:00
parent 7395d78d67
commit 2aea6eb28a
8 changed files with 15 additions and 11 deletions

Binary file not shown.

View File

@ -107,13 +107,17 @@ namespace FirstPlugin
for (int i = 0; i < FileEntries.Count; i++)
{
FileEntries[i].CanLoadFile = SupportedExtensions.Contains(Utils.GetExtension(FileEntries[i].FileName));
files.Add(FileEntries[i]);
}
}
}
private List<string> SupportedExtensions = new List<string>()
{ ".dds", ".tga" ,".mmb", ".png", ".jpg" };
{".mgraphobject" };
// private List<string> SupportedExtensions = new List<string>()
// { ".dds", ".tga" ,".mmb", ".png", ".jpg", ".mgraphobject" };
private TreeNode GetNodes(TreeNode parent, string[] fileList)
{

View File

@ -68,6 +68,7 @@ namespace Switch_Toolbox.Library
Flags |= PostProcessSteps.GenerateNormals;*/
scene = Importer.ImportFile(FileName, settings.GetFlags());
GetRealNodeNames(FileName);
LoadScene();
@ -105,6 +106,8 @@ namespace Switch_Toolbox.Library
Name = att.InnerText;
}
Console.WriteLine($"BONE ID {ID} Name {Name}");
if (!DaeHelper.IDMapToName.ContainsKey(ID))
DaeHelper.IDMapToName.Add(ID, Name);
}
@ -461,12 +464,10 @@ namespace Switch_Toolbox.Library
bone.skeletonParent = skeleton;
skeleton.bones.Add(bone);
bone.Text = node.Name;
if (node.Name.Contains($"{ParentArmatureName}"))
{
bone.Text = node.Name.Replace($"{ParentArmatureName}_", "");
}
if (DaeHelper.IDMapToName.ContainsKey(node.Name))
bone.Text = DaeHelper.IDMapToName[node.Name];
else
bone.Text = node.Name;
bone.SmoothMatrixIndex = (short)skeleton.bones.IndexOf(bone);
bone.RigidMatrixIndex = -1; //Todo calculate these
@ -634,7 +635,6 @@ namespace Switch_Toolbox.Library
if (msh.HasVertexColors(0))
{
vert.col = new Vector4(msh.VertexColorChannels[0][v].R, msh.VertexColorChannels[0][v].G, msh.VertexColorChannels[0][v].B, msh.VertexColorChannels[0][v].A);
Console.WriteLine("VTX Col " + vert.col);
}
if (msh.HasTangentBasis)
vert.bitan = new Vector4(msh.BiTangents[v].X, msh.BiTangents[v].Y, msh.BiTangents[v].Z, 1);
@ -642,9 +642,6 @@ namespace Switch_Toolbox.Library
}
if (msh.HasBones)
{
STConsole.WriteLine(msh.Name + " HasBones " + msh.HasBones);
STConsole.WriteLine(msh.Name + " BoneCount " + msh.BoneCount);
for (int i = 0; i < msh.BoneCount; i++)
{
Bone bn = msh.Bones[i];
@ -652,6 +649,9 @@ namespace Switch_Toolbox.Library
{
foreach (VertexWeight w in bn.VertexWeights)
{
if (DaeHelper.IDMapToName.ContainsKey(bn.Name))
bn.Name = DaeHelper.IDMapToName[bn.Name];
vertices[w.VertexID].boneWeights.Add(w.Weight);
vertices[w.VertexID].boneNames.Add(bn.Name);
BoneNames.Add(bn.Name);