Skip to content

SphereGeometry

Generated geometry representing a sphere.

SphereGeometry constructs a UV-parameterized sphere centered at the origin. The radius defines its size, while segmentation properties control tessellation along longitude and latitude. Higher segment counts produce smoother lighting and silhouettes at the cost of additional vertices.

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

auto material = vglx::PhongMaterial::Create(0x049EF4);

my_scene->Add(vglx::Mesh::Create(geometry, material));

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


SphereGeometry()

Constructs a sphere geometry.

cpp
SphereGeometry::SphereGeometry(const Parameters& params);
ParameterDescription
paramsInitialization parameters that control the size and tessellation of the sphere.

Factories preferred


SphereGeometry::Create() auto

Creates a shared instance of SphereGeometry with default parameters.

cpp
static auto SphereGeometry::Create();

SphereGeometry::Create() auto

Creates a shared instance of SphereGeometry with custom parameters.

cpp
static auto SphereGeometry::Create(const Parameters& params);
ParameterDescription
paramsInitialization parameters used to generate the sphere.

Types

SphereGeometry::Parameters struct

Parameters for constructing a SphereGeometry object.

ParameterDescription
radius floatRadius of the sphere.
width_segments unsignedSegments around the circumference (longitude).
height_segments unsignedSegments from top to bottom (latitude).

Released under the MIT License.