private void ModeCB_SelectedIndexChanged(object sender, EventArgs e) { if (!IsLoaded) { return; } if (activeSkeleton.node.SkeletonU != null) { activeSkeleton.node.SkeletonU.FlagsRotation = (ResU.SkeletonFlagsRotation)rotationModeCB.SelectedItem; activeSkeleton.node.SkeletonU.FlagsScaling = (ResU.SkeletonFlagsScaling)scalingModeCB.SelectedItem; foreach (var bone in activeSkeleton.bones) { bone.UseSegmentScaleCompensate = activeSkeleton.node.SkeletonU.FlagsScaling.HasFlag(SkeletonFlagsScaling.Maya); } activeSkeleton.update(); } else { activeSkeleton.node.Skeleton.FlagsRotation = (SkeletonFlagsRotation)rotationModeCB.SelectedItem; activeSkeleton.node.Skeleton.FlagsScaling = (SkeletonFlagsScaling)scalingModeCB.SelectedItem; foreach (var bone in activeSkeleton.bones) { bone.UseSegmentScaleCompensate = activeSkeleton.node.Skeleton.FlagsScaling.HasFlag(SkeletonFlagsScaling.Maya); } activeSkeleton.update(); } LibraryGUI.UpdateViewport(); }
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 static void SaveSkeleton(FSKL fskl, List <STBone> Bones) { fskl.node.Skeleton.Bones.Clear(); fskl.node.Skeleton.MatrixToBoneList = new List <ushort>(); fskl.node.Skeleton.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>(); 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); bn.Text = genericBone.Text; //Set the bfres bone data if (bn.Bone == null) { bn.Bone = new Bone(); } bn.GenericToBfresBone(); if (bn.SmoothMatrixIndex != short.MaxValue) { fskl.node.Skeleton.MatrixToBoneList.Add(SmoothIndex++); } fskl.node.Skeleton.InverseModelMatrices.Add(Syroot.Maths.Matrix3x4.Zero); //Check duplicated names List <string> names = fskl.bones.Select(o => o.Text).ToList(); bn.Text = Utils.RenameDuplicateString(names, bn.Text); bn.Bone.Name = bn.Text; fskl.bones.Add(bn); fskl.node.Skeleton.Bones.Add(bn.Bone); //Add bones to tree if (bn.Parent == null) { fskl.node.Nodes.Add(bn); } } fskl.update(); fskl.reset(); fskl.Node_Array = new int[fskl.node.Skeleton.MatrixToBoneList.Count]; int nodes = 0; foreach (ushort node in fskl.node.Skeleton.MatrixToBoneList) { fskl.Node_Array[nodes] = node; nodes++; } }
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 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); }