Пример #1
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, OMO.read(new FileData(dat)));
                        MainForm.animNode.Nodes.Add(t.Text);
                    }
                }
            }
        }
Пример #2
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.PreRender();

            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 = OMO.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");*/
        }
Пример #3
0
        private void openStageToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            using (var ofd = new FolderSelectDialog())
            {
                ofd.Title = "Stage Folder";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string        stagePath     = ofd.SelectedPath;
                    string        modelPath     = stagePath + "\\model\\";
                    string        paramPath     = stagePath + "\\param\\";
                    string        animationPath = stagePath + "\\animation\\";
                    List <string> nuds          = new List <string>();

                    if (Directory.Exists(modelPath))
                    {
                        foreach (string d in Directory.GetDirectories(modelPath))
                        {
                            foreach (string f in Directory.GetFiles(d))
                            {
                                if (f.EndsWith(".nud"))
                                {
                                    openNud(f, Path.GetFileName(d));
                                }
                            }
                        }
                    }

                    if (Directory.Exists(paramPath))
                    {
                        Runtime.TargetLVD = null;
                        foreach (string f in Directory.GetFiles(paramPath))
                        {
                            if (Path.GetExtension(f).Equals(".lvd") && Runtime.TargetLVD == null)
                            {
                                Runtime.TargetLVD = new LVD(f);
                                lvdList.fillList();
                            }
                        }
                    }

                    if (Directory.Exists(animationPath))
                    {
                        foreach (string d in Directory.GetDirectories(animationPath))
                        {
                            foreach (string f in Directory.GetFiles(d))
                            {
                                if (f.EndsWith(".omo"))
                                {
                                    Runtime.Animations.Add(f, OMO.read(new FileData(f)));
                                    animNode.Nodes.Add(f);
                                }
                                else if (f.EndsWith("path.bin"))
                                {
                                    Runtime.TargetPath = new PathBin();
                                    Runtime.TargetPath.Read(f);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*if (Runtime.TargetVBN == null)
             * {
             *  return;
             * }*/

            using (var sfd = new SaveFileDialog())
            {
                sfd.Filter = "Supported Files (.omo, .anim, .pac, .mta)|*.omo;*.anim;*.pac;*.mta|" +
                             "Object Motion (.omo)|*.omo|" +
                             "Material Animation (.mta)|*.mta|" +
                             "Maya Anim (.anim)|*.anim|" +
                             "OMO Pack (.pac)|*.pac|" +
                             "All Files (*.*)|*.*";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    sfd.FileName = sfd.FileName;

                    if (sfd.FileName.EndsWith(".anim"))
                    {
                        if (Runtime.TargetAnim.Tag is AnimTrack)
                        {
                            ((AnimTrack)Runtime.TargetAnim.Tag).createANIM(sfd.FileName, Runtime.TargetVBN);
                        }
                        else
                        {
                            ANIM.createANIM(sfd.FileName, Runtime.TargetAnim, Runtime.TargetVBN);
                        }
                    }

                    if (sfd.FileName.EndsWith(".omo"))
                    {
                        if (Runtime.TargetAnim.Tag is FileData)
                        {
                            FileOutput o = new FileOutput();
                            o.writeBytes(((FileData)Runtime.TargetAnim.Tag).getSection(0, ((FileData)Runtime.TargetAnim.Tag).size()));
                            o.save(sfd.FileName);
                        }
                        else
                        {
                            OMO.createOMO(Runtime.TargetAnim, Runtime.TargetVBN, sfd.FileName);
                        }
                    }

                    if (sfd.FileName.EndsWith(".pac"))
                    {
                        var pac = new PAC();
                        foreach (var anim in Runtime.Animations)
                        {
                            var bytes = OMO.createOMO(anim.Value, Runtime.TargetVBN);
                            if (Runtime.TargetAnim.Tag is FileData)
                            {
                                bytes = ((FileData)Runtime.TargetAnim.Tag).getSection(0, ((FileData)Runtime.TargetAnim.Tag).size());
                            }

                            pac.Files.Add(anim.Key, bytes);
                        }
                        pac.Save(sfd.FileName);
                    }

                    if (sfd.FileName.EndsWith(".mta"))
                    {
                        FileOutput f = new FileOutput();
                        f.writeBytes(Runtime.TargetMTA.Rebuild());
                        f.save(sfd.FileName);
                    }
                }
            }
        }