public static void Build(RooFile Room)
        {
            if (Room == null)
            {
                return;
            }

            room = Room;

            if (BuildStarted != null)
            {
                BuildStarted(null, new EventArgs());
            }

            ///////////////////////////////////////////////////////////////

            BoundingBox2D box = Room.GetBoundingBox2D(true);

            Polygon poly = new Polygon();

            poly.Add(box.Min);
            poly.Add(box.Min + new V2(box.Max.X - box.Min.X, 0f));
            poly.Add(box.Max);
            poly.Add(box.Max - new V2(box.Max.X - box.Min.X, 0f));

            ///////////////////////////////////////////////////////////////

            // clean up old data from room
            Room.Walls.Clear();
            Room.BSPTree.Clear();
            foreach (RooSector sector in Room.Sectors)
            {
                sector.Walls.Clear();
                sector.Sides.Clear();
            }

            // convert roomeditor walls to roowall
            for (int i = 0; i < Room.WallsEditor.Count; i++)
            {
                RooWall wall = Room.WallsEditor[i].ToRooWall(RooFile.VERSIONHIGHRESGRID, Room);
                Room.Walls.Add(wall);
            }

            ///////////////////////////////////////////////////////////////

            RooBSPItem tree = BuildNode(Room.Walls, poly, 0);

            ///////////////////////////////////////////////////////////////

            FillNode(tree, Room.BSPTree);
            SetNums(Room.BSPTree);
        }
示例#2
0
        /// <summary>
        /// Creates a RooWall instance based on this RooWallEditor instance.
        /// </summary>
        /// <param name="RooVersion"></param>
        /// <param name="Room"></param>
        /// <returns></returns>
        public RooWall ToRooWall(uint RooVersion, RooFile Room)
        {
            if (Room == null)
            {
                return(null);
            }

            V2 q1, q2;

            // first try get boundingbox as defined by 'Things'
            BoundingBox2D box = Room.GetBoundingBox2DFromThings();

            // no thingsbox? build based on editorwalls
            if (box == BoundingBox2D.NULL)
            {
                box = Room.GetBoundingBox2D(false);
            }

            // 1) Convert from 1:64 to 1:1024
            // 2) Modify coordinate system (y-axis different)
            q1.X = (P0.X - box.Min.X) * 16f;
            q1.Y = (box.Max.Y - P0.Y) * 16f;
            q2.X = (P1.X - box.Min.X) * 16f;
            q2.Y = (box.Max.Y - P1.Y) * 16f;

            // sidenum in editorwall is  0 to n ( 0=unset)
            // sectnum in editorwall is -1 to n (-1=unset)

            RooWall wall = new RooWall(
                RooVersion,
                0,
                (ushort)this.FileSideDef1, // no +1
                (ushort)this.FileSideDef2, // no +1
                q1,
                q2,
                Side1XOffset,
                Side2XOffset,
                Side1YOffset,
                Side2YOffset,
                (ushort)(Side1Sector + 1),  // +1 mapping
                (ushort)(Side2Sector + 1)); // +1 mapping

            // now resolve the object references from indices
            // and fill in heights
            wall.ResolveIndices(Room);
            wall.CalculateWallSideHeights();

            // done
            return(wall);
        }