public TextureFormat Import(MetadataReader metadata, string directory)
        {
            metadata.EnterSection("PE3DAT");

            int    count    = metadata.GetAttribute <int>("Textures");
            string basename = metadata.GetAttribute <string>("Basename");

            uint[]   positions1 = new uint[count];
            ushort[] widths     = new ushort[count];
            ushort[] heights    = new ushort[count];
            uint[]   positions2 = new uint[count];
            int[]    bpps       = new int[count];

            IList <Image> images = new List <Image>(count);

            for (int i = 0; i < count; i++)
            {
                metadata.EnterSection("PE3DATSegment");

                positions1[i] = metadata.Get <uint>("Position1");
                positions2[i] = metadata.Get <uint>("Position2");
                bpps[i]       = metadata.Get <int>("Bpp");

                Image img = Image.FromFile(Path.Combine(directory, basename + "_" + i + ".png"));
                widths[i]  = (ushort)img.Width;
                heights[i] = (ushort)img.Height;
                images.Add(img);

                metadata.ExitSection();
            }

            metadata.ExitSection();
            return(new PE3DATTexture(images, positions1, positions2, widths, heights, bpps));
        }
Пример #2
0
        private void Readmetadata(MetadataReader metadata, out TIM2Segment.TIM2SegmentParameters parameters, out string basename, out int palCount)
        {
            metadata.EnterSection("TIM2Texture");

            basename = metadata.GetAttribute <string>("Basename");
            palCount = metadata.GetAttribute <int>("Cluts");

            parameters = new TIM2Segment.TIM2SegmentParameters();

            parameters.swizzled = swizzled;

            parameters.linearPalette = metadata.GetAttribute <bool>("LinearClut");

            parameters.width       = metadata.Get <int>("Width");
            parameters.height      = metadata.Get <int>("Height");
            parameters.bpp         = metadata.Get <byte>("Bpp");
            parameters.colorSize   = metadata.Get <int>("ColorSize");
            parameters.mipmapCount = metadata.Get <byte>("MipmapCount");

            parameters.format = metadata.Get <byte>("Format");

            parameters.GsTEX0 = metadata.Get <byte[]>("GsTEX0");
            parameters.GsTEX1 = metadata.Get <byte[]>("GsTEX1");

            parameters.GsRegs    = metadata.Get <uint>("GsRegs");
            parameters.GsTexClut = metadata.Get <uint>("GsTexClut");

            parameters.userdata = metadata.Get <byte[]>("UserData");

            metadata.ExitSection();
        }
Пример #3
0
        public TextureFormat Import(MetadataReader metadata, string directory)
        {
            TIM2Texture tim2 = null;

            try
            {
                metadata.EnterSection("TIM2");

                int    version      = metadata.GetAttribute <int>("Version");
                string basename     = metadata.GetAttribute <string>("Basename");
                bool   swizzled     = metadata.GetAttribute <bool>("Swizzled");
                int    textureCount = metadata.GetAttribute <int>("Textures");

                List <TIM2Segment> imagesList = new List <TIM2Segment>();

                for (int i = 0; i < textureCount; i++)
                {
                    TIM2Segment segment = (TIM2Segment) new TIM2SegmentSerializer(swizzled).Import(metadata, directory);
                    imagesList.Add(segment);
                }

                metadata.ExitSection();
                tim2         = new TIM2Texture(imagesList);
                tim2.Version = version;
            }
            catch (FormatException e)
            {
                throw new TextureFormatException("Cannot parse value!\n" + e.Message, e);
            }
            catch (XmlException e)
            {
                throw new TextureFormatException("Not valid metadata!\n" + e.Message, e);
            }
            catch (TextureFormatException e)
            {
                throw new TextureFormatException(e.Message, e);
            }
            catch (Exception e)
            {
                throw new TextureFormatException("Error:\n" + e.Message, e);
            }

            return(tim2);
        }
        public TextureFormat Import(MetadataReader metadata, string directory)
        {
            metadata.EnterSection("PE3SimpleDAT");
            string basename = metadata.GetAttribute <string>("Basename");

            byte[] rawHeader = metadata.Get <byte[]>("RawHeader");

            Image img = Image.FromFile(Path.Combine(directory, basename + ".png"));

            metadata.ExitSection();

            return(new PE3SimpleDATTexture(rawHeader, img));
        }
Пример #5
0
        public TextureFormat Import(MetadataReader metadata, string directory)
        {
            metadata.EnterSection("TX48Texture");
            string basename = metadata.GetAttribute <string>("Basename");

            metadata.EnterSection("TX48Segment");
            int   bpp = metadata.Get <int>("Bpp");
            Image img = Image.FromFile(Path.Combine(directory, basename + ".png"));

            metadata.ExitSection();

            metadata.ExitSection();


            PalettedTextureFormat segment = new PalettedTextureFormat.Builder()
                                            .SetPaletteCodec(ColorCodec.CODEC_32BIT_RGBA)
                                            .SetIndexCodec(IndexCodec.FromBitPerPixel(bpp))
                                            .Build(img);
            TX48Texture texture = new TX48Texture();

            texture.TextureFormats.Add(segment);

            return(texture);
        }