WireSphere

Sealed shape drawer that renders wireframe spheres by drawing latitude and longitude lines. Contains the nested Sphere readonly struct for storing sphere parameters. Pre-computes a latitude/longitude vertex grid at construction time (6 latitude bands × 8 longitude segments) and transforms vertices per-frame using radius and center offset.

Definition

Namespace: Paragon.Core.ShapesDrawer Assembly: Paragon.dll

public sealed class WireSphereDrawer : ShapeDrawer<WireSphereDrawer.Sphere>

Inheritance: ShapeDrawer<Sphere> → WireSphereDrawer

Methods

Add

Enqueues a wireframe sphere for rendering this frame.

public void Add(Vector3 center, float radius, Color color, float thickness = 1f)
Parameter
Type
Default
Description

center

Vector3

Sphere center position

radius

float

Sphere radius

color

Color

Wire color

thickness

float

1f

Line thickness in pixels

Draw

Renders all queued wireframe spheres. Sets lineGeometry, thicknessSpace, and per-sphere Thickness, then calls DrawSphere() for each entry.

Rendering approach: The DrawSphere method draws two sets of lines:

  1. Latitude lines (horizontal rings): For each latitude band (1 through latitude_count - 1), draws longitude_count line segments connecting adjacent longitude vertices. Skips the poles (latitude 0 and latitude_count).

  2. Longitude lines (vertical arcs): For each longitude segment, draws latitude_count line segments connecting adjacent latitude vertices from pole to pole.

Each unit vertex is scaled by radius and offset by center: vertex * radius + center.

Sphere Struct

Readonly struct holding all parameters for a single wireframe sphere draw call.

Constants

Constant
Value
Description

latitude_count

6

Number of latitude bands (horizontal rings from pole to pole)

longitude_count

8

Number of longitude segments (vertical lines around the sphere)

The total vertex count is (latitude_count + 1) × (longitude_count + 1) = 63 vertices.

Construction

The constructor calls InitializeVertexData() which pre-computes a unit sphere vertex grid using standard spherical-to-Cartesian conversion:

Vertex generation:

  • theta (latitude): evenly distributed from 0 to π (north pole to south pole)

  • phi (longitude): evenly distributed from 0 to (full revolution)

  • Conversion: x = cos(phi) * sin(theta), y = cos(theta), z = sin(phi) * sin(theta)

Common Pitfalls

circle-exclamation
circle-info

Vertices are pre-computed once. The vertex grid is calculated in the constructor and reused for every draw call. At render time, only multiplication and addition are applied per vertex (v * radius + center), making this efficient for multiple spheres per frame.

Examples

Direct Usage via ShapesDrawer

Detection Range Visualization

See Also

Last updated