46 const QVector4D leftWingColor = linearColor(0xc7 / 255.0f, 0x2b / 255.0f, 0x27 / 255.0f);
47 const QVector4D rightWingColor = linearColor(0xee / 255.0f, 0x34 / 255.0f, 0x24 / 255.0f);
48 const QVector4D fuselageColor = linearColor(0xf5 / 255.0f, 0xf5 / 255.0f, 0xf5 / 255.0f);
58 {kNose, kLeftTip, kTailNotch, leftWingColor},
59 {kNose, kTailNotch, kRightTip, rightWingColor},
60 {kNose, kTailNotch, kKeelBottom, fuselageColor},
65 QVector3D minBounds = kNose;
66 QVector3D maxBounds = kNose;
67 for (
const Triangle& triangle : triangles) {
68 const QVector3D normal = QVector3D::crossProduct(triangle.b - triangle.a, triangle.c - triangle.a).normalized();
69 for (
const QVector3D& position : {triangle.a, triangle.b, triangle.c}) {
70 floats << position.x() << position.y() << position.z();
71 floats << normal.x() << normal.y() << normal.z();
72 floats << triangle.color.x() << triangle.color.y() << triangle.color.z() << triangle.color.w();
73 minBounds = QVector3D(qMin(minBounds.x(), position.x()), qMin(minBounds.y(), position.y()),
74 qMin(minBounds.z(), position.z()));
75 maxBounds = QVector3D(qMax(maxBounds.x(), position.x()), qMax(maxBounds.y(), position.y()),
76 qMax(maxBounds.z(), position.z()));
81 setVertexData(QByteArray(
reinterpret_cast<const char*
>(floats.constData()),
82 static_cast<qsizetype
>(floats.size() *
sizeof(
float))));
83 setPrimitiveType(QQuick3DGeometry::PrimitiveType::Triangles);
84 addAttribute(QQuick3DGeometry::Attribute::PositionSemantic, 0, QQuick3DGeometry::Attribute::F32Type);
85 addAttribute(QQuick3DGeometry::Attribute::NormalSemantic, 3 *
sizeof(
float), QQuick3DGeometry::Attribute::F32Type);
86 addAttribute(QQuick3DGeometry::Attribute::ColorSemantic, 6 *
sizeof(
float), QQuick3DGeometry::Attribute::F32Type);
87 setBounds(minBounds, maxBounds);