Beispiel #1
0
 internal void DrawLine(object dc, IShapeRenderer renderer, IPointShape a, IPointShape b, double dx, double dy, double scale)
 {
     _line.StyleId      = _strokeStyleId;
     _line.StartPoint.X = a.X;
     _line.StartPoint.Y = a.Y;
     _line.Point.X      = b.X;
     _line.Point.Y      = b.Y;
     _line.Draw(dc, renderer, dx, dy, scale, null, null);
 }
 /// <summary>
 /// Draws the given camrea
 /// </summary>
 public void Draw(GraphicsDevice graphicsDevice, ContentManager cm, Camera camera, MatrixStack stack)
 {
     mCameraPosition.Draw(graphicsDevice, cm, camera, stack);
     mLookAt.Draw(graphicsDevice, cm, camera, stack);
     mUpVectorPosition.Draw(graphicsDevice, cm, camera, stack);
     mViewVector.Draw(graphicsDevice, cm, camera, stack);
     mUpVector.Draw(graphicsDevice, cm, camera, stack);
 }
Beispiel #3
0
 public void DrawLine(object dc, ShapeRenderer renderer, PointShape a, PointShape b, double dx, double dy)
 {
     _line.Style        = _strokeStyle;
     _line.StartPoint.X = a.X;
     _line.StartPoint.Y = a.Y;
     _line.Point.X      = b.X;
     _line.Point.Y      = b.Y;
     _line.Draw(dc, renderer, dx, dy, null, null);
 }
Beispiel #4
0
        public override void Draw()
        {
            var position = GetComponent <PositionComponent>();

            // Layers and scenes have methods for searching entities/components.
            foreach (BotComponent bot in Layer.GetComponentList <BotComponent>())
            {
                var botPosition = bot.Owner.GetComponent <PositionComponent>();

                LineShape.Draw(position.Position, botPosition.Position, Color.Transparent, Color.White * 0.2f);
            }
        }
Beispiel #5
0
        public void Draw()
        {
            // Transform matrices took care of the rotations,
            // so all panels assume they are drawn with no rotation\offset.
            RectangleShape.DrawBySize(Offset - Vector2.UnitY * Size / 2f, Size, true);

            CircleShape.Draw(Offset, 4, true);

            LineShape.Draw(Offset, Offset - Vector2.UnitY * 8);

            if (Attachments == null)
            {
                return;
            }

            // Transform matrices stack.
            GraphicsMgr.AddTransformMatrix(
                Matrix.CreateTranslation(-(Vector2.UnitY * Size / 2f).ToVector3())
                );
            foreach (var panel in Attachments)
            {
                // We need to offset the child panel by half of parent's
                // width or height depending on the side.
                var length     = Size.X / 2f;
                var resultSide = panel.Side;
                if (panel.Side % 2 == 0)
                {
                    length = Size.Y / 2f;
                }

                GraphicsMgr.AddTransformMatrix(
                    //Matrix.CreateRotationZ(0.3f) // Future reference - use this to pivot the panels.
                    Matrix.CreateTranslation(-(Vector2.UnitY * length).ToVector3())
                    * Matrix.CreateRotationZ((float)(Math.PI - Math.PI / 2f * resultSide))
                    * Matrix.CreateTranslation(Offset.ToVector3())
                    );
                panel.Draw();
                GraphicsMgr.ResetTransformMatrix();
            }

            GraphicsMgr.ResetTransformMatrix();
        }
Beispiel #6
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(64, 64);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = _mainColor;

            // This position accounts for current camera transform matrix.
            // Visually it will be at the pointer's position when camera will move.
            CircleShape.Draw(Input.MousePosition, 4, false);

            // This position only accounts for screen transformation.
            // When the camera will move, it will offset.
            CircleShape.Draw(Input.ScreenMousePosition, 8, true);

            // You can also get mouse position from any camera.
            // This method can be used in Update, when no camera is active.
            CircleShape.Draw(GraphicsMgr.CurrentCamera.GetRelativeMousePosition(), 12, true);


            Text.CurrentFont = ResourceHub.GetResource <IFont>("Fonts", "Arial");

            Text.Draw("Keyboard input: " + _keyboardInput.ToString(), position);


            // Gamepad, mouse and keyboard buttons are using the same method.
            position += Vector2.UnitY * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(KeyboardTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(GamepadTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(MouseTestButton));


            position = new Vector2(200, 200);

            if (Input.GamepadConnected(0))
            {
                Text.Draw("Gamepad is connected!", position);
            }
            else
            {
                Text.Draw("Gamepad is not connected.", position);
            }


            // Sticks.
            position += Vector2.UnitY * 96;
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetLeftStick(0) * 64 * new Vector2(1, -1), 16, false);
            position += Vector2.UnitX * (128 + 64);
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetRightStick(0) * 64 * new Vector2(1, -1), 16, false);

            // Triggers.
            position -= Vector2.UnitX * (64 + 16);
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetRightTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
            position -= Vector2.UnitX * 32;
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetLeftTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
        }
Beispiel #7
0
        public override void Draw()
        {
            base.Draw();

            _secondaryColor.H += TimeKeeper.Global.Time(360 / 4f);
            if (_secondaryColor.H >= 360f)
            {
                _secondaryColor.H -= 360;
            }
            Debug.WriteLine(_secondaryColor.H);

            // This code shows how to draw shapes using static methods and instanced objects.

            var startingPosition = new Vector2(100, 100);
            var position         = startingPosition;
            var spacing          = 100;

            // Circles.
            GraphicsMgr.CurrentColor = _mainColor;             // Setting current color. It's active for all shapes and sprites.
            CircleShape.Draw(position, 24, false);             // Filled circle.

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);             // Outline.


            position += Vector2.UnitX * spacing;


            CircleShape.CircleVerticesCount = 8;             // Changing the amount of circle vertices.

            GraphicsMgr.CurrentColor = _mainColor;
            CircleShape.Draw(position, 24, false);

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);

            CircleShape.CircleVerticesCount = 32;
            // Circles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Rectangles.

            // You can draw rectangle using its top left and bottom right point...
            RectangleShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, false);

            GraphicsMgr.CurrentColor = _mainColor;
            // ...or its center position and size!
            RectangleShape.DrawBySize(position, Vector2.One * 64, true);

            position += Vector2.UnitX * spacing;

            RectangleShape.Draw(             // We can also manually set colors for each vertex.
                position - Vector2.One * 24,
                position + Vector2.One * 24,
                false,
                _mainColor,
                _mainColor,
                _mainColor,
                _secondaryColor.ToColor()
                );

            RectangleShape.DrawBySize(
                position,
                Vector2.One * 64,
                true,
                _mainColor,
                _secondaryColor.ToColor(),
                _mainColor,
                _mainColor
                );
            // Rectangles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Triangles.

            _triangle.Position = position;
            _triangle.Draw();             // Drawing an instantiated triangle.

            GraphicsMgr.CurrentColor = _mainColor;

            TriangleShape.Draw(
                position + new Vector2(-24, -24),
                position + new Vector2(24, -24),
                position + new Vector2(24, 24),
                false
                );

            // Be aware of culling. This triangle, for example, will be culled.
            // You can disable culling, if you don't want to deal with it.
            TriangleShape.Draw(new Vector2(-24, -24), new Vector2(24, 24), new Vector2(24, -24), false);

            // Triangles.



            // Lines.

            position += Vector2.UnitX * spacing;
            LineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24);

            position += Vector2.UnitX * spacing / 2f;
            ThickLineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, 5);

            // Lines.
        }