Example #1
0
        public virtual void DebugDraw(DebugRenderer renderer, float elapsedSeconds, float totalSeconds)
        {
            var body = Entity.Body;

            switch (Fixture.Shape.ShapeType)
            {
            case ShapeType.Circle:
                var circle = (CircleShape)Fixture.Shape;
                var radius = circle.Radius;
                renderer.DebugDrawCircle(body.Position + circle.Position, radius, color: debugShapeColor);
                break;

            case ShapeType.Polygon:
                var polygon = (PolygonShape)Fixture.Shape;

                var transformedPos = polygon.Vertices.Select(v =>
                {
                    return(Vector2.Transform(v, Matrix.CreateRotationZ(body.Rotation)));
                }).ToArray();


                renderer.DebugDrawPolygon(transformedPos, body.Position, color: debugShapeColor);
                break;
            }

            // Draw border
            if (body.FixtureList.Count > 1 && body.BodyType == BodyType.Static)
            {
                foreach (var f in body.FixtureList)
                {
                    if (f.Shape is PolygonShape)
                    {
                        var polygon = (PolygonShape)f.Shape;
                        renderer.DebugDrawPolygon(polygon.Vertices, f.Body.Position);
                    }
                }
            }
        }