Пример #1
0
        private void DrawFixture(Fixture fixture)
        {
            Color     color = new Color(0.95f, 0.95f, 0.6f);
            Transform xf    = fixture.Body.GetTransform();

            switch (fixture.Shape.ShapeType)
            {
            case ShapeType.Circle:
            {
                CircleShape circle = (CircleShape)fixture.Shape;

                Vector2 center = Transform.Multiply(circle.Position, ref xf);
                float   radius = circle.Radius;

                DebugDraw.DrawSolidCircle(center, radius, Vector2.Zero, color);
            }
            break;

            case ShapeType.Polygon:
            {
                PolygonShape poly        = (PolygonShape)fixture.Shape;
                int          vertexCount = poly.Vertices.Count;
                Debug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                Vector2[] vertices = new Vector2[Settings.MaxPolygonVertices];

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = Transform.Multiply(poly.Vertices[i], ref xf);
                }

                DebugDraw.DrawSolidPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
Пример #2
0
        public void Draw(SpriteBatch sb, SpriteFont font)
        {
            var projection = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Height), 0f, 0f, 1f);

            _debugView.RenderDebugData(projection, camera.getScaledViewMatrix());


            var projection2 = Matrix.CreateOrthographicOffCenter(0f, sb.GraphicsDevice.Viewport.Width, sb.GraphicsDevice.Viewport.Height, 0f, 0f, 1f);

            _debugView.BeginCustomDraw(projection2, camera.getViewMatrix());

            foreach (var ray in player.controller.castList)
            {
                _debugView.DrawSegment(ray.from, ray.to, Color.Blue);
            }

            foreach (var p in platformList)
            {
                foreach (var ray in p.controller.castList)
                {
                    _debugView.DrawSegment(ray.from, ray.to, Color.White);
                }
            }


            var areaPoints = new Vector2[] {
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.bottom)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.bottom))
            };

            _debugView.DrawSolidPolygon(areaPoints, 4, Color.Red);

            _debugView.DrawPoint(ConvertUnits.ToDisplayUnits(camera.focusPosition), 3, Color.White);

            _debugView.DrawPoint(camera.Position, 3, Color.Pink);

            var cameraBounds = new Vector2[] {
                new Vector2(camera.Bounds.Left, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Bottom),
                new Vector2(camera.Bounds.Left, camera.Bounds.Bottom)
            };

            _debugView.DrawPolygon(cameraBounds, 4, Color.Green);

            _debugView.EndCustomDraw();
        }