Exemplo n.º 1
0
 public void DrawSegment(System.Numerics.Vector2 start, System.Numerics.Vector2 end, Color color)
 {
     start = FSConvert.ToDisplayUnits(start);
     end   = FSConvert.ToDisplayUnits(end);
     _primitiveBatch.AddVertex(start, color, PrimitiveType.LineList);
     _primitiveBatch.AddVertex(end, color, PrimitiveType.LineList);
 }
Exemplo n.º 2
0
        public void DrawSolidCircle(System.Numerics.Vector2 center, float radius, System.Numerics.Vector2 axis, Color color)
        {
            const double increment = Math.PI * 2.0 / CircleSegments;
            double       theta     = 0.0;

            Color colorFill = color * 0.5f;

            System.Numerics.Vector2 v0 = center + radius * new System.Numerics.Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));
            FSConvert.ToDisplayUnits(ref v0, out v0);
            theta += increment;

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

                _primitiveBatch.AddVertex(v0, colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(v1), colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(v2), colorFill, PrimitiveType.TriangleList);

                theta += increment;
            }

            DrawCircle(center, radius, color);
            DrawSegment(center, center + axis * radius, color);
        }
Exemplo n.º 3
0
 public void DrawPolygon(Vector2[] vertices, int count, Color color, bool closed = true)
 {
     for (int i = 0; i < count - 1; i++)
     {
         _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[i]), color, PrimitiveType.LineList);
         _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[i + 1]), color, PrimitiveType.LineList);
     }
     if (closed)
     {
         _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[count - 1]), color, PrimitiveType.LineList);
         _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[0]), color, PrimitiveType.LineList);
     }
 }
Exemplo n.º 4
0
        public void DrawCircle(Vector2 center, float radius, Color color)
        {
            const double increment = Math.PI * 2.0 / CircleSegments;
            double       theta     = 0.0;

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

                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(v1), color, PrimitiveType.LineList);
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(v2), color, PrimitiveType.LineList);

                theta += increment;
            }
        }
Exemplo n.º 5
0
        public void DrawSolidPolygon(Vector2[] vertices, int count, Color color, bool outline = true)
        {
            if (count == 2)
            {
                DrawPolygon(vertices, count, color);
                return;
            }

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

            for (int i = 1; i < count - 1; i++)
            {
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[0]), colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[i]), colorFill, PrimitiveType.TriangleList);
                _primitiveBatch.AddVertex(FSConvert.ToDisplayUnits(vertices[i + 1]), colorFill, PrimitiveType.TriangleList);
            }

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