diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs index 0c78832e..ddaa2402 100644 --- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs +++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs @@ -384,7 +384,7 @@ namespace FirstPlugin { //Reset bone as rigid var node = (GFLXBone)Model.Skeleton.bones[i]; - node.Bone.RigidCheck = new BoneRigidData() { Unknown1 = 0 }; + /* node.Bone.RigidCheck = new BoneRigidData() { Unknown1 = 0 }; if (node.Bone.BoneType == 1) node.Bone.BoneType = 0; @@ -396,7 +396,7 @@ namespace FirstPlugin node.Bone.BoneType = 1; node.Bone.RigidCheck = null; } - } + }*/ if (Model.GenericMeshes.Any(x => x.Text == node.Text)) { @@ -464,20 +464,19 @@ namespace FirstPlugin if (importer.Settings.OptmizeZeroWeights) { - float MaxWeight = 1; + float[] weightsA = new float[4]; + + int MaxWeight = 255; for (int j = 0; j < 4; j++) { - if (mesh.vertices[i].boneWeights.Count <= j) - continue; - - if (mesh.vertices[i].boneIds.Count < j + 1) + if (mesh.vertices[i].boneWeights.Count < j + 1) { - mesh.vertices[i].boneWeights[j] = 0; + weightsA[j] = 0; MaxWeight = 0; } else { - float weight = mesh.vertices[i].boneWeights[j]; + int weight = (int)(mesh.vertices[i].boneWeights[j] * 255); if (mesh.vertices[i].boneWeights.Count == j + 1) weight = MaxWeight; @@ -489,9 +488,11 @@ namespace FirstPlugin else MaxWeight -= weight; - mesh.vertices[i].boneWeights[j] = weight; + weightsA[j] = weight / 255f; } } + + mesh.vertices[i].boneWeights = weightsA.ToList(); } for (int j = 0; j < mesh.vertices[i].boneNames?.Count; j++) @@ -528,7 +529,7 @@ namespace FirstPlugin bone.Translation = new GFMDLStructs.Vector3(0,0,0); bone.RadiusStart = new GFMDLStructs.Vector3(0, 0, 0); bone.RadiusEnd = new GFMDLStructs.Vector3(0, 0, 0); - bone.RigidCheck = new BoneRigidData(); + // bone.RigidCheck = new BoneRigidData(); Model.Model.Bones.Add(bone); int NodeIndex = Model.Model.Bones.IndexOf(bone); diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFLXMeshBufferHelper.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFLXMeshBufferHelper.cs index e42a398b..8bc1996f 100644 --- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFLXMeshBufferHelper.cs +++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFLXMeshBufferHelper.cs @@ -236,24 +236,20 @@ namespace FirstPlugin var pos = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.pos = new OpenTK.Vector3(pos.X, pos.Y, pos.Z); vertex.pos = OpenTK.Vector3.TransformPosition(vertex.pos, transform); - Console.WriteLine($"pos {pos}"); break; case VertexType.Normal: var normal = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.nrm = new OpenTK.Vector3(normal.X, normal.Y, normal.Z); vertex.normalW = normal.W; vertex.nrm = OpenTK.Vector3.TransformNormal(vertex.nrm, transform); - Console.WriteLine($"nrm {normal}"); break; case VertexType.UV1: var texcoord1 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.uv0 = new OpenTK.Vector2(texcoord1.X, texcoord1.Y); - Console.WriteLine($"uv0 {texcoord1}"); break; case VertexType.UV2: var texcoord2 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.uv1 = new OpenTK.Vector2(texcoord2.X, texcoord2.Y); - Console.WriteLine($"uv1 {texcoord2}"); break; case VertexType.UV3: var texcoord3 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); @@ -289,8 +285,6 @@ namespace FirstPlugin colors1 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.col = colors1 / 255f; - - Console.WriteLine($"colors1 {colors1}"); break; case VertexType.Color2: OpenTK.Vector4 colors2 = new OpenTK.Vector4(1, 1, 1, 1); @@ -298,20 +292,14 @@ namespace FirstPlugin colors2 = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.col2 = colors2 / 255f; - - Console.WriteLine($"colors2 {colors2}"); break; case VertexType.Bitangent: var bitans = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.bitan = new OpenTK.Vector4(bitans.X, bitans.Y, bitans.Z, bitans.W); - - Console.WriteLine($"bitans {bitans}"); break; case VertexType.Tangents: var tans = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); vertex.tan = new OpenTK.Vector4(tans.X, tans.Y, tans.Z, tans.W); - - Console.WriteLine($"tans {tans}"); break; default: var values = ParseBuffer(reader, attribute.BufferFormat, attribute.VertexType, attribute.ElementCount); diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GfbmdlImportSettings.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GfbmdlImportSettings.cs index e3f0682f..94971a8d 100644 --- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GfbmdlImportSettings.cs +++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GfbmdlImportSettings.cs @@ -9,7 +9,7 @@ namespace FirstPlugin { public class GfbmdlImportSettings { - public bool OptmizeZeroWeights { get; set; } = false; + public bool OptmizeZeroWeights { get; set; } = true; public List MeshSettings = new List();