Esempio n. 1
0
        /// <summary>
        ///     Loads a PC monster model from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the monster meshes</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            models = BCH.load(new MemoryStream(container.content[0].data));

            return(models);
        }
Esempio n. 2
0
        /// <summary>
        ///     Loads a CP overworld character model from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the character meshes</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            models = CM.load(new MemoryStream(container.ElementAt(1).data));

            return(models);
        }
Esempio n. 3
0
        /// <summary>
        ///     Loads a BS animation file from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the animations</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            List <RenderBase.OModelGroup> models = new List <RenderBase.OModelGroup>();
            OContainer naCont = PkmnContainer.load(data); //Get NA containers from BS

            for (int i = 1; i < naCont.content.Count; i++)
            {                                                                                      //Skip first entry because its not a NA (TODO: figure out this data)
                OContainer bchCont = PkmnContainer.load(new MemoryStream(naCont.content[1].data)); //Get BCH from NA containers
                models.Add(BCH.load(new System.IO.MemoryStream(bchCont.content[0].data)));
            }

            return(models[0]); //TODO: Figure out how to load all anim BCHs
        }
Esempio n. 4
0
        /// <summary>
        ///     Loads a BS animation file from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the animations</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            List <RenderBase.OModelGroup> models = new List <RenderBase.OModelGroup>();
            OContainer naCont = PkmnContainer.load(data); //Get NA containers from BS
            var        naList = naCont.GetList();

            foreach (var entry in naCont.Skip(1))
            {
                OContainer bchCont = PkmnContainer.load(new MemoryStream(entry.data)); //Get BCH from NA containers
                models.Add(BCH.load(new MemoryStream(bchCont.First().data)));
            }

            return(models[0]); //TODO: Figure out how to load all anim BCHs
        }
Esempio n. 5
0
        /// <summary>
        ///     Loads all map textures (and other data) on a AD Pokémon container.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with textures and stuff</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            for (int i = 1; i < container.content.Count; i++)
            {
                FileIO.file file = FileIO.load(new MemoryStream(container.content[i].data));
                if (file.type == FileIO.formatType.model)
                {
                    models.merge((RenderBase.OModelGroup)file.data);
                }
            }

            return(models);
        }
Esempio n. 6
0
        /// <summary>
        ///     Loads a CM overworld character model from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the character meshes</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            models = GfModel.load(new MemoryStream(container.content[0].data));

            List <RenderBase.OSkeletalAnimation> anms = GfMotion.load(new MemoryStream(container.content[1].data));

            foreach (RenderBase.OSkeletalAnimation anm in anms)
            {
                models.skeletalAnimation.list.Add(anm);
            }

            return(models);
        }
Esempio n. 7
0
        /// <summary>
        ///     Loads all map textures (and other data) on a AD Pokémon container.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with textures and stuff</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            foreach (var entry in container)
            {
                FileIO.file file = FileIO.load(new MemoryStream(entry.data));
                if (file.type == FileIO.formatType.model)
                {
                    models.merge((RenderBase.OModelGroup)file.data);
                }
            }

            return(models);
        }
Esempio n. 8
0
        /// <summary>
        ///     Loads all monster textures on a PT Pokémon container.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The monster textures</returns>
        public static List <RenderBase.OTexture> load(Stream data)
        {
            List <RenderBase.OTexture> textures = new List <RenderBase.OTexture>();

            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            for (int i = 0; i < container.content.Count; i++)
            {
                FileIO.file file = FileIO.load(new MemoryStream(container.content[i].data));
                if (file.type == FileIO.formatType.model)
                {
                    textures.AddRange(((RenderBase.OModelGroup)file.data).texture);
                }
            }

            return(textures);
        }
Esempio n. 9
0
        /// <summary>
        ///     Loads all monster textures on a PT Pokémon container.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The monster textures</returns>
        public static List <RenderBase.OTexture> load(Stream data)
        {
            List <RenderBase.OTexture> textures = new List <RenderBase.OTexture>();

            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            foreach (var entry in container)
            {
                FileIO.file file = FileIO.load(new MemoryStream(entry.data));
                if (file.type == FileIO.formatType.model)
                {
                    textures.AddRange(((RenderBase.OModelGroup)file.data).texture);
                }
            }

            return(textures);
        }
Esempio n. 10
0
        /// <summary>
        ///     Loads a PC monster model from Pokémon.
        /// </summary>
        /// <param name="data">The data</param>
        /// <returns>The Model group with the monster meshes</returns>
        public static RenderBase.OModelGroup load(Stream data)
        {
            RenderBase.OModelGroup models = new RenderBase.OModelGroup();

            OContainer container = PkmnContainer.load(data);

            foreach (OContainer.FileEntry file in container)
            {
                FileIO.file loaded = new FileIO.file();

                try
                {
                    loaded = FileIO.load(new MemoryStream(file.data));
                }
                catch (Exception e)
                {
                    Debug.WriteLine(string.Format("Error opening file:\n{0}\n{1}", e.Message, e.StackTrace));
                }

                if (loaded.data == null)
                {
                    continue;
                }

                switch (loaded.type)
                {
                case FileIO.formatType.model: models.merge((RenderBase.OModelGroup)loaded.data); break;

                case FileIO.formatType.anims: models.skeletalAnimation.Add((RenderBase.OSkeletalAnimation)loaded.data); break;

                case FileIO.formatType.image: models.texture.Add((RenderBase.OTexture)loaded.data); break;
                }
            }

            return(models);
        }
Esempio n. 11
0
        public static file load(Stream data)
        {
            //Too small
            if (data.Length < 0x10)
            {
                data.Close();
                return(new file {
                    type = formatType.unsupported
                });
            }

            BinaryReader input = new BinaryReader(data);
            uint         magic, length;

            switch (peek(input))
            {
            case 0x00010000: return(new file {
                    data = GfModel.load(data), type = formatType.model
                });

            case 0x00060000: return(new file {
                    data = GfMotion.loadAnim(input), type = formatType.anims
                });

            case 0x15041213: return(new file {
                    data = GfTexture.load(data), type = formatType.image
                });

            case 0x15122117:
                RenderBase.OModelGroup mdls = new RenderBase.OModelGroup();
                mdls.model.Add(GfModel.loadModel(data));
                return(new file {
                    data = mdls, type = formatType.model
                });
            }

            switch (getMagic(input, 5))
            {
            case "MODEL": return(new file {
                    data = DQVIIPack.load(data), type = formatType.container
                });
            }

            switch (getMagic(input, 4))
            {
            case "CGFX": return(new file {
                    data = CGFX.load(data), type = formatType.model
                });

            case "CRAG": return(new file {
                    data = GARC.load(data), type = formatType.container
                });

            case "darc": return(new file {
                    data = DARC.load(data), type = formatType.container
                });

            case "FPT0": return(new file {
                    data = FPT0.load(data), type = formatType.container
                });

            case "IECP":
                magic  = input.ReadUInt32();
                length = input.ReadUInt32();
                return(load(new MemoryStream(LZSS.decompress(data, length))));

            case "NLK2":
                data.Seek(0x80, SeekOrigin.Begin);
                return(new file
                {
                    data = CGFX.load(data),
                    type = formatType.model
                });

            case "SARC": return(new file {
                    data = SARC.load(data), type = formatType.container
                });

            case "SMES": return(new file {
                    data = NLP.loadMesh(data), type = formatType.model
                });

            case "Yaz0":
                magic  = input.ReadUInt32();
                length = IOUtils.endianSwap(input.ReadUInt32());
                data.Seek(8, SeekOrigin.Current);
                return(load(new MemoryStream(Yaz0.decompress(data, length))));

            case "zmdl": return(new file {
                    data = ZMDL.load(data), type = formatType.model
                });

            case "ztex": return(new file {
                    data = ZTEX.load(data), type = formatType.texture
                });
            }

            //Check if is a BCLIM or BFLIM file (header on the end)
            if (data.Length > 0x28)
            {
                data.Seek(-0x28, SeekOrigin.End);
                string clim = IOUtils.readStringWithLength(input, 4);
                if (clim == "CLIM" || clim == "FLIM")
                {
                    return new file {
                               data = BCLIM.load(data), type = formatType.image
                    }
                }
                ;
            }

            switch (getMagic(input, 3))
            {
            case "BCH":
                byte[] buffer = new byte[data.Length];
                input.Read(buffer, 0, buffer.Length);
                data.Close();
                return(new file
                {
                    data = BCH.load(new MemoryStream(buffer)),
                    type = formatType.model
                });

            case "DMP": return(new file {
                    data = DMP.load(data), type = formatType.image
                });
            }

            string magic2b = getMagic(input, 2);

            switch (magic2b)
            {
            case "AD": return(new file {
                    data = AD.load(data), type = formatType.model
                });

            case "BM": return(new file {
                    data = MM.load(data), type = formatType.model
                });

            case "BS": return(new file {
                    data = BS.load(data), type = formatType.anims
                });

            case "CM": return(new file {
                    data = CM.load(data), type = formatType.model
                });

            case "CP": return(new file {
                    data = CP.load(data), type = formatType.model
                });

            case "GR": return(new file {
                    data = GR.load(data), type = formatType.model
                });

            case "MM": return(new file {
                    data = MM.load(data), type = formatType.model
                });

            case "PC": return(new file {
                    data = PC.load(data), type = formatType.model
                });

            case "PT": return(new file {
                    data = PT.load(data), type = formatType.texture
                });
            }

            if (magic2b.Length == 2)
            {
                if ((magic2b[0] >= 'A' && magic2b[0] <= 'Z') &&
                    (magic2b[1] >= 'A' && magic2b[1] <= 'Z'))
                {
                    return(new file {
                        data = PkmnContainer.load(data), type = formatType.container
                    });
                }
            }

            //Compressions
            data.Seek(0, SeekOrigin.Begin);
            uint cmp = input.ReadUInt32();

            if ((cmp & 0xff) == 0x13)
            {
                cmp = input.ReadUInt32();
            }
            switch (cmp & 0xff)
            {
            case 0x11: return(load(new MemoryStream(LZSS_Ninty.decompress(data, cmp >> 8))));

            case 0x90:
                byte[] buffer  = BLZ.decompress(data);
                byte[] newData = new byte[buffer.Length - 1];
                Buffer.BlockCopy(buffer, 1, newData, 0, newData.Length);
                return(load(new MemoryStream(newData)));
            }

            data.Close();
            return(new file {
                type = formatType.unsupported
            });
        }