예제 #1
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);
                    }
                }
            }
        }
예제 #2
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));
                 }
             }
         }
     }
 }
예제 #3
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);
                    }
                }
            }
        }
예제 #4
0
        public void Read(FileData d)
        {
            d.Endian = Endianness.Big;

            d.seek(0x16);
            int count = d.readShort();

            d.seek(0x60);

            for (int i = 0; i < count; i++)
            {
                string name = d.readString(d.pos(), -1);
                d.skip(0x40);
                int unk      = d.readInt();
                int nextFile = d.readInt();
                int c2       = d.readShort();
                int c1       = d.readShort();
                d.skip(4); // padding?

                int[] partsizes = new int[4];
                for (int j = 0; j < 4; j++)
                {
                    partsizes[j] = d.readInt();
                }

                TreeNode part = new TreeNode();
                part.Text = name;
                Nodes.Add(part);

                int off = 0;
                for (int j = 0; j < c1; j++)
                {
                    TreeNode t = new TreeNode();
                    part.Nodes.Add(t);
                    int    decompressedSize = d.readInt();
                    byte[] dat = FileData.InflateZLIB(d.getSection(d.pos(), partsizes[j] - 4 - off));
                    d.skip(partsizes[j] - 4);
                    off += partsizes[j];
                    string mag = new FileData(dat).Magic();
                    t.Text = name + "." + mag;

                    if (mag.Equals("NTWD"))
                    {
                        Runtime.TextureContainers.Add(new NUT(new FileData(dat)));
                    }

                    if (mag.Equals("OMO "))
                    {
                        Runtime.Animations.Add(t.Text, OMOOld.read(new FileData(dat)));
                        MainForm.Instance.animList.treeView1.Nodes.Add(t.Text);
                    }
                }
            }
        }
예제 #5
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);
                    }
                }
            }
        }
예제 #6
0
        public void ImportAnimation(string filename)
        {
            if (filename.ToLower().EndsWith(".pac"))
            {
                PAC p = new PAC();
                p.Read(filename);
                AnimationGroupNode animGroup = new AnimationGroupNode()
                {
                    Text = filename
                };
                string groupname = null;
                foreach (var pair in p.Files)
                {
                    if (pair.Key.EndsWith(".omo"))
                    {
                        var anim = OMOOld.read(new FileData(pair.Value));
                        animGroup.Nodes.Add(anim);
                        string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();

                        if (!string.IsNullOrEmpty(AnimName))
                        {
                            if (groupname == null)
                            {
                                groupname = pair.Key.Replace(AnimName, "");
                            }
                            anim.Text = AnimName;
                        }
                        //Runtime.acmdEditor.updateCrcList();
                    }
                    else if (pair.Key.EndsWith(".mta"))
                    {
                        MTA mta = new MTA();
                        mta.read(new FileData(pair.Value));
                        mta.Text = pair.Key;
                        animGroup.Nodes.Add(mta);
                    }
                }

                if (groupname != null && !groupname.Equals(""))
                {
                    animGroup.UseGroupName = true;
                    animGroup.Text         = groupname;
                }

                treeView1.Nodes.Add(animGroup);
            }
        }
예제 #7
0
        private void exportAllAsOMOToolStripMenuItem_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)
                    {
                        if (v is Animation)
                        {
                            OMOOld.createOMO(((Animation)v), Runtime.TargetVBN, path + "\\" + v.Text + ".omo");
                        }
                    }
                }
            }
        }
예제 #8
0
        public void Save(object sender, EventArgs args)
        {
            //BackgroundWorker worker = sender as BackgroundWorker;

            float f = 1;

            if (FileName.ToLower().EndsWith(".bch"))
            {
                List <Animation> anims = new List <Animation>();
                foreach (Animation a in ((TreeNode)Node).Nodes)
                {
                    //worker.ReportProgress((int)((f / Node.Nodes.Count) * 100f));
                    f++;
                    anims.Add(a);
                }
                BCH_Animation.Rebuild(FileName, anims);
            }
            if (FileName.ToLower().EndsWith(".pac"))
            {
                var pac = new PAC();
                foreach (Animation anim in Node.Nodes)
                {
                    //worker.ReportProgress((int)((f / Node.Nodes.Count) * 100f));
                    f++;
                    //Console.WriteLine("Working on " + anim.Text + " " + (anim.Tag is FileData));
                    var bytes = new byte[1];
                    if (anim.Tag != null && anim.Tag is FileData)
                    {
                        bytes = ((FileData)anim.Tag).getSection(0, ((FileData)anim.Tag).size());
                    }
                    else
                    {
                        bytes = OMOOld.CreateOMOFromAnimation(anim, Runtime.TargetVBN);
                    }

                    pac.Files.Add((UseGroupName ? Text : "") + (anim.Text.EndsWith(".omo") ? anim.Text : anim.Text + ".omo"), bytes);
                }
                pac.Save(FileName);
            }
        }
예제 #9
0
        public static void MakePichu(string path = "C:\\Pichu\\")
        {
            if (!path.EndsWith("\\"))
            {
                path += "\\";
            }
            DAT dat = new DAT();

            dat.Read(new FileData(path + "PlPcNr.dat"));
            dat.PreRender();

            dat.ExportTextures(path, 0x401B1000);

            BoneNameFix(dat.bones);

            // model--------------------------------------------------------
            ModelContainer converted = dat.wrapToNUD();
            NUD            nud       = converted.NUD;
            float          sca       = 0.6f;


            removeLowPolyNr(nud);
            nud.UpdateRenderMeshes();

            //Runtime.ModelContainers.Add(converted);
            //-------------------------------------------------

            Runtime.TargetVBN = converted.VBN;

            MainForm.HashMatch();

            Dictionary <string, SkelAnimation> anims = DAT_Animation.LoadAJ(path + "PlPcAJ.dat", converted.VBN);

            //ArrangeBones(converted.vbn, converted.nud);

            // note bone 40 - 51 is disabled for pika

            foreach (string an in anims.Keys)
            {
                effectiveScale(anims[an], Matrix4.CreateTranslation(0, 0, 0) * Matrix4.CreateScale(sca, sca, sca));
            }
            effectiveScale(converted.NUD, converted.VBN, Matrix4.CreateTranslation(0, 0, 0) * Matrix4.CreateScale(sca, sca, sca));

            Directory.CreateDirectory(path + "build\\model\\body\\c00\\");
            nud.Save(path + "build\\model\\body\\c00\\model.nud");
            converted.VBN.Endian = Endianness.Little;
            converted.VBN.Save(path + "build\\model\\body\\c00\\model.vbn");


            PAC org  = new PAC();
            PAC npac = new PAC();

            org.Read(path + "main.pac");
            foreach (string key in org.Files.Keys)
            {
                byte[] d = org.Files[key];

                foreach (string an in anims.Keys)
                {
                    string name = an.Replace("PlyPichu5K_Share_ACTION_", "").Replace("_figatree", "");
                    if (key.Contains(name))
                    {
                        Console.WriteLine("Matched " + name + " with " + key);

                        if (!anims[an].getNodes(true).Contains(0) && !key.Contains("Cliff"))
                        {
                            KeyNode node = anims[an].getNode(0, 0);
                            node.t_type = 1;
                        }
                        d = OMOOld.createOMO(anims[an], converted.VBN);
                        break;
                    }
                }

                npac.Files.Add(key, d);
            }
            Directory.CreateDirectory(path + "build\\motion\\");
            npac.Save(path + "build\\motion\\main.pac");

            /*FileOutput omo = new FileOutput();
             * converted.vbn.reset();
             * converted.vbn.totalBoneCount = (uint)converted.vbn.bones.Count;
             * omo.writeBytes(OMO.createOMO(anims["PlyPichu5K_Share_ACTION_Wait1_figatree"], converted.vbn));
             * omo.save(path + "PlyPichu5K_Share_ACTION_Wait1_figatree.omo");*/
        }