コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        /// Splits this wall into two using infinite line given by Q1Q2.
        /// </summary>
        /// <param name="Q1"></param>
        /// <param name="Q2"></param>
        /// <returns>Item1: P1 to I. Item2: I to P2</returns>
        public Tuple<RooWall, RooWall> Split(V2 Q1, V2 Q2)
        {
            V2 intersect;

            // intersect this wall (finite line) with the infinite line given by Q1Q2
            LineInfiniteLineIntersectionType intersecttype =
                MathUtil.IntersectLineInfiniteLine(P1, P2, Q1, Q2, out intersect);

            // must have a real intersection, not only boundarypoint or even coincide
            if (intersecttype != LineInfiniteLineIntersectionType.OneIntersection)
                return null;

            /*****************************************************************/

            // 1) Piece from P1 to intersection
            RooWall wall1 = new RooWall(
                RooVersion,
                NextWallNumInPlane,
                RightSideNum,
                LeftSideNum,
                P1,
                intersect,
                RightXOffset,  // readjust below
                LeftXOffset,   // readjust below
                RightYOffset,  // readjust below
                LeftYOffset,   // readjust below
                RightSectorNum,
                LeftSectorNum
                );

            // also keep references of old wall
            wall1.RightSector = RightSector;
            wall1.LeftSector = LeftSector;
            wall1.RightSide = RightSide;
            wall1.LeftSide = LeftSide;
            wall1.BowtieFlags = BowtieFlags;
            wall1.CalculateWallSideHeights();

            /*****************************************************************/

            // 2) Piece from intersection to P2
            RooWall wall2 = new RooWall(
                RooVersion,
                NextWallNumInPlane,
                RightSideNum,
                LeftSideNum,
                intersect,
                P2,
                RightXOffset,  // readjust below
                LeftXOffset,   // readjust below
                RightYOffset,  // readjust below
                LeftYOffset,   // readjust below
                RightSectorNum,
                LeftSectorNum
                );

            // also keep references of old wall
            wall2.RightSector = RightSector;
            wall2.LeftSector = LeftSector;
            wall2.RightSide = RightSide;
            wall2.LeftSide = LeftSide;
            wall2.BowtieFlags = BowtieFlags;
            wall2.CalculateWallSideHeights();

            /*****************************************************************/

            // 3) Readjust texture offsets to accoutn for split

            // RightSide
            if (wall1.RightSide != null && wall1.RightSide.Flags.IsBackwards)
                wall1.RightXOffset += (short)wall2.ClientLength;
            else wall2.RightXOffset += (short)wall1.ClientLength;

            // LeftSide (Do this backwards, because client exchanges vertices of negative walls)
            if (wall1.LeftSide != null && wall1.LeftSide.Flags.IsBackwards)
                wall2.LeftXOffset += (short)wall1.ClientLength;
            else wall1.LeftXOffset += (short)wall2.ClientLength;

            /*****************************************************************/

            return new Tuple<RooWall, RooWall>(wall1, wall2);
        }
コード例 #3
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;
        }