private void DumpDistinctMissingTextures(List <HogFile> fileData) { var path = $@"c:\temp\DescentAssets\cube_missing_texture_list.txt"; File.Delete(path); // dump the distinct texture list with a cube number and it's side var sideList = new Dictionary <int, string>(); var translationTable = new TextureTranslation(); foreach (var hogFile in fileData) { if (hogFile.FileType == HogFileType.RDL) { var rdlFile = new Rdl(hogFile, hogFile.FileName); for (var i = 0; i < rdlFile.Cubes.Count; i++) { for (var j = 0; j < 6; j++) { if (rdlFile.Cubes[i].Sides[j].PrimaryTexture > -1) { if (!sideList.ContainsKey(rdlFile.Cubes[i].Sides[j].PrimaryTexture) && translationTable[rdlFile.Cubes[i].Sides[j].PrimaryTexture] == 255) { var result = hogFile.FileName + " Cube:" + i + " Wall:" + rdlFile.Cubes[i].Sides[j].WallName + " Texture:" + rdlFile.Cubes[i].Sides[j].PrimaryTexture + Environment.NewLine; sideList[rdlFile.Cubes[i].Sides[j].PrimaryTexture] = result; } } } } } } foreach (var side in sideList.OrderBy(x => x.Key)) { File.AppendAllText(path, side.Value); } }
/// <summary> /// To string /// </summary> /// <returns>String representation</returns> public override string ToString() => TextureTranslation.ToString();
private void ReadHogFile() { Rdl rdlFile; byte[] buffer = File.ReadAllBytes("Assets/DESCENT.HOG"); int index = 3; ReadTextureNames(); var textureTranslation = new TextureTranslation(); var fileData = new List <HogFile>(); while (index < buffer.Length) { fileData.Add(new HogFile(buffer, index)); index += fileData[fileData.Count - 1].FileSize + 13 + 4; if (fileData[fileData.Count - 1].FileName == "level01.rdl") { if (fileData[fileData.Count - 1].FileType == HogFileType.RDL) { // read one rdl file and break out of the loop rdlFile = new Rdl(fileData[fileData.Count - 1], fileData[fileData.Count - 1].FileName); //TODO: temporary UVs Vector2[] uvs0 = { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0), }; var sideList = new int [6, 4] { { 2, 6, 7, 3 }, { 0, 3, 7, 4 }, { 1, 0, 4, 5 }, { 1, 5, 6, 2 }, { 7, 6, 5, 4 }, { 0, 1, 2, 3 } }; foreach (var cube in rdlFile.Cubes) { for (var i = 0; i < 6; i++) { if (cube.Children[i] == -1 || cube.Sides[i].Number != -1) { var vertices = new Vector3[] { new Vector3((float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 0]]].X, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 0]]].Y, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 0]]].Z), new Vector3((float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 1]]].X, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 1]]].Y, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 1]]].Z), new Vector3((float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 2]]].X, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 2]]].Y, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 2]]].Z), new Vector3((float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 3]]].X, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 3]]].Y, (float)rdlFile.Vertices[cube.BoxVertices[sideList[i, 3]]].Z), }; AddWall(_textureNames[textureTranslation[cube.Sides[i].PrimaryTexture]], vertices, uvs0); } } } break; } } } //DumpDistinctMissingTextures(fileData); }