コード例 #1
0
        private void ReadGameCubeData(BinaryReader binaryReader)
        {
            binaryReader.BaseStream.Position += 2;
            byte addressMode = binaryReader.ReadByte();

            addressModeU = (TextureAddressMode)((addressMode & 0xF0) >> 4);
            addressModeV = (TextureAddressMode)(addressMode & 0x0F);
            filterMode   = (TextureFilterMode)binaryReader.ReadByte();

            gcnUnknown1 = Shared.Switch(binaryReader.ReadInt32());
            gcnUnknown2 = Shared.Switch(binaryReader.ReadInt32());
            gcnUnknown3 = Shared.Switch(binaryReader.ReadInt32());
            gcnUnknown4 = Shared.Switch(binaryReader.ReadInt32());

            textureName = ReadString(binaryReader);
            alphaName   = ReadString(binaryReader);

            if (ReadFileMethods.treatStuffAsByteArray)
            {
                sectionData = binaryReader.ReadBytes((int)(sectionSize - (binaryReader.BaseStream.Position - startSectionPosition)));
                return;
            }

            rasterFormatFlags = (TextureRasterFormat)Shared.Switch(binaryReader.ReadInt32());
            width             = Shared.Switch(binaryReader.ReadInt16());
            height            = Shared.Switch(binaryReader.ReadInt16());

            bitDepth    = binaryReader.ReadByte();
            mipMapCount = binaryReader.ReadByte();
            type        = binaryReader.ReadByte();
            compression = binaryReader.ReadByte();

            int palleteSize =
                ((rasterFormatFlags & TextureRasterFormat.RASTER_PAL4) != 0) ? 0x80 / 4 :
                ((rasterFormatFlags & TextureRasterFormat.RASTER_PAL8) != 0) ? 0x400 / 4 : 0;

            if (palleteSize != 0)
            {
                palette = new Color[palleteSize];
                for (int i = 0; i < palleteSize; i++)
                {
                    palette[i] = new Color(binaryReader.ReadInt32());
                }
            }

            mipMaps = new MipMapEntry[mipMapCount];
            for (int i = 0; i < mipMapCount; i++)
            {
                int    dataSize = Shared.Switch(binaryReader.ReadInt32());
                byte[] data     = binaryReader.ReadBytes(dataSize);

                mipMaps[i] = new MipMapEntry(dataSize, data);
            }
        }
コード例 #2
0
        private void ReadNormalData(BinaryReader binaryReader, int endOfSectionPosition)
        {
            filterMode = (TextureFilterMode)binaryReader.ReadByte();
            byte addressMode = binaryReader.ReadByte();

            addressModeU = (TextureAddressMode)((addressMode & 0xF0) >> 4);
            addressModeV = (TextureAddressMode)(addressMode & 0x0F);
            binaryReader.BaseStream.Position += 2;

            textureName = ReadString(binaryReader);
            alphaName   = ReadString(binaryReader);

            rasterFormatFlags = (TextureRasterFormat)binaryReader.ReadInt32();
            hasAlpha          = binaryReader.ReadInt32() != 0;
            width             = binaryReader.ReadInt16();
            height            = binaryReader.ReadInt16();

            bitDepth    = binaryReader.ReadByte();
            mipMapCount = binaryReader.ReadByte();
            type        = binaryReader.ReadByte();
            compression = binaryReader.ReadByte();

            if (platformType == 5)
            {
                totalMipMapDataSize = binaryReader.ReadInt32();
            }

            int palleteSize =
                ((rasterFormatFlags & TextureRasterFormat.RASTER_PAL4) != 0) ? 0x80 / 4 :
                ((rasterFormatFlags & TextureRasterFormat.RASTER_PAL8) != 0) ? 0x400 / 4 : 0;

            if (palleteSize != 0)
            {
                palette = new Color[palleteSize];
                for (int i = 0; i < palleteSize; i++)
                {
                    palette[i] = new Color(binaryReader.ReadInt32());
                }
            }

            int passedSize = 0;

            mipMaps = new MipMapEntry[mipMapCount];
            for (int i = 0; i < mipMapCount; i++)
            {
                int dataSize = 0;

                if (platformType == 8)
                {
                    dataSize = binaryReader.ReadInt32();
                }
                else if (platformType == 5)
                {
                    dataSize = BiggestPowerOfTwoUnder(totalMipMapDataSize - passedSize);
                }

                byte[] data = binaryReader.ReadBytes(dataSize);
                mipMaps[i] = new MipMapEntry(dataSize, data);

                passedSize += dataSize;
            }
        }