15 #include "Base/Util/Assert.h"
25 float const D = .5f, t = D * (1 - qMin(tD, 1.f));
29 QVector<float> as({+D, +t, -t, -D, -D, -t, +t, +D});
30 QVector<float> bs({+t, +D, +D, +t, -t, -D, -D, -t});
32 auto side = [&](
int ax,
int ay,
int az,
int bx,
int by,
int bz,
const Vector3D& d,
bool rev) {
34 for (
int i = 0; i < 8; ++i)
35 vs_[rev ? 7 - i : i] =
36 Vector3D(ax * as.at(i) + bx * bs.at(i), ay * as.at(i) + by * bs.at(i),
37 az * as.at(i) + bz * bs.at(i))
39 vs.addFan(vs_, {0, 1, 2, 3, 4, 5, 6, 7, 0});
44 auto corner = [&](
int x,
int y,
int z) {
45 Vertices vs_({{D * x, D * y, t * z + 0.5f},
46 {D * x, t * y, D * z + 0.5f},
47 {t * x, D * y, D * z + 0.5f}});
51 vs.addTriangle(vs_.at(0), vs_.at(1), vs_.at(2));
54 side(0, 1, 0, 0, 0, 1,
Vector3D(+D, 0, +0.5f),
false);
55 side(0, 1, 0, 0, 0, 1,
Vector3D(-D, 0, +0.5f),
true);
56 side(1, 0, 0, 0, 0, 1,
Vector3D(0, +D, +0.5f),
true);
57 side(1, 0, 0, 0, 0, 1,
Vector3D(0, -D, +0.5f),
false);
58 side(1, 0, 0, 0, 1, 0,
Vector3D(0, 0, +D + 0.5f),
false);
59 side(1, 0, 0, 0, 1, 0,
Vector3D(0, 0, -D + 0.5f),
true);
61 for (
int x : {-1, +1})
62 for (
int y : {-1, +1})
63 for (
int z : {-1, +1})
66 ASSERT(150 == vs.count());
static Mesh makeMesh(const Vertices &vs, Vertices const *ns=nullptr)
QVector< Vert_Normal > Mesh
static Mesh meshTruncBox(float tD)
void addTriangle(const Vector3D &, const Vector3D &, const Vector3D &)