Beispiel #1
0
        public static TxpMipMap FromDds(DdsMipMap mip, DdsPixelFormat pf)
        {
            TxpMipMap tex = new TxpMipMap();

            if (mip == null)
            {
                return(tex);
            }
            tex.width  = mip.width;
            tex.height = mip.height;
            switch (new string(pf.compressionName))
            {
            case "RGB ": tex.type = TexType.RGB; break;

            case "RGBA": tex.type = TexType.RGBA; break;

            case "DXT1": tex.type = TexType.DXT1; break;

            case "DXT3": tex.type = TexType.DXT3; break;

            case "DXT5": tex.type = TexType.DXT5; break;

            case "ATI2": tex.type = TexType.ATI2n; break;
            }
            tex.byteSize = mip.byteSize;
            tex.data     = mip.data;
            return(tex);
        }
Beispiel #2
0
        public TxpTexture(Stream s)
        {
            uint txpStart = (uint)s.Position;

#if (DEBUG)
            Console.Write("TxpTexture - Begin \n");
#endif
            if (DataStream.ReadString(s, 3) != magic)
            {
                return;
            }
#if (DEBUG)
            Console.Write("TxpTexture - Magic correct\n");
#endif
            flag = DataStream.ReadByte(s);
#if (DEBUG)
            Console.Write("TxpTexture - Flag is " + flag + "\n");
#endif
            mipCount = DataStream.ReadUInt32(s);
            mipMaps  = new TxpMipMap[mipCount];
            version  = DataStream.ReadUInt32(s);
            uint offsetTbl = (uint)s.Position;
            for (int i = 0; i < mipCount; i++)
            {
                s.Seek(offsetTbl + (i * 4), SeekOrigin.Begin);
                //Console.Write(offsetTbl + (i * 4) + "\n");
                uint offset = DataStream.ReadUInt32(s);
                s.Seek(txpStart + offset, SeekOrigin.Begin);
                //Console.Write(txpStart + offset + "\n");
                mipMaps[i] = new TxpMipMap(s);
            }
        }
Beispiel #3
0
        public static TxpTexture FromDds(DdsFile dds)
        {
            TxpTexture tex = new TxpTexture();

            tex.mipCount = dds.mipMapCount;
            uint counter = 0;

            TxpMipMap[] mips = new TxpMipMap[tex.mipCount];
            foreach (DdsMipMap ddsMip in dds.mipMaps)
            {
                Console.Write(ddsMip == null);
                Console.Write("\n");
                TxpMipMap mip = TxpMipMap.FromDds(ddsMip, dds.pixelFormat);
                mips[counter] = mip;
            }
            tex.mipMaps = mips;
            return(tex);
        }