Beispiel #1
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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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.tType = 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");*/
        }