Avara3D 0.2.0
C++ API reference
RoundedBox.h
1//
2// RoundedBox.h
3// avara3d
4//
5// Created by Morgan Davis on 3/6/24.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_ROUNDEDBOX_H
10#define AVARA3D_MESH_PRIMITIVE_ROUNDEDBOX_H
11
12#include <memory>
13
14#include "a3d/mesh/MeshElement.h"
15
16namespace a3d {
17
18 class Mesh;
19 class Material;
20
28 class RoundedBox : public MeshElement {
29
30 public:
31 // [Public Static Member Functions]
32
34 static std::shared_ptr<Mesh> Mesh(float radius,
35 float length,
36 float width,
37 float height,
38 unsigned slices = DEFAULT_SLICES,
39 unsigned lengthSegments = DEFAULT_SEGMENTS,
40 unsigned widthSegments = DEFAULT_SEGMENTS,
41 unsigned heightSegments = DEFAULT_SEGMENTS,
42 std::shared_ptr<Material> material = nullptr);
43
44 // [Public Lifecycle Functions]
45
48 float length,
49 float width,
50 float height,
51 unsigned slices = DEFAULT_SLICES,
52 unsigned lengthSegments = DEFAULT_SEGMENTS,
53 unsigned widthSegments = DEFAULT_SEGMENTS,
54 unsigned heightSegments = DEFAULT_SEGMENTS);
55
56 // [Public Member Functions]
57
59 float radius() const;
60
62 float length() const;
63
65 float width() const;
66
68 float height() const;
69
71 unsigned slices() const;
72
74 unsigned lengthSegments() const;
75
77 unsigned widthSegments() const;
78
80 unsigned heightSegments() const;
81
82 private:
83 // [Private Constants]
84
85 static constexpr unsigned DEFAULT_SLICES = 8;
86 static constexpr unsigned DEFAULT_SEGMENTS = 8;
87
88 // [Private Member Variables]
89
90 float _radius;
91 float _length;
92 float _width;
93 float _height;
94 unsigned _slices;
95 unsigned _lengthSegments;
96 unsigned _widthSegments;
97 unsigned _heightSegments;
98 };
99
100}
101
102#endif // AVARA3D_MESH_PRIMITIVE_ROUNDEDBOX_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Rounded box mesh element centered at the origin.
Definition: RoundedBox.h:28
float radius() const
Returns the configured edge radius.
unsigned heightSegments() const
Returns the height subdivision count.
float width() const
Returns the configured box width along X.
unsigned lengthSegments() const
Returns the length subdivision count.
float height() const
Returns the configured box height along Y.
unsigned widthSegments() const
Returns the width subdivision count.
static std::shared_ptr< Mesh > Mesh(float radius, float length, float width, float height, unsigned slices=DEFAULT_SLICES, unsigned lengthSegments=DEFAULT_SEGMENTS, unsigned widthSegments=DEFAULT_SEGMENTS, unsigned heightSegments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a RoundedBox and optional material.
float length() const
Returns the configured box length along Z.
RoundedBox(float radius, float length, float width, float height, unsigned slices=DEFAULT_SLICES, unsigned lengthSegments=DEFAULT_SEGMENTS, unsigned widthSegments=DEFAULT_SEGMENTS, unsigned heightSegments=DEFAULT_SEGMENTS)
Generates rounded-box geometry with the supplied dimensions and subdivisions.
unsigned slices() const
Returns the rounded-edge subdivision count.