Avara3D 0.2.0
C++ API reference
Capsule.h
1//
2// Capsule.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_CAPSULE_H
10#define AVARA3D_MESH_PRIMITIVE_CAPSULE_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18 class Mesh;
19 class Material;
20
29 class Capsule : public MeshElement {
30
31 public:
32 // [Public Static Member Functions]
33
35 static std::shared_ptr<Mesh> Mesh(float radius,
36 float height,
37 unsigned slices = DEFAULT_SLICES,
38 unsigned segments = DEFAULT_SEGMENTS,
39 unsigned rings = DEFAULT_RINGS,
40 std::shared_ptr<Material> material = nullptr);
41
42 // [Public Lifecycle Functions]
43
46 float height,
47 unsigned slices = DEFAULT_SLICES,
48 unsigned segments = DEFAULT_SEGMENTS,
49 unsigned rings = DEFAULT_RINGS);
50
51 // [Public Member Functions]
52
54 float radius() const;
55
57 float height() const;
58
60 unsigned slices() const;
61
63 unsigned segments() const;
64
66 unsigned rings() const;
67
68 private:
69 // [Private Constants]
70
71 static constexpr unsigned DEFAULT_SLICES = 32;
72 static constexpr unsigned DEFAULT_SEGMENTS = 4;
73 static constexpr unsigned DEFAULT_RINGS = 8;
74
75 // [Private Member Variables]
76
77 float _radius;
78 float _height;
79 unsigned _slices;
80 unsigned _segments;
81 unsigned _rings;
82 };
83
84}
85
86#endif // AVARA3D_MESH_PRIMITIVE_CAPSULE_H
Capsule mesh element centered at the origin and aligned along the Y axis.
Definition: Capsule.h:29
unsigned slices() const
Returns the circumferential subdivision count.
Capsule(float radius, float height, unsigned slices=DEFAULT_SLICES, unsigned segments=DEFAULT_SEGMENTS, unsigned rings=DEFAULT_RINGS)
Generates capsule geometry with the supplied dimensions and subdivisions.
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 Capsule and optional material.
float height() const
Returns the configured distance between the centers of the capsule caps.
unsigned segments() const
Returns the straight-section subdivision count.
unsigned rings() const
Returns the cap subdivision count.
float radius() const
Returns the configured capsule radius.
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43