public void LoadBone(BfresBone bone) { activeBone = bone; if (bone.Parent == null) { parentUD.Value = bone.parentIndex; } else { parentUD.Value = -1; } billboardIDUD.Value = bone.BillboardIndex; rotModeCB.SelectedIndex = (int)bone.boneRotationType; chkboxVisible.Checked = bone.IsVisible; textBoxName.Text = bone.Text; transXUD.Value = (decimal)bone.position[0]; transYUD.Value = (decimal)bone.position[1]; transZUD.Value = (decimal)bone.position[2]; rotUDX.Value = (decimal)bone.rotation[0]; rotUDY.Value = (decimal)bone.rotation[1]; rotUDZ.Value = (decimal)bone.rotation[2]; scaleUDX.Value = (decimal)bone.scale[0]; scaleUDY.Value = (decimal)bone.scale[1]; scaleUDZ.Value = (decimal)bone.scale[2]; }
private void SetBoneTransform(BfresBone bn) { bn.Position = new OpenTK.Vector3( (float)posXUD.Value, (float)posYUD.Value, (float)posZUD.Value ); if ((BoneFlagsRotation)rotModeCB.SelectedItem == BoneFlagsRotation.Quaternion) { bn.Rotation = new OpenTK.Quaternion( (float)RotXUD.Value, (float)RotYUD.Value, (float)RotZUD.Value, (float)RotWUD.Value ); } else { bn.EulerRotation = new OpenTK.Vector3( (float)RotXUD.Value, (float)RotYUD.Value, (float)RotZUD.Value ); } bn.Scale = new OpenTK.Vector3( (float)ScaXUD.Value, (float)ScaYUD.Value, (float)ScaZUD.Value ); bn.GenericToBfresBone(); }
public static void ReadBone(this BfresBone bone, Bone bn, bool SetParent = true) { bone.BoneU = bn; bone.FlagVisible = bn.Flags.HasFlag(BoneFlags.Visible); bone.Text = bn.Name; bone.RigidMatrixIndex = bn.RigidMatrixIndex; bone.SmoothMatrixIndex = bn.SmoothMatrixIndex; bone.BillboardIndex = bn.BillboardIndex; if (SetParent) { bone.parentIndex = bn.ParentIndex; } bone.scale = new float[3]; bone.rotation = new float[4]; bone.position = new float[3]; if (bn.FlagsRotation == BoneFlagsRotation.Quaternion) { bone.RotationType = STBone.BoneRotationType.Quaternion; } else { bone.RotationType = STBone.BoneRotationType.Euler; } bone.scale[0] = bn.Scale.X; bone.scale[1] = bn.Scale.Y; bone.scale[2] = bn.Scale.Z; bone.rotation[0] = bn.Rotation.X; bone.rotation[1] = bn.Rotation.Y; bone.rotation[2] = bn.Rotation.Z; bone.rotation[3] = bn.Rotation.W; bone.position[0] = bn.Position.X; bone.position[1] = bn.Position.Y; bone.position[2] = bn.Position.Z; }
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 ReadBone(this BfresBone bone, Bone bn, bool SetParent = true) { bone.BoneU = bn; bone.FlagVisible = bn.Flags.HasFlag(BoneFlags.Visible); bone.Text = bn.Name; bone.RigidMatrixIndex = bn.RigidMatrixIndex; bone.SmoothMatrixIndex = bn.SmoothMatrixIndex; bone.BillboardIndex = bn.BillboardIndex; if (SetParent) { bone.parentIndex = bn.ParentIndex; } if (bn.FlagsRotation == BoneFlagsRotation.Quaternion) { bone.RotationType = STBone.BoneRotationType.Quaternion; } else { bone.RotationType = STBone.BoneRotationType.Euler; } bone.Position = new OpenTK.Vector3( bn.Position.X, bn.Position.Y, bn.Position.Z); bone.Rotation = new OpenTK.Quaternion( bn.Rotation.X, bn.Rotation.Y, bn.Rotation.Z, bn.Rotation.W); bone.Scale = new OpenTK.Vector3( bn.Scale.X, bn.Scale.Y, bn.Scale.Z); }
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 SetBone(this BfresBone bone, Bone bn) { bone.BoneU = bn; bone.Text = bn.Name; bone.BillboardIndex = bn.BillboardIndex; bone.parentIndex = bn.ParentIndex; bone.scale = new float[3]; bone.rotation = new float[4]; bone.position = new float[3]; if (bn.FlagsRotation == BoneFlagsRotation.Quaternion) { bone.boneRotationType = 1; } else { bone.boneRotationType = 0; } bone.scale[0] = bn.Scale.X; bone.scale[1] = bn.Scale.Y; bone.scale[2] = bn.Scale.Z; bone.rotation[0] = bn.Rotation.X; bone.rotation[1] = bn.Rotation.Y; bone.rotation[2] = bn.Rotation.Z; bone.rotation[3] = bn.Rotation.W; bone.position[0] = bn.Position.X; bone.position[1] = bn.Position.Y; bone.position[2] = bn.Position.Z; }
private void SetBoneTransform(BfresBone bn) { bn.position[0] = (float)posXUD.Value; bn.position[1] = (float)posYUD.Value; bn.position[2] = (float)posZUD.Value; bn.rotation[0] = (float)RotXUD.Value; bn.rotation[1] = (float)RotYUD.Value; bn.rotation[2] = (float)RotZUD.Value; bn.rotation[3] = (float)RotWUD.Value; bn.scale[0] = (float)ScaXUD.Value; bn.scale[1] = (float)ScaYUD.Value; bn.scale[2] = (float)ScaZUD.Value; if (bn.BoneU != null) { bn.BoneU.Position = new Syroot.Maths.Vector3F(bn.position[0], bn.position[1], bn.position[2]); bn.BoneU.Rotation = new Syroot.Maths.Vector4F(bn.rotation[0], bn.rotation[1], bn.rotation[2], bn.rotation[3]); bn.BoneU.Scale = new Syroot.Maths.Vector3F(bn.scale[0], bn.scale[1], bn.scale[2]); } else { bn.Bone.Position = new Syroot.Maths.Vector3F(bn.position[0], bn.position[1], bn.position[2]); bn.Bone.Rotation = new Syroot.Maths.Vector4F(bn.rotation[0], bn.rotation[1], bn.rotation[2], bn.rotation[3]); bn.Bone.Scale = new Syroot.Maths.Vector3F(bn.scale[0], bn.scale[1], bn.scale[2]); } }
public static void LoadBoneEditor(BfresBone bone) { BfresBoneEditor BfresBone = new BfresBoneEditor(); BfresBone.Text = bone.Text; BfresBone.Dock = DockStyle.Fill; BfresBone.LoadBone(bone); LibraryGUI.Instance.LoadDockContent(BfresBone, PluginRuntime.FSHPDockState); }
public static bool BoneEditorIsActive(DockContent dock, BfresBone bone) { foreach (Control ctrl in dock.Controls) { if (ctrl is BfresBoneEditor) { ((BfresBoneEditor)ctrl).LoadBone(bone); return(true); } } return(false); }
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 LoadBone(BfresBone bn) { Loaded = false; activeBone = bn; parentTB.Text = ""; if (bn.parentIndex != -1) { parentTB.Text = bn.Parent.Text; } nameIndexUD.Value = bn.GetIndex(); nameTB.Text = bn.BoneName; parentIndexUD.Bind(bn, "parentIndex"); visibleChk.Bind(bn, "Visible"); Loaded = true; }
public static void LoadBoneEditor(BfresBone bone) { foreach (Control control in FirstPlugin.MainF.Controls) { if (control is DockPanel) { if (FirstPlugin.DockedEditorS == null) { FirstPlugin.DockedEditorS = new DockContent(); FirstPlugin.DockedEditorS.Show((DockPanel)control, PluginRuntime.FSHPDockState); } } } if (!BoneEditorIsActive(FirstPlugin.DockedEditorS, bone)) { FirstPlugin.DockedEditorS.Controls.Clear(); BfresBoneEditor BfresBone = new BfresBoneEditor(); BfresBone.Text = bone.Text; BfresBone.Dock = DockStyle.Fill; BfresBone.LoadBone(bone); FirstPlugin.DockedEditorS.Controls.Add(BfresBone); } }
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); }
public void LoadBone(BfresBone bn) { activeBone = bn; IsLoaded = false; boneInfoPanel1.LoadBone(bn); if (bn.BoneU != null) { var bone = bn.BoneU; userDataEditor1.LoadUserData(bone.UserData); rotModeCB.DataSource = Enum.GetValues(typeof(ResU.BoneFlagsRotation)); rotModeCB.SelectedItem = bone.FlagsRotation; billboardModeCB.Bind(typeof(BoneFlagsBillboard), bone, "FlagsBillboard"); billboardIndexUD.Value = bone.BillboardIndex; smoothIndexUD.Value = bone.SmoothMatrixIndex; rigidIndexUD.Value = bone.RigidMatrixIndex; chkTransformIdentity.Bind(bone, "TransformIdentity"); chkTransformRotateTranslateZero.Bind(bone, "TransformRotateTranslateZero"); chkTransformRotateZero.Bind(bone, "TransformRotateZero"); chkTransformScaleOne.Bind(bone, "TransformScaleOne"); chkTransformScaleUniform.Bind(bone, "TransformScaleUniform"); chkTransformScaleVolumeOne.Bind(bone, "TransformScaleVolumeOne"); chkTransformTranslateZero.Bind(bone, "TransformTranslateZero"); chkTransformCuIdenity.Bind(bone, "TransformCumulativeIdentity"); chkTransformCuRotateTrnaslateZero.Bind(bone, "TransformCumulativeRotateTranslateZero"); chkTransformCuRotateZero.Bind(bone, "TransformCumulativeRotateZero"); chkTransformCuScaleOne.Bind(bone, "TransformCumulativeScaleOne"); chkTransformCuScaleUniform.Bind(bone, "TransformCumulativeScaleUniform"); chkTransformCuScaleVolumeOne.Bind(bone, "TransformCumulativeScaleVolumeOne"); chkTransformCuTranslateZero.Bind(bone, "TransformCumulativeTranslateZero"); } else { var bone = bn.Bone; userDataEditor1.LoadUserData(bone.UserData.ToList()); rotModeCB.DataSource = Enum.GetValues(typeof(BoneFlagsRotation)); rotModeCB.SelectedItem = bone.FlagsRotation; billboardModeCB.Bind(typeof(BoneFlagsBillboard), bone, "FlagsBillboard"); billboardIndexUD.Bind(bone, "BillboardIndex"); smoothIndexUD.Bind(bone, "SmoothMatrixIndex"); rigidIndexUD.Bind(bone, "RigidMatrixIndex"); chkTransformIdentity.Bind(bone, "TransformIdentity"); chkTransformRotateTranslateZero.Bind(bone, "TransformRotateTranslateZero"); chkTransformRotateZero.Bind(bone, "TransformRotateZero"); chkTransformScaleOne.Bind(bone, "TransformScaleOne"); chkTransformScaleUniform.Bind(bone, "TransformScaleUniform"); chkTransformScaleVolumeOne.Bind(bone, "TransformScaleVolumeOne"); chkTransformTranslateZero.Bind(bone, "TransformTranslateZero"); chkTransformCuIdenity.Bind(bone, "TransformCumulativeIdentity"); chkTransformCuRotateTrnaslateZero.Bind(bone, "TransformCumulativeRotateTranslateZero"); chkTransformCuRotateZero.Bind(bone, "TransformCumulativeRotateZero"); chkTransformCuScaleOne.Bind(bone, "TransformCumulativeScaleOne"); chkTransformCuScaleUniform.Bind(bone, "TransformCumulativeScaleUniform"); chkTransformCuScaleVolumeOne.Bind(bone, "TransformCumulativeScaleVolumeOne"); chkTransformCuTranslateZero.Bind(bone, "TransformCumulativeTranslateZero"); } GetBoneTransform(bn); IsLoaded = true; }
public void LoadBone(BfresBone bn) { IsLoaded = false; rotModeCB.Items.Clear(); billboardModeCB.Items.Clear(); activeBone = bn; boneInfoPanel1.LoadBone(bn); rigidSkinningChkBox.Bind(bn, "UseRigidMatrix"); smoothSkinningChkBox.Bind(bn, "UseSmoothMatrix"); if (bn.BoneU != null) { var bone = bn.BoneU; userDataEditor1.LoadUserData(bone.UserData); foreach (var item in Enum.GetValues(typeof(ResU.BoneFlagsRotation))) { rotModeCB.Items.Add(item); } foreach (var item in Enum.GetValues(typeof(ResU.BoneFlagsBillboard))) { billboardModeCB.Items.Add(item); } rotModeCB.SelectedItem = bone.FlagsRotation; billboardModeCB.SelectedItem = bone.FlagsBillboard; billboardIndexUD.Value = bone.BillboardIndex; smoothIndexUD.Value = bone.SmoothMatrixIndex; rigidIndexUD.Value = bone.RigidMatrixIndex; chkTransformIdentity.Bind(bone, "TransformIdentity"); chkTransformRotateTranslateZero.Bind(bone, "TransformRotateTranslateZero"); chkTransformRotateZero.Bind(bone, "TransformRotateZero"); chkTransformScaleOne.Bind(bone, "TransformScaleOne"); chkTransformScaleUniform.Bind(bone, "TransformScaleUniform"); chkTransformScaleVolumeOne.Bind(bone, "TransformScaleVolumeOne"); chkTransformTranslateZero.Bind(bone, "TransformTranslateZero"); chkTransformCuIdenity.Bind(bone, "TransformCumulativeIdentity"); chkTransformCuRotateTrnaslateZero.Bind(bone, "TransformCumulativeRotateTranslateZero"); chkTransformCuRotateZero.Bind(bone, "TransformCumulativeRotateZero"); chkTransformCuScaleOne.Bind(bone, "TransformCumulativeScaleOne"); chkTransformCuScaleUniform.Bind(bone, "TransformCumulativeScaleUniform"); chkTransformCuScaleVolumeOne.Bind(bone, "TransformCumulativeScaleVolumeOne"); chkTransformCuTranslateZero.Bind(bone, "TransformCumulativeTranslateZero"); } else { var bone = bn.Bone; userDataEditor1.LoadUserData(bone.UserData.ToList()); foreach (var item in Enum.GetValues(typeof(BoneFlagsBillboard))) { billboardModeCB.Items.Add(item); } foreach (var item in Enum.GetValues(typeof(BoneFlagsRotation))) { rotModeCB.Items.Add(item); } rotModeCB.SelectedItem = bone.FlagsRotation; billboardModeCB.SelectedItem = bone.FlagsBillboard; billboardIndexUD.Bind(bone, "BillboardIndex"); smoothIndexUD.Bind(bone, "SmoothMatrixIndex"); rigidIndexUD.Bind(bone, "RigidMatrixIndex"); chkTransformIdentity.Bind(bone, "TransformIdentity"); chkTransformRotateTranslateZero.Bind(bone, "TransformRotateTranslateZero"); chkTransformRotateZero.Bind(bone, "TransformRotateZero"); chkTransformScaleOne.Bind(bone, "TransformScaleOne"); chkTransformScaleUniform.Bind(bone, "TransformScaleUniform"); chkTransformScaleVolumeOne.Bind(bone, "TransformScaleVolumeOne"); chkTransformTranslateZero.Bind(bone, "TransformTranslateZero"); chkTransformCuIdenity.Bind(bone, "TransformCumulativeIdentity"); chkTransformCuRotateTrnaslateZero.Bind(bone, "TransformCumulativeRotateTranslateZero"); chkTransformCuRotateZero.Bind(bone, "TransformCumulativeRotateZero"); chkTransformCuScaleOne.Bind(bone, "TransformCumulativeScaleOne"); chkTransformCuScaleUniform.Bind(bone, "TransformCumulativeScaleUniform"); chkTransformCuScaleVolumeOne.Bind(bone, "TransformCumulativeScaleVolumeOne"); chkTransformCuTranslateZero.Bind(bone, "TransformCumulativeTranslateZero"); } GetBoneTransform(bn); IsLoaded = true; }
public static void LoadEditor(BfresBone bone) { }