예제 #1
0
 private void exportAllAsANIMToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var ofd = new FolderSelectDialog())
     {
         ofd.Title = "Character Folder";
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             string path = ofd.SelectedPath;
             foreach (TreeNode b in treeView1.Nodes)
             {
                 foreach (TreeNode v in b.Nodes)
                 {
                     foreach (TreeNode f in v.Nodes)
                     {
                         foreach (TreeNode a in f.Nodes)
                         {
                             if (a is Animation)
                             {
                                 ANIM.CreateANIM(path + "\\" + a.Text + ".anim", ((Animation)a), Runtime.TargetVbn);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public void ReplaceAnimation(object sender, EventArgs args)
        {
            using (OpenFileDialog of = new OpenFileDialog())
            {
                of.ShowDialog();

                foreach (string filename in of.FileNames)
                {
                    if (filename.EndsWith(".omo"))
                    {
                        Animation a = OMOOld.read(new FileData(filename));
                        a.Text = filename;
                        ReplaceMe(a);
                    }
                    if (filename.EndsWith(".smd"))
                    {
                        Animation a = new Animation(filename.Replace(".smd", ""));
                        Smd.Read(filename, a, Runtime.TargetVbn);
                        ReplaceMe(a);
                    }
                    if (filename.EndsWith(".chr0"))
                    {
                        Animation a = (CHR0.read(new FileData(filename), Runtime.TargetVbn));
                        ReplaceMe(a);
                    }
                    if (filename.EndsWith(".anim"))
                    {
                        Animation a = (ANIM.read(filename, Runtime.TargetVbn));
                        ReplaceMe(a);
                    }
                }
            }
        }
예제 #3
0
 public void Import(object sender, EventArgs args)
 {
     using (OpenFileDialog fd = new OpenFileDialog())
     {
         fd.Filter = "Supported Formats|*.omo;*.anim;*.chr0;*.smd;*.mta;|" +
                     "Object Motion|*.omo|" +
                     "Maya Animation|*.anim|" +
                     "NW4R Animation|*.chr0|" +
                     "Source Animation (SMD)|*.smd|" +
                     "Smash 4 Material Animation (MTA)|*.mta|" +
                     "All files(*.*)|*.*";
         if (fd.ShowDialog() == DialogResult.OK)
         {
             foreach (string filename in fd.FileNames)
             {
                 if (filename.EndsWith(".mta"))
                 {
                     MTA mta = new MTA();
                     try
                     {
                         mta.Read(filename);
                         Runtime.MaterialAnimations.Add(filename, mta);
                         Nodes.Add(filename);
                     }
                     catch (Exception)
                     {
                         mta = null;
                     }
                 }
                 else if (filename.EndsWith(".smd"))
                 {
                     var anim = new Animation(filename);
                     if (Runtime.TargetVbn == null)
                     {
                         Runtime.TargetVbn = new VBN();
                     }
                     Smd.Read(filename, anim, Runtime.TargetVbn);
                     Nodes.Add(anim);
                 }
                 if (filename.EndsWith(".omo"))
                 {
                     Animation a = OMOOld.read(new FileData(filename));
                     a.Text = filename;
                     Nodes.Add(a);
                 }
                 if (filename.EndsWith(".chr0"))
                 {
                     Nodes.Add(CHR0.read(new FileData(filename), Runtime.TargetVbn));
                 }
                 if (filename.EndsWith(".anim"))
                 {
                     Nodes.Add(ANIM.read(filename, Runtime.TargetVbn));
                 }
             }
         }
     }
 }
예제 #4
0
        public void SaveAs(object sender, EventArgs args)
        {
            if (Runtime.TargetVbn == null)
            {
                MessageBox.Show("You must have a bone-set (VBN) selected to save animations.");
                return;
            }
            using (var sfd = new SaveFileDialog())
            {
                sfd.Filter = "Supported Files (.omo, .anim, .smd)|*.omo;*.anim;*.smd|" +
                             "Maya Anim (.anim)|*.anim|" +
                             "Object Motion (.omo)|*.omo|" +
                             "Source Animation (.smd)|*.smd|" +
                             "All Files (*.*)|*.*";

                sfd.DefaultExt = "smd"; //Set a default extension to prevent crashing if not specified by user
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    sfd.FileName = sfd.FileName;

                    if (sfd.FileName.EndsWith(".anim"))
                    {
                        if (Tag is AnimTrack)
                        {
                            ((AnimTrack)Tag).CreateAnim(sfd.FileName, Runtime.TargetVbn);
                        }
                        else
                        {
                            ANIM.CreateANIM(sfd.FileName, this, Runtime.TargetVbn);
                        }
                    }

                    if (sfd.FileName.EndsWith(".omo"))
                    {
                        if (Tag is FileData)
                        {
                            FileOutput o = new FileOutput();
                            o.WriteBytes(((FileData)Tag).GetSection(0,
                                                                    ((FileData)Tag).Size()));
                            o.Save(sfd.FileName);
                        }
                        else
                        {
                            File.WriteAllBytes(sfd.FileName, OMOOld.CreateOMOFromAnimation(this, Runtime.TargetVbn));
                        }
                    }


                    if (sfd.FileName.EndsWith(".smd"))
                    {
                        Smd.Save(this, Runtime.TargetVbn, sfd.FileName);
                    }
                }
            }
        }
예제 #5
0
        public void Apply(VBN bone)
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                List <AnimType> used = new List <AnimType>();

                Bone    b    = bone.bones[i];
                Vector3 erot = ANIM.quattoeul(b.rot);

                foreach (DATAnimTrack track in nodes[i])
                {
                    KeyNode node = track.keys[0];

                    if (Debug)
                    {
                        Console.WriteLine("Bone " + i + " " + track.type + " " + node.value);
                    }

                    switch (track.type)
                    {
                    case AnimType.XPOS:
                        b.pos.X = node.value;
                        break;

                    case AnimType.YPOS:
                        b.pos.Y = node.value;
                        break;

                    case AnimType.ZPOS:
                        b.pos.Z = node.value;
                        break;

                    case AnimType.XROT:
                        erot.X = node.value;
                        break;

                    case AnimType.YROT:
                        erot.Y = node.value;
                        break;

                    case AnimType.ZROT:
                        erot.Z = node.value;
                        break;
                    }
                }
                b.rot = VBN.FromEulerAngles(erot.Z, erot.Y, erot.X);
            }

            bone.update();
        }
예제 #6
0
        public static void Save(Animation anim, VBN skeleton, String fname)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fname))
            {
                file.WriteLine("version 1");

                file.WriteLine("nodes");
                foreach (Bone b in skeleton.bones)
                {
                    file.WriteLine(skeleton.bones.IndexOf(b) + " \"" + b.Text + "\" " + b.parentIndex);
                }
                file.WriteLine("end");

                file.WriteLine("skeleton");
                anim.SetFrame(0);
                for (int i = 0; i <= anim.frameCount; i++)
                {
                    anim.NextFrame(skeleton);

                    file.WriteLine("time " + i);

                    foreach (Animation.KeyNode sb in anim.bones)
                    {
                        Bone b = skeleton.getBone(sb.Text);
                        if (b == null)
                        {
                            continue;
                        }
                        Vector3 eul = ANIM.quattoeul(b.rot);
                        file.WriteLine(skeleton.bones.IndexOf(b) + " " + b.pos.X + " " + b.pos.Y + " " + b.pos.Z + " " + eul.X + " " + eul.Y + " " + eul.Z);
                    }
                }
                file.WriteLine("end");

                file.Close();
            }
        }
예제 #7
0
            public void SetKeyFromBone(float frame, Bone bone)
            {
                Vector3 rot = ANIM.quattoeul(bone.rot);

                if (rot.X != bone.rotation[0] || rot.Y != bone.rotation[1] || rot.Z != bone.rotation[2])
                {
                    xrot.GetKeyFrame(frame).Value = bone.rot.X;
                    yrot.GetKeyFrame(frame).Value = bone.rot.Y;
                    zrot.GetKeyFrame(frame).Value = bone.rot.Z;
                    wrot.GetKeyFrame(frame).Value = bone.rot.W;
                }
                if (bone.pos.X != bone.position[0] || bone.pos.Y != bone.position[1] || bone.pos.Z != bone.position[2])
                {
                    xpos.GetKeyFrame(frame).Value = bone.pos.X;
                    ypos.GetKeyFrame(frame).Value = bone.pos.Y;
                    zpos.GetKeyFrame(frame).Value = bone.pos.Z;
                }
                if (bone.sca.X != bone.scale[0] || bone.sca.Y != bone.scale[1] || bone.sca.Z != bone.scale[2])
                {
                    xsca.GetKeyFrame(frame).Value = bone.sca.X;
                    ysca.GetKeyFrame(frame).Value = bone.sca.Y;
                    zsca.GetKeyFrame(frame).Value = bone.sca.Z;
                }
            }