public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {

            for (int i = 0; i < vertexCount - 1; i++)
            {
                DrawNode.AddLineVertex(vertices[i].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i+1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));

            }

            DrawNode.AddLineVertex(vertices[vertexCount - 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
            DrawNode.AddLineVertex(vertices[0].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
        }
        public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {

            if (vertexCount == 2)
            {
                DrawPolygon(vertices, vertexCount, color);
                return;
            }

            var colorFill = color.ToCCColor4B() * 0.5f;

            for (int i = 1; i < vertexCount - 1; i++)
            {
                DrawNode.AddLineVertex(vertices[0].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i + 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));

            }

            DrawPolygon(vertices, vertexCount, color);
        }
Esempio n. 3
0
        public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            if (!primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }

            if (vertexCount == 2)
            {
                DrawPolygon(vertices, vertexCount, color);
                return;
            }

            var colorFill = color.ToCCColor4B() * 0.5f;

            for (int i = 1; i < vertexCount - 1; i++)
            {
                primitiveBatch.AddVertex(vertices[0].ToCCVector2() * PTMRatio, colorFill, PrimitiveType.TriangleList);
                primitiveBatch.AddVertex(vertices[i].ToCCVector2() * PTMRatio, colorFill, PrimitiveType.TriangleList);
                primitiveBatch.AddVertex(vertices[i + 1].ToCCVector2() * PTMRatio, colorFill, PrimitiveType.TriangleList);
            }

            DrawPolygon(vertices, vertexCount, color);
        }
Esempio n. 4
0
        public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            if (!primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }

            for (int i = 0; i < vertexCount - 1; i++)
            {
                primitiveBatch.AddVertex(vertices[i].ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
                primitiveBatch.AddVertex(vertices[i + 1].ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
            }

            primitiveBatch.AddVertex(vertices[vertexCount - 1].ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
            primitiveBatch.AddVertex(vertices[0].ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
        }
Esempio n. 5
0
 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     if (!primitiveBatch.IsReady())
     {
         throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
     }
     primitiveBatch.AddVertex(p1.ToCCVector2() * PTMRatio , color.ToCCColor4B(), PrimitiveType.LineList);
     primitiveBatch.AddVertex(p2.ToCCVector2() * PTMRatio, color.ToCCColor4B(), PrimitiveType.LineList);
 }
Esempio n. 6
0
        public override void DrawSolidCircle(b2Vec2 center, float radius, b2Vec2 axis, b2Color color)
        {
            if (!primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            const double increment = Math.PI * 2.0 / CircleSegments;
            double theta = 0.0;

            var colorFill = color.ToCCColor4B() * 0.5f;
            var centr = center.ToCCVector2();

            CCVector2 v0 = center.ToCCVector2() + radius * new CCVector2((float) Math.Cos(theta), (float) Math.Sin(theta));
            theta += increment;

            v0 *= PTMRatio;

            for (int i = 1; i < CircleSegments - 1; i++)
            {
                var v1 = centr + radius * new CCVector2((float) Math.Cos(theta), (float) Math.Sin(theta));

                v1 *= PTMRatio;

                var v2 = centr +
                    radius * new CCVector2((float) Math.Cos(theta + increment), (float) Math.Sin(theta + increment));

                v2 *= PTMRatio;

                primitiveBatch.AddVertex(ref v0, colorFill, PrimitiveType.TriangleList);
                primitiveBatch.AddVertex(ref v1, colorFill, PrimitiveType.TriangleList);
                primitiveBatch.AddVertex(ref v2, colorFill, PrimitiveType.TriangleList);

                theta += increment;
            }
            DrawCircle(center, radius, color);

            DrawSegment(center, center + axis * radius, color);
        }
Esempio n. 7
0
        public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
        {
            if (!primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            const double increment = Math.PI * 2.0 / CircleSegments;
            double theta = 0.0;

            var col = color.ToCCColor4B();
            CCVector2 centr = center.ToCCVector2();

            for (int i = 0, count = CircleSegments; i < count; i++)
            {
                CCVector2 v1 = (centr + radius * new CCVector2((float) Math.Cos(theta), (float) Math.Sin(theta))) * PTMRatio;
                CCVector2 v2 = (centr +
                    radius *
                    new CCVector2((float) Math.Cos(theta + increment), (float) Math.Sin(theta + increment))) * PTMRatio;

                primitiveBatch.AddVertex(ref v1, col, PrimitiveType.LineList);
                primitiveBatch.AddVertex(ref v2, col, PrimitiveType.LineList);

                theta += increment;
            }
        }
 public override void DrawCircle(b2Vec2 center, float radius, b2Color color)
 {
     var centr = center.ToCCPoint() * PTMRatio;
     var rad = radius * PTMRatio;
     DrawNode.DrawCircle(centr, rad, color.ToCCColor4B());
 }
 public override void DrawSolidCircle(b2Vec2 center, float radius, b2Vec2 axis, b2Color color)
 {
     var colorFill = color.ToCCColor4B() * 0.5f;
     var centr = center.ToCCPoint() * PTMRatio;
     var rad = radius * PTMRatio;
     DrawNode.DrawSolidCircle(centr, rad, colorFill);
     DrawNode.DrawLine(centr, centr + (axis.ToCCPoint() * PTMRatio) * radius,3, color.ToCCColor4B());
 }
Esempio n. 10
0
 public override void DrawSegment(b2Vec2 p1, b2Vec2 p2, b2Color color)
 {
     DrawNode.AddLineVertex(p1.ToVectorC4B(color.ToCCColor4B(), PTMRatio));
     DrawNode.AddLineVertex(p2.ToVectorC4B(color.ToCCColor4B(), PTMRatio));
 }
Esempio n. 11
0
 public void DrawSolidCircle(CCPoint center, float radius, b2Color color)
 {
     base.DrawCircle(center.ToCCPoint(), radius, color.ToCCColor4B());
 }
Esempio n. 12
0
 public void DrawRect(CCRect rect, b2Color color)
 {
     base.DrawRect(rect, color.ToCCColor4B());
 }
Esempio n. 13
0
 public void DrawDot(CCPoint pos, float radius, b2Color color)
 {
     //base.DrawDot(pos.ToCCPoint(), radius, color.ToCCColor4F());
     base.DrawSolidCircle(pos.ToCCPoint(), radius, color.ToCCColor4B());
 }
Esempio n. 14
0
 public void DrawCircle(CCPoint center, float radius, float angle, int segments, b2Color color)
 {
     base.DrawCircle(center.ToCCPoint(), radius, angle, segments, color.ToCCColor4B());
 }
Esempio n. 15
0
 public void DrawCircle(CCPoint center, float radius, b2Color color)
 {
     var centerPoint = center.ToCCPoint();
     var colorOutline = color.ToCCColor4B();
     var colorFill = colorOutline * 0.5f;
     base.DrawCircle(centerPoint, radius, colorOutline);
     base.DrawSolidCircle(centerPoint, radius, colorFill);
 }