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)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:
Latitude lines (horizontal rings): For each latitude band (1 through
latitude_count - 1), drawslongitude_countline segments connecting adjacent longitude vertices. Skips the poles (latitude 0 andlatitude_count).Longitude lines (vertical arcs): For each longitude segment, draws
latitude_countline 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
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 from0toπ(north pole to south pole)phi(longitude): evenly distributed from0to2π(full revolution)Conversion:
x = cos(phi) * sin(theta),y = cos(theta),z = sin(phi) * sin(theta)
Common Pitfalls
Fixed resolution. The wireframe has a fixed 6×8 grid resolution. Unlike Shapes.Draw.Sphere() which renders a smooth sphere, this wireframe will appear faceted. The resolution cannot be changed per-call — it is determined by the constants latitude_count and longitude_count.
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
ShapesDrawer — static API entry point (
DrawWireSphere)ShapeDrawer<TShape> — base class
SphereDrawer — solid sphere variant (uses
Shapes.Draw.Sphere())WireCubeDrawer — similar wireframe approach for cubes
Shapes — shapes overview
Last updated