示例#1
0
    public static TextureData Open(uint fileDataId)
    {
        if (fileDataId == 0)
        {
            return(null);
        }

        var stream = CASC.OpenFile(fileDataId);

        if (stream == null)
        {
            return(null);
        }

        var textureData = new TextureData();
        var blp         = new BLP();
        var blpData     = blp.GetUncompressed(stream);
        var blpInfo     = blp.GetInfo();

        textureData.HasMipmaps    = blpInfo.hasMipmaps;
        textureData.Width         = blpInfo.width;
        textureData.Height        = blpInfo.height;
        textureData.RawData       = blpData;
        textureData.TextureFormat = blpInfo.textureFormat;

        return(textureData);
    }
示例#2
0
        public static void ReadTXID(BinaryReader reader, M2Model model, uint chunkSize)
        {
            var txidSize = chunkSize / 4;

            for (var i = 0; i < txidSize; ++i)
            {
                var fileDataId = reader.ReadUInt32();

                if (!TextureFileIds.Contains(fileDataId))
                {
                    var m2Texture   = new M2Texture();
                    var textureData = new TextureData();

                    using (var blpStream = CASC.OpenFile(fileDataId))
                    {
                        var blp     = new BLP();
                        var blpData = blp.GetUncompressed(blpStream);
                        var blpInfo = blp.GetInfo();

                        textureData.HasMipmaps    = blpInfo.hasMipmaps;
                        textureData.Width         = blpInfo.width;
                        textureData.Height        = blpInfo.height;
                        textureData.RawData       = blpData;
                        textureData.TextureFormat = blpInfo.textureFormat;

                        m2Texture.TextureData = textureData;
                        m2Texture.FileDataId  = fileDataId;

                        TextureFileIds.Add(fileDataId);
                    }

                    model.Textures.Add(m2Texture);
                }
            }
        }