static void dumpContinent(mpq.Wrapper mpq_h, string continent) { Console.WriteLine(@"Dumping " + continent); wow.Map map = new wow.Map(); string wdt_file = mpq_h.FindFile("*"+continent + ".wdt")[0]; wow.Wdt wdt = new wow.Wdt(mpq_h, wdt_file); Vertices_t v = new Vertices_t(); Indices32_t i = new Indices32_t(); Normals_t n = new Normals_t(); float tile_step = 533 + (1 / 3.0f); float border_width = tile_step / 16; Vector3 border = new Vector3(border_width, 0, border_width); //wdt._adtCoords.Clear(); //wdt._adtCoords.Add(new Vector2(40, 29)); //wdt._adtCoords.Add(new Vector2(40, 30)); foreach (Vector2 coords in wdt._adtCoords) { BoundingBox bb; bb.Min = new Vector3((coords.X - 32) * tile_step, float.MinValue, (coords.Y - 32) * tile_step); bb.Max = bb.Min + new Vector3(tile_step, float.MaxValue * 2, tile_step); Vector2 _min, _max; BoundingBox gbb = bb; gbb.Min -= border; gbb.Max += border; _min = wow.Util.coords2map(gbb.Min); _max = wow.Util.coords2map(gbb.Max); for (int _x = (int)_min.X; _x <= _max.X; _x++) { for (int _y = (int)_min.Y; _y <= _max.Y; _y++) { Console.WriteLine(String.Format(@"Loading : {0} {1} {2}", continent, _x, _y)); map.Add(mpq_h, continent, _x, _y); } } //map.Add(mpq_h, "kalimdor", 40, 29); // map.Add(mpq_h, "kalimdor", 40, 30); string fn = String.Format("{0}_{1}_{2}", continent, (int)coords.X, (int)coords.Y); string path = @"C:\g\maps\" + continent + @".mesh\"; string filename = path + fn + ".mesh" ; Console.Write("Tiling " + coords.X + " x " + coords.Y); int ov = map.GetTile(gbb, ref v, ref i); if (ov > 0) { Console.WriteLine(" - " + v.Count + " vertices"); if (v.Count > 0) { Vector3 v_min, v_max; v_min = v_max = v[0]; v.ForEach(xx => { v_min.X = Math.Min(v_min.X, xx.X); v_min.Y = Math.Min(v_min.Y, xx.Y); v_min.Z = Math.Min(v_min.Z, xx.Z); v_max.X = Math.Max(v_max.X, xx.X); v_max.Y = Math.Max(v_max.Y, xx.Y); v_max.Z = Math.Max(v_max.Z, xx.Z); }); //StreamWriter fs = new StreamWriter(@"C:\Dev\wow\Nav\recastnavigation.svn\RecastDemo\Bin\Meshes\" + fn + ".obj"); //v.ForEach(xx => fs.WriteLine("v {0} {1} {2}", xx.X, xx.Y, xx.Z)); //for (int ii = 0; ii < i.Count; ii += 3) //{ // fs.WriteLine("f {0} {1} {2}", i[ii + 0] + 1, i[ii + 1] + 1, i[ii + 2] + 1); //} //fs.Close(); Directory.CreateDirectory(path); BinaryWriter bs = new BinaryWriter(File.Create(filename)); bb.Min.Y = v_min.Y; bb.Max.Y = v_max.Y; bs.Write(bb.Min.X); bs.Write(bb.Min.Y); bs.Write(bb.Min.Z); bs.Write(bb.Max.X); bs.Write(bb.Max.Y); bs.Write(bb.Max.Z); bs.Write(v_min.X); bs.Write(v_min.Y); bs.Write(v_min.Z); bs.Write(v.Count); bs.Write(i.Count); v.ForEach(xx => { bs.Write(xx.X); bs.Write(xx.Y); bs.Write(xx.Z); }); i.ForEach(xx => bs.Write(xx)); bs.Close(); } } else Console.WriteLine(" - is empty"); i.Clear(); v.Clear(); map.Clear(); } }
static void Main(string[] args) { mpq.Wrapper mpq_h = new mpq.Wrapper(@"c:\g\wow\data"); // loadMpq(mpq_h, "wow-update-13329.MPQ"); // loadMpq(mpq_h, "wow-update-13287.MPQ"); // loadMpq(mpq_h, "wow-update-13205.MPQ"); // loadMpq(mpq_h, "wow-update-13164.MPQ"); // loadMpq(mpq_h, "wow-update-oldworld-13154.MPQ"); loadMpq(mpq_h, "expansion2.MPQ"); loadMpq(mpq_h, "expansion3.MPQ"); loadMpq(mpq_h, "expansion1.MPQ"); loadMpq(mpq_h, "world.MPQ"); loadMpq(mpq_h, "OldWorld.MPQ"); loadMpq(mpq_h, "art.MPQ"); loadMpq(mpq_h, "enUS\\locale-enUS.MPQ"); mpq_h.ApplyPatch("world.MPQ", @"C:\g\wow\Data\wow-update-13164.MPQ", "base"); mpq_h.ApplyPatch("world.MPQ", @"C:\g\wow\Data\wow-update-13205.MPQ", "base"); mpq_h.ApplyPatch("world.MPQ", @"C:\g\wow\Data\wow-update-13287.MPQ", "base"); mpq_h.ApplyPatch("world.MPQ", @"C:\g\wow\Data\wow-update-13329.MPQ", "base"); mpq_h.ApplyPatch("expansion1.MPQ", @"C:\g\wow\Data\wow-update-13164.MPQ", "base"); mpq_h.ApplyPatch("expansion1.MPQ", @"C:\g\wow\Data\wow-update-13205.MPQ", "base"); mpq_h.ApplyPatch("expansion1.MPQ", @"C:\g\wow\Data\wow-update-13287.MPQ", "base"); mpq_h.ApplyPatch("expansion1.MPQ", @"C:\g\wow\Data\wow-update-13329.MPQ", "base"); mpq_h.ApplyPatch("expansion2.MPQ", @"C:\g\wow\Data\wow-update-13164.MPQ", "base"); mpq_h.ApplyPatch("expansion2.MPQ", @"C:\g\wow\Data\wow-update-13205.MPQ", "base"); mpq_h.ApplyPatch("expansion2.MPQ", @"C:\g\wow\Data\wow-update-13287.MPQ", "base"); mpq_h.ApplyPatch("expansion2.MPQ", @"C:\g\wow\Data\wow-update-13329.MPQ", "base"); mpq_h.ApplyPatch("expansion3.MPQ", @"C:\g\wow\Data\wow-update-13164.MPQ", "base"); mpq_h.ApplyPatch("expansion3.MPQ", @"C:\g\wow\Data\wow-update-13205.MPQ", "base"); mpq_h.ApplyPatch("expansion3.MPQ", @"C:\g\wow\Data\wow-update-13287.MPQ", "base"); mpq_h.ApplyPatch("expansion3.MPQ", @"C:\g\wow\Data\wow-update-13329.MPQ", "base"); wow.Map m = new wow.Map(); wow.WDBC wdbc = new wow.WDBC(mpq_h); wdbc.dumpStructure(); var rc = wdbc.getWorlds(); if ( args.Count() > 0 ) { foreach(string arg in args) { dumpContinent(mpq_h, arg); } return ; } rc.ForEach(x => dumpContinent(mpq_h, x)); }