public static void SaveSkeleton(FSKL fskl, List <STBone> Bones) { fskl.node.SkeletonU.Bones.Clear(); fskl.node.SkeletonU.MatrixToBoneList = new List <ushort>(); fskl.node.SkeletonU.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>(); fskl.node.Nodes.Clear(); ushort SmoothIndex = 0; foreach (STBone genericBone in Bones) { genericBone.BillboardIndex = ushort.MaxValue; //Clone a generic bone with the generic data BfresBone bn = new BfresBone(fskl); bn.CloneBaseInstance(genericBone); //Set the bfres bone data if (bn.BoneU == null) { bn.BoneU = new Bone(); } bn.GenericToBfresBone(); if (bn.SmoothMatrixIndex != short.MaxValue) { fskl.node.SkeletonU.MatrixToBoneList.Add(SmoothIndex++); } fskl.node.SkeletonU.InverseModelMatrices.Add(Syroot.Maths.Matrix3x4.Zero); fskl.bones.Add(bn); } foreach (BfresBone wrapper in fskl.bones) { //Check duplicated names List <string> names = fskl.bones.Select(o => o.Text).ToList(); wrapper.Text = Utils.RenameDuplicateString(names, wrapper.Text); wrapper.BoneU.Name = wrapper.Text; fskl.node.SkeletonU.Bones.Add(wrapper.Text, wrapper.BoneU); //Add bones to tree if (wrapper.Parent == null) { fskl.node.Nodes.Add(wrapper); } } fskl.Node_Array = new int[fskl.node.SkeletonU.MatrixToBoneList.Count]; int nodes = 0; foreach (ushort node in fskl.node.SkeletonU.MatrixToBoneList) { fskl.Node_Array[nodes] = node; nodes++; } }
public static void ReadSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton) { if (skeleton.MatrixToBoneList == null) { skeleton.MatrixToBoneList = new List <ushort>(); } RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count]; int nodes = 0; foreach (ushort node in skeleton.MatrixToBoneList) { RenderableSkeleton.Node_Array[nodes] = node; nodes++; } foreach (Bone bone in skeleton.Bones.Values) { BfresBone STBone = new BfresBone(RenderableSkeleton); ReadBone(STBone, bone); RenderableSkeleton.bones.Add(STBone); } RenderableSkeleton.update(); RenderableSkeleton.reset(); foreach (var bone in RenderableSkeleton.bones) { if (bone.Parent == null) { skl.Nodes.Add(bone); } } }
public void LoadIndices(List <ushort> Indices, FSKL fskl) { if (Indices == null) { return; } foreach (ushort index in Indices) { listViewCustom1.Items.Add(fskl.bones[index].Text).SubItems.Add(index.ToString()); } }
public void LoadMatrixToIndexIndices(IList <ushort> Indices, FSKL fskl) { if (Indices == null) { return; } foreach (ushort index in Indices) { listViewCustom1.Items.Add(fskl.bones[fskl.Node_Array[index]].Text).SubItems.Add(fskl.Node_Array[index].ToString()); } }
public static void SetSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton) { if (skeleton.MatrixToBoneList == null) { skeleton.MatrixToBoneList = new List <ushort>(); } RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count]; int nodes = 0; foreach (ushort node in skeleton.MatrixToBoneList) { RenderableSkeleton.Node_Array[nodes] = node; nodes++; } for (int i = 0; i < skeleton.Bones.Count; i++) { if (skeleton.InverseModelMatrices == null) { break; } if (i < skeleton.InverseModelMatrices.Count) { RenderableSkeleton.matrices.Add(Utils.ToMat3x4(skeleton.InverseModelMatrices[i])); } else { RenderableSkeleton.matrices.Add(Matrix3x4.Zero); } } foreach (Bone bone in skeleton.Bones.Values) { BfresBone STBone = new BfresBone(RenderableSkeleton); SetBone(STBone, bone); STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits RenderableSkeleton.bones.Add(STBone); if (bone.InverseMatrix != null) { RenderableSkeleton.matrices.Add(Utils.ToMat3x4(bone.InverseMatrix)); } } RenderableSkeleton.update(); RenderableSkeleton.reset(); // foreach (var bone in RenderableSkeleton.bones) // if (bone.Parent == null) // skl.Nodes.Add(bone); Runtime.abstractGlDrawables.Add(RenderableSkeleton); }
public static void SaveSkeleton(FSKL fskl, List <STBone> Bones) { if (fskl.node.SkeletonU == null) { fskl.node.SkeletonU = new Skeleton(); } fskl.node.SkeletonU.Bones.Clear(); fskl.node.SkeletonU.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>(); fskl.node.Nodes.Clear(); ushort SmoothIndex = 0; foreach (STBone genericBone in Bones) { genericBone.BillboardIndex = -1; //Clone a generic bone with the generic data BfresBone bn = new BfresBone(fskl); bn.CloneBaseInstance(genericBone); //Set the bfres bone data if (bn.BoneU == null) { bn.BoneU = new Bone(); } bn.GenericToBfresBone(); //Check duplicated names List <string> names = fskl.bones.Select(o => o.Text).ToList(); bn.Text = Utils.RenameDuplicateString(names, bn.Text); fskl.node.SkeletonU.InverseModelMatrices.Add(Syroot.Maths.Matrix3x4.Zero); fskl.bones.Add(bn); bn.BoneU.Name = bn.Text; fskl.node.SkeletonU.Bones.Add(bn.Text, bn.BoneU); //Add bones to tree if (bn.Parent == null) { fskl.node.Nodes.Add(bn); } } fskl.update(); fskl.reset(); }
public void LoadSkeleton(FSKL fskl) { activeSkeleton = fskl; if (fskl.node.SkeletonU != null) { rotationModeCB.Bind(typeof(ResU.SkeletonFlagsRotation), fskl.node.SkeletonU, "FlagsRotation"); scalingModeCB.Bind(typeof(ResU.SkeletonFlagsScaling), fskl.node.SkeletonU, "FlagsScaling"); rotationModeCB.SelectedItem = fskl.node.SkeletonU.FlagsRotation; scalingModeCB.SelectedItem = fskl.node.SkeletonU.FlagsScaling; } else { rotationModeCB.Bind(typeof(SkeletonFlagsRotation), fskl.node.Skeleton, "FlagsRotation"); scalingModeCB.Bind(typeof(SkeletonFlagsScaling), fskl.node.Skeleton, "FlagsScaling"); rotationModeCB.SelectedItem = fskl.node.Skeleton.FlagsRotation; scalingModeCB.SelectedItem = fskl.node.Skeleton.FlagsScaling; } }
public void LoadSkeleton(FSKL fskl) { IsLoaded = false; rotationModeCB.DataSource = null; scalingModeCB.DataSource = null; rotationModeCB.Items.Clear(); scalingModeCB.Items.Clear(); activeSkeleton = fskl; if (fskl.node.SkeletonU != null) { foreach (var item in Enum.GetValues(typeof(ResU.SkeletonFlagsRotation))) { rotationModeCB.Items.Add(item); } foreach (var item in Enum.GetValues(typeof(ResU.SkeletonFlagsScaling))) { scalingModeCB.Items.Add(item); } rotationModeCB.SelectedItem = fskl.node.SkeletonU.FlagsRotation; scalingModeCB.SelectedItem = fskl.node.SkeletonU.FlagsScaling; Console.WriteLine("FlagsScaling " + fskl.node.SkeletonU.FlagsScaling); } else { foreach (var item in Enum.GetValues(typeof(SkeletonFlagsRotation))) { rotationModeCB.Items.Add(item); } foreach (var item in Enum.GetValues(typeof(SkeletonFlagsScaling))) { scalingModeCB.Items.Add(item); } rotationModeCB.SelectedItem = fskl.node.Skeleton.FlagsRotation; scalingModeCB.SelectedItem = fskl.node.Skeleton.FlagsScaling; } IsLoaded = true; }
public static void SetSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton) { if (skeleton.MatrixToBoneList == null) { skeleton.MatrixToBoneList = new List <ushort>(); } RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count]; int nodes = 0; foreach (ushort node in skeleton.MatrixToBoneList) { RenderableSkeleton.Node_Array[nodes] = node; nodes++; } foreach (Bone bone in skeleton.Bones.Values) { BfresBone STBone = new BfresBone(RenderableSkeleton); SetBone(STBone, bone); STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits RenderableSkeleton.bones.Add(STBone); } RenderableSkeleton.update(); RenderableSkeleton.reset(); foreach (var bone in RenderableSkeleton.bones) { if (bone.Parent == null) { skl.Nodes.Add(bone); } } Runtime.abstractGlDrawables.Add(RenderableSkeleton); }