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


C++ QVector4D::z方法代码示例

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


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

示例1: fuzzyCompare

static bool fuzzyCompare(const QVector4D &v1, const QVector4D &v2)
{
    return qAbs(v1.x() - v2.x()) <= 0.00001 &&
           qAbs(v1.y() - v2.y()) <= 0.00001 &&
           qAbs(v1.z() - v2.z()) <= 0.00001 &&
           qAbs(v1.w() - v2.w()) <= 0.00001;
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:7,代码来源:tst_qvectorarray.cpp

示例2: screenToWorld

QVector3D Camera::screenToWorld(QVector3D vec, QMatrix4x4 modelview, QMatrix4x4 projection)
{
    int viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    float winX = vec.x();
    float winY = vec.y();
    winY = viewport[3] - winY;
    float winZ;
    glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);

    QVector4D v((winX-(float)viewport[0])/(float)viewport[2]*2.0-1.0,
                   (winY-(float)viewport[1])/(float)viewport[3]*2.0-1.0,
                   0, 1);


    QVector4D v2((winX-(float)viewport[0])/(float)viewport[2]*2.0-1.0,
                   (winY-(float)viewport[1])/(float)viewport[3]*2.0-1.0,
                   1, 1);

    QMatrix4x4 mat(modelview * projection);

    QVector4D t = v * mat.inverted();
    float w = 1 / t.w();
    QVector3D pt1(t.x() * w, t.y() * w, t.z() * w);

    t = v2 * mat.inverted();
    w = 1 / t.w();
    QVector3D pt2(t.x() * w, t.y() * w, t.z() * w);

    QVector3D out;
    intersects(QVector3D(1, 0, vec.z()), QVector3D(0, 1, vec.z()), QVector3D(1, 1, vec.z()),
               pt1, pt2, out);
    return out;
}
开发者ID:znoraka,项目名称:SexyDwarfEngine,代码行数:34,代码来源:camera.cpp

示例3:

 PolarVec::PolarVec(const QVector4D& _vec)
 {
   if (_vec.w() != 0.0)
     operator=(QVector3D(_vec.x()/_vec.w(),_vec.y()/_vec.w(),_vec.z()/_vec.w()));
   else
     operator=(QVector3D(_vec.x(),_vec.y(),_vec.z()));
 }
开发者ID:avilleret,项目名称:omnidome,代码行数:7,代码来源:PolarVec.cpp

示例4: ipEsferica

QVector4D iPolacion::ipEsferica(QVector4D q1, QVector4D q2, float lam){
    // Caso facil primero.
        if (lam <= 0.0f)
            return q1;
        else if (lam >= 1.0f)
            return q2;

        // Determinamos el angulo
        QVector4D q2b;
        float dot;
        dot = q1.x() * q2.x() + q1.y() * q2.y() + q1.z() * q2.z() + q1.w() * q2.w();
        if (dot >= 0.0f) {
            q2b = q2;
        } else {
            q2b = -q2;
            dot = -dot;
        }

        // Obtenemos los factores de interpolacion
        float factor1 = 1.0f - lam;
        float factor2 = lam;
        if ((1.0f - dot) > 0.0000001) {
            float angle = float(acos(dot));
            float sinOfAngle = float(sin(angle));
            if (sinOfAngle > 0.0000001) {
                factor1 = float(sin((1.0f - lam) * angle)) / sinOfAngle;
                factor2 = float(sin(lam * angle)) / sinOfAngle;

            }
        }

        // Construimos el nuevo quaternion
        return q1 * factor1 + q2b * factor2;
}
开发者ID:JavierPin,项目名称:Animacion3D,代码行数:34,代码来源:ipolacion.cpp

示例5: if

QVector<float> UniformItem::getGlData() const
{
    QVector<float> glData;
    if (type == UniformType::SPHERICAL_3D) {
        QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], 0.0);
        glData.push_back(cartesian.x());
        glData.push_back(cartesian.y());
        glData.push_back(cartesian.z());
    } else if (type == UniformType::SPHERICAL_4D) {
        QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], data[3]);
        glData.push_back(cartesian.x());
        glData.push_back(cartesian.y());
        glData.push_back(cartesian.z());
        glData.push_back(cartesian.w());
    } else if (type == UniformType::COLOR) {
        glData.push_back(data[0] / 255.0f);
        glData.push_back(data[1] / 255.0f);
        glData.push_back(data[2] / 255.0f);
    } else if (type == UniformType::COLOR_ALPHA) {
        glData.push_back(data[0] / 255.0f);
        glData.push_back(data[1] / 255.0f);
        glData.push_back(data[2] / 255.0f);
        glData.push_back(data[3] / 255.0f);
    } else {
        glData = data;
    }
    return glData;
}
开发者ID:eseidinger,项目名称:glsl-editor,代码行数:28,代码来源:uniformitem.cpp

示例6: Property

PropertyGroup::PropertyGroup(QVector4D min, QVector4D max, QVector4D t, QString name)
{
	createBox(name);

	properties.emplace_back(new Property(min.x(), max.x(), t.x(), box));
	properties.emplace_back(new Property(min.y(), max.y(), t.y(), box));
	properties.emplace_back(new Property(min.z(), max.z(), t.z(), box));
	properties.emplace_back(new Property(min.w(), max.w(), t.w(), box));

	config();
}
开发者ID:otah007,项目名称:fractal-z,代码行数:11,代码来源:propertygroup.cpp

示例7:

static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
{
    if (a.x() != b.x())
        return a.x() > b.x() ? 1 : -1;
    if (a.y() != b.y())
        return a.y() > b.y() ? 1 : -1;
    if (a.z() != b.z())
        return a.z() > b.z() ? 1 : -1;
    if (a.w() != b.w())
        return a.w() > b.w() ? 1 : -1;
    return 0;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:qsgdefaultglyphnode_p.cpp

示例8: convertMouseCoordToWorld

ShipCAD::PickRay ViewportView::convertMouseCoordToWorld(QPoint pos, int w, int h) const
{
    float x = (2.0f * pos.x()) / w - 1.0f;
    float y = 1.0f - (2.0f * pos.y()) / h;

    QVector4D from = _worldInv * QVector4D(x, y, -1.0, 1.0);
    QVector4D to = _worldInv * QVector4D(x, y, 1.0, 1.0);

    from /= from.w();
    to /= to.w();

    PickRay ray;
    ray.pt = from.toVector3D();
    ray.dir = to.toVector3D() - from.toVector3D();
    ray.dir.normalize();

#if 0
    cout << "from:" << from.x() << "," << from.y() << "," << from.z() << endl;
    cout << "to:" << to.x() << "," << to.y() << "," << to.z() << endl;

    // find the intersection with the xz plane if possible
    Plane xz(0,1,0,0);
    bool coplanar;
    QVector3D intpt;
    if (!xz.intersectLine(ray.pt, ray.dir, coplanar, intpt))
        cout << "xz intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
    else
        cout << "parallel to xz" << endl;
    if (coplanar)
        cout << "coplanar" << endl;
    // find the intersection with the yz plane if possible
    Plane yz(1,0,0,0);
    if (!yz.intersectLine(ray.pt, ray.dir, coplanar, intpt))
        cout << "yz intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
    else
        cout << "parallel to yz" << endl;
    if (coplanar)
        cout << "coplanar" << endl;
    // find the intersection with the xy plane if possible
    Plane xy(0,0,1,0);
    if (!xy.intersectLine(ray.pt, ray.dir, coplanar, intpt))
        cout << "xy intersect:" << intpt.x() << "," << intpt.y() << "," << intpt.z() << endl;
    else
        cout << "parallel to xy" << endl;
    if (coplanar)
        cout << "coplanar" << endl;
#endif

    return ray;
}
开发者ID:OpenScadHullModelling,项目名称:ShipCAD,代码行数:50,代码来源:viewportview.cpp

示例9: mouseMoveEvent

void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
	if ((event->buttons() & Qt::RightButton) && dragging) {
		double xtrans = (event->pos().x() - lastPoint.x()) / 1000.0;
		double ytrans = -(event->pos().y() - lastPoint.y()) / 1000.0; //Qt y-coord is inverted
		QVector4D trans(xtrans, ytrans, 0, 1);
		QVector4D worldTrans = trans * camera->getCameraMatrix();
		if(cameraActive) {
            this->camera->setpointOfInterest(scene->getMainBoat()->getPosition());
			this->camera->translate(-worldTrans.x(), -worldTrans.y(), -worldTrans.z());

			updateGL();
		} else {
			emit translate(worldTrans.x(), worldTrans.y(), worldTrans.z());
		}
	}

//	if ((event->buttons() & Qt::LeftButton) && dragging) {
		//Here we implement the trackball. Sample two points on the sphere and
		//calculate their angle to use as the rotation.

		//normalize to intervals [-1,1]
		double lastx = clampUnit(lastPoint.x() / (this->size().width() / 2.0) - 1.0);
		double lasty = clampUnit(-(lastPoint.y() / (this->size().height() / 2.0) - 1.0));

		double newx = clampUnit(event->pos().x() / (this->size().width() / 2.0) - 1.0);
		double newy = clampUnit(-(event->pos().y() / (this->size().height() / 2.0) - 1.0));

		//Project the two points into the sphere (or the hyperbolic plane)
		QVector3D v1(lastx, lasty, z(lastx, lasty));
		v1.normalize();
		QVector3D v2(newx, newy, z(newx, newy));
		v2.normalize();

		//Determine the normal of the generated plane through the center of the sphere
		QVector3D normal = QVector3D::crossProduct(v1, v2);
		double theta = acos(QVector3D::dotProduct(v1, v2)) / 3.0;

		//angle/2.0, because the quats double cover SO(3)
		QQuaternion newRot = QQuaternion(cos(theta/2.0), sin(theta/2.0) * normal.normalized());
		QQuaternion cameraQuat = M4toQuat(camera->getCameraMatrix());
		QQuaternion worldQuat = cameraQuat.conjugate() * newRot * cameraQuat;
		if(cameraActive) {
			this->camera->rotate(newRot);
			updateGL();
		} else {
			emit rotate(&worldQuat);
		}
//	}
}
开发者ID:TheSlothExperience,项目名称:SheepBattleBoats,代码行数:50,代码来源:glwidget.cpp

示例10: intersectCap

bool Cylinder::intersectCap(const Ray &localRay, double &t)
{
    if (localRay.direction().y() < 0.0)
        t = (0.5 * m_length - localRay.origin().y()) / localRay.direction().y();
    else if (localRay.direction().y() > 0.0)
        t = (-0.5 * m_length - localRay.origin().y()) / localRay.direction().y();
    else
        return false;

    QVector4D p = localRay.along(t);
    if (p.x() * p.x() + p.z() * p.z() < m_rSq)
        return true;

    return false;
}
开发者ID:elpuri,项目名称:reijo,代码行数:15,代码来源:cylinder.cpp

示例11: vectorX

colour4::colour4( QVector4D in ) : vectorX( 4 )
{
    r() = in.x();
    g() = in.y();
    b() = in.z();
    a() = in.w();
}
开发者ID:davidmueller13,项目名称:vexx,代码行数:7,代码来源:math.colour4.cpp

示例12: setLight

static void setLight(int light, const Light *parameters,
                     const QMatrix4x4& transform = QMatrix4x4())
{
    GLfloat params[4];

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    QColor color = parameters->ambientColor();
    params[0] = color.redF();
    params[1] = color.greenF();
    params[2] = color.blueF();
    params[3] = color.alphaF();
    glLightfv(light, GL_AMBIENT, params);

    color = parameters->diffuseColor();
    params[0] = color.redF();
    params[1] = color.greenF();
    params[2] = color.blueF();
    params[3] = color.alphaF();
    glLightfv(light, GL_DIFFUSE, params);

    color = parameters->specularColor();
    params[0] = color.redF();
    params[1] = color.greenF();
    params[2] = color.blueF();
    params[3] = color.alphaF();
    glLightfv(light, GL_SPECULAR, params);

    QVector4D vector = parameters->eyePosition(transform);
    params[0] = vector.x();
    params[1] = vector.y();
    params[2] = vector.z();
    params[3] = vector.w();
    glLightfv(light, GL_POSITION, params);

    QVector3D spotDirection = parameters->eyeSpotDirection(transform);
    params[0] = spotDirection.x();
    params[1] = spotDirection.y();
    params[2] = spotDirection.z();
    glLightfv(light, GL_SPOT_DIRECTION, params);

    params[0] = parameters->spotExponent();
    glLightfv(light, GL_SPOT_EXPONENT, params);

    params[0] = parameters->spotAngle();
    glLightfv(light, GL_SPOT_CUTOFF, params);

    params[0] = parameters->constantAttenuation();
    glLightfv(light, GL_CONSTANT_ATTENUATION, params);

    params[0] = parameters->linearAttenuation();
    glLightfv(light, GL_LINEAR_ATTENUATION, params);

    params[0] = parameters->quadraticAttenuation();
    glLightfv(light, GL_QUADRATIC_ATTENUATION, params);

    glPopMatrix();
}
开发者ID:kaltsi,项目名称:qt-mobility,代码行数:60,代码来源:painter_fixed.cpp

示例13:

QDebug operator<<(QDebug dbg, const QVector4D &vector)
{
    dbg.nospace() << "QVector4D("
        << vector.x() << ", " << vector.y() << ", "
        << vector.z() << ", " << vector.w() << ')';
    return dbg.space();
}
开发者ID:husninazer,项目名称:qt,代码行数:7,代码来源:qvector4d.cpp

示例14:

int
ClipPlanes::inViewport(int x, int y, int ow, int oh)
{
  float ar = (float)ow/(float)oh;
  float y1 = oh-y;
  for(int i=0; i<m_clips.count(); i++)
    {
      QVector4D vp = m_clips[i]->viewport();
      if (m_clips[i]->tfset() >= 0 &&
	  m_clips[i]->tfset() < Global::lutSize() &&
	  vp.x() >= 0.0)
	{
	  int vx, vy, vh, vw;
	  vx = vp.x()*ow;
	  vy = vp.y()*oh;
	  vw = vp.z()*ow;
	  vh = vp.w()*oh;
	  
	  if (x >= vx && x <= vx+vw &&
	      y1 >= vy && y1 <= vy+vh)
	    return i;
	}
    }
  return -1;
}
开发者ID:mdoube,项目名称:drishti,代码行数:25,代码来源:clipplane.cpp

示例15: convert

void ClippingConverter::convert(const QByteArray &clippingData, const QString &directory)
{
    QDataStream stream(clippingData);
    stream.setFloatingPointPrecision(QDataStream::SinglePrecision);
    stream.setByteOrder(QDataStream::LittleEndian);

    QString newDirectory = directory;

    newDirectory.replace('\\', '/');
    if (!newDirectory.endsWith('/'))
        newDirectory.append('/');

    int objectCount, instanceCount;
    stream >> objectCount >> instanceCount;

    for (int i = 0; i < objectCount; ++i) {
        MeshPtr mesh = importObject(stream);

        // Serialize to a temporary file, then read it in again
        QTemporaryFile tempFile;
        if (!tempFile.open()) {
            qWarning("Unable to open the temporary %s file.", qPrintable(tempFile.fileName()));
            continue;
        }

        d->ogre->meshSerializer->exportMesh(mesh.getPointer(), tempFile.fileName().toStdString());

        QByteArray meshData = tempFile.readAll();
        QString meshFilename = QString("%1clipping/mesh-%2.mesh").arg(newDirectory).arg(i+1);

        d->output->writeFile(meshFilename, meshData);
    }

    QByteArray instances;

    instances.append("[");

    for (int i = 0; i < instanceCount; ++i) {
        QVector4D position;
        int index;

        stream >> position >> index;

        QString line = QString("{\"position\":[%1,%2,%3],\"file\":\"%5mesh-%4.mesh\"}")
                .arg(position.x())
                .arg(position.y())
                .arg(position.z())
                .arg(index+1)
                .arg(newDirectory);
        if (i > 0)
            instances.append(",");
        instances.append(line.toAscii());

    }

    instances.append("]");

    d->output->writeFile(newDirectory + "clipping.json", instances);

}
开发者ID:GrognardsFromHell,项目名称:EvilTemple-Native,代码行数:60,代码来源:clippingconverter.cpp


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