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