Skip to main content

WireframeSphere Struct

Static wireframe sphere mesh definition. More...

Declaration

struct helios::engine::rendering::mesh::assets::WireframeSphere { ... }

Public Static Functions Index

static MeshDatameshData ()

Creates a lightweight MeshData view over the static sphere buffers. More...

static helios::math::aabbfboundsData ()

Returns the local bounds of this mesh. More...

Private Static Functions Index

static std::size_tvertexIndex (const std::size_t stack, const std::size_t slice) noexcept
static std::array< Vertex, VertexCount >makeVertices ()
static std::array< unsigned int, IndexCount >makeIndices ()

Public Static Attributes Index

static constexpr std::size_tStacks = 12
static constexpr std::size_tSlices = 24
static constexpr floatRadius = 0.5f
static constexpr std::size_tVertexCount = ...
static constexpr std::size_tHorizontalEdgeCount = ...
static constexpr std::size_tVerticalEdgeCount = ...
static constexpr std::size_tIndexCount = ...
static const std::array< Vertex, VertexCount >vertices = makeVertices()

Interleaved vertex data. More...

static const std::array< unsigned int, IndexCount >indices = makeIndices()

Line index buffer. More...

static constexpr PrimitiveTypeprimitiveType = PrimitiveType::Lines

Primitive topology used to interpret indices. More...

Description

Static wireframe sphere mesh definition.

The sphere is centered at the origin and has radius 0.5. It is rendered as latitude and longitude line segments.

Definition at line 31 of file WireframeSphere.ixx.

Public Static Functions

boundsData()

helios::math::aabbf helios::engine::rendering::mesh::assets::WireframeSphere::boundsData ()
inline static

Returns the local bounds of this mesh.

Returns

local bounds as aabb

Definition at line 155 of file WireframeSphere.ixx.

155 static helios::math::aabbf boundsData() {
156 return helios::math::aabbf{
157 -Radius, -Radius, -Radius,
159 };
160 }

Reference Radius.

meshData()

MeshData helios::engine::rendering::mesh::assets::WireframeSphere::meshData ()
inline static

Creates a lightweight MeshData view over the static sphere buffers.

Returns

MeshData referencing vertices, indices, and primitiveType.

Definition at line 143 of file WireframeSphere.ixx.

143 static MeshData meshData() {
144 return MeshData{
145 std::span{vertices},
146 std::span{indices},
148 };
149 }

References indices, primitiveType and vertices.

Private Static Functions

makeIndices()

std::array< unsigned int, IndexCount > helios::engine::rendering::mesh::assets::WireframeSphere::makeIndices ()
inline static

Definition at line 93 of file WireframeSphere.ixx.

93 static std::array<unsigned int, IndexCount> makeIndices() {
94 std::array<unsigned int, IndexCount> result{};
95 std::size_t cursor = 0;
96
97 // Latitude rings, excluding top and bottom poles.
98 for (std::size_t stack = 1; stack < Stacks; ++stack) {
99 for (std::size_t slice = 0; slice < Slices; ++slice) {
100 const auto current = vertexIndex(stack, slice);
101 const auto next = vertexIndex(stack, (slice + 1) % Slices);
102
103 result[cursor++] = static_cast<unsigned int>(current);
104 result[cursor++] = static_cast<unsigned int>(next);
105 }
106 }
107
108 // Longitude arcs.
109 for (std::size_t slice = 0; slice < Slices; ++slice) {
110 for (std::size_t stack = 0; stack < Stacks; ++stack) {
111 const auto current = vertexIndex(stack, slice);
112 const auto next = vertexIndex(stack + 1, slice);
113
114 result[cursor++] = static_cast<unsigned int>(current);
115 result[cursor++] = static_cast<unsigned int>(next);
116 }
117 }
118
119 return result;
120 }

makeVertices()

std::array< Vertex, VertexCount > helios::engine::rendering::mesh::assets::WireframeSphere::makeVertices ()
inline static

Definition at line 59 of file WireframeSphere.ixx.

59 static std::array<Vertex, VertexCount> makeVertices() {
60 std::array<Vertex, VertexCount> result{};
61
62 constexpr float pi = std::numbers::pi_v<float>;
63
64 for (std::size_t stack = 0; stack <= Stacks; ++stack) {
65 const float v = static_cast<float>(stack) / static_cast<float>(Stacks);
66 const float theta = v * pi;
67
68 const float y = std::cos(theta) * Radius;
69 const float ringRadius = std::sin(theta) * Radius;
70
71 for (std::size_t slice = 0; slice < Slices; ++slice) {
72 const float u = static_cast<float>(slice) / static_cast<float>(Slices);
73 const float phi = u * 2.0f * pi;
74
75 const float x = std::cos(phi) * ringRadius;
76 const float z = std::sin(phi) * ringRadius;
77
78 const float nx = x / Radius;
79 const float ny = y / Radius;
80 const float nz = z / Radius;
81
82 result[vertexIndex(stack, slice)] = Vertex{
83 {x, y, z},
84 {nx, ny, nz},
85 {u, v}
86 };
87 }
88 }
89
90 return result;
91 }

vertexIndex()

std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::vertexIndex (const std::size_t stack, const std::size_t slice)
inline noexcept static

Definition at line 52 of file WireframeSphere.ixx.

52 static std::size_t vertexIndex(
53 const std::size_t stack,
54 const std::size_t slice
55 ) noexcept {
56 return stack * Slices + slice;
57 }

Public Static Attributes

HorizontalEdgeCount

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::HorizontalEdgeCount
constexpr static
Initialiser
= (Stacks - 1) * Slices

Definition at line 41 of file WireframeSphere.ixx.

41 static constexpr std::size_t HorizontalEdgeCount =

IndexCount

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::IndexCount
constexpr static
Initialiser

Definition at line 47 of file WireframeSphere.ixx.

47 static constexpr std::size_t IndexCount =

indices

const std::array<unsigned int, IndexCount> helios::engine::rendering::mesh::assets::WireframeSphere::indices = makeIndices()
static

Line index buffer.

Definition at line 132 of file WireframeSphere.ixx.

132 inline static const std::array<unsigned int, IndexCount> indices = makeIndices();

Referenced by meshData.

primitiveType

constexpr PrimitiveType helios::engine::rendering::mesh::assets::WireframeSphere::primitiveType = PrimitiveType::Lines
constexpr static

Primitive topology used to interpret indices.

Definition at line 137 of file WireframeSphere.ixx.

137 static constexpr PrimitiveType primitiveType = PrimitiveType::Lines;

Referenced by meshData.

Radius

constexpr float helios::engine::rendering::mesh::assets::WireframeSphere::Radius = 0.5f
constexpr static

Definition at line 36 of file WireframeSphere.ixx.

36 static constexpr float Radius = 0.5f;

Referenced by boundsData.

Slices

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::Slices = 24
constexpr static

Definition at line 34 of file WireframeSphere.ixx.

34 static constexpr std::size_t Slices = 24;

Stacks

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::Stacks = 12
constexpr static

Definition at line 33 of file WireframeSphere.ixx.

33 static constexpr std::size_t Stacks = 12;

VertexCount

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::VertexCount
constexpr static
Initialiser
= (Stacks + 1) * Slices

Definition at line 38 of file WireframeSphere.ixx.

38 static constexpr std::size_t VertexCount =

VerticalEdgeCount

constexpr std::size_t helios::engine::rendering::mesh::assets::WireframeSphere::VerticalEdgeCount
constexpr static
Initialiser

Definition at line 44 of file WireframeSphere.ixx.

44 static constexpr std::size_t VerticalEdgeCount =

vertices

const std::array<Vertex, VertexCount> helios::engine::rendering::mesh::assets::WireframeSphere::vertices = makeVertices()
static

Interleaved vertex data.

Definition at line 127 of file WireframeSphere.ixx.

127 inline static const std::array<Vertex, VertexCount> vertices = makeVertices();

Referenced by meshData.


The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.