Avara3D 0.2.0
C++ API reference
Cylinder.h
1//
2// Cylinder.h
3// avara3d
4//
5// Created by Morgan Davis on 11/8/17.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_CYLINDER_H
10#define AVARA3D_MESH_PRIMITIVE_CYLINDER_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18 class Mesh;
19 class Material;
20
27 class Cylinder : public MeshElement {
28
29 public:
30 // [Public Static Member Functions]
31
33 static std::shared_ptr<Mesh> Mesh(float radius,
34 float height,
35 unsigned slices = DEFAULT_SLICES,
36 unsigned segments = DEFAULT_SEGMENTS,
37 unsigned rings = DEFAULT_RINGS,
38 std::shared_ptr<Material> material = nullptr);
39
40 // [Public Lifecycle Functions]
41
44 float height,
45 unsigned slices = DEFAULT_SLICES,
46 unsigned segments = DEFAULT_SEGMENTS,
47 unsigned rings = DEFAULT_RINGS);
48
49 // [Public Member Functions]
50
52 float radius() const;
53
55 float height() const;
56
58 unsigned slices() const;
59
61 unsigned segments() const;
62
64 unsigned rings() const;
65
66 private:
67 // [Private Constants]
68
69 static constexpr unsigned DEFAULT_SLICES = 32;
70 static constexpr unsigned DEFAULT_SEGMENTS = 8;
71 static constexpr unsigned DEFAULT_RINGS = 4;
72
73 // [Private Member Variables]
74
75 float _radius;
76 float _height;
77 unsigned _slices;
78 unsigned _segments;
79 unsigned _rings;
80 };
81
82}
83
84#endif // AVARA3D_MESH_PRIMITIVE_CYLINDER_H
Capped cylinder mesh element centered at the origin and aligned along the Y axis.
Definition: Cylinder.h:27
static std::shared_ptr< Mesh > Mesh(float radius, float height, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, unsigned rings=DEFAULT_RINGS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a Cylinder and optional material.
unsigned rings() const
Returns the radial cap subdivision count.
unsigned slices() const
Returns the circumferential subdivision count.
float height() const
Returns the configured axial height.
float radius() const
Returns the configured cylinder radius.
unsigned segments() const
Returns the axial subdivision count.
Cylinder(float radius, float height, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, unsigned rings=DEFAULT_RINGS)
Generates capped cylinder geometry with the supplied dimensions and subdivisions.
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43