Пример #1
0
void Patch::addTri( const QVector3D &a, const QVector3D &b, const QVector3D &c,
                    const QVector3D &n )
{
    QVector3D norm = n.isNull() ? QVector3D::normal( a, b, c ) : n;
    if (sm == Smooth) {
        geom->appendSmooth( a, norm, initv );
        geom->appendSmooth( b, norm, initv );
        geom->appendSmooth( c, norm, initv );
    } else {
        geom->appendFaceted( a, norm );
        geom->appendFaceted( b, norm );
        geom->appendFaceted( c, norm );
    }
    count += 3;
}
Пример #2
0
void Patch::addQuad(const QVector3D &a, const QVector3D &b,  const QVector3D &c, const QVector3D &d)
{
    QVector3D norm = QVector3D::normal(a, b, c);

    if (sm == Smooth) {
        addTri(a, b, c, norm);
        addTri(a, c, d, norm);
    } else {
        // If faceted share the two common vertices
        addTri(a, b, c, norm);
        int k = geom->vertices.count();
        geom->appendSmooth(a, norm, k);
        geom->appendSmooth(c, norm, k);
        geom->appendFaceted(d, norm);
        count += 3;
    }
}