Ejemplo n.º 1
0
        public static void ExtractWMOs(List <MapObjectDefinition> list)
        {
            foreach (var def in list.Where(def => !string.IsNullOrEmpty(def.FilePath)))
            {
                WMORoot root;
                if (!LoadedWMORoots.TryGetValue(def.FilePath, out root))
                {
                    root = WMORootParser.Process(WDTExtractor.MpqManager, def.FilePath);
                    LoadedWMORoots.Add(def.FilePath, root);
                }

                ExtractWMOGroups(def.FilePath, root);
                ExtractWMOM2s(root);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        private static TileModels ExtractWDTM2s(IList <MapObjectDefinition> wmos)
        {
            var LoadedWMOIds = new List <uint>();
            var tileModels   = new TileModels
            {
                Models = new List <TileModel>()
            };

            for (var i = 0; i < wmos.Count; i++)
            {
                var wmo = wmos[i];
                if (LoadedWMOIds.Contains(wmo.UniqueId))
                {
                    continue;
                }

                var filePath = wmo.FileName;
                var root     = WMORootParser.Process(manager, filePath);
                if (root == null)
                {
                    Console.WriteLine("Invalid WMORoot returned.");
                    return(null);
                }

                LoadedWMOIds.AddUnique(wmo.UniqueId);
                if (root.DoodadDefinitions == null)
                {
                    Console.WriteLine("No models defined in Root.");
                    return(null);
                }

                ExtractWMOM2s(wmo, root, tileModels);
            }

            return(tileModels);
        }
Ejemplo n.º 4
0
        private static TileModels ExtractTileM2s(int tileX, int tileY, ADTFile adt)
        {
            var LoadedWMOIds = new List <uint>();
            var list         = adt.DoodadDefinitions;

            var tileModels = new TileModels
            {
                Models = new List <TileModel>(list.Count)
            };

            foreach (var definition in list)
            {
                if (LoadedM2Ids.Contains(definition.UniqueId))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(definition.FilePath))
                {
                    continue;
                }

                var model = ExtractModel(definition);

                if (model.Vertices.Length < 1)
                {
                    continue;
                }
                tileModels.Models.Add(model);

                LoadedM2Ids.AddUnique(definition.UniqueId);
            }

            var wmoList = adt.ObjectDefinitions;

            foreach (var wmo in wmoList)
            {
                if (LoadedWMOIds.Contains(wmo.UniqueId))
                {
                    continue;
                }

                var worldPos = new Vector3(TerrainConstants.CenterPoint - wmo.Position.X,
                                           wmo.Position.Y,
                                           TerrainConstants.CenterPoint - wmo.Position.Z);
                worldPos = CorrectWMOOrigin(worldPos);

                // If this WMO belongs to another tile, skip it.
                var wmoTileX = (int)((TerrainConstants.CenterPoint - worldPos.Y) / TerrainConstants.TileSize);
                var wmoTileY = (int)((TerrainConstants.CenterPoint - worldPos.X) / TerrainConstants.TileSize);
                if (wmoTileX != tileX || wmoTileY != tileY)
                {
                    continue;
                }

                var filePath = wmo.FileName;
                var root     = WMORootParser.Process(manager, filePath);

                ExtractWMOM2s(wmo, root, tileModels);
                LoadedWMOIds.AddUnique(wmo.UniqueId);
            }

            return(tileModels);
        }