Skip to content

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);
ParameterDescription
paramsInitialization 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);
ParameterDescription
paramsInitialization parameters for constructing the geometry.

Types

CylinderGeometry::Parameters struct

Parameters for constructing a CylinderGeometry object.

ParameterDescription
radius_top floatRadius of the top cap.
radius_bottom floatRadius of the bottom cap.
height floatHeight along the +Y axis.
radial_segments unsigned intNumber of radial subdivisions.
height_segments unsigned intNumber of vertical subdivisions.
open_ended boolIf true, the end caps are omitted.

Released under the MIT License.