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);| Parameter | Description |
|---|---|
| params | Initialization 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);| Parameter | Description |
|---|---|
| params | Initialization parameters used to generate the sphere. |
Types
SphereGeometry::Parameters struct
Parameters for constructing a SphereGeometry object.
| Parameter | Description |
|---|---|
| radius float | Radius of the sphere. |
| width_segments unsigned | Segments around the circumference (longitude). |
| height_segments unsigned | Segments from top to bottom (latitude). |