Ejemplo n.º 1
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));
                 }
             }
         }
     }
 }
Ejemplo n.º 2
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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void SaveAs(object sender, EventArgs args)
        {
            if (Runtime.TargetVBN == null)
            {
                MessageBox.Show("You must have a bone set (VBN) open before saving 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 (*.*)|*.*";

                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
                        {
                            OMOOld.CreateOMOFromAnimation(this, Runtime.TargetVBN);
                        }
                    }


                    if (sfd.FileName.EndsWith(".smd"))
                    {
                        SMD.Save(this, Runtime.TargetVBN, sfd.FileName);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void exportAllAsSMDToolStripMenuItem_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 v in treeView1.Nodes)
                    {
                        foreach (TreeNode a in v.Nodes)
                        {
                            if (a is Animation)
                            {
                                SMD.Save(((Animation)a), Runtime.TargetVBN, path + "\\" + a.Text + ".smd");
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //<summary>
        //Open an animation based on filename
        //</summary>
        public void openAnimation(string filename)
        {
            //Runtime.Animations.Clear();
            if (filename.EndsWith(".mta"))
            {
                MTA mta = new MTA();
                try
                {
                    mta.Read(filename);
                    Runtime.MaterialAnimations.Add(filename, mta);
                    mtaNode.Nodes.Add(filename);
                    MainForm.Instance.viewports[0].loadMTA(mta);
                    Runtime.TargetMTAString = filename;
                }
                catch (EndOfStreamException)
                {
                    mta = null;
                }
            }
            else if (filename.EndsWith(".smd"))
            {
                var anim = new SkelAnimation();
                if (Runtime.TargetVBN == null)
                {
                    Runtime.TargetVBN = new VBN();
                }
                SMD.read(filename, anim, Runtime.TargetVBN);
                leftPanel.treeRefresh();
                Runtime.Animations.Add(filename, anim);
                animNode.Nodes.Add(filename);
            }
            else if (filename.EndsWith(".pac"))
            {
                PAC p = new PAC();
                p.Read(filename);

                foreach (var pair in p.Files)
                {
                    if (pair.Key.EndsWith(".omo"))
                    {
                        var    anim     = OMO.read(new FileData(pair.Value));
                        string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();
                        //AnimName = pair.Key;
                        //AnimName = AnimName.Remove(AnimName.Length - 4);
                        //AnimName = AnimName.Insert(3, "_");
                        if (!string.IsNullOrEmpty(AnimName))
                        {
                            if (Runtime.Animations.ContainsKey(AnimName))
                            {
                                Runtime.Animations[AnimName].children.Add(anim);
                            }
                            else
                            {
                                animNode.Nodes.Add(AnimName);
                                Runtime.Animations.Add(AnimName, anim);
                            }
                        }
                        else
                        {
                            if (Runtime.Animations.ContainsKey(pair.Key))
                            {
                                Runtime.Animations[pair.Key].children.Add(anim);
                            }
                            else
                            {
                                animNode.Nodes.Add(pair.Key);
                                Runtime.Animations.Add(pair.Key, anim);
                            }
                        }
                    }
                    else if (pair.Key.EndsWith(".mta"))
                    {
                        MTA mta = new MTA();
                        try
                        {
                            if (!Runtime.MaterialAnimations.ContainsKey(pair.Key))
                            {
                                mta.read(new FileData(pair.Value));
                                Runtime.MaterialAnimations.Add(pair.Key, mta);
                                mtaNode.Nodes.Add(pair.Key);
                            }

                            // matching
                            string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString().Replace(".mta", ".omo");
                            if (Runtime.Animations.ContainsKey(AnimName))
                            {
                                Runtime.Animations[AnimName].children.Add(mta);
                            }
                        }
                        catch (EndOfStreamException)
                        {
                            mta = null;
                        }
                    }
                }
            }

            if (filename.EndsWith(".dat"))
            {
                if (!filename.EndsWith("AJ.dat"))
                {
                    MessageBox.Show("Not a DAT animation");
                }
                else
                {
                    if (Runtime.ModelContainers[0].dat_melee == null)
                    {
                        MessageBox.Show("Load a DAT model first");
                    }
                    else
                    {
                        DAT_Animation.LoadAJ(filename, Runtime.ModelContainers[0].dat_melee.bones);
                    }
                }
            }
            //if (Runtime.TargetVBN.bones.Count > 0)
            //{
            if (filename.EndsWith(".omo"))
            {
                Runtime.Animations.Add(filename, OMO.read(new FileData(filename)));
                animNode.Nodes.Add(filename);
            }
            if (filename.EndsWith(".chr0"))
            {
                Runtime.Animations.Add(filename, CHR0.read(new FileData(filename), Runtime.TargetVBN));
                animNode.Nodes.Add(filename);
            }
            if (filename.EndsWith(".anim"))
            {
                Runtime.Animations.Add(filename, ANIM.read(filename, Runtime.TargetVBN));
                animNode.Nodes.Add(filename);
            }
        }
Ejemplo n.º 6
0
        ///<summary>
        ///Open a file based on the filename
        ///</summary>
        /// <param name="filename"> Filename of file to open</param>
        public void openFile(string filename)
        {
            if (!filename.EndsWith(".mta") && !filename.EndsWith(".dat") && !filename.EndsWith(".smd"))
            {
                openAnimation(filename);
            }

            if (filename.EndsWith(".vbn"))
            {
                Runtime.TargetVBN = new VBN(filename);

                if (Directory.Exists("Skapon\\"))
                {
                    NUD            nud = Skapon.Create(Runtime.TargetVBN);
                    ModelContainer con = new ModelContainer();
                    con.vbn = Runtime.TargetVBN;
                    con.nud = nud;
                    nud.PreRender();
                    Runtime.ModelContainers.Add(con);
                }
            }

            if (filename.EndsWith(".sb"))
            {
                SB sb = new SB();
                sb.Read(filename);
                SwagEditor swagEditor = new SwagEditor(sb)
                {
                    ShowHint = DockState.DockRight
                };
                AddDockedControl(swagEditor);
                SwagEditors.Add(swagEditor);
            }

            if (filename.EndsWith(".dat"))
            {
                if (filename.EndsWith("AJ.dat"))
                {
                    MessageBox.Show("This is animation; load with Animation -> Import");
                    return;
                }
                DAT dat = new DAT();
                dat.Read(new FileData(filename));
                ModelContainer c = new ModelContainer();
                Runtime.ModelContainers.Add(c);
                c.dat_melee = dat;
                dat.PreRender();

                HashMatch();

                Runtime.TargetVBN = dat.bones;

                DAT_TreeView p = new DAT_TreeView()
                {
                    ShowHint = DockState.DockLeft
                };
                p.setDAT(dat);
                AddDockedControl(p);
                //Runtime.TargetVBN = dat.bones;
                meshList.refresh();
            }

            if (filename.EndsWith(".nut"))
            {
                Runtime.TextureContainers.Add(new NUT(filename));
                NUTEditor ev = new NUTEditor();
                ev.Show();
            }

            if (filename.EndsWith(".lvd"))
            {
                Runtime.TargetLVD = new LVD(filename);
                LVD test = Runtime.TargetLVD;
                lvdList.fillList();
            }

            if (filename.EndsWith(".mta"))
            {
                Runtime.TargetMTA = new MTA();
                Runtime.TargetMTA.Read(filename);
                viewports[0].loadMTA(Runtime.TargetMTA);
                MTAEditor temp = new MTAEditor(Runtime.TargetMTA)
                {
                    ShowHint = DockState.DockLeft
                };
                temp.Text = Path.GetFileName(filename);
                AddDockedControl(temp);
                mtaEditors.Add(temp);
            }

            if (filename.EndsWith(".mtable"))
            {
                //project.openACMD(filename);
                Runtime.Moveset = new MovesetManager(filename);
            }

            if (filename.EndsWith("path.bin"))
            {
                Runtime.TargetPath = new PathBin(filename);
            }
            else
            if (filename.EndsWith(".bin"))
            {
                //Note to whoever is readin this:
                //Eventually we need to look at the magic here (and also make all .bins look at magic)
                //Runtime.TargetCMR0 = new CMR0();
                //Runtime.TargetCMR0.read(new FileData(filename));
                PARAMEditor p = new PARAMEditor(filename)
                {
                    ShowHint = DockState.Document
                };
                p.Text = Path.GetFileName(filename);
                AddDockedControl(p);
                paramEditors.Add(p);
            }

            if (filename.EndsWith(".mdl0"))
            {
                MDL0Bones mdl0 = new MDL0Bones();
                Runtime.TargetVBN = mdl0.GetVBN(new FileData(filename));
            }

            if (filename.EndsWith(".smd"))
            {
                Runtime.TargetVBN = new VBN();
                SMD.read(filename, new SkelAnimation(), Runtime.TargetVBN);
            }

            if (filename.ToLower().EndsWith(".dae"))
            {
                DAEImportSettings m = new DAEImportSettings();
                m.ShowDialog();
                if (m.exitStatus == DAEImportSettings.Opened)
                {
                    if (Runtime.ModelContainers.Count < 1)
                    {
                        Runtime.ModelContainers.Add(new ModelContainer());
                    }

                    Collada.DAEtoNUD(filename, Runtime.ModelContainers[0]);

                    // apply settings
                    m.Apply(Runtime.ModelContainers[0].nud);
                    Runtime.ModelContainers[0].nud.MergePoly();

                    meshList.refresh();
                }
            }

            if (filename.EndsWith(".mbn"))
            {
                MBN m = new MBN();
                m.Read(filename);
                ModelContainer con = new ModelContainer();
                BCH            b   = new BCH();
                con.bch = b;
                b.mbn   = m;
                b.Read("C:\\s\\Smash\\extract\\data\\fighter\\lucas\\Ness3DS - h00\\normal.bch");
                Runtime.ModelContainers.Add(con);
            }

            /*if (filename.EndsWith(".bch"))
             * {
             *  ModelContainer con = new ModelContainer();
             *  BCH b = new BCH();
             *  b.Read(filename);
             *  con.bch = b;
             *  Runtime.ModelContainers.Add(con);
             * }*/

            if (filename.EndsWith(".nud"))
            {
                openNud(filename);
            }

            if (filename.EndsWith(".moi"))
            {
                MOI moi = new MOI(filename);
                AddDockedControl(new MOIEditor(moi)
                {
                    ShowHint = DockState.DockRight
                });
            }

            if (filename.EndsWith(".wrkspc"))
            {
                Workspace = new WorkspaceManager(project);
                Workspace.OpenWorkspace(filename);
            }

            if (Runtime.TargetVBN != null)
            {
                ModelContainer m = new ModelContainer();
                m.vbn = Runtime.TargetVBN;
                Runtime.ModelContainers.Add(m);

                if (filename.EndsWith(".smd"))
                {
                    m.nud = SMD.toNUD(filename);
                    meshList.refresh();
                }

                leftPanel.treeRefresh();
            }
            else
            {
                foreach (ModelContainer m in Runtime.ModelContainers)
                {
                    if (m.vbn != null)
                    {
                        Runtime.TargetVBN = Runtime.ModelContainers[0].vbn;
                        break;
                    }
                }
            }
            // Don't want to mess up the project tree if we
            // just set it up already
            if (!filename.EndsWith(".wrkspc"))
            {
                project.fillTree();
            }
        }