public void DrawSphere(Vector3 origin, float radius, Color color, int numSegments = 32)
{
int N = numSegments;
Vector3[] points = new Vector3[N + 1];
for (int i = 0; i <= N; i++)
{
points[i].X = origin.X + radius * (float)Math.Cos(Math.PI * 2 * i / N);
points[i].Y = origin.Y;
points[i].Z = origin.Z + radius * (float)Math.Sin(Math.PI * 2 * i / N);
}
for (int i = 0; i < N; i++)
{
DrawLine(points[i], points[i + 1], color);
}
for (int i = 0; i <= N; i++)
{
points[i].X = origin.X + radius * (float)Math.Cos(Math.PI * 2 * i / N);
points[i].Y = origin.Y + radius * (float)Math.Sin(Math.PI * 2 * i / N);
points[i].Z = origin.Z;
}
for (int i = 0; i < N; i++)
{
DrawLine(points[i], points[i + 1], color);
}
for (int i = 0; i <= N; i++)
{
points[i].X = origin.X;
points[i].Y = origin.Y + radius * (float)Math.Cos(Math.PI * 2 * i / N);
points[i].Z = origin.Z + radius * (float)Math.Sin(Math.PI * 2 * i / N);
}
for (int i = 0; i < N; i++)
{
DrawLine(points[i], points[i + 1], color);
}
}