public virtual void Draw(b2Draw draw)
        {
            b2Color c = new b2Color(0.4f, 0.5f, 0.7f);

            for (int i = 0; i < m_count - 1; ++i)
            {
                draw.DrawSegment(m_ps[i], m_ps[i + 1], c);
            }
        }
Exemple #2
0
        public void DrawShape(b2Fixture fixture, b2Transform xf, b2Color color)
        {
            switch (fixture.ShapeType)
            {
            case b2ShapeType.e_circle:
            {
                b2CircleShape circle = (b2CircleShape)fixture.Shape;

                b2Vec2 center = b2Math.b2Mul(xf, circle.Position);
                float  radius = circle.Radius;
                b2Vec2 axis   = b2Math.b2Mul(xf.q, new b2Vec2(1.0f, 0.0f));

                m_debugDraw.DrawSolidCircle(center, radius, axis, color);
            }
            break;

            case b2ShapeType.e_edge:
            {
                b2EdgeShape edge = (b2EdgeShape)fixture.Shape;
                b2Vec2      v1   = b2Mul(xf, edge.m_vertex1);
                b2Vec2      v2   = b2Mul(xf, edge.m_vertex2);
                m_debugDraw.DrawSegment(v1, v2, color);
            }
            break;

            case b2ShapeType.e_chain:
            {
                b2ChainShape chain    = (b2ChainShape)fixture.Shape;
                int          count    = chain.Count;
                b2Vec2[]     vertices = chain.Vertices;

                b2Vec2 v1 = b2Math.b2Mul(xf, vertices[0]);
                for (int i = 1; i < count; ++i)
                {
                    b2Vec2 v2 = b2Math.b2Mul(xf, vertices[i]);
                    m_debugDraw.DrawSegment(v1, v2, color);
                    m_debugDraw.DrawCircle(v1, 0.05f, color);
                    v1 = v2;
                }
            }
            break;

            case b2ShapeType.e_polygon:
            {
                b2PolygonShape poly        = (b2PolygonShape)fixture.Shape;
                int            vertexCount = poly.VertexCount;
                b2Vec2[]       vertices    = new b2Vec2[b2Settings.b2_maxPolygonVertices];

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

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

            default:
                break;
            }
        }