private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { dontChange = true; SB.SBEntry sbEntry = (SB.SBEntry)listBox1.SelectedItem; if (sbEntry == null) { return; } boneButton1.vbn = vbn; boneButton1.SetBone(vbn.GetBone(sbEntry.hash)); for (int i = 0; i < buttons.Length; i++) { buttons[i].vbn = vbn; Bone bone = vbn.GetBone(sbEntry.boneHashes[i]); buttons[i].SetBone(bone); } xMin.Value = (Decimal)sbEntry.rx1; xMax.Value = (Decimal)sbEntry.rx2; yMin.Value = (Decimal)sbEntry.ry1; yMax.Value = (Decimal)sbEntry.ry2; zMin.Value = (Decimal)sbEntry.rz1; zMax.Value = (Decimal)sbEntry.rz2; weightBox.Value = (Decimal)sbEntry.factor; numericUpDown1.Value = (Decimal)sbEntry.param1_1; numericUpDown2.Value = (Decimal)sbEntry.param1_2; numericUpDown3.Value = (Decimal)sbEntry.param1_3; numericUpDown4.Value = (Decimal)sbEntry.param2_1; numericUpDown5.Value = (Decimal)sbEntry.param2_2; numericUpDown6.Value = (Decimal)sbEntry.param2_3; numericUpDown7.Value = (Decimal)sbEntry.unks1[0]; numericUpDown8.Value = (Decimal)sbEntry.unks1[1]; numericUpDown9.Value = (Decimal)sbEntry.unks1[2]; numericUpDown10.Value = (Decimal)sbEntry.unks1[3]; numericUpDown11.Value = (Decimal)sbEntry.unks2[0]; numericUpDown12.Value = (Decimal)sbEntry.unks2[1]; numericUpDown13.Value = (Decimal)sbEntry.unks2[2]; numericUpDown14.Value = (Decimal)sbEntry.unks2[3]; numericUpDown15.Value = (Decimal)sbEntry.unks2[4]; numericUpDown16.Value = (Decimal)sbEntry.ints[0]; numericUpDown17.Value = (Decimal)sbEntry.ints[1]; numericUpDown18.Value = (Decimal)sbEntry.ints[2]; numericUpDown19.Value = (Decimal)sbEntry.ints[3]; dontChange = false; }
public void NextFrame(VBN skeleton, bool isChild = false) { if (Frame >= FrameCount) { return; } if (Frame == 0 && !isChild) { skeleton.reset(); } foreach (object child in Children) { if (child is Animation) { ((Animation)child).SetFrame(Frame); ((Animation)child).NextFrame(skeleton, isChild: true); } if (child is MTA) { //foreach (ModelContainer con in Runtime.ModelContainers) { if (((ModelContainer)skeleton.Parent).NUD != null) { ((ModelContainer)skeleton.Parent).NUD.ApplyMta(((MTA)child), (int)Frame); } } } if (child is BFRES.MTA) //For BFRES { { if (((ModelContainer)skeleton.Parent).BFRES != null) { ((ModelContainer)skeleton.Parent).BFRES.ApplyMta(((BFRES.MTA)child), (int)Frame); } } } } bool Updated = false; // no need to update skeleton of animations that didn't change foreach (KeyNode node in Bones) { // Get Skeleton Node Bone b = null; if (node.Hash == -1) { b = skeleton.getBone(node.Text); } else { b = skeleton.GetBone((uint)node.Hash); } if (b == null) { continue; } Updated = true; if (node.XPOS.HasAnimation() && b.boneType != 3) { b.pos.X = node.XPOS.GetValue(Frame); } if (node.YPOS.HasAnimation() && b.boneType != 3) { b.pos.Y = node.YPOS.GetValue(Frame); } if (node.ZPOS.HasAnimation() && b.boneType != 3) { b.pos.Z = node.ZPOS.GetValue(Frame); } if (node.XSCA.HasAnimation()) { b.sca.X = node.XSCA.GetValue(Frame); } else { b.sca.X = 1; } if (node.YSCA.HasAnimation()) { b.sca.Y = node.YSCA.GetValue(Frame); } else { b.sca.Y = 1; } if (node.ZSCA.HasAnimation()) { b.sca.Z = node.ZSCA.GetValue(Frame); } else { b.sca.Z = 1; } if (node.XROT.HasAnimation() || node.YROT.HasAnimation() || node.ZROT.HasAnimation()) { if (node.RotType == RotationType.QUATERNION) { KeyFrame[] x = node.XROT.GetFrame(Frame); KeyFrame[] y = node.YROT.GetFrame(Frame); KeyFrame[] z = node.ZROT.GetFrame(Frame); KeyFrame[] w = node.WROT.GetFrame(Frame); Quaternion q1 = new Quaternion(x[0].Value, y[0].Value, z[0].Value, w[0].Value); Quaternion q2 = new Quaternion(x[1].Value, y[1].Value, z[1].Value, w[1].Value); if (x[0].Frame == Frame) { b.rot = q1; } else if (x[1].Frame == Frame) { b.rot = q2; } else { b.rot = Quaternion.Slerp(q1, q2, (Frame - x[0].Frame) / (x[1].Frame - x[0].Frame)); } } else if (node.RotType == RotationType.EULER) { float x = node.XROT.HasAnimation() ? node.XROT.GetValue(Frame) : b.rotation[0]; float y = node.YROT.HasAnimation() ? node.YROT.GetValue(Frame) : b.rotation[1]; float z = node.ZROT.HasAnimation() ? node.ZROT.GetValue(Frame) : b.rotation[2]; b.rot = EulerToQuat(z, y, x); } } } Frame += 1f; if (Frame >= FrameCount) { Frame = 0; } if (!isChild && Updated) { skeleton.update(); } }