Avara3D 0.2.0
C++ API reference
Sphere.h
1//
2// Sphere.h
3// avara3d
4//
5// Created by Morgan Davis on 11/6/17.
6// Copyright © 2026 Morgan K Davis. All rights reserved.
7//
8
9#ifndef AVARA3D_MESH_PRIMITIVE_SPHERE_H
10#define AVARA3D_MESH_PRIMITIVE_SPHERE_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 Sphere : public MeshElement {
27
28 public:
29 // [Public Static Member Functions]
30
32 static std::shared_ptr<Mesh> Mesh(float radius,
33 unsigned segments = DEFAULT_SEGMENTS,
34 std::shared_ptr<Material> material = nullptr);
35
36 // [Public Lifecycle Functions]
37
39 explicit Sphere(float radius, unsigned segments = DEFAULT_SEGMENTS);
40
41 // [Public Member Functions]
42
44 float radius() const;
45
47 unsigned segments() const;
48
49 private:
50 // [Private Constants]
51
52 static constexpr unsigned DEFAULT_SEGMENTS = 4;
53
54 // [Private Member Variables]
55
56 float _radius;
57 unsigned _segments;
58 };
59
60}
61
62#endif // AVARA3D_MESH_PRIMITIVE_SPHERE_H
Owns the vertex and optional index data for one mesh primitive.
Definition: MeshElement.h:43
Icosphere mesh element centered at the origin.
Definition: Sphere.h:26
float radius() const
Returns the configured sphere radius.
static std::shared_ptr< Mesh > Mesh(float radius, unsigned segments=DEFAULT_SEGMENTS, std::shared_ptr< Material > material=nullptr)
Creates a Mesh containing a Sphere and optional material.
Sphere(float radius, unsigned segments=DEFAULT_SEGMENTS)
Generates icosphere geometry with radius and segments subdivisions per edge.
unsigned segments() const
Returns the number of subdivisions per icosahedron edge.