CylinderGeometry
Generated geometry representing a 3D cylinder.
CylinderGeometry constructs a mesh for a cylinder aligned along the +Y axis. It supports differing top and bottom radii (allowing tapered shapes), an adjustable height, optional subdivision along both radial and vertical directions, and the option to render the cylinder with or without end caps. The geometry is centered with its midpoint at the origin.
cpp
auto geometry = vglx::CylinderGeometry::Create({
.radius_top = 0.8f,
.radius_bottom = 1.0f,
.height = 2.5f,
.radial_segments = 32,
.height_segments = 3,
.open_ended = false
});
auto material = vglx::PhongMaterial::Create(0x8BC34A);
my_scene->Add(vglx::Mesh::Create(geometry, material));INFO
Derives from Geometry and inherits all public properties and methods.
Construction
Constructors
CylinderGeometry()
Constructs a cylinder geometry.
cpp
CylinderGeometry::CylinderGeometry(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters for constructing the geometry. |
Factories preferred
CylinderGeometry::Create() std::shared_ptr<CylinderGeometry>
Creates a shared instance of CylinderGeometry with default parameters.
cpp
static std::shared_ptr<CylinderGeometry> CylinderGeometry::Create();CylinderGeometry::Create() std::shared_ptr<CylinderGeometry>
Creates a shared instance of CylinderGeometry with custom parameters.
cpp
static std::shared_ptr<CylinderGeometry> CylinderGeometry::Create(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters for constructing the geometry. |
Types
CylinderGeometry::Parameters struct
Parameters for constructing a CylinderGeometry object.
| Parameter | Description |
|---|---|
| radius_top float | Radius of the top cap. |
| radius_bottom float | Radius of the bottom cap. |
| height float | Height along the +Y axis. |
| radial_segments unsigned int | Number of radial subdivisions. |
| height_segments unsigned int | Number of vertical subdivisions. |
| open_ended bool | If true, the end caps are omitted. |