示例#1
0
        public void Rotate()
        {
            V2 expected;
            V2 returned;

            // --- TEST ---

            expected = new V2(0.0f, 1.0f);
            returned = new V2(1.0f, 0.0f);
            returned.Rotate(2f * (Real)Math.PI * 0.25f);

            Assert.AreEqual(expected.X, returned.X, EPSILON);
            Assert.AreEqual(expected.Y, returned.Y, EPSILON);

            // --- TEST ---

            expected = new V2(-1.0f, 0.0f);
            returned = new V2(1.0f, 0.0f);
            returned.Rotate(2f * (Real)Math.PI * 0.5f);

            Assert.AreEqual(expected.X, returned.X, EPSILON);
            Assert.AreEqual(expected.Y, returned.Y, EPSILON);

            // --- TEST ---

            expected = new V2(-1.0f, 0.0f);
            returned = new V2(0.0f, -1.0f);
            returned.Rotate(-2f * (Real)Math.PI * 0.25f);

            Assert.AreEqual(expected.X, returned.X, EPSILON);
            Assert.AreEqual(expected.Y, returned.Y, EPSILON);
        }
        public void RotateLocal(Point3D theta)
        {
            Point3D oldCenter = Center;

            TranslateTo(new Point3D(0, 0, 0));
            V1.Rotate(theta);
            V2.Rotate(theta);
            V3.Rotate(theta);
            TranslateTo(oldCenter);
        }
 public void RotateGlobal(Point3D theta)
 {
     V1.Rotate(theta);
     V2.Rotate(theta);
     V3.Rotate(theta);
 }
示例#4
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();
        }