Beispiel #1
0
        private void DrawRTSDatastructures()
        {
            float displayWidth  = GraphicsDevice.DisplayMode.Width;
            float displayHeight = GraphicsDevice.DisplayMode.Height;

            Vector2   origin    = new Vector2(displayWidth / 2, displayHeight / 2);
            Rectangle rectangle = new Rectangle(
                origin,
                displayWidth / 2, displayHeight / 2
                );

            rtsRendrer.Draw(rectangle, Color.Red, false);

            Vector2     p1     = new Vector2(displayWidth * .25f, displayHeight * 0.75f);
            Vector2     p2     = new Vector2(displayWidth * .25f, displayHeight * 0.25f);
            Vector2     p3     = new Vector2(displayWidth * .75f, displayHeight * 0.75f);
            Vector2     p4     = new Vector2(displayWidth * .75f, displayHeight * 0.25f);
            BezierCurve bCurve = new BezierCurve(p1, p2, p3, p4);

            rtsRendrer.DrawPoint(p1, Color.Red, 10);
            rtsRendrer.DrawPoint(p2, Color.Green, 10);
            rtsRendrer.DrawPoint(p3, Color.Blue, 10);
            rtsRendrer.DrawPoint(p4, Color.Purple, 10);
            rtsRendrer.Draw(bCurve, Color.White, 2, 1 / 1000f);
        }
        private void GenerateHorizontalStrip()
        {
            float scale = 10;

            rtsRenderer.Scale = scale;
            float displayWidth  = game.GraphicsDevice.DisplayMode.Width / scale;
            float displayHeight = game.GraphicsDevice.DisplayMode.Height / scale;

            float padding = displayWidth / 4;

            Vector2             posIntersection1 = new Vector2(padding, displayHeight / 2);
            FourWayIntersection intersection1    = new FourWayIntersection(posIntersection1);

            Vector2             posIntersection2 = new Vector2(displayWidth / 2, 0.8f * displayHeight);
            FourWayIntersection intersection2    = new FourWayIntersection(posIntersection2);

            Vector2             middle             = new Vector2(displayWidth / 2, displayHeight / 2);
            FourWayIntersection intersectionMiddle = new FourWayIntersection(middle);

            Road road1 = new Road(ref intersection1, ref intersectionMiddle, 3, 3, 30);
            Road road2 = new Road(ref intersectionMiddle, ref intersection2, 3, 3, 30);

            world.AddIntersection(intersection1);
            world.AddIntersection(intersection2);
            world.AddIntersection(intersectionMiddle);
            world.AddRoad(road1);
            world.AddRoad(road2);
        }
Beispiel #3
0
        public void DrawScaledRectange(Rectangle rectangle, Color c)
        {
            Vector2   location        = rectangle.Origin * Scale;
            Rectangle sourceRectangle = new Rectangle(new Vector2(0, 0), rectangle.Width, rectangle.Length);
            Vector2   origin          = new Vector2(rectangle.Width / 2, rectangle.Length / 2);
            Vector2   scale           = new Vector2(Scale, Scale);

            dRenderer.Draw(sourceRectangle, c, location, origin, scale, rectangle.Angle);
        }
        private void GenerateGrid()
        {
            float scale = 10;

            rtsRenderer.Scale = scale;
            float displayWidth  = game.GraphicsDevice.DisplayMode.Width / scale;
            float displayHeight = game.GraphicsDevice.DisplayMode.Height / scale;

            // Generate the world map here
            Vector2             posIntersection1 = new Vector2(0.25f * displayWidth, 0.25f * displayHeight);
            FourWayIntersection intersection1    = new FourWayIntersection(posIntersection1);

            Vector2             posIntersection2 = new Vector2(0.25f * displayWidth, 0.75f * displayHeight);
            FourWayIntersection intersection2    = new FourWayIntersection(posIntersection2);

            Vector2             posIntersection3 = new Vector2(0.5f * displayWidth, 0.25f * displayHeight);
            FourWayIntersection intersection3    = new FourWayIntersection(posIntersection3);

            Vector2             posIntersection4 = new Vector2(0.5f * displayWidth, 0.75f * displayHeight);
            FourWayIntersection intersection4    = new FourWayIntersection(posIntersection4);

            Vector2             posIntersection5 = new Vector2(0.75f * displayWidth, 0.25f * displayHeight);
            FourWayIntersection intersection5    = new FourWayIntersection(posIntersection5);

            Vector2             posIntersection6 = new Vector2(0.75f * displayWidth, 0.75f * displayHeight);
            FourWayIntersection intersection6    = new FourWayIntersection(posIntersection6);


            Road road12 = new Road(ref intersection1, ref intersection2, 2, 2, 120);
            Road road13 = new Road(ref intersection1, ref intersection3, 2, 2, 120);
            Road road24 = new Road(ref intersection2, ref intersection4, 2, 2, 120);
            Road road34 = new Road(ref intersection3, ref intersection4, 2, 2, 120);
            Road road35 = new Road(ref intersection3, ref intersection5, 2, 2, 120);
            Road road46 = new Road(ref intersection4, ref intersection6, 2, 2, 120);
            Road road56 = new Road(ref intersection5, ref intersection6, 2, 2, 120);

            // Add the stuff
            world.AddIntersection(intersection1);
            world.AddIntersection(intersection2);
            world.AddIntersection(intersection3);
            world.AddIntersection(intersection4);
            world.AddIntersection(intersection5);
            world.AddIntersection(intersection6);

            world.AddRoad(road12);
            world.AddRoad(road13);
            world.AddRoad(road24);
            world.AddRoad(road34);
            world.AddRoad(road35);
            world.AddRoad(road46);
            world.AddRoad(road56);
        }
Beispiel #5
0
        private void DrawRTSDatastructures()
        {
            Vector2     a1     = new Vector2(centerHorL, centerVertL + spacingVertL);
            Vector2     c1     = new Vector2(centerHorL, centerVertL - spacingVertL);
            Vector2     a2     = new Vector2(centerHorR, centerVertR - spacingVertR);
            Vector2     c2     = new Vector2(centerHorR, centerVertR + spacingVertR);
            BezierCurve bCurve = new BezierCurve(a1, c1, a2, c2);

            rtsRendrer.DrawPoint(a1, Color.Red, 10);
            rtsRendrer.DrawPoint(c1, Color.Green, 10);
            rtsRendrer.DrawPoint(a2, Color.Red, 10);
            rtsRendrer.DrawPoint(c2, Color.Green, 10);
            rtsRendrer.Draw(bCurve, Color.White, 2, 1 / 1000f, true);
        }
Beispiel #6
0
        public void Draw(BezierCurve bCurve, Color c, float thickness = 1, float step = 0.01f, bool drawTangent = false)
        {
            for (float t = 0; t <= 1; t += step)
            {
                Vector2 point = bCurve.GetPosition(t);
                DrawPoint(point, c, thickness);

                if (drawTangent)
                {
                    Vector2 tangent        = bCurve.GetTangent(t);
                    Segment tangentSegment = new Segment(point, point + tangent.Normalized * 500);
                    Draw(tangentSegment, Color.Red, thickness * 0.5f);
                }
            }
        }
Beispiel #7
0
        public void Draw(Rectangle rect, Color c, Vector2 location, Vector2 origin, Vector2 scale, float angle)
        {
            Microsoft.Xna.Framework.Rectangle sourceRectangle = new Microsoft.Xna.Framework.Rectangle(
                (int)Math.Round(rect.Origin.X),
                (int)Math.Round(rect.Origin.Y),
                (int)Math.Round(rect.Width),
                (int)Math.Round(rect.Length));

            primitives2D.DrawRectangle(
                LinAlgConversion.XNAVector(location),
                sourceRectangle,
                angle,
                LinAlgConversion.XNAVector(origin),
                LinAlgConversion.XNAVector(scale),
                c);
        }
        private void GenerateCross()
        {
            float scale = 10;

            rtsRenderer.Scale = scale;
            float displayWidth  = game.GraphicsDevice.DisplayMode.Width / scale;
            float displayHeight = game.GraphicsDevice.DisplayMode.Height / scale;

            float paddingHor = displayWidth / 8;
            float paddingVer = displayHeight / 8;

            Vector2             posIntersection1 = new Vector2(paddingHor, displayHeight / 2);
            FourWayIntersection intersection1    = new FourWayIntersection(posIntersection1);

            Vector2             posIntersection2 = new Vector2(displayWidth / 2, paddingVer);
            FourWayIntersection intersection2    = new FourWayIntersection(posIntersection2);

            Vector2             posIntersection3 = new Vector2(displayWidth - paddingHor, displayHeight / 2);
            FourWayIntersection intersection3    = new FourWayIntersection(posIntersection3);

            Vector2             posIntersection4 = new Vector2(displayWidth / 2, displayHeight - paddingVer);
            FourWayIntersection intersection4    = new FourWayIntersection(posIntersection4);

            Vector2             middle             = new Vector2(displayWidth / 2, displayHeight / 2);
            FourWayIntersection intersectionMiddle = new FourWayIntersection(middle);

            Road road1 = new Road(ref intersection1, ref intersectionMiddle, 3, 3, 30);
            Road road2 = new Road(ref intersection2, ref intersectionMiddle, 3, 3, 30);
            Road road3 = new Road(ref intersectionMiddle, ref intersection3, 3, 3, 30);
            Road road4 = new Road(ref intersectionMiddle, ref intersection4, 3, 3, 30);

            world.AddIntersection(intersection1);
            world.AddIntersection(intersection2);
            world.AddIntersection(intersection3);
            world.AddIntersection(intersection4);
            world.AddIntersection(intersectionMiddle);
            world.AddRoad(road1);
            world.AddRoad(road2);
            world.AddRoad(road3);
            world.AddRoad(road4);
        }
Beispiel #9
0
 public void Draw(Vector2 point, Color c, float thickness = 1)
 {
     Draw(new Segment(point, point + point.Normalized), c, thickness);
 }
Beispiel #10
0
 public void DrawPoint(Vector2 point, Color c, float thickness = 1)
 {
     primitives2D.DrawPixel(point.X, point.Y, c, thickness);
 }