示例#1
0
 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.unks2[5];
     numericUpDown17.Value = (Decimal)sbEntry.ints[0];
     numericUpDown18.Value = (Decimal)sbEntry.ints[1];
     numericUpDown19.Value = (Decimal)sbEntry.ints[2];
     dontChange            = false;
 }
示例#2
0
        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();
            }
        }