Exemple #1
0
        public void DrawSolidCircle(FVector2 center, float radius, FVector2 axis, Color 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;

            Color colorFill = color * 0.5f;

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

            theta += increment;

            for (int i = 1; i < CircleSegments - 1; i++)
            {
                FVector2 v1 = center + radius * new FVector2((float)Math.Cos(theta), (float)Math.Sin(theta));
                FVector2 v2 = center +
                              radius *
                              new FVector2((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment));

                triangleListBatch.Add(FDVertex.FromTriangleList(v0, v1, v2, colorFill));
                //_primitiveBatch.AddVertex(v0, colorFill, PrimitiveType.TriangleList);
                //_primitiveBatch.AddVertex(v1, colorFill, PrimitiveType.TriangleList);
                //_primitiveBatch.AddVertex(v2, colorFill, PrimitiveType.TriangleList);

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

            DrawSegment(center, center + axis * radius, color);
        }
Exemple #2
0
        public void DrawSolidPolygon(FVector2[] vertices, int count, Color color, bool outline)
        {
            //if (!_primitiveBatch.IsReady())
            //{
            //    throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            //}
            if (count == 2)
            {
                DrawPolygon(vertices, count, color);
                return;
            }

            Color colorFill = color * (outline ? 0.5f : 1.0f);

            for (int i = 1; i < count - 1; i++)
            {
                triangleListBatch.Add(FDVertex.FromTriangleList(vertices[0], vertices[i], vertices[i + 1], colorFill));
                //_primitiveBatch.AddVertex(vertices[0], colorFill, PrimitiveType.TriangleList);
                //_primitiveBatch.AddVertex(vertices[i], colorFill, PrimitiveType.TriangleList);
                //_primitiveBatch.AddVertex(vertices[i + 1], colorFill, PrimitiveType.TriangleList);
            }

            if (outline)
            {
                DrawPolygon(vertices, count, color);
            }
        }