Exemplo n.º 1
0
        public LineSegment(V2 a, V2 b)
        {
            this.Start = a.Clone();
            this.End   = b.Clone();

            var diff = this.End - this.Start;

            this.Length = diff.L2Norm();
            this.Unit   = diff / this.Length;
        }
Exemplo n.º 2
0
        public override object Clone()
        {
            Vertex3D v1 = (Vertex3D)V1.Clone();
            Vertex3D v2 = (Vertex3D)V2.Clone();

            Edge3D e = new Edge3D(v1, v2);

            e.extID = extID;

            return(e);
        }
Exemplo n.º 3
0
        private static List <V2> GenerateCoordinates(IEnumerable <V2> directions, V2 origin)
        {
            var coords     = new List <V2>();
            var currOrigin = origin.Clone();

            foreach (var dir in directions)
            {
                currOrigin += dir;
                coords.Add(currOrigin.Clone());
            }
            return(coords);
        }
Exemplo n.º 4
0
        private static List <LineSegment> GenerateSegments(IEnumerable <V2> directions, V2 origin)
        {
            var segs       = new List <LineSegment>();
            V2  currOrigin = origin.Clone();

            foreach (var dir in directions)
            {
                //< Generate the segment
                var A = currOrigin.Clone();
                var B = currOrigin + dir;
                segs.Add(new LineSegment(A, B));
                //< Move the origin to the final point
                currOrigin = B.Clone();
            }
            return(segs);
        }
Exemplo n.º 5
0
        public override object Clone()
        {
            Vertex2D v1 = (Vertex2D)V1.Clone();
            Vertex2D v2 = (Vertex2D)V2.Clone();
            Vertex2D v3 = (Vertex2D)V3.Clone();

            Triangle2D tr = new Triangle2D(v1, v2, v3);

            tr.extID = extID;

            tr.E1 = (Edge2D)E1.Clone();
            tr.E2 = (Edge2D)E2.Clone();
            tr.E3 = (Edge2D)E3.Clone();

            return(tr);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Call regularly from mainthread, will possibly update mapimage and trigger event
        /// </summary>
        public void Tick(double Tick, double Span)
        {
            Real       deltax, deltay;
            Real       transx1, transy1, transx2, transy2;
            RooFile    room;
            RoomObject avatar;

            // basic checks
            if (DataController == null ||
                DataController.AvatarObject == null ||
                DataController.RoomInformation == null ||
                DataController.RoomInformation.ResourceRoom == null)
            {
                return;
            }

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

            room   = DataController.RoomInformation.ResourceRoom;
            avatar = DataController.AvatarObject;

            // get the deltas based on zoom, zoombase and mapsize
            // the center of the bounding box is the player position
            deltax = 0.5f * zoom * (Real)Width;
            deltay = 0.5f * zoom * (Real)Height;

            // update box boundaries (box = what to draw from map)
            scope.Min.X = avatar.Position3D.X - deltax;
            scope.Min.Y = avatar.Position3D.Z - deltay;
            scope.Max.X = avatar.Position3D.X + deltax;
            scope.Max.Y = avatar.Position3D.Z + deltay;

            // prepare drawing
            PrepareDraw();

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

            // start drawing walls from roo
            foreach (RooWall rld in room.Walls)
            {
                // Don't show line if:
                // 1) both sides not set
                // 2) left side set to not show up on map, right side unset
                // 3) right side set to not show up on map, left side unset
                // 4) both sides set and set to not show up on map
                if ((rld.LeftSide == null && rld.RightSide == null) ||
                    (rld.LeftSide != null && rld.RightSide == null && rld.LeftSide.Flags.IsMapNever) ||
                    (rld.LeftSide == null && rld.RightSide != null && rld.RightSide.Flags.IsMapNever) ||
                    (rld.LeftSide != null && rld.LeftSide != null && rld.LeftSide.Flags.IsMapNever && rld.RightSide.Flags.IsMapNever))
                {
                    continue;
                }

                // transform wall points
                transx1 = (rld.P1.X * 0.0625f + 64f - scope.Min.X) * ZoomInv;
                transy1 = (rld.P1.Y * 0.0625f + 64f - scope.Min.Y) * ZoomInv;
                transx2 = (rld.P2.X * 0.0625f + 64f - scope.Min.X) * ZoomInv;
                transy2 = (rld.P2.Y * 0.0625f + 64f - scope.Min.Y) * ZoomInv;

                // draw wall
                DrawWall(rld, transx1, transy1, transx2, transy2);
            }

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

            // draw roomobjects
            foreach (RoomObject obj in DataController.RoomObjects)
            {
                transx1 = (obj.Position3D.X - scope.Min.X) * ZoomInv;
                transy1 = (obj.Position3D.Z - scope.Min.Y) * ZoomInv;

                if (!obj.IsAvatar)
                {
                    Real width     = 50.0f * ZoomInv;
                    Real widthhalf = width / 2.0f;
                    Real rectx     = transx1 - widthhalf;
                    Real recty     = transy1 - widthhalf;

                    DrawObject(obj, rectx, recty, width, width);
                }
                else
                {
                    V2 pos   = new V2(transx1, transy1);
                    V2 line1 = MathUtil.GetDirectionForRadian(obj.Angle) * 50.0f * ZoomInv;
                    V2 line2 = line1.Clone();
                    V2 line3 = line1.Clone();

                    line2.Rotate(GeometryConstants.HALFPERIOD - 0.5f);
                    line3.Rotate(-GeometryConstants.HALFPERIOD + 0.5f);

                    DrawAvatar(obj, pos + line1, pos + line2, pos + line3);
                }
            }

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

            FinishDraw();

            // trigger event
            RaiseImageChanged();
        }