当前位置: 首页>>代码示例>>C++>>正文


C++ QVector3D::isNull方法代码示例

本文整理汇总了C++中QVector3D::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector3D::isNull方法的具体用法?C++ QVector3D::isNull怎么用?C++ QVector3D::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QVector3D的用法示例。


在下文中一共展示了QVector3D::isNull方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qSameDirection

static inline bool qSameDirection(const QVector3D &a , const QVector3D &b)
{
    bool res = false;
    if (!a.isNull() && !b.isNull())
    {
        float dot = QVector3D::dotProduct(a, b);
        res = qFskCompare((qreal)dot, a.length() * b.length());
    }
    return res;
}
开发者ID:slavablind91,项目名称:code,代码行数:10,代码来源:qglsection.cpp

示例2: qCalculateNormal

static bool qCalculateNormal(int i, int j, int k, QGeometryData &p, QVector3D *vec = 0)
{
    QVector3D norm;
    QVector3D *n = &norm;
    if (vec)
        n = vec;
    bool nullTriangle = false;
    *n = QVector3D::crossProduct(p.vertexAt(j) - p.vertexAt(i),
                                   p.vertexAt(k) - p.vertexAt(j));
    if (qFskIsNull(n->x()))
        n->setX(0.0f);
    if (qFskIsNull(n->y()))
        n->setY(0.0f);
    if (qFskIsNull(n->z()))
        n->setZ(0.0f);
    if (n->isNull())
    {
        nullTriangle = true;
    }
    else
    {
        setNormals(i, j, k, p, *n);
    }
    return nullTriangle;
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:25,代码来源:qglbuilder.cpp

示例3: distanceToPlane

/*!
    Returns the distance that this vertex is from a line defined
    by \a point and the unit vector \a direction.

    If \a direction is a null vector, then it does not define a line.
    In that case, the distance from \a point to this vertex is returned.

    \sa distanceToPlane()
*/
qreal QVector3D::distanceToLine
(const QVector3D& point, const QVector3D& direction) const
{
    if (direction.isNull())
        return (*this - point).length();
    QVector3D p = point + dotProduct(*this - point, direction) * direction;
    return (*this - p).length();
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:17,代码来源:qvector3d.cpp

示例4: addTri

void QMesh::addTri(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &an, const QVector3D &bn, const QVector3D &cn)
{
    QVector3D anorm = an.isNull() ? QVector3D::normal(a, b, c) : an;
    QVector3D bnorm = bn.isNull() ? QVector3D::normal(a, b, c) : bn;
    QVector3D cnorm = cn.isNull() ? QVector3D::normal(a, b, c) : cn;

    if (sm == Smooth) {
        geom->appendSmooth(a, anorm, initv);
        geom->appendSmooth(b, bnorm, initv);
        geom->appendSmooth(c, cnorm, initv);
    } else {
        geom->appendFaceted(a, anorm);
        geom->appendFaceted(b, bnorm);
        geom->appendFaceted(c, cnorm);
    }

    count += 3;
}
开发者ID:LaurensVergote,项目名称:Robotic-Hand,代码行数:18,代码来源:qmesh.cpp

示例5:

/*!
    \internal
*/
void QGraphicsRotation3D::applyTo(QMatrix4x4 *matrix) const
{
    qreal angle = this->angle();
    QVector3D axis = this->axis();
    QVector3D origin = this->origin();

    if (angle == 0. || axis.isNull())
        return;

    matrix->translate(origin);
    matrix->rotate(angle, axis.x(), axis.y(), axis.z());
    matrix->translate(-origin);
}
开发者ID:slavablind91,项目名称:code,代码行数:16,代码来源:qgraphicsrotation3d.cpp

示例6: addQuadRandom

void tst_QGLBuilder::addQuadRandom()
{
    QFETCH(int, size);
    QFETCH(int, type);

    int n = qSqrt(size);
    size = n * n;
    QVector3DArray data;
    data.reserve(size);
    for (int i = 0; i < size; ++i)
    {
        // make sure (in face of randomness) we get a planar quad
        QVector3D origin = randVector();
        QVector3D a;
        while (a.isNull())
            a = randVector();
        QVector3D b;
        while (b.isNull())
            b = randVector();
        data.append(origin, a, a+b, b);
    }
    addQuadBenchMarks(data, type);
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:23,代码来源:tst_qglbuilder_perf.cpp

示例7: pointInDirection

void GLGameModel::pointInDirection(QVector3D d)
{
    if(d.isNull())
    {
        setAngleY(0.0);
        return;
    }

    // roate the object to point in direction
    // we only rotate in the x-z plane
    float cos_y = d.normalized().z();
    setAngleY(360.0 * qAcos(cos_y) / (2*M_PI));

    //qDebug() << "pointing to" << d << "with angles" << angleX << angleY << angleZ;
}
开发者ID:rku,项目名称:Settleboard,代码行数:15,代码来源:GLGameModel.cpp

示例8: addTri

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;
}
开发者ID:emeralddusk,项目名称:umlgfxproj,代码行数:15,代码来源:qtlogo.cpp

示例9: addTriangulatedFace

/*!
    Adds to this section a polygonal face made of triangular sub-faces,
    defined by \a face.  The 0'th vertex is used for the center, while
    the subsequent vertices form the perimeter of the face, which must
    at minimum be a triangle.

    If \a face has less than four vertices this function exits without
    doing anything.

    This function provides functionality similar to the OpenGL mode GL_POLYGON,
    except it divides the face into sub-faces around a \b{central point}.
    The center and perimeter vertices must lie in the same plane (unlike
    triangle fan).  If they do not normals will be incorrectly calculated.

    \image triangulated-face.png

    Here the sub-faces are shown divided by green lines.  Note how this
    function handles some re-entrant (non-convex) polygons, whereas
    addTriangleFan will not support such polygons.

    If required, the center point can be calculated using the center() function
    of QGeometryData:

    \code
    QGeometryData face;
    face.appendVertex(perimeter.center()); // perimeter is a QGeometryData
    face.appendVertices(perimeter);
    builder.addTriangulatedFace(face);
    \endcode

    N sub-faces are generated where \c{N == face.count() - 2}.

    Each triangular sub-face consists of the center; followed by the \c{i'th}
    and \c{((i + 1) % N)'th} vertex.  The last face generated then is
    \c{(center, face[N - 1], face[0]}, the closing face.  Note that the closing
    face is automatically created, unlike addTriangleFan().

    If no normals are supplied in the vertices of \a face, normals are
    calculated as per addTriangle().  One normal is calculated, since a
    face's vertices lie in the same plane.

    Degenerate triangles are skipped in the same way as addTriangles().

    \sa addTriangleFan(), addTriangles()
*/
void QGLBuilder::addTriangulatedFace(const QGeometryData &face)
{
    if (face.count() < 4)
        return;
    QGeometryData f;
    f.appendGeometry(face);
    int cnt = f.count();
    bool calcNormal = !f.hasField(QGL::Normal);
    if (calcNormal)
    {
        QVector3DArray nm(cnt);
        f.appendNormalArray(nm);
    }
    bool skip = false;
    QVector3D norm;
    int k = 0;
    for (int i = 1; i < cnt; ++i)
    {
        int n = i + 1;
        if (n == cnt)
            n = 1;
        if (calcNormal)
        {
            skip = qCalculateNormal(0, i, n, f);
            if (norm.isNull() && !skip)
            {
                norm = f.normalAt(0);
                for (int i = 0; i < cnt; ++i)
                    f.normal(i) = norm;
            }
        }
        if (!skip)
            dptr->addTriangle(0, i, n, f, k);
    }
    dptr->currentNode->setCount(dptr->currentNode->count() + k);
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:81,代码来源:qglbuilder.cpp

示例10:

void Plane3D::setNormal(const QVector3D &normal)
{
    m_vecNormal = normal.isNull() ? normal : normal.normalized();
}
开发者ID:x6herbius,项目名称:calliper,代码行数:4,代码来源:plane3d.cpp


注:本文中的QVector3D::isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。