Box2D.Callbacks.DebugDraw.DrawPolygon C# (CSharp) Метод

DrawPolygon() публичный Метод

Draw a closed polygon provided in CCW order. This implementation uses {@link #drawSegment(Vec2, Vec2, Color3f)} to draw each side of the polygon.
public DrawPolygon ( Vec2 vertices, int vertexCount, Color3f color ) : void
vertices Box2D.Common.Vec2
vertexCount int
color Box2D.Common.Color3f
Результат void
        public void DrawPolygon(Vec2[] vertices, int vertexCount, Color3f color)
        {
            if (vertexCount == 1)
            {
                DrawSegment(vertices[0], vertices[0], color);
                return;
            }

            for (int i = 0; i < vertexCount - 1; i += 1)
            {
                DrawSegment(vertices[i], vertices[i + 1], color);
            }

            if (vertexCount > 2)
            {
                DrawSegment(vertices[vertexCount - 1], vertices[0], color);
            }
        }

Usage Example

Пример #1
0
        public void DrawTree(DebugDraw argDraw, int nodeId, int spot, int height)
        {
            TreeNode node = m_nodes[nodeId];
            node.AABB.GetVertices(drawVecs);

            color.Set(1, (height - spot) * 1f / height, (height - spot) * 1f / height);
            argDraw.DrawPolygon(drawVecs, 4, color);

            argDraw.ViewportTranform.GetWorldToScreen(node.AABB.UpperBound, textVec);
            argDraw.DrawString(textVec.X, textVec.Y, nodeId + "-" + (spot + 1) + "/" + height, color);

            if (node.Child1 != TreeNode.NULL_NODE)
            {
                DrawTree(argDraw, node.Child1, spot + 1, height);
            }
            if (node.Child2 != TreeNode.NULL_NODE)
            {
                DrawTree(argDraw, node.Child2, spot + 1, height);
            }
        }