示例#1
0
        private void DrawFixture(Fixture fixture)
        {
            Color     color = new Color(0.95f, 0.95f, 0.6f);
            Transform xf;

            fixture.Body.GetTransform(out xf);

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

                Vector2 center = MathUtils.Mul(ref xf, circle.Position);
                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] = MathUtils.Mul(ref xf, poly.Vertices[i]);
                }

                DebugDraw.DrawSolidPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }