public void LoadAttribute(FSHP.VertexAttribute attribute) { activeAttribute = attribute; SetFormat(attribute); nameTB.Text = attribute.Name; bool HasFormat = formatCB.Items.Contains(attribute.Format); if (!HasFormat) { formatCB.Items.Add(attribute.Format); } formatCB.SelectedItem = attribute.Format; }
public void LoadAttribute(FSHP.VertexAttribute attribute) { activeAttribute = attribute; SetFormat(attribute); // bool HasFormat = formatCB.Items.Cast<ComboBoxItem>().Any(cbi => cbi.Content.Equals(attribute.Format.ToString())); nameTB.Text = attribute.Name; bool HasFormat = formatCB.Items.Contains(attribute.Format); if (!HasFormat) { formatCB.Items.Add(attribute.Format); } formatCB.SelectedItem = attribute.Format; }
private void attributeCB_SelectedIndexChanged(object sender, EventArgs e) { if (attributeCB.SelectedIndex >= 0) { string SelectedText = attributeCB.GetItemText(attributeCB.SelectedItem); hintLabel.Text = $"Hint: {SetHintLabel(SelectedText)}"; foreach (var attribute in ActiveFSHP.vertexAttributes) { if (SelectedText == attribute.Name) { ActiveAttribute = attribute; } } if (ActiveAttribute != null) { formatCB.SelectedItem = ActiveAttribute.Format; } } }
private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model) { fshp.vertices.Clear(); fshp.vertexAttributes.Clear(); //Create a buffer instance which stores all the buffer data VertexBufferHelper helper = new VertexBufferHelper(vtx, Syroot.BinaryData.ByteOrder.BigEndian); //Set each array first from the lib if exist. Then add the data all in one loop Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4Normals = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv1 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv2 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4c0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4t0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4b0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4w0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4i0 = new Syroot.Maths.Vector4F[0]; //For shape morphing Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0]; foreach (VertexAttrib att in vtx.Attributes.Values) { FSHP.VertexAttribute attr = new FSHP.VertexAttribute(); attr.Name = att.Name; attr.Format = attr.GetTypeWiiU(att.Format); if (att.Name == "_p0") { vec4Positions = AttributeData(att, helper, "_p0"); } if (att.Name == "_n0") { vec4Normals = AttributeData(att, helper, "_n0"); } if (att.Name == "_u0") { vec4uv0 = AttributeData(att, helper, "_u0"); } if (att.Name == "_u1") { vec4uv1 = AttributeData(att, helper, "_u1"); } if (att.Name == "_u2") { vec4uv2 = AttributeData(att, helper, "_u2"); } if (att.Name == "_c0") { vec4c0 = AttributeData(att, helper, "_c0"); } if (att.Name == "_t0") { vec4t0 = AttributeData(att, helper, "_t0"); } if (att.Name == "_b0") { vec4b0 = AttributeData(att, helper, "_b0"); } if (att.Name == "_w0") { vec4w0 = AttributeData(att, helper, "_w0"); } if (att.Name == "_i0") { vec4i0 = AttributeData(att, helper, "_i0"); } if (att.Name == "_p1") { vec4Positions1 = AttributeData(att, helper, "_p1"); } if (att.Name == "_p2") { vec4Positions2 = AttributeData(att, helper, "_p2"); } fshp.vertexAttributes.Add(attr); } for (int i = 0; i < vec4Positions.Length; i++) { Vertex v = new Vertex(); if (vec4Positions.Length > 0) { v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z); } if (vec4Positions1.Length > 0) { v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z); } if (vec4Positions2.Length > 0) { v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z); } if (vec4Normals.Length > 0) { v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z); } if (vec4uv0.Length > 0) { v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y); } if (vec4uv1.Length > 0) { v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y); } if (vec4uv2.Length > 0) { v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y); } if (vec4w0.Length > 0) { v.boneWeights.Add(vec4w0[i].X); v.boneWeights.Add(vec4w0[i].Y); v.boneWeights.Add(vec4w0[i].Z); v.boneWeights.Add(vec4w0[i].W); } if (vec4i0.Length > 0) { v.boneIds.Add((int)vec4i0[i].X); v.boneIds.Add((int)vec4i0[i].Y); v.boneIds.Add((int)vec4i0[i].Z); v.boneIds.Add((int)vec4i0[i].W); } if (vec4t0.Length > 0) { v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W); } if (vec4b0.Length > 0) { v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W); } if (vec4c0.Length > 0) { v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W); } if (fshp.VertexSkinCount == 1) { Matrix4 sb = model.Skeleton.bones[model.Skeleton.Node_Array[v.boneIds[0]]].Transform; v.pos = Vector3.TransformPosition(v.pos, sb); v.nrm = Vector3.TransformNormal(v.nrm, sb); } if (fshp.VertexSkinCount == 0) { Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform; v.pos = Vector3.TransformPosition(v.pos, NoBindFix); v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix); } fshp.vertices.Add(v); } }
public List <FSHP.VertexAttribute> CreateNewAttributes() { List <FSHP.VertexAttribute> attribute = new List <FSHP.VertexAttribute>(); Console.WriteLine($"EnablePositions {EnablePositions}"); Console.WriteLine($"EnableNormals {EnableNormals}"); Console.WriteLine($"EnableVertexColors {EnableVertexColors}"); Console.WriteLine($"EnableUV0 {EnableUV0}"); Console.WriteLine($"EnableUV1 {EnableUV1}"); Console.WriteLine($"EnableUV2 {EnableUV2}"); Console.WriteLine($"EnableUV2 {EnableUV2}"); Console.WriteLine($"EnableTangents {EnableTangents}"); Console.WriteLine($"EnableTangents {EnableTangents}"); Console.WriteLine($"EnableBitangents {EnableBitangents}"); Console.WriteLine($"EnableWeights {EnableWeights}"); Console.WriteLine($"EnableIndices {EnableIndices}"); if (EnablePositions) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_p0"; att.Format = (AttribFormat)comboBoxFormatPositions.SelectedItem; attribute.Add(att); } if (EnableNormals) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_n0"; att.Format = (AttribFormat)comboBoxFormatNormals.SelectedItem; attribute.Add(att); } if (EnableVertexColors) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_c0"; att.Format = (AttribFormat)comboBoxFormatVertexColors.SelectedItem; attribute.Add(att); } if (EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u0"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att); } if (EnableUV1 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u1"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att); } if (EnableUV2 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u2"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att); } if (EnableTangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_t0"; att.Format = (AttribFormat)comboBoxFormatTangents.SelectedItem; attribute.Add(att); } if (EnableBitangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_b0"; att.Format = (AttribFormat)comboBoxFormatBitans.SelectedItem; attribute.Add(att); } if (EnableWeights) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_w0"; att.Format = (AttribFormat)comboBoxFormatWeights.SelectedItem; attribute.Add(att); } if (EnableIndices) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_i0"; att.Format = (AttribFormat)comboBoxFormatIndices.SelectedItem; attribute.Add(att); } return(attribute); }
private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model) { fshp.vertices.Clear(); fshp.vertexAttributes.Clear(); //Create a buffer instance which stores all the buffer data VertexBufferHelper helper = new VertexBufferHelper(vtx, Syroot.BinaryData.ByteOrder.BigEndian); //Set each array first from the lib if exist. Then add the data all in one loop Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4Normals = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv1 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4uv2 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4c0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4t0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4b0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4w0 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4i0 = new Syroot.Maths.Vector4F[0]; //For shape morphing Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0]; Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0]; List <VertexAttrib> SortedList = vtx.Attributes.Values.OrderBy(o => o.BufferIndex).ToList(); foreach (VertexAttrib att in SortedList) { Console.WriteLine($"{att.Name} {att.BufferIndex} {att.Offset} {att.Format} "); } foreach (VertexAttrib att in vtx.Attributes.Values) { FSHP.VertexAttribute attr = new FSHP.VertexAttribute(); attr.Name = att.Name; attr.Format = attr.GetTypeWiiU(att.Format); attr.BufferIndex = att.BufferIndex; if (att.Name == "_p0") { vec4Positions = AttributeData(att, helper, "_p0"); } if (att.Name == "_n0") { vec4Normals = AttributeData(att, helper, "_n0"); } if (att.Name == "_u0") { vec4uv0 = AttributeData(att, helper, "_u0"); } if (att.Name == "_u1") { vec4uv1 = AttributeData(att, helper, "_u1"); } if (att.Name == "_u2") { vec4uv2 = AttributeData(att, helper, "_u2"); } if (att.Name == "_c0") { vec4c0 = AttributeData(att, helper, "_c0"); } if (att.Name == "_t0") { vec4t0 = AttributeData(att, helper, "_t0"); } if (att.Name == "_b0") { vec4b0 = AttributeData(att, helper, "_b0"); } if (att.Name == "_w0") { vec4w0 = AttributeData(att, helper, "_w0"); } if (att.Name == "_i0") { vec4i0 = AttributeData(att, helper, "_i0"); } if (att.Name == "_p1") { vec4Positions1 = AttributeData(att, helper, "_p1"); } if (att.Name == "_p2") { vec4Positions2 = AttributeData(att, helper, "_p2"); } fshp.vertexAttributes.Add(attr); } for (int i = 0; i < vec4Positions.Length; i++) { Vertex v = new Vertex(); if (vec4Positions.Length > 0) { v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z); } if (vec4Positions1.Length > 0) { v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z); } if (vec4Positions2.Length > 0) { v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z); } if (vec4Normals.Length > 0) { v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z); } if (vec4uv0.Length > 0) { v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y); } if (vec4uv1.Length > 0) { v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y); } if (vec4uv2.Length > 0) { v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y); } if (vec4w0.Length > 0) { v.boneWeights.Add(vec4w0[i].X); v.boneWeights.Add(vec4w0[i].Y); v.boneWeights.Add(vec4w0[i].Z); v.boneWeights.Add(vec4w0[i].W); } if (vec4i0.Length > 0) { v.boneIds.Add((int)vec4i0[i].X); v.boneIds.Add((int)vec4i0[i].Y); v.boneIds.Add((int)vec4i0[i].Z); v.boneIds.Add((int)vec4i0[i].W); } if (vec4t0.Length > 0) { v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W); } if (vec4b0.Length > 0) { v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W); } if (vec4c0.Length > 0) { v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W); } if (fshp.VertexSkinCount == 1) { int boneIndex = fshp.BoneIndex; if (v.boneIds.Count > 0) { boneIndex = model.Skeleton.Node_Array[v.boneIds[0]]; } //Check if the bones are a rigid type //In game it seems to not transform if they are not rigid if (model.Skeleton.bones[boneIndex].RigidMatrixIndex != -1) { Matrix4 sb = model.Skeleton.bones[boneIndex].Transform; v.pos = Vector3.TransformPosition(v.pos, sb); v.nrm = Vector3.TransformNormal(v.nrm, sb); } } if (fshp.VertexSkinCount == 0) { try { if (model.Skeleton.bones.Count > 0) { int boneIndex = fshp.BoneIndex; Matrix4 NoBindFix = model.Skeleton.bones[boneIndex].Transform; v.pos = Vector3.TransformPosition(v.pos, NoBindFix); v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix); } } catch //Matrix failed. Print the coordinate data of the bone { Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].Text); Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetPosition()); Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetRotation()); Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetScale()); } } fshp.vertices.Add(v); } }
public List <FSHP.VertexAttribute> CreateNewAttributes() { List <FSHP.VertexAttribute> attribute = new List <FSHP.VertexAttribute>(); if (EnablePositions) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_p0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatPositions)); attribute.Add(att); } if (EnableNormals) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_n0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatNormals)); attribute.Add(att); } if (EnableVertexColors) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_c0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatVertexColors)); attribute.Add(att); } if (EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs)); attribute.Add(att); } if (EnableUV1 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u1"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs)); attribute.Add(att); } if (EnableUV2 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u2"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs)); attribute.Add(att); } if (EnableTangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_t0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatTangents)); attribute.Add(att); } if (EnableBitangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_b0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatBitans)); attribute.Add(att); } if (EnableWeights) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_w0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatWeights)); attribute.Add(att); } if (EnableIndices) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_i0"; att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatIndices)); attribute.Add(att); } return(attribute); }
private void SetFormat(FSHP.VertexAttribute attribute) { formatCB.Items.Clear(); var index = string.Concat(attribute.Name.ToArray().Reverse().TakeWhile(char.IsNumber).Reverse()); if (attribute.Name == $"_p{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_10_10_10_2_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_SNorm); } if (attribute.Name == $"_n{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_10_10_10_2_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_SNorm); } if (attribute.Name == $"_i{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_32_UInt); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_UInt); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_UInt); formatCB.Items.Add(AttribFormat.Format_32_32_32_UInt); formatCB.Items.Add(AttribFormat.Format_32_32_UInt); formatCB.Items.Add(AttribFormat.Format_16_16_UInt); formatCB.Items.Add(AttribFormat.Format_8_8_UInt); formatCB.Items.Add(AttribFormat.Format_32_UInt); formatCB.Items.Add(AttribFormat.Format_16_UInt); formatCB.Items.Add(AttribFormat.Format_8_UInt); } if (attribute.Name == $"_w{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_UNorm); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_UNorm); formatCB.Items.Add(AttribFormat.Format_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_UNorm); formatCB.Items.Add(AttribFormat.Format_8_8_UNorm); formatCB.Items.Add(AttribFormat.Format_8_UNorm); } if (attribute.Name == $"_t{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_10_10_10_2_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_SNorm); } if (attribute.Name == $"_b{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_10_10_10_2_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_8_8_SNorm); } if (attribute.Name == $"_u{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_UNorm); } if (attribute.Name == $"_c{index}") { formatCB.Items.Add(AttribFormat.Format_32_32_Single); formatCB.Items.Add(AttribFormat.Format_16_16_Single); formatCB.Items.Add(AttribFormat.Format_16_16_SNorm); formatCB.Items.Add(AttribFormat.Format_10_10_10_2_SNorm); formatCB.Items.Add(AttribFormat.Format_8_8_SNorm); } }
public List <FSHP.VertexAttribute> CreateNewAttributes() { Dictionary <string, FSHP.VertexAttribute> attribute = new Dictionary <string, FSHP.VertexAttribute>(); Console.WriteLine($"EnablePositions {EnablePositions}"); Console.WriteLine($"EnableNormals {EnableNormals}"); Console.WriteLine($"EnableVertexColors {EnableVertexColors}"); Console.WriteLine($"EnableUV0 {EnableUV0}"); Console.WriteLine($"EnableUV1 {EnableUV1}"); Console.WriteLine($"EnableUV2 {EnableUV2}"); Console.WriteLine($"EnableUV2 {EnableUV2}"); Console.WriteLine($"EnableTangents {EnableTangents}"); Console.WriteLine($"EnableTangents {EnableTangents}"); Console.WriteLine($"EnableBitangents {EnableBitangents}"); Console.WriteLine($"EnableWeights {EnableWeights}"); Console.WriteLine($"EnableIndices {EnableIndices}"); if (EnablePositions) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_p0"; att.Format = (AttribFormat)comboBoxFormatPositions.SelectedItem; attribute.Add(att.Name, att); } if (EnableNormals) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_n0"; att.Format = (AttribFormat)comboBoxFormatNormals.SelectedItem; attribute.Add(att.Name, att); } if (EnableVertexColors) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_c0"; att.Format = (AttribFormat)comboBoxFormatVertexColors.SelectedItem; attribute.Add(att.Name, att); } if (EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u0"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att.Name, att); } if (EnableUV1 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u1"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att.Name, att); } if (EnableUV2 && EnableUV0) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_u2"; att.Format = (AttribFormat)comboBoxFormatUvs.SelectedItem; attribute.Add(att.Name, att); } if (EnableTangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_t0"; att.Format = (AttribFormat)comboBoxFormatTangents.SelectedItem; attribute.Add(att.Name, att); } if (EnableBitangents) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_b0"; att.Format = (AttribFormat)comboBoxFormatBitans.SelectedItem; attribute.Add(att.Name, att); } if (EnableWeights) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_w0"; att.Format = (AttribFormat)comboBoxFormatWeights.SelectedItem; attribute.Add(att.Name, att); } if (EnableIndices) { FSHP.VertexAttribute att = new FSHP.VertexAttribute(); att.Name = "_i0"; att.Format = (AttribFormat)comboBoxFormatIndices.SelectedItem; attribute.Add(att.Name, att); } switch ((GamePreset)gamePresetCB.SelectedItem) { //Use single buffer case GamePreset.WindWakerHD: case GamePreset.SuperMario3DWorld: foreach (var att in attribute.Values) { att.BufferIndex = 0; } break; case GamePreset.BreathOfTheWild: //A bit hacky. The position uses first buffer //Weight data uses 1 //The rest besides bitangents use 2, bitans using 3 //If no weight data, then it shifts by 1 byte posIndex = 0; byte weightIndex = 1; byte dataIndex = 1; if (attribute.ContainsKey("_w0") || attribute.ContainsKey("_i0")) { dataIndex += 1; } byte bitanIndex = (byte)(dataIndex + 1); if (attribute.ContainsKey("_p0")) { attribute["_p0"].BufferIndex = posIndex; } if (attribute.ContainsKey("_i0")) { attribute["_i0"].BufferIndex = weightIndex; } if (attribute.ContainsKey("_w0")) { attribute["_w0"].BufferIndex = weightIndex; //Same buffer as indices } if (attribute.ContainsKey("_n0")) { attribute["_n0"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_u0")) { attribute["_u0"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_u1")) { attribute["_u1"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_u2")) { attribute["_u2"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_t0")) { attribute["_t0"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_c0")) { attribute["_c0"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_c1")) { attribute["_c1"].BufferIndex = dataIndex; } if (attribute.ContainsKey("_b0")) { attribute["_b0"].BufferIndex = bitanIndex; } break; default: var attirbutes = attribute.Values.ToList(); for (int i = 0; i < attirbutes.Count; i++) { attirbutes[i].BufferIndex = (byte)i; } return(attirbutes); } return(attribute.Values.ToList()); }