26void AddOutward(
Triangles& triangles, Vector3 a, Vector3 b, Vector3 c,
29 Vector3Scale(Vector3Add(Vector3Add(a, b), c), 1.0f / 3);
30 if (Vector3DotProduct(
FaceNormal(a, b, c), Vector3Subtract(centre, middle)) <
34 triangles.Add(a, b, c, WHITE);
41 const Vector3 middle{0.0f, 0.0f, 0.0f};
42 const auto rim = [](
int side,
float y) {
43 const float angle = 2.0f * std::numbers::pi_v<float> * side / kSides;
44 return Vector3{0.5f * std::cos(angle), y, 0.5f * std::sin(angle)};
46 for (
int side = 0; side < kSides; ++side) {
47 const Vector3 top = rim(side, 0.5f);
48 const Vector3 next_top = rim(side + 1, 0.5f);
49 const Vector3 bottom = rim(side, -0.5f);
50 const Vector3 next_bottom = rim(side + 1, -0.5f);
52 AddOutward(disc, {0.0f, 0.5f, 0.0f}, top, next_top, middle);
53 AddOutward(disc, bottom, next_bottom, next_top, middle);
54 AddOutward(disc, bottom, next_top, top, middle);
61 const Vector3 middle{0.0f, 0.0f, 0.0f};
63 constexpr std::array<Vector2, 4> kCorners = {
64 {{-1.0f, -1.0f}, {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}}};
65 const Vector3 point{0.0f, 0.5f, 0.0f};
66 for (std::size_t i = 0; i < kCorners.size(); ++i) {
67 const Vector2 here = kCorners[i];
68 const Vector2 next = kCorners[(i + 1) % kCorners.size()];
69 const Vector3 low{0.5f * here.x, -0.5f, 0.5f * here.y};
70 const Vector3 next_low{0.5f * next.x, -0.5f, 0.5f * next.y};
71 const Vector3 high{kNarrow * here.x, kShoulder, kNarrow * here.y};
72 const Vector3 next_high{kNarrow * next.x, kShoulder, kNarrow * next.y};
73 AddOutward(spire, low, next_low, next_high, middle);
74 AddOutward(spire, low, next_high, high, middle);
75 AddOutward(spire, high, next_high, point, middle);