コード例 #1
0
        public void ExtractTextures()
        {
            App.PushLog($"Reading {App.CurFileNameNoExt}...");

            //wismt
            FileStream   fsWIFNT = new FileStream(App.CurFilePathAndName + ".wifnt", FileMode.Open, FileAccess.Read);
            BinaryReader brWIFNT = new BinaryReader(fsWIFNT);

            List <Structs.LBIM> TextureLBIMs = new List <Structs.LBIM>();

            fsWIFNT.Seek(-0x4, SeekOrigin.End);
            if (brWIFNT.ReadInt32() == 0x4D49424C)
            {
                Structs.LBIM lbim = ft.ReadLBIM(fsWIFNT, brWIFNT, 0x1000, (int)fsWIFNT.Length - 0x1000);
                lbim.Filename = "thistestcool";
                lbim.Type     = 75;
                if (lbim.Data != null)
                {
                    TextureLBIMs.Add(lbim);
                }
            }

            ft.ReadTextures(new Structs.MSRD {
                Version = Int32.MaxValue
            }, App.CurFilePath, TextureLBIMs);

            App.PushLog("Done!");
        }
コード例 #2
0
        public void SaveMapTextures(Structs.WISMDA WISMDA, string texturesFolderPath)
        {
            //"cache/" contains all base colors and normals
            //"seamwork/tecpac//" contains PBR materials but in severely disjointed fashion
            //"seamwork/texture//" contains PBR materials and some base color things, seems to be for props exclusively?

            List <Structs.LBIM> TextureLBIMs = new List <Structs.LBIM>();

            List <Structs.XBC1> MapCache   = WISMDA.FilesBySearch($"cache/cache_{App.CurFileNameNoExt}").ToList();
            List <int>          DoubleSize = new List <int>();

            for (int i = 0; i < MapCache.Count; i++)
            {
                BinaryReader brTexture = new BinaryReader(MapCache[i].Data);
                MapCache[i].Data.Seek(-0x4, SeekOrigin.End);
                if (brTexture.ReadInt32() == 0x4D49424C)
                {
                    Structs.LBIM lbim = ft.ReadLBIM(MapCache[i].Data, brTexture, 0, (int)MapCache[i].Data.Length);
                    lbim.Filename = MapCache[i].Name.Split('/').LastOrDefault();
                    if (lbim.Type == 66)
                    {
                        DoubleSize.Add(i);
                    }
                    else if (lbim.Data != null && lbim.Width > 15 && lbim.Height > 15) //get rid of the tinies
                    {
                        TextureLBIMs.Add(lbim);
                    }
                }
                else
                {
                    Structs.LBIM lbim = ft.ReadLBIM(MapCache[DoubleSize.First()].Data, new BinaryReader(MapCache[DoubleSize.First()].Data), 0, (int)MapCache[DoubleSize.First()].Data.Length);
                    //lbim.Filename = MapCache[i].Name.Split('/').LastOrDefault();
                    lbim.Filename = $"{MapCache[i].Name.Split('/').LastOrDefault()}-yoda-{i}-{DoubleSize.First()}";
                    lbim.Data     = MapCache[i].Data;
                    lbim.Width   *= 2;
                    lbim.Height  *= 2;
                    TextureLBIMs.Add(lbim);
                    DoubleSize.RemoveAt(0);
                }
            }

            /*for (int i = 0; i < DoubleSize.Count; i++)
             * {
             *  Structs.LBIM lbim = DoubleSize[i];
             *  lbim.Data = MapCache[i + (MapCache.Count - DoubleSize.Count)].Data;
             *  lbim.Width *= 2;
             *  lbim.Height *= 2;
             *  TextureLBIMs.Add(lbim);
             * }*/

            /*List<Structs.XBC1> TextureCache = WISMDA.FilesBySearch("cache//texture").ToList();
             * TextureCache.AddRange(WISMDA.FilesBySearch("seamwork/tecpac"));
             * foreach (Structs.XBC1 xbc1 in TextureCache)
             * {
             *  BinaryReader brTexture = new BinaryReader(xbc1.Data);
             *  xbc1.Data.Seek(-0x4, SeekOrigin.End);
             *  if (brTexture.ReadInt32() == 0x4D49424C)
             *  {
             *      Structs.LBIM lbim = ft.ReadLBIM(xbc1.Data, brTexture, 0, (int)xbc1.Data.Length);
             *      lbim.Filename = xbc1.Name.Split('/').LastOrDefault();
             *      if (lbim.Data != null && lbim.Width > 15 && lbim.Height > 15) //get rid of the tinies
             *          TextureLBIMs.Add(lbim);
             *  }
             * }*/

            ft.ReadTextures(new Structs.MSRD {
                Version = Int32.MaxValue
            }, texturesFolderPath + @"\CacheAndTecPac", TextureLBIMs);
            foreach (Structs.LBIM lbim in TextureLBIMs)
            {
                lbim.Data.Dispose();
            }

            TextureLBIMs.Clear();

            foreach (Structs.XBC1 xbc1 in WISMDA.FilesBySearch("seamwork/texture"))
            {
                BinaryReader            brTexture    = new BinaryReader(xbc1.Data);
                Structs.SeamworkTexture smwrkTexture = new Structs.SeamworkTexture
                {
                    TableCount  = brTexture.ReadInt32(),
                    TableOffset = brTexture.ReadInt32()
                };

                smwrkTexture.Table = new Structs.SeamworkTextureTable[smwrkTexture.TableCount];
                xbc1.Data.Seek(smwrkTexture.TableOffset, SeekOrigin.Begin);
                for (int i = 0; i < smwrkTexture.TableCount; i++)
                {
                    smwrkTexture.Table[i] = new Structs.SeamworkTextureTable
                    {
                        Unknown1 = brTexture.ReadInt32(),
                        Size     = brTexture.ReadInt32(),
                        Offset   = brTexture.ReadInt32(),
                        Unknown2 = brTexture.ReadInt32()
                    };
                }
                foreach (Structs.SeamworkTextureTable table in smwrkTexture.Table)
                {
                    Structs.LBIM lbim = ft.ReadLBIM(xbc1.Data, brTexture, table.Offset, table.Size);

                    if (lbim.Data != null && lbim.Width > 15 && lbim.Height > 15) //get rid of the tinies
                    {
                        TextureLBIMs.Add(lbim);
                    }
                }
            }

            ft.ReadTextures(new Structs.MSRD {
                Version = Int32.MaxValue
            }, texturesFolderPath + @"\SeamworkTexture", TextureLBIMs);
            foreach (Structs.LBIM lbim in TextureLBIMs)
            {
                lbim.Data.Dispose();
            }

            TextureLBIMs.Clear();
        }