Example #1
0
        private bool LoadFile( Stream stream )
        {
            string magic = stream.ReadAscii( 4 );
            switch ( magic ) {
                case "G1TG": Endian = Util.Endianness.BigEndian; break;
                case "GT1G": Endian = Util.Endianness.LittleEndian; break;
                default: throw new Exception( "Not a g1t file!" );
            }

            uint version = stream.ReadUInt32().FromEndian( Endian );

            switch ( version ) {
                case 0x30303530: break;
                case 0x30303630: break;
                default: throw new Exception( "Unsupported g1t version!" );
            }

            uint fileSize = stream.ReadUInt32().FromEndian( Endian );
            uint headerSize = stream.ReadUInt32().FromEndian( Endian );
            uint numberTextures = stream.ReadUInt32().FromEndian( Endian );
            uint unknown = stream.ReadUInt32().FromEndian( Endian );

            stream.Position = headerSize;
            uint bytesUnknownData = stream.ReadUInt32().FromEndian( Endian );
            stream.Position = headerSize + bytesUnknownData;
            Textures = new List<g1tTexture>( (int)numberTextures );
            for ( uint i = 0; i < numberTextures; ++i ) {
                var g = new g1tTexture( stream, Endian );
                Textures.Add( g );
            }

            return true;
        }
Example #2
0
        private bool LoadFile(Stream stream)
        {
            string magic = stream.ReadAscii(4);

            switch (magic)
            {
            case "G1TG": Endian = EndianUtils.Endianness.BigEndian; break;

            case "GT1G": Endian = EndianUtils.Endianness.LittleEndian; break;

            default: throw new Exception("Not a g1t file!");
            }

            uint version = stream.ReadUInt32().FromEndian(Endian);

            switch (version)
            {
            case 0x30303530: break;

            case 0x30303630: break;

            default: throw new Exception("Unsupported g1t version!");
            }

            uint fileSize       = stream.ReadUInt32().FromEndian(Endian);
            uint headerSize     = stream.ReadUInt32().FromEndian(Endian);
            uint numberTextures = stream.ReadUInt32().FromEndian(Endian);
            uint unknown        = stream.ReadUInt32().FromEndian(Endian);

            stream.Position = headerSize;
            uint bytesUnknownData = stream.ReadUInt32().FromEndian(Endian);

            stream.Position = headerSize + bytesUnknownData;
            Textures        = new List <g1tTexture>((int)numberTextures);
            for (uint i = 0; i < numberTextures; ++i)
            {
                var g = new g1tTexture(stream, Endian);
                Textures.Add(g);
            }

            return(true);
        }