private static void ParseM2_Skin(string dataPath, M2Data m2Data) { // check how many skins files there are // string noExtension = Path.GetFileNameWithoutExtension(dataPath); string directoryPath = Path.GetDirectoryName(dataPath); int skinCount = 0; for (int i = 0; i <= 20; i++) { string fileNumber = i.ToString("00"); if (Casc.FileExists(directoryPath + @"\" + noExtension + fileNumber + ".skin")) { skinCount++; } else { break; } } if (skinCount > 0) { // Load only skin00 for now // string skinDataPath = directoryPath + @"\" + noExtension + "00" + ".skin"; string skinPath = Casc.GetFile(skinDataPath); byte[] M2SkinData = File.ReadAllBytes(skinPath); using (MemoryStream ms = new MemoryStream(M2SkinData)) { ParseSkin(ms, m2Data); } } }
public static void Load_hTextures() { if (ADTTexData.textureBlockData.MTXP) { ADTTexData.textureBlockData.terrainHTextures = new Dictionary <string, ADTTexData.Texture2Ddata>(); foreach (string texturePath in ADTTexData.textureBlockData.terrainTexturePaths) { string noExtension = Path.GetFileNameWithoutExtension(texturePath); string directoryPath = Path.GetDirectoryName(texturePath); string hTexturePath = directoryPath + @"\" + noExtension + "_h" + ".blp"; if (Casc.FileExists(hTexturePath)) { string extractedPath = Casc.GetFile(hTexturePath); Stream stream = File.Open(extractedPath, FileMode.Open); BLP blp = new BLP(); byte[] data = blp.GetUncompressed(stream, true); BLPinfo info = blp.Info(); ADTTexData.Texture2Ddata texture2Ddata = new ADTTexData.Texture2Ddata(); texture2Ddata.hasMipmaps = info.hasMipmaps; texture2Ddata.width = info.width; texture2Ddata.height = info.height; if (info.width != info.height) // Unity doesn't support nonsquare mipmaps // sigh { texture2Ddata.hasMipmaps = false; } texture2Ddata.textureFormat = info.textureFormat; texture2Ddata.TextureData = data; ADTTexData.textureBlockData.terrainHTextures.Add(texturePath, texture2Ddata); stream.Close(); stream = null; } } } }
public static void Initialize() { // Check existing DB2 files // foreach (string fileName in fileNames) { if (Casc.FileExists(dbfilesclient + fileName)) { availableFiles.Add(fileName, true); Read(fileName); } else { availableFiles.Add(fileName, false); Debug.LogWarning("Warning: " + "Missing " + fileName); } } }