Inheritance: TerrainDisplay.MPQ.ADT.Components.MapObjectDefinition
        private void Add(ExtractedWMODefinition def)
        {
            var wmo = ExtractedWMOParser.Process(_baseDirectory, _mapId, def.FilePath);

            var doodadSetId = def.DoodadSetId;
            var doodadSet = new List<ExtractedWMOM2Definition>();
            doodadSet.AddRange(wmo.WMOM2Defs[0].Values);
            if (doodadSetId > 0)
            {
                doodadSet.AddRange(wmo.WMOM2Defs[doodadSetId].Values);
            }

            var m2s = new List<ExtractedM2>(doodadSet.Count);
            foreach (var m2Def in doodadSet)
            {
                var m2 = ExtractedM2Parser.Process(_baseDirectory, _mapId, m2Def.FilePath);
                TransformM2(m2, m2Def);

                m2s.Add(m2);
            }

            Transform(wmo, m2s, def);

            _WMOs.Add(wmo);
            _WMOM2s.AddRange(m2s);
        }
 private static void ReadWMODefs(BinaryReader br, ExtractedADT adt)
 {
     var count = br.ReadInt32();
     var wmoDefList = new List<ExtractedWMODefinition>(count);
     for (var i = 0; i < count; i++)
     {
         var def = new ExtractedWMODefinition {
                                                  UniqueId = br.ReadUInt32(),
                                                  FilePath = br.ReadString(),
                                                  Extents = br.ReadBoundingBox(),
                                                  Position = br.ReadVector3(),
                                                  DoodadSetId = br.ReadUInt16(),
                                                  WorldToWMO = br.ReadMatrix(),
                                                  WMOToWorld = br.ReadMatrix()
                                              };
         wmoDefList.Add(def);
     }
     adt.WMODefs = wmoDefList;
 }
        private static void Transform(ExtractedWMO wmo, List<ExtractedM2> m2s, ExtractedWMODefinition def)
        {
            foreach (var group in wmo.Groups)
            {
                for (var j = 0; j < group.WmoVertices.Count; j++)
                {
                    var vec = group.WmoVertices[j];

                    Vector3 rotatedVector;
                    Vector3.Transform(ref vec, ref def.WMOToWorld, out rotatedVector);

                    // Translate
                    Vector3 finalVector;
                    Vector3.Add(ref rotatedVector, ref def.Position, out finalVector);

                    group.WmoVertices[j] = finalVector;

                    if (!group.HasLiquid) continue;

                    var liqOrigin = group.LiquidBaseCoords;

                    for (var xStep = 0; xStep <= group.LiqTileCountX; xStep++)
                    {
                        for (var yStep = 0; yStep <= group.LiqTileCountY; yStep++)
                        {
                            var xPos = liqOrigin.X + xStep * TerrainConstants.UnitSize;
                            var yPos = liqOrigin.Y + yStep * TerrainConstants.UnitSize;
                            var zPosTop = group.LiquidHeights[xStep, yStep];

                            var liqVecTop = new Vector3(xPos, yPos, zPosTop);

                            Vector3 rotatedTop;
                            Vector3.Transform(ref liqVecTop, ref def.WMOToWorld, out rotatedTop);

                            Vector3 vecTop;
                            Vector3.Add(ref rotatedTop, ref def.Position, out vecTop);

                            group.LiquidVertices.Add(vecTop);
                        }
                    }
                }
            }

            foreach (var m2 in m2s)
            {
                for (var j = 0; j < m2.BoundingVertices.Count; j++)
                {
                    var vec = m2.BoundingVertices[j];

                    Vector3 rotatedVector;
                    Vector3.Transform(ref vec, ref def.WMOToWorld, out rotatedVector);

                    // Translate
                    Vector3 finalVector;
                    Vector3.Add(ref rotatedVector, ref def.Position, out finalVector);

                    m2.BoundingVertices[j] = finalVector;
                }
            }
        }