示例#1
0
        public void CrossingTest()
        {
            MpqManager.Initialize("S:\\WoW");
            byte[] dataA, dataB;

            // Build tile A
            {
                var builder = new TileBuilder("Azeroth", 31, 49);
                dataA = builder.Build(new ConsoleLog());
                Assert.IsNotNull(dataA);
            }

            // Build tile B
            {
                var builder = new TileBuilder("Azeroth", 32, 49);
                dataB = builder.Build(new ConsoleLog());
                Assert.IsNotNull(dataB);
            }

            // Load into mesh
            var pather = new Pather("Azeroth");

            Assert.IsTrue(pather.LoadTile(dataA));
            Assert.IsTrue(pather.LoadTile(dataB));

            // and try pathing, coords from AzerothMeshTest -> TileCrossing which is a non-building version of this
            var start = new Vector3(-9467.8f, 64.2f, 55.9f);
            var end   = new Vector3(-9248.9f, -93.35f, 70.3f);
            var path  = pather.FindPath(start, end);

            // check result
            Assert.IsNotNull(path);
            Assert.Greater(path.Count, 0);
            Assert.Less((end - path[path.Count - 1].Location).Length(), 3f);
        }
示例#2
0
        public static string GetFullFileNameFromDisplayId(int displayId)
        {
            Initialize();
            string ret;

            if (_cache.TryGetValue(displayId, out ret))
            {
                return(ret);
            }
            var displayInfoEntry = _cachedGameobjectDisplayInfoRecords.Where(e => e.DisplayId == displayId).FirstOrDefault();

            if (displayInfoEntry.DataId == 0)
            {
                return(string.Empty);
            }

            string path = MpqManager.GetFullNameByDataId(displayInfoEntry.DataId);

            //Console.WriteLine("path found:  " + path);
            if (path.Contains("unknown")) // the path with unknown is actually fine, but the next function will break it by adding .m2 at the end. so better go fileId.
            {
                return(displayInfoEntry.DataId.ToString());
            }
            else
            {
                return(path);
            }
        }
示例#3
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            //MpqManager.InitializeDBC();
            _taxiNodes           = MpqManager.GetDB6("TaxiNodes");
            _taxiPath            = MpqManager.GetDB6("TaxiPath");
            _cachedTaxiNodesRows = _taxiNodes.Rows.ToArray();
            _cachedTaxiPathRows  = _taxiNodes.Rows.ToArray();

            _cachedTaxiPathRecords = new TaxiPath.TaxiPathDb2Record[_cachedTaxiPathRows.Length];
            for (int i = 0; i < _cachedTaxiPathRows.Length - 1; i++)
            {
                _cachedTaxiPathRecords[i] = DB6Reader.ByteToType <TaxiPath.TaxiPathDb2Record>(_cachedTaxiPathRows[i]);
            }
            _cachedTaxiNodesRecords = new TaxiNode.TaxiNodesDb2Record[_cachedTaxiNodesRows.Length];
            for (int i = 0; i < _cachedTaxiNodesRows.Length - 1; i++)
            {
                _cachedTaxiNodesRecords[i] = DB6Reader.ByteToType <TaxiNode.TaxiNodesDb2Record>(_cachedTaxiNodesRows[i]);
            }
            _initialized = true;
        }
示例#4
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            _cache = new Dictionary <int, string>(1000);
            _gameobjectDisplayInfo           = MpqManager.GetDB6("GameobjectDisplayInfo");
            _cachedGameobjectDisplayInfoRows = _gameobjectDisplayInfo.Rows.ToArray();

            _cachedGameobjectDisplayInfoRecords = new GameobjectDisplayInfoEntry.GameobjectDisplayInfoDb2Record[_cachedGameobjectDisplayInfoRows.Length];
            for (int i = 0; i < _cachedGameobjectDisplayInfoRows.Length - 1; i++)
            {
                _cachedGameobjectDisplayInfoRecords[i] = DB6Reader.ByteToType <GameobjectDisplayInfoEntry.GameobjectDisplayInfoDb2Record>(_cachedGameobjectDisplayInfoRows[i]);
            }

            /*_fileData = MpqManager.GetDBC("FileData");
             * _filaDataEntries = _fileData.Records.Select(r => new FileDataEntry(r));*/
            // FileData no longer requires, we can open files directly from their FileDataId, but need a CascLib update first.
            _myConn = new MySqlConnection("server=127.0.0.1; user id=tnb; password=tnb006; database=offydump;");
            _myConn.Open();

            /*List<MapEntry> titi = PhaseHelper.GetAllMaps();
             * foreach (MapEntry e in titi)
             * {
             *  string sqlcode = "INSERT INTO Maps VALUES (" + e.Id + ",'" + e.InternalName.Replace("'", "\\'") + "','" + e.Name.Replace("'", "\\'") + "',";
             *  sqlcode += (int)e.InstanceType + "," + (int)e.MapType + "," + e.PhaseParent + "," + e.Flags + ");";
             *  System.Console.WriteLine(sqlcode);
             *  var cmd = new MySqlCommand(sqlcode, _myConn);
             *  cmd.ExecuteNonQuery();
             * }*/
            _initialized = true;
        }
示例#5
0
        public MpqTerrainManager(TileIdentifier tileId)
        {
            var wowRootDir = DBCTool.FindWowDir();

            MpqManager = new MpqManager(wowRootDir);
            TileId     = tileId;

            var     entries = GetMapEntries();
            MapInfo entry   = null;

            foreach (var item in entries)
            {
                if (item.Id != tileId.MapId)
                {
                    continue;
                }

                entry = item;
                break;
            }

            WDTParser.MpqManager = MpqManager;
            _wdt = WDTParser.Process(entry);

            _adtManager              = new ADTManager(this);
            _wmoManager              = new WMOManager();
            _m2Manager               = new M2Manager();
            _meshManager             = new NavMeshManager();
            _selectedTriangleManager = new SelectedTriangleManager(_adtManager);
        }
示例#6
0
 public MainWindow()
 {
     _startY = 0;
     InitializeComponent();
     MpqManager.Initialize("S:\\WoW\\");
     PopulateContinents();
 }
示例#7
0
 private void button1_Click(object sender, EventArgs e)
 {
     _onlyOneCategory = false;
     if (wowDirCB.Text == string.Empty)
     {
         return;
     }
     if (continentNameCB.Text == "BUILD ALL")
     {
         _buildIndex = 2;
         continentNameCB.SelectedIndex = _buildIndex;
     }
     if (continentNameCB.Text.Contains("------"))
     {
         _onlyOneCategory = true;
         _buildIndex      = continentNameCB.SelectedIndex + 1;
         continentNameCB.SelectedIndex = _buildIndex;
     }
     if (!_initialized)
     {
         MpqManager.Initialize(wowDirCB.Text);
         _initialized = true;
     }
     builderLauncher(continentNameCB.Text);
 }
示例#8
0
        static void Main()
        {
            MpqManager.Initialize("S:\\WoW");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Interface());
        }
示例#9
0
 private void Interface_FormClosing(object sender, FormClosingEventArgs e)
 {
     MpqManager.Close();
     if (_builder != null)
     {
         _builder.CleanupLastLock();
     }
 }
示例#10
0
        public void FlightmasterTest()
        {
            MpqManager.Initialize("S:\\WoW");

            var builder = new TileBuilder("Azeroth", 36, 49);

            builder.Build(new ConsoleLog());
        }
示例#11
0
文件: Program.cs 项目: qKa/meshReader
        static void Main()
        {
            MpqManager.Initialize(@"L:\World of Warcraft 3.3.5a");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Interface());
        }
示例#12
0
        private static void PrepareChunkInfo(MpqManager manager, ADT adt)
        {
            for (var chunkX = 0; chunkX < TerrainConstants.ChunksPerTileSide; chunkX++)
            {
                for (var chunkY = 0; chunkY < TerrainConstants.ChunksPerTileSide; chunkY++)
                {
                    var chunk = adt.MapChunks[chunkY, chunkX];
                    foreach (var dRefId in chunk.DoodadRefs)
                    {
                        var dRef = adt.DoodadDefinitions[dRefId];
                        if (dRef == null)
                        {
                            continue;
                        }
                        if (ModelsToIgnore.Contains(dRef.FilePath))
                        {
                            continue;
                        }
                        if (LoadedM2Ids.Contains(dRef.UniqueId))
                        {
                            continue;
                        }

                        M2Model model;
                        if (!WorldObjectExtractor.LoadedM2Models.TryGetValue(dRef.FilePath, out model))
                        {
                            model = M2ModelParser.Process(manager, dRef.FilePath);
                            WorldObjectExtractor.LoadedM2Models.Add(dRef.FilePath, model);
                        }

                        // This model may have no collision information. If so there is no point saving the data.
                        if (model.BoundingVertices.IsNullOrEmpty())
                        {
                            // This model has no collision information. We'll ignore it.
                            ModelsToIgnore.Add(dRef.FilePath);
                            WorldObjectExtractor.LoadedM2Models.Remove(dRef.FilePath);
                        }

                        // At this point, we're using the model for collision stuff
                        PrepareM2Info(dRef, model);
                        LoadedM2Ids.Add(dRef.UniqueId);
                    }

                    foreach (var oRefId in chunk.ObjectRefs)
                    {
                        var oRef = adt.ObjectDefinitions[oRefId];
                        if (oRef == null)
                        {
                            continue;
                        }
                        LoadWMO(manager, oRef);
                    }

                    PrepareChunk(adt, chunkX, chunkY);
                }
            }
        }
示例#13
0
        public void Initialize(string MeshesPath, string WowPath)
        {
            iBaseMeshesPath = MeshesPath;
            string fullPath = iBaseMeshesPath + "Draenor";

            Initialize(@fullPath);
            MpqManager.Initialize(@WowPath);
            //Pather.LoadAllTiles();
        }
示例#14
0
        public static M2Model Process(MpqManager manager, string filePath)
        {
            if (!manager.FileExists(filePath))
            {
                var altFilePath = Path.ChangeExtension(filePath, ".m2");
                if (!manager.FileExists(altFilePath))
                {
                    throw new Exception("File does not exist: " + filePath);
                }

                filePath = altFilePath;
            }

            var model = new M2Model();

            using (var stream = manager.OpenFile(filePath))
                using (var br = new BinaryReader(stream))
                {
                    ReadHeader(br, model);
                    ReadGlobalSequences(br, model);
                    ReadAnimations(br, model);
                    ReadAnimationLookup(br, model);
                    ReadBones(br, model);
                    ReadKeyBoneLookup(br, model);
                    ReadVertices(br, model);
                    ReadColors(br, model);
                    ReadTextures(br, model);
                    ReadTransparency(br, model);
                    ReadUVAnimation(br, model);
                    ReadTexReplace(br, model);
                    ReadRenderFlags(br, model);
                    ReadBoneLookupTable(br, model);
                    ReadTexLookup(br, model);
                    ReadTexUnits(br, model);
                    ReadTransLookup(br, model);
                    ReadUVAnimLookup(br, model);
                    ReadBoundingTriangles(br, model);
                    ReadBoundingVertices(br, model);
                    ReadBoundingNormals(br, model);
                    ReadAttachments(br, model);
                    ReadAttachLookups(br, model);
                    ReadEvents(br, model);
                    ReadLights(br, model);
                    ReadCameras(br, model);
                    ReadCameraLookup(br, model);
                    ReadRibbonEmitters(br, model);
                    ReadParticleEmitters(br, model);

                    if (model.Header.HasUnknownFinalPart)
                    {
                        ReadOptionalSection(br, model);
                    }
                }

            return(model);
        }
示例#15
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            _map         = MpqManager.GetDBC("Map");
            _entries     = _map.Records.Select(r => new MapEntry(r));
            _initialized = true;
        }
示例#16
0
        public void TestGameAdt()
        {
            MpqManager.Initialize("S:\\WoW");
            var test = new ADT("World\\maps\\Northrend\\Northrend_43_29.adt");

            test.Read();

            Assert.AreEqual(test.MapChunks.Length, 16 * 16);
            Assert.IsNotNull(test.DoodadHandler.Vertices);
            Assert.IsNotNull(test.DoodadHandler.Triangles);
        }
示例#17
0
        /// <summary>
        /// Initialize the helper. Will be automatically called by all other helper functions that require the data.
        /// </summary>
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            var dbc = MpqManager.GetDBC("WorldMapArea");

            _data        = dbc.Records.Select(r => new WorldMapArea(r)).ToList();
            _initialized = true;
        }
示例#18
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }


            _map         = MpqManager.GetDB6("Map");
            _entries     = _map.Rows.Select(DB6Reader.ByteToType <WoWMap.MapDbcRecord>);
            _initialized = true;
        }
示例#19
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            MpqManager.InitializeDBC(@"L:\World of Warcraft 3.3.5a");
            _taxiNodes   = MpqManager.GetDBC("TaxiNodes");
            _taxiPath    = MpqManager.GetDBC("TaxiPath");
            _initialized = true;
        }
示例#20
0
        public static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            MpqManager.InitializeDBC("S:\\WoW");
            _taxiNodes   = MpqManager.GetDBC("TaxiNodes");
            _taxiPath    = MpqManager.GetDBC("TaxiPath");
            _initialized = true;
        }
示例#21
0
        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)));
        }
示例#22
0
文件: Model.cs 项目: zbx91/meshReader
        public Model(string path)
        {
            _stream = MpqManager.GetFile(FixModelPath(path));
            Header  = new ModelHeader();
            Header.Read(_stream);

            if (Header.OffsetBoundingNormals > 0 && Header.OffsetBoundingVertices > 0 &&
                Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
            {
                IsCollidable = true;
                ReadVertices(_stream);
                ReadBoundingNormals(_stream);
                ReadBoundingTriangles(_stream);
            }
        }
示例#23
0
        private static void LoadWMO(MpqManager manager, MapObjectDefinition def)
        {
            if (LoadedWmoIds.Contains(def.UniqueId))
            {
                return;
            }
            LoadedWmoIds.Add(def.UniqueId);

            if (!WorldObjectExtractor.LoadedWMORoots.ContainsKey(def.FilePath))
            {
                var root = WMORootParser.Process(manager, def.FilePath);
                WorldObjectExtractor.LoadedWMORoots.Add(def.FilePath, root);
            }

            PrepareWMOInfo(def);
        }
示例#24
0
        /// <summary>
        /// Gets a WMOGroup from the WMO Group file
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="filePath">File path to the WMOGroup</param>
        /// <param name="root"></param>
        /// <param name="groupIndex">Current index in the WMO Group</param>
        /// <returns>A WMOGroup from the WMO Group file</returns>
        public static WMOGroup Process(MpqManager manager, string filePath, WMORoot root, int groupIndex)
        {
            if (!manager.FileExists(filePath))
            {
                log.Error("WMOGroup file does not exist: ", filePath);
            }

            var currentWMOGroup = new WMOGroup(root, groupIndex);

            using (var stream = manager.OpenFile(filePath))
                using (var br = new BinaryReader(stream))
                {
                    ReadRequiredChunks(br, currentWMOGroup);
                    ReadOptionalChunks(br, currentWMOGroup);
                }

            return(currentWMOGroup);
        }
示例#25
0
文件: Game.cs 项目: zbx91/meshReader
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ClearBackground  = true;
            BackgroundColor  = Color.White;
            ExitConfirmation = false;

            Camera = new CameraManager(this);
            Components.Add(Camera);

            MpqManager.Initialize("S:\\WoW");
            //Components.Add(new AdtDrawer(this, "World\\maps\\Azeroth\\Azeroth_36_49.adt"));
            //Components.Add(new AdtDrawer(this, "World\\maps\\Azeroth\\Azeroth_29_49.adt")); Stormwind
            //Components.Add(new AdtDrawer(this, "World\\maps\\Kalimdor\\Kalimdor_32_30.adt"));

            IsMouseVisible = true;

            base.Initialize();

            GeneralDialog = new GeneralDialog(Manager);
        }
示例#26
0
文件: Model.cs 项目: zneel/TheNoobBot
        public Model(string path)
        {
            uint fileId;

            uint.TryParse(path, out fileId);

            _stream = fileId == 0 ? MpqManager.GetFile(FixModelPath(path)) : MpqManager.GetFile(fileId);
            //if (_stream == null) // required for file list
            //    return;
            Header = new ModelHeader();
            Header.Read(_stream);

            if (Header.OffsetBoundingNormals > 0 && Header.OffsetBoundingVertices > 0 &&
                Header.OffsetBoundingTriangles > 0 && Header.BoundingRadius > 0.0f)
            {
                IsCollidable = true;
                ReadVertices(_stream, Header.IsMD21);
                ReadBoundingNormals(_stream, Header.IsMD21);
                ReadBoundingTriangles(_stream, Header.IsMD21);
            }
        }
示例#27
0
        public static ADTFile Process(MpqManager manager, string dataDirectory, string adtName)
        {
            var adtFilePath = Path.Combine(dataDirectory, adtName + ".adt");

            if (!manager.FileExists(adtFilePath))
            {
                return(null);
            }

            var fileReader = new BinaryReader(manager.OpenFile(adtFilePath));
            var adt        = new ADTFile()
            {
                Name = adtName,
                Path = dataDirectory
            };

            ReadMVER(fileReader, adt);
            ReadMHDR(fileReader, adt);

            if (adt.Header.offsInfo != 0)
            {
                fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsInfo;
                ReadMCIN(fileReader, adt);
            }

            ReadMCNKs(fileReader, adt);

            if (adt.Header.offsMH2O != 0)
            {
                fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsMH2O;
                ReadMH2O(fileReader, adt);
            }

            fileReader.Close();

            return(adt);
        }
示例#28
0
        /// <summary>
        /// Starts processing all WDT and ADT files
        /// </summary>
        public static void ProcessAll()
        {
            if (Parsed == null)
            {
                throw new Exception("WDTExtractor.Parsed must be set before calling WDTExtractor.Process");
            }

            var wowRootDir = DBCTool.FindWowDir();

            MpqManager = new MpqManager(wowRootDir);
            var entryList = GetMapEntries();

            WDTParser.MpqManager = MpqManager;
            foreach (var mapEntry in entryList)
            {
                //if (mapEntry.Id != MapId.EasternKingdoms) continue;
                var wdt = WDTParser.Process(mapEntry);
                if (wdt == null)
                {
                    continue;
                }

                var path = Path.Combine(TerrainDisplayConfig.MapDir, wdt.Entry.Id.ToString());
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                var filePath = Path.Combine(path, string.Format("{0}{1}", wdt.Entry.Id, Extension));
                using (var file = File.Create(filePath))
                {
                    WriteWdt(file, wdt);
                    file.Close();
                }
                Parsed(wdt);
            }
        }
示例#29
0
        public void Build()
        {
            if (!Directory.Exists(_meshDir + Continent))
            {
                Directory.CreateDirectory(_meshDir + Continent);
            }

            _timeStart = (int)Environment.TickCount;
            // Start mesh creation
            for (int y = StartY; y < (StartY + CountY); y++)
            {
                for (int x = StartX; x < (StartX + CountX); x++)
                {
                    _doneTiles[x, y] = 0;
                    // Get if tile is alreay Build
                    if (File.Exists(GetTileNameAndPath(x, y)) || File.Exists(GetTileLockAndPath(x, y)) || File.Exists(GetTileNoneAndPath(x, y)))
                    {
                        continue;
                    }
                    else
                    {
                        // If the tile does not exist in wow
                        if (!TileMap.HasTile(x, y))
                        {
                            continue;
                        }
                    }
                    try
                    {
                        string tlock = GetTileLockAndPath(x, y);
                        var    sw    = File.CreateText(tlock);
                        current = tlock;
                        sw.Close();
                    }
                    catch (Exception)
                    {
                        // In case 2 builder are trying to create the same file
                        continue;
                    }
                    ScanFolderAndReport();
                    Report(x, y, TileEventType.StartedBuild);
                    _currentTile = Continent + "_" + x + "_" + y;
                    Console.WriteLine(_currentTile);
                    var    builder = new TileBuilder(Continent, x, y);
                    byte[] data    = null;
                    bool   failed  = false;

                    try
                    {
                        builder.PrepareData(new MemoryLog());
                        for (int i = 0; i < Constant.Division; i++)
                        {
                            for (int j = 0; j < Constant.Division; j++)
                            {
                                data = null;
                                data = builder.Build(i, j);
                                if (data == null)
                                {
                                    failed = true;
                                    var none = File.CreateText(GetTileNoneAndPath(x, y));
                                    none.Close();
                                    break;
                                }
                                SaveTile(x, y, data, i, j);
                            }
                            if (failed)
                            {
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        File.Delete(GetTileLockAndPath(x, y));
                        throw;
                    }

                    _meshBuild++;

                    if (failed)
                    {
                        Report(x, y, TileEventType.FailedBuild);
                    }
                    else
                    {
                        _doneTiles[x, y] = 1;
                        Report(x, y, TileEventType.CompletedBuild);
                    }
                    File.Delete(GetTileLockAndPath(x, y));
                }
            }
            ScanFolderAndReport();
            _currentTile = "Finish";
            MpqManager.Close();
        }
示例#30
0
 public void Initialize()
 {
     MpqManager.Initialize("S:\\World of Warcraft");
     Initialize("S:\\meshReader\\Meshes\\Kalimdor");
     //Pather.LoadAllTiles();
 }