static void ReadMVER(BinaryReader fileReader, WDT wdt) { var type = fileReader.ReadUInt32(); var size = fileReader.ReadUInt32(); wdt.Version = fileReader.ReadInt32(); }
public static ADT ExtractWMOOnly(WDT wdt) { var tileId = new TileIdentifier { MapId = wdt.Entry.Id, MapName = wdt.Name, TileX = 0, TileY = 0 }; var adt = new ADT(tileId); adt.ObjectDefinitions.Capacity = wdt.WmoDefinitions.Count; foreach (var wmoDefinition in wdt.WmoDefinitions) { adt.ObjectDefinitions.Add(wmoDefinition); } adt.ObjectFiles.Capacity = wdt.WmoFiles.Count; foreach (var wmoFile in wdt.WmoFiles) { adt.ObjectFiles.Add(wmoFile); } foreach (var def in adt.ObjectDefinitions) { LoadWMO(wdt.Manager, def); } adt.IsWMOOnly = true; return(adt); }
private bool LoadTile(int tileX, int tileY) { if (!WDT.HasTile(tileX, tileY)) { return(false); } if (IsTileLoaded(tileX, tileY)) { return(false); } // Generate tile var tile = new ADT(Continent, tileX, tileY, WDT); tile.Read(); tile.Generate(); // Generate renderer var renderer = new ADTRenderer(Controller, tile); renderer.Generate(); renderer.Bind(Controller.Shader); ADTRenderer.Renderers.Add(renderer); return(true); }
static void ReadMODF(BinaryReader fileReader, WDT wdt) { var type = fileReader.ReadUInt32(); var size = fileReader.ReadUInt32(); var endPos = fileReader.BaseStream.Position + size; while (fileReader.BaseStream.Position < endPos) { var objectDef = new MapObjectDefinition(); var nameIndex = fileReader.ReadInt32(); // 4 bytes objectDef.FilePath = wdt.WmoFiles[nameIndex]; objectDef.UniqueId = fileReader.ReadUInt32(); // 4 bytes objectDef.Position = fileReader.ReadVector3(); // 12 bytes objectDef.OrientationA = fileReader.ReadSingle(); // 4 Bytes objectDef.OrientationB = fileReader.ReadSingle(); // 4 Bytes objectDef.OrientationC = fileReader.ReadSingle(); // 4 Bytes objectDef.Extents = fileReader.ReadBoundingBox(); // 12*2 bytes objectDef.Flags = fileReader.ReadUInt16(); // 2 bytes objectDef.DoodadSetId = fileReader.ReadUInt16(); // 2 bytes objectDef.NameSet = fileReader.ReadUInt16(); // 2 bytes fileReader.ReadUInt16(); // padding wdt.WmoDefinitions.Add(objectDef); } }
public void AddWDTGlobalmodel(WDT s) { if (s.ModelScene != null) { AddWMOScene(s.ModelScene); } }
public static void ExtractAndWriteAll() { foreach (MapId mapId in Enum.GetValues(typeof(MapId))) { var name = TileIdentifier.GetName(mapId); if (string.IsNullOrEmpty(name)) { Console.WriteLine(@"No ADT for map {0}.", mapId); continue; } var terrain = new SimpleTerrain(mapId); for (var tileX = 0; tileX < 64; tileX++) { for (var tileY = 0; tileY < 64; tileY++) { string filePath; MpqLibrarian mpqFinder; if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder)) { continue; } // try to extract from MPQ //var adt = ADTReader.ReadADT(terrain, tileX, tileY); //Console.WriteLine(@"EXPORTING: Tile ({0}, {1}) in Map {2} ...", tileX, tileY, mapId); //Console.WriteLine(@"Extraction will take a while, please have patience..."); try { var adt = WDT.LoadTile(mapId, tileX, tileY); if (adt != null) { Console.WriteLine(@"Tile ({0}, {1}) in Map {2} has been imported...", tileX, tileY, mapId); Console.WriteLine(@"Writing to file..."); // export to file SimpleTileWriter.WriteADT(adt); // try loading again Console.WriteLine(@"Loading extracted tile and generating Navigation mesh..."); terrain.ForceLoadTile(tileX, tileY); if (terrain.IsAvailable(tileX, tileY)) { Console.WriteLine(@"Done. Tile ({0}, {1}) in Map {2} has been loaded successfully.", tileX, tileY, mapId); continue; } } } catch (ArgumentException) { } Console.WriteLine(@"Loading FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId); } } } }
public string SetZone(string zone) { int continentID; if (!zoneToMapId.TryGetValue(zone, out continentID)) { int colon = zone.IndexOf(":"); if (colon == -1) { return(null); } zone = zone.Substring(colon); if (!zoneToMapId.TryGetValue(zone, out continentID)) { return(null); } } archive.ExtractFile("DBFilesClient\\Map.dbc", "Map.dbc"); DBC maps = new DBC(); DBCFile mf = new DBCFile("Map.dbc", maps); for (int i = 0; i < maps.recordCount; i++) { int mapID = maps.GetInt(i, 0); // Console.WriteLine(" ID:" + maps.GetInt(i, 0)); // Console.WriteLine(" File: " + maps.GetString(i, 1)); // Console.WriteLine(" Name: " + maps.GetString(i, 4)); // the file!!! if (mapID == continentID) // file == continentFile) { // Console.WriteLine(String.Format("{0,4} {1}", mapID, maps.GetString(i, 1))); string file = maps.GetString(i, 1); continentFile = file; wdt = new WDT(); wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager); if (!wdtf.loaded) { wdt = null; // bad } else { // Console.WriteLine(" global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count); //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f }; } return(continentFile); } } if (wdt == null) { return("Failed to open file files for continent ID" + continentID); } return(null); }
public void TestWorldModelContinent() { var wdt = new WDT(@"World\maps\OrgrimmarInstance\OrgrimmarInstance.wdt"); Assert.IsTrue(wdt.IsValid); Assert.IsTrue(wdt.IsGlobalModel); Assert.IsNotNullOrEmpty(wdt.ModelFile); Assert.IsNotNull(wdt.ModelDefinition); }
public MCAL(MapChunk chunk, WDT wdt, Chunk c) : base(c, false) { Debug.Assert(wdt != null, "WDT Cannot be null in order to read MCAL!"); _mapChunk = chunk; _wdt = wdt; Read(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == string.Empty) { return; } try { var wdt = new WDT("World\\maps\\" + textBox1.Text + "\\" + textBox1.Text + ".wdt"); if (!wdt.IsValid) { return; } if (wdt.IsGlobalModel) { _dungeonBuilder = new DungeonBuilder(textBox1.Text); _dungeonBuilder.OnProgress += OnProgress; _builder = null; _lastProgressX = 0; } else { int startX = startXBox.Text.Length > 0 ? int.Parse(startXBox.Text) : 0; int startY = startYBox.Text.Length > 0 ? int.Parse(startYBox.Text) : 0; int countX = countXBox.Text.Length > 0 ? int.Parse(countXBox.Text) : (64 - startX); int countY = countYBox.Text.Length > 0 ? int.Parse(countYBox.Text) : (64 - startY); startXBox.Text = startX.ToString(); startXBox.ReadOnly = true; startYBox.Text = startY.ToString(); startYBox.ReadOnly = true; countXBox.Text = countX.ToString(); countXBox.ReadOnly = true; countYBox.Text = countY.ToString(); countYBox.ReadOnly = true; _builder = new ContinentBuilder(textBox1.Text, startX, startY, countX, countY); _builder.OnTileEvent += OnTileEvent; _dungeonBuilder = null; } } catch (Exception) { return; } textBox1.ReadOnly = true; button1.Enabled = false; button1.Text = "Building..."; _buildThread = new Thread(RunBuild) { IsBackground = true }; _buildThread.Start(); }
public ContinentRenderer(RenderView controller, string continent, WDT wdt) { Controller = controller; Continent = continent; WDT = wdt; ADTRenderer = new GenericCollectionRenderer <ADTRenderer>(Controller); InitializeView(); }
public void MapSelected(string mapName) { UIManager.GetComponent <MinimapHandler>().ClearMinimaps(); string mapPath = null; string minimapPath = null; // Parse WDT // if (!WDT.Flags.ContainsKey(mapName)) { string wdtPath = @"world\maps\" + mapName + @"\"; WDT.Load(wdtPath, mapName); } if (Settings.Data[2] == "2") // extracted // { mapPath = Settings.Data[8] + @"\" + @"world\maps\" + mapName + @"\"; minimapPath = Settings.Data[8] + @"\" + @"world\minimaps\" + mapName + @"\"; } else if (Settings.Data[2] == "0") // game // { mapPath = @"world\maps\" + mapName; minimapPath = @"world\minimaps\" + mapName; } bool MinimapsExist = CheckForMinimaps(minimapPath); if (CheckForADTs(mapPath)) { if (CheckForMinimaps(minimapPath)) { PanelErrorMessage.SetActive(false); // load minimaps // UIManager.GetComponent <MinimapHandler>().LoadMinimaps(minimapPath, mapName); } else { PanelErrorMessage.SetActive(true); ErrorMessageText.text = "No minimaps available."; // load blank minimaps // UIManager.GetComponent <MinimapHandler>().LoadBlankMinimaps(mapPath, mapName); } } else { if (CheckForMinimaps(minimapPath)) { PanelErrorMessage.SetActive(true); ErrorMessageText.text = "WMO Only Zone."; // load minimaps // UIManager.GetComponent <MinimapHandler>().LoadMinimaps(minimapPath, mapName); } else { PanelErrorMessage.SetActive(true); ErrorMessageText.text = "WMO Only Zone." + "\n" + "No minimaps available."; } } }
public GlobalModelRenderer(RenderView controller, WDT wdt) { Controller = controller; MeshRenderers = new GenericCollectionRenderer <MeshRenderer>(Controller); InitializeView(wdt); Generate(wdt); MeshRenderers.Bind(Controller.Shader); }
public ContinentBuilder(string continent, int startX, int startY, int countX, int countY) { StartX = startX; StartY = startY; CountX = countX; CountY = countY; Continent = continent; TileMap = new WDT("World\\Maps\\" + continent + "\\" + continent + ".wdt"); }
/// <summary> /// Writes all height maps to the default MapDir /// </summary> public static void ExportMapTiles(WDT wdt) { // Map data should only be stored per map ClearObjectData(); var path = Path.Combine(TerrainDisplayConfig.MapDir, wdt.Entry.Id.ToString()); if (wdt.IsWMOOnly) { // This Map has no Tiles, but the MODF still needs to be written // These maps will be considered to have one tile at {0, 0} with only one MODF written therein var adt = ExtractWMOOnly(wdt); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (var file = File.Create(Path.Combine(path, TerrainConstants.GetMapFilename(0, 0)))) { WriteTileInfo(file, adt); } return; } // Read in the ADT data - this includes height and liquid maps, WMO information and M2 information TerrainInfo = ExtractMapTiles(wdt); // Write the processed data to files var count = 0; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } for (var tileX = 0; tileX < TerrainConstants.TilesPerMapSide; tileX++) { for (var tileY = 0; tileY < TerrainConstants.TilesPerMapSide; tileY++) { var adt = TerrainInfo[tileY, tileX]; if (adt == null) { continue; } var filePath = Path.Combine(path, TerrainConstants.GetMapFilename(tileX, tileY)); using (var file = File.Create(filePath)) { WriteTileInfo(file, adt); file.Close(); } count++; } } log.Info("Extracted {0} tiles for {1}.", count, wdt.Entry.Id); }
public void Button_LoadTestMap(string id) { CASCHandler = CASC.GetComponent <CascHandler>().cascHandler; //World.ClearAllTerrain(); uint WdtFileDataId = 0; Vector2 currentSelectedPlayerSpawn = Vector2.zero; switch (id) { case "BC": { WdtFileDataId = 828395; currentSelectedPlayerSpawn = new Vector2(32, 27); } break; case "Wrath": { WdtFileDataId = 822688; currentSelectedPlayerSpawn = new Vector2(18, 24); } break; case "Cata": { WdtFileDataId = 782779; currentSelectedPlayerSpawn = new Vector2(33, 35); } break; case "MoP": { WdtFileDataId = 805681; currentSelectedPlayerSpawn = new Vector2(32, 31); } break; default: Debug.Log("Unknown Map"); break; } WDT.WDTEntries.Clear(); if (WDT.ParseWDT(WdtFileDataId)) { //World.LoadSingleADT(WdtFileDataId, currentSelectedPlayerSpawn); //world2.LoadWorld(WdtFileDataId, currentSelectedPlayerSpawn); world.LoadWorld(WdtFileDataId, currentSelectedPlayerSpawn); } else { Debug.Log("Error"); } }
public static void GetTileSets(WDT wdt) { if (!wdt.IsWMOOnly) { var tileSet = new ZoneTileSet(); Tiles[(int)wdt.MapId] = tileSet; ZoneGrid grid; // Rows are along the x-axis for (var x = 0; x < 64; x++) { // Columns are along the y-axis for (var y = 0; y < 64; y++) { if (!wdt.TileProfile[y, x]) { continue; } ++count; var adt = ADTReader.ReadADT(wdt, x, y); if (adt == null) { continue; } tileSet.ZoneGrids[y, x] = grid = new ZoneGrid(new uint[TerrainConstants.ChunksPerTileSide, TerrainConstants.ChunksPerTileSide]); // Rows along the x-axis for (var chunkX = 0; chunkX < 16; chunkX++) { // Columns along the y-axis for (var chunkY = 0; chunkY < 16; chunkY++) { var areaId = adt.GetADTChunk(chunkY, chunkX).Header.AreaId; if (Enum.IsDefined(typeof(ZoneId), areaId)) { grid.ZoneIds[chunkY, chunkX] = (uint)areaId; } else { grid.ZoneIds[chunkY, chunkX] = 0; } } } //return tiles; } } } else { log.Info("Could not read Zones from WMO: " + wdt.MapId); } }
public void AddInstance(string path) { var wdt = new WDT(path); if (!wdt.IsValid || !wdt.IsGlobalModel) { return; } Components.Add(new WmoDrawer(this, wdt.ModelFile, wdt.ModelDefinition)); }
static void ReadWDT() { const string path = @"PVPZone01.wdt"; var wdt = new WDT(path); var sw = Stopwatch.StartNew(); wdt.Read(); sw.Stop(); Console.WriteLine("Loaded {0} chunks from '{1}' in {2}ms", wdt.Data.Chunks.Count, System.IO.Path.GetFileName(path), sw.ElapsedMilliseconds); }
private void btnAbout_Click(object sender, EventArgs e) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("azeroth.wdt", FileMode.Open, FileAccess.Read, FileShare.Read); WDT obj = (WDT)formatter.Deserialize(stream); stream.Close(); Console.WriteLine("n1: {0}", obj.magic); Console.WriteLine("n2: {0}", obj.size); Console.WriteLine("str: {0}", obj.version); }
public void TestDungeonWithWater() { //MpqManager.Initialize("S:\\World of Warcraft"); var wdt = new WDT("world\\maps\\orgrimmarinstance\\orgrimmarinstance.wdt"); Assert.IsTrue(wdt.IsValid && wdt.IsGlobalModel); var file = wdt.ModelFile; var model = new WorldModelRoot(file); var verts = new System.Collections.Generic.List<Vector3>(); var tris = new System.Collections.Generic.List<Triangle<uint>>(); WorldModelHandler.InsertModelGeometry(verts, tris, wdt.ModelDefinition, model); Assert.IsFalse(verts.Any(v => float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z))); }
public static void CreateAndWriteAllMeshes() { GC.AddMemoryPressure(1 * 1024 * 1024 * 1024); foreach (MapId mapId in Enum.GetValues(typeof(MapId))) { var name = TileIdentifier.GetName(mapId); if (string.IsNullOrEmpty(name)) { Console.WriteLine(@"No ADT for map {0}.", mapId); continue; } var terrain = new SimpleTerrain(mapId); for (var tileX = 0; tileX < 64; tileX++) { for (var tileY = 0; tileY < 64; tileY++) { string filePath; MpqLibrarian mpqFinder; if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder)) { continue; } try { var adt = WDT.LoadTile(mapId, tileX, tileY); if (adt != null) { // try loading Console.WriteLine(@"Loading extracted tile and generating Navigation mesh..."); terrain.ForceLoadTile(tileX, tileY); if (terrain.IsAvailable(tileX, tileY)) { Console.WriteLine(@"Done. Tile ({0}, {1}) in Map {2} has been loaded successfully.", tileX, tileY, mapId); terrain.Tiles[tileX, tileY] = null; continue; } } } catch (ArgumentException) { } Console.WriteLine(@"Extracting FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId); } } } GC.RemoveMemoryPressure(1 * 1024 * 1024 * 1024); }
public override void Close() { archive.Close(); wdt = null; wdtf = null; modelmanager = null; wmomanager = null; zoneToMapId = null; mapIdToFile = null; areaIdToName = null; archive = null; base.Close(); }
static void ReadMPHD(BinaryReader fileReader, WDT wdt) { var type = fileReader.ReadUInt32(); var size = fileReader.ReadUInt32(); wdt.Header.Header1 = (WDTFlags)fileReader.ReadInt32(); wdt.Header.Header2 = fileReader.ReadInt32(); wdt.Header.Header3 = fileReader.ReadInt32(); wdt.Header.Header4 = fileReader.ReadInt32(); wdt.Header.Header5 = fileReader.ReadInt32(); wdt.Header.Header6 = fileReader.ReadInt32(); wdt.Header.Header7 = fileReader.ReadInt32(); wdt.Header.Header8 = fileReader.ReadInt32(); }
static void ReadWDT() { string path = string.Format(@"World\Maps\{0}\{0}.wdt", "WailingCaverns"); var sw = Stopwatch.StartNew(); var wdt = new WDT(path); Console.WriteLine("Loaded {0} chunks from '{1}' in {2}ms", wdt.Data.Chunks.Count, System.IO.Path.GetFileName(path), sw.ElapsedMilliseconds); wdt.GenerateGlobalModel(); sw.Stop(); var geom = new Geometry(); geom.AddWDTGlobalmodel(wdt); geom.SaveWavefrontObject("WailingCaverns.obj"); }
public WDTRenderer(RenderView controller, string mapName, WDT wdt) { Controller = controller; WDT = wdt; if (wdt.IsGlobalModel) { Renderer = new GlobalModelRenderer(controller, wdt); } else { Renderer = new ContinentRenderer(controller, mapName, wdt); } }
public void Generate(WDT wdt) { if (!wdt.IsGlobalModel) { return; } wdt.GenerateGlobalModel(); // Terrain AddMeshRenderer(wdt.ModelScene.Terrain); // Doodads AddMeshRenderer(wdt.ModelScene.Doodads); // Liquids AddMeshRenderer(wdt.ModelScene.Liquids); }
public static void ExtractAllADTs() { foreach (MapId mapId in Enum.GetValues(typeof(MapId))) { var name = TileIdentifier.GetName(mapId); if (string.IsNullOrEmpty(name)) { Console.WriteLine(@"No ADT for map {0}.", mapId); continue; } var wdt = new WDT(mapId); for (var tileX = 0; tileX < 64; tileX++) { for (var tileY = 0; tileY < 64; tileY++) { string filePath; MpqLibrarian mpqFinder; if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder)) { continue; } try { wdt.TileProfile[tileX, tileY] = true; var adt = ADTReader.ReadADT(wdt, tileX, tileY); if (adt != null) { adt.GenerateMapWithNoSimplification(); Console.WriteLine(@"Tile ({0}, {1}) in Map {2} has been imported...", tileX, tileY, mapId); Console.WriteLine(@"Writing to file..."); // export to file SimpleTileWriter.WriteADT(adt); continue; } } catch (ArgumentException) { } Console.WriteLine(@"Extracting FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId); } } } }
//////////////////// //////////////////// #region UI Interaction // Map Selected in the Map List Panel // public void MapSelected(string mapName) { MiniMap.ClearMinimaps(minimapScrollPanel); if (miniMap.TryGetValue(mapName, out MapRecord record)) { selectedWDTId = record.WdtFileDataID; WDTFileDataIDText.text = $"{selectedWDTId}"; WDT.WDTEntries.Clear(); if (WDT.ParseWDT(record.WdtFileDataID)) { MiniMap.Load(record.WdtFileDataID, minimapScrollPanel); } } }
public IEnumerator LoadMap(CancellationToken cancel) { var fullName = gameFiles.Wdt(gameContext.CurrentMap.Directory); var wdtBytesTask = gameFiles.ReadFile(fullName); yield return(wdtBytesTask); using var wdtBytes = wdtBytesTask.Result; if (wdtBytes == null) { Console.WriteLine("Couldn't load map " + fullName + ". This is quite fatal..."); yield break; } ClearData(); var wdt = new WDT(new MemoryBinaryReader(wdtBytes)); Vector3 middlePosSum = Vector3.Zero; int chunks = 0; foreach (var chunk in wdt.Chunks) { presentChunks[chunk.Y, chunk.X] = chunk.HasAdt; if (chunk.HasAdt) { middlePosSum += chunk.MiddlePosition; chunks++; } } if (chunks > 0) { var avg = middlePosSum / chunks; if (gameContext.CurrentMap.Id == 1) { // this is just for debugging // since the beginning this was the initial position in Kalimdor // and it is quite nice starting position cameraManager.Relocate(new Vector3(285.396f, -4746.17f, 9.48428f + 20).ToOpenGlPosition()); } else { cameraManager.Relocate(avg.ToOpenGlPosition().WithY(100)); } } }
public static void Draw(WDT wdt) { }
public void SetContinent(string continent) { continentFile = continent; wdt = new WDT(); wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager); if (!wdtf.loaded) { wdt = null; // bad throw new Exception("Failed to set continent to: " + continent); } else { // Console.WriteLine(" global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count); //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f }; } }
public override void Close() { archive.Close(); wdt = null; wdtf = null; modelmanager = null; wmomanager = null; zoneToMapId = null; mapIdToFile = null; areaIdToName = null; archive = null; base.Close(); }
public string SetZone(string zone) { int continentID; if (!zoneToMapId.TryGetValue(zone, out continentID)) { int colon = zone.IndexOf(":"); if(colon == -1) return null; zone = zone.Substring(colon); if (!zoneToMapId.TryGetValue(zone, out continentID)) { return null; } } archive.ExtractFile("DBFilesClient\\Map.dbc", "Map.dbc"); DBC maps = new DBC(); DBCFile mf = new DBCFile("Map.dbc", maps); for (int i = 0; i < maps.recordCount; i++) { int mapID = maps.GetInt(i, 0); // Console.WriteLine(" ID:" + maps.GetInt(i, 0)); // Console.WriteLine(" File: " + maps.GetString(i, 1)); // Console.WriteLine(" Name: " + maps.GetString(i, 4)); // the file!!! if (mapID == continentID) // file == continentFile) { // Console.WriteLine(String.Format("{0,4} {1}", mapID, maps.GetString(i, 1))); string file = maps.GetString(i, 1); continentFile = file; wdt = new WDT(); wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager); if (!wdtf.loaded) wdt = null; // bad else { // Console.WriteLine(" global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count); //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f }; } return continentFile; } } if (wdt == null) { return "Failed to open file files for continent ID" + continentID; } return null; }