Skip to content

SphereGeometry

Generates a sphere geometry assignable to any mesh.

SphereGeometry creates a UV sphere composed of triangles, configurable via radius, width segments (longitude), and height segments (latitude). It’s useful for rendering planets, lighting probes, collision volumes, or decorative primitives.

cpp
auto geometry = vglx::SphereGeometry::Create({
    .radius = 1.5f,
    .width_segments = 48,
    .height_segments = 24
});

auto mesh = vglx::Mesh::Create(geometry, UnlitMaterial::Create(0x049EF4));
my_scene->Add(mesh);

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


SphereGeometry()

Constructs a SphereGeometry object.

cpp
SphereGeometry::SphereGeometry(const Parameters& params);
ParameterDescription
paramsSphereGeometry::Parameters

Factories preferred


SphereGeometry::Create() auto

Creates a shared pointer to a SphereGeometry object with default parameters.

cpp
static auto SphereGeometry::Create();

SphereGeometry::Create() auto

Creates a shared pointer to a SphereGeometry object.

cpp
static auto SphereGeometry::Create(const Parameters& params);
ParameterDescription
paramsSphereGeometry::Parameters

Types

SphereGeometry::Parameters struct

Parameters for constructing a SphereGeometry object.

ParameterDescription
radius floatRadius of the sphere.
width_segments unsignedSubdivisions along the width.
height_segments unsignedSubdivisions along the height.

Released under the MIT License.