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


C++ QVector3D类代码示例

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


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

示例1: setUp

 void Camera::setUp(QVector3D const& _up)
 {
   up_ = _up.normalized();
 }
开发者ID:avilleret,项目名称:omnidome,代码行数:4,代码来源:Camera.cpp

示例2: QTAIMLocateNuclearCriticalPoint

  QList<QVariant> QTAIMLocateNuclearCriticalPoint( QList<QVariant> input  )
  {
    const QString fileName=input.at(0).toString();
    const qint64 nucleus=input.at(1).toInt();
    const QVector3D x0y0z0(
        input.at(2).toReal(),
        input.at(3).toReal(),
        input.at(4).toReal()
        );

    QTAIMWavefunction wfn;
    wfn.loadFromBinaryFile(fileName);

    QTAIMWavefunctionEvaluator eval(wfn);

    QVector3D result;

    if( wfn.nuclearCharge(nucleus) < 4 )
    {
      //      QTAIMODEIntegrator ode(eval,QTAIMODEIntegrator::CMBPMinusThreeGradientInElectronDensity);
      QTAIMLSODAIntegrator ode(eval,QTAIMLSODAIntegrator::CMBPMinusThreeGradientInElectronDensity);
      result=ode.integrate(x0y0z0);
    }
    else
    {
      result=x0y0z0;
    }

    bool correctSignature;
    Matrix<qreal,3,1> xyz; xyz << result.x(), result.y(), result.z();

    if(
        QTAIMMathUtilities::signatureOfASymmetricThreeByThreeMatrix(
            eval.hessianOfElectronDensity(xyz)
            ) == -3
        )
    {
      correctSignature=true;
    }
    else
    {
      correctSignature=false;
    }

    QList<QVariant> value;

    if( correctSignature )
    {
      value.append(correctSignature);
      value.append(result.x());
      value.append(result.y());
      value.append(result.z());
    }
    else
    {
      value.append(false);
    }

    return value;

  }
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:61,代码来源:qtaimcriticalpointlocator.cpp

示例3: Q_UNUSED

void RotateYHandle::drag(QVector3D center, QVector3D delta)
{
    Q_UNUSED(delta);
    QVector3D d = center - position();
    setValue("a", atan2(d.z(), d.x()) * 180 / M_PI);
}
开发者ID:denji,项目名称:antimony,代码行数:6,代码来源:rotatey_control.cpp

示例4: QTAIMLocateBondCriticalPoint

  QList<QVariant> QTAIMLocateBondCriticalPoint( QList<QVariant> input  )
  {

    QList<QVariant> value;
    value.clear();

    const QString wfnFileName=input.at(0).toString();
    const QString nuclearCriticalPointsFileName=input.at(1).toString();
    const qint64 nucleusA=input.at(2).toInt();
    const qint64 nucleusB=input.at(3).toInt();
    const QVector3D x0y0z0(
        input.at(4).toReal(),
        input.at(5).toReal(),
        input.at(6).toReal()
        );

    QTAIMWavefunction wfn;
    wfn.loadFromBinaryFile(wfnFileName);

    QList<QVector3D> nuclearCriticalPoints;
    QFile nuclearCriticalPointsFile(nuclearCriticalPointsFileName);
    nuclearCriticalPointsFile.open(QIODevice::ReadOnly);
    QDataStream nuclearCriticalPointsFileIn(&nuclearCriticalPointsFile);
    nuclearCriticalPointsFileIn >> nuclearCriticalPoints ;
    nuclearCriticalPointsFile.close();

    QList<QPair<QVector3D,qreal> > betaSpheres;
    for( qint64 i=0 ; i < nuclearCriticalPoints.length() ; ++i )
    {
      QPair<QVector3D,qreal> thisBetaSphere;
      thisBetaSphere.first=nuclearCriticalPoints.at(i);
      thisBetaSphere.second=0.1;
      betaSpheres.append(thisBetaSphere);
    }

    QTAIMWavefunctionEvaluator eval(wfn);

    QList<QVector3D> ncpList;

    QVector3D result;
    //    QTAIMODEIntegrator ode(eval,QTAIMODEIntegrator::CMBPMinusOneGradientInElectronDensity);
    QTAIMLSODAIntegrator ode(eval,QTAIMLSODAIntegrator::CMBPMinusOneGradientInElectronDensity);
    result=ode.integrate(x0y0z0);
    Matrix<qreal,3,1> xyz; xyz << result.x(), result.y(), result.z();

    if(
        !( QTAIMMathUtilities::signatureOfASymmetricThreeByThreeMatrix(
            eval.hessianOfElectronDensity(xyz)
            ) == -1 )
        || (eval.gradientOfElectronDensity(xyz)).norm() > SMALL_GRADIENT_NORM
        )
    {
      value.append(false);
      value.append(result.x());
      value.append(result.y());
      value.append(result.z());
      return value;
    }

    Matrix<qreal,3,3> eigenvectorsOfHessian;
    eigenvectorsOfHessian=QTAIMMathUtilities::eigenvectorsOfASymmetricThreeByThreeMatrix(
        eval.hessianOfElectronDensity(xyz)
        );
    Matrix<qreal,3,1> highestEigenvectorOfHessian;
    highestEigenvectorOfHessian <<
        eigenvectorsOfHessian(0,2),
        eigenvectorsOfHessian(1,2),
        eigenvectorsOfHessian(2,2);

    const qreal smallStep=0.01;

    QVector3D forwardStartingPoint( result.x() + smallStep*highestEigenvectorOfHessian(0),
                                    result.y() + smallStep*highestEigenvectorOfHessian(1),
                                    result.z() + smallStep*highestEigenvectorOfHessian(2) );

    QVector3D backwardStartingPoint( result.x() - smallStep*highestEigenvectorOfHessian(0),
                                     result.y() - smallStep*highestEigenvectorOfHessian(1),
                                     result.z() - smallStep*highestEigenvectorOfHessian(2) );

    //    QTAIMODEIntegrator forwardODE(eval,QTAIMODEIntegrator::SteepestAscentPathInElectronDensity);
    QTAIMLSODAIntegrator forwardODE(eval,QTAIMLSODAIntegrator::SteepestAscentPathInElectronDensity);
    forwardODE.setBetaSpheres( betaSpheres );
    QVector3D forwardEndpoint=forwardODE.integrate(forwardStartingPoint);
    QList<QVector3D> forwardPath=forwardODE.path();

    //    QTAIMODEIntegrator backwardODE(eval,QTAIMODEIntegrator::SteepestAscentPathInElectronDensity);
    QTAIMLSODAIntegrator backwardODE(eval,QTAIMLSODAIntegrator::SteepestAscentPathInElectronDensity);
    backwardODE.setBetaSpheres( betaSpheres );
    QVector3D backwardEndpoint=backwardODE.integrate(backwardStartingPoint);
    QList<QVector3D> backwardPath=backwardODE.path();

    qreal smallestDistance=HUGE_REAL_NUMBER;
    qint64 smallestDistanceIndex=0;

    for( qint64 n=0 ; n < wfn.numberOfNuclei()  ; ++n )
    {
      Matrix<qreal,3,1> a(forwardEndpoint.x(),forwardEndpoint.y(),forwardEndpoint.z());
      Matrix<qreal,3,1> b(wfn.xNuclearCoordinate(n), wfn.yNuclearCoordinate(n), wfn.zNuclearCoordinate(n));

      qreal distance=QTAIMMathUtilities::distance(a,b);
//.........这里部分代码省略.........
开发者ID:AlbertDeFusco,项目名称:avogadro,代码行数:101,代码来源:qtaimcriticalpointlocator.cpp

示例5:

void GdvCanvas2D::clearBuffer(const QVector3D &clearColor)
{
    buffer2D.fill(QColor(clearColor.x()*255,
                         clearColor.y()*255,
                         clearColor.z()*255));
}
开发者ID:jobusch,项目名称:gdv-labor,代码行数:6,代码来源:gdvcanvas2d.cpp

示例6:

void Node::setPos3D(const QVector3D &vector)
{
	setPos(vector.toPoint());
	setZValue(vector.z());
}
开发者ID:Etrnls,项目名称:etrnlabs,代码行数:5,代码来源:node.cpp

示例7: switch

void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
    const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
    const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));

    //Set data manually here so we can use our own item roles.
    switch(pAbstractItem->type()) {
        case MetaTreeItemTypes::SurfaceColorGyri: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceColorSulci: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::ColormapType: {
            QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorMapType->currentText());

            model->setData(index, data, MetaTreeItemRoles::ColormapType);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::DataThreshold: {
            if(Spline* pSpline = dynamic_cast<Spline*>(editor)) {
                QVector3D returnVector;
                returnVector = pSpline->getThreshold();

                QString displayThreshold;
                displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
                QVariant data;
                data.setValue(displayThreshold);
                model->setData(index, data, Qt::DisplayRole);
                data.setValue(returnVector);
                model->setData(index, data, MetaTreeItemRoles::DataThreshold);
            }
            break;
        }

        case MetaTreeItemTypes::StreamingTimeInterval: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::StreamingTimeInterval);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::VisualizationType: {
            QComboBox* pVisType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pVisType->currentText());

            model->setData(index, data, MetaTreeItemRoles::VisualizationType);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::Color: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::Color);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::NumberAverages: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::NumberAverages);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::AlphaValue: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
//.........这里部分代码省略.........
开发者ID:chdinh,项目名称:mne-cpp,代码行数:101,代码来源:data3Dtreedelegate.cpp

示例8: isInRange

bool Tools::isInRange(QVector3D x, QVector3D y, float dist)
{
    if (x.distanceToPoint(y) < dist)  return true ;
}
开发者ID:guilhemheinrich,项目名称:MultiAgentSystem,代码行数:4,代码来源:tools.cpp

示例9: while

/*
 *
 * **************************************************/
void CubeObj::takeTexture() {
    // Calculate Matrix using the parent matrixes too
    std::stack<QMatrix4x4> mats;
    QMatrix4x4 cmat;

    // Store previous matrixes in stack
    CubeObj *po = this;
    bool notroot = true;
    while ( notroot ) {
        if ( po != pro.objectRoot ) {
            mats.push( po->getMatrix() );
           // qDebug() << po->m_itemData;
            po = (CubeObj * ) po->parentItem();
        } else {
            mats.push( po->getMatrix() );
            //qDebug() << po->m_itemData;
            notroot = false;
        }
    }

    // camera mat * parent mat * parent mat ..... * parent mat * this mat * this scale
//    cmat = pro.getManger().fixCamera->getMatrix();          // TODO
    for ( int i=0 , e = mats.size(); i < e ; i ++ ) {
        cmat *= mats.top();
        mats.pop();
       // qDebug() << "mat";
    }
    cmat.scale(scale);

    // Project points to screen
    QVector3D vect;
    qDebug() << "verticies " << vertices.size();
    qDebug() << "TexCoords " << texCoords.size();

    QVector<QVector2D> projectedPoints;
    for ( int i = 0; i < vertices.size(); i++) {    // verticies.size
        vect =  cmat * vertices[i];
        projectedPoints.append(  QVector2D ( ( vect.x()   + 1 ) / 2   , ( 1 - vect.y() )  / 2 ) );
    }

    // The output texture image coordinate and size
    int w,h;
    w = textureMat->cols;
    h = textureMat->rows;

    cv::Point2f ocoords[ 4 ];
    ocoords[0] = cv::Point2f (0, 0);
    ocoords[1] = cv::Point2f (0, h);
    ocoords[2] = cv::Point2f (w, h);
    ocoords[3] = cv::Point2f (w, 0);

    cv::Point2f textpoints[24];      // TODO
 //   UvtoCvCoordinate( *pro.actualBackground, projectedPoints, textpoints ); TODO
/*
    // for test
    for ( int i = 0; i < 24 ; i++) {
        //qDebug() << textpoints[i].x << " : " << textpoints[i].y;
        cv::circle( pro.actualBackground, textpoints[i],3, cv::Scalar(1,255,1), 2 );
        pro.reLoadback();
    }
    // -------------------*/

    GLWidget & gl = pro.getManger().getMainGLW();
    for ( int i =0; i < 6; i++) {
        cv::Mat ptransform = getPerspectiveTransform ( &textpoints[i*4], ocoords);
//        cv::warpPerspective( *pro.actualBackground, *textureMat, ptransform,  textureMat->size() );
        if ( textureIDs[i] == 0 ) {
            gl.glGenBuffers( 1, &textureIDs[i]);
            qDebug() << "TextureId:" << textureIDs[i];
        }
        gl.glBindTexture ( GL_TEXTURE_2D , textureIDs[i]);
        gl.glTexImage2D(  GL_TEXTURE_2D, 0, GL_RGB, textureMat->cols, textureMat->rows, 0, GL_RGB,
                          GL_UNSIGNED_BYTE, ( GLvoid * ) textureMat->data );
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    }



  /*  texCoords[0] =  QVector2D ( 0,0);                      // Set Texture coordinate
    texCoords[1] =  QVector2D ( 0,1);
    texCoords[2] =  QVector2D ( 1,1);
    texCoords[3] =  QVector2D ( 1,0);*/
 /*  textPixmap   =  QPixmap::fromImage( this->cvMatToQImage( *textureMat) );*/


}
开发者ID:Nand-e,项目名称:2to3d,代码行数:92,代码来源:cubeObj.cpp

示例10: GenerateSegments

int Slice::GenerateSegments(B9ModelInstance* inputInstance)
{
    unsigned int t;
	int v1;
	int v2;
	int cmpcount = 0;//0 or 1 for knowing what point your trying to find.;

	QVector3D* thisvert = NULL;//local pointer to make quick access to vertices
	QVector3D* thatvert = NULL;

    std::vector<Triangle3D*>* rangedTriangles;

	double xdisp;
	double ydisp;
	double zdisp;
	double planefraction;

	int intersections = 0;


	//Triangle Splitting here:
    //Get the right container of triangles and use that as the list
    //(we used to use the triList which was O(n^2))
    rangedTriangles = inputInstance->GetTrianglesAroundZ(realAltitude);


    for(t = 0; t < rangedTriangles->size(); t++)//for each triangle in the model
	{
		//we want to create a temporary pointer to the currenct triangle
        Triangle3D* pTransTri = rangedTriangles->at(t);

		//test if the triangle intersects the XY plane of this slice!
		if(!pTransTri->IntersectsXYPlane(realAltitude))
		{
            continue;
		}
			
		intersections++;
		cmpcount = 0;
		
		//create 1 new segment object for the end result 
		Segment* seg1 = new Segment;
		QVector2D points[2];
		for(v1=0;v1<3;v1++)//for 1 or 2 triangle verts ABOVE the plane:
		{
			thisvert = &pTransTri->vertex[v1];
			if(thisvert->z() <= realAltitude)//we only want to compare FROM above the plane by convention (yes this means flush triangles below the plane)
			{
				continue;
			}
			for(v2=0; v2<3; v2++)//to every other triangle vert
			{
				if(v2 == v1)
				{continue;}

				thatvert = &pTransTri->vertex[v2];

				//are both points on the same side of plane?
				//if so we dont want to compare
				if((thatvert->z() > realAltitude))
				{
					continue;
				}
					
				cmpcount++;
				//common
				//displacments (final - initial)
				xdisp = thatvert->x() - thisvert->x();
				ydisp = thatvert->y() - thisvert->y();
				zdisp = thatvert->z() - thisvert->z();

                planefraction = (thisvert->z() - realAltitude)/fabs(zdisp);//0-1 fraction of where the plane is in relation to the z distance between the 2 verts.
				//(0 would be the plane is at the hieght of thisvert)

				points[cmpcount-1].setX(thisvert->x() + xdisp*planefraction);
				points[cmpcount-1].setY(thisvert->y() + ydisp*planefraction);
			}
		}
	
		//initiallize the segment.
		seg1->normal.setX(pTransTri->normal.x());
		seg1->normal.setY(pTransTri->normal.y());

		seg1->p1.setX(points[0].x());
		seg1->p1.setY(points[0].y());

		seg1->p2.setX(points[1].x());
		seg1->p2.setY(points[1].y());

		seg1->normal.normalize();

		seg1->CorrectPointOrder();//to match the normal convention!
			
		AddSegment(seg1);
	}
	return segmentList.size();
}
开发者ID:trackpack,项目名称:Software,代码行数:97,代码来源:Slice.cpp

示例11: move

QVector3D EnvRoomTemplate::ClipPlayerTrajectory(const QVector3D & pos, const QVector3D & vel) const
{

    QVector3D new_vel;

    bool x_collide = false;
    bool z_collide = false;

    QPointF move(pos.x() + vel.x(), pos.z() + vel.z());
    QPointF move_x(pos.x() + vel.x(), pos.z());
    QPointF move_z(pos.x(), pos.z() + vel.z());

    for (int i=0; i<colliders.size(); ++i) {

        if (colliders[i].contains(move)) {

            if (colliders[i].contains(move_x)) {
                x_collide = true;
            }

            if (colliders[i].contains(move_z)) {
                z_collide = true;
            }

        }

    }

    if (!x_collide && z_collide) {
        new_vel = QVector3D(vel.x(), 0, 0);
    }
    else if (!z_collide && x_collide) {
        new_vel = QVector3D(0, 0, vel.z());
    }
    else if (x_collide && z_collide) {
        new_vel = QVector3D(0, 0, 0);
    }
    else {
        new_vel = vel;
    }

    move = QPointF(pos.x() + new_vel.x(), pos.z() + new_vel.z());
    for (int i=0; i<circ_colliders.size(); ++i) {

        QVector3D cent_dir = QVector3D(circ_colliders[i].pos.x() - move.x(), 0, circ_colliders[i].pos.y() - move.y());
        const float cent_dist = cent_dir.length();

        if ((circ_colliders[i].stay_inside && cent_dist > circ_colliders[i].rad) ||
             (!circ_colliders[i].stay_inside && cent_dist < circ_colliders[i].rad)) {
            new_vel += cent_dir.normalized() * (cent_dist - circ_colliders[i].rad);
        }

    }

    /*
    qDebug() << "the mountpoints:";
    for (int angle=0; angle<=360; angle+=18) {

        if (angle % 36 == 0) {
            qDebug() << sinf(float(angle)* MathUtil::_PI_OVER_180) * 20.0f << "0" << cosf(float(angle)* MathUtil::_PI_OVER_180) * 20.0f
                     << -sinf(float(angle)* MathUtil::_PI_OVER_180) << "0" << -cosf(float(angle)* MathUtil::_PI_OVER_180);
        }
        else {
            qDebug() << sinf(float(angle)* MathUtil::_PI_OVER_180) * 12.1f << "0" << cosf(float(angle)* MathUtil::_PI_OVER_180) * 12.1f
                        << sinf(float(angle)* MathUtil::_PI_OVER_180) << "0" << cosf(float(angle)* MathUtil::_PI_OVER_180);
        }
    }
    */

    return new_vel;

}
开发者ID:jaxzin,项目名称:firebox,代码行数:72,代码来源:envroomtemplate.cpp

示例12: switch

void TrackBall::move(const QPointF& p, const QQuaternion &transformation, bool bFromRelease)
{
    if (!m_pressed)
        return;

    QTime currentTime = QTime::currentTime();
    int msecs = m_lastTime.msecsTo(currentTime);
    if (msecs <= 20)
        return;

    switch (m_mode) {
    case Plane: // rotate the camera
    {
        QLineF delta(m_lastPos, p);
        m_angularVelocity = 180*delta.length() / (PI*msecs);
        m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized(); // normal direction
        m_axis = transformation.rotatedVector(m_axis);
        m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation;
    }
    break;
    case Sphere: // rotate the model
    {
        // lastPos3D lies on a unit sphere
        QVector3D lastPos3D = QVector3D(m_lastPos.x(), m_lastPos.y(), 0.0f);
        float sqrZ = 1 - QVector3D::dotProduct(lastPos3D, lastPos3D);
        if (sqrZ > 0)
            lastPos3D.setZ(sqrt(sqrZ));
        else
            lastPos3D.normalize();

        // currentPos3D lies on a unit sphere
        QVector3D currentPos3D = QVector3D(p.x(), p.y(), 0.0f);
        sqrZ = 1 - QVector3D::dotProduct(currentPos3D, currentPos3D);
        if (sqrZ > 0)
            currentPos3D.setZ(sqrt(sqrZ));
        else
            currentPos3D.normalize();

        m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D);
        // a x b = |a|.|b|.sin(angle).n
        float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis)));

        m_angularVelocity = angle / msecs;
        m_axis.normalize();
        m_axis = transformation.rotatedVector(m_axis);
        m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation;
    }
    break;
    case Drag:
    {
        if (!bFromRelease)
        {
            QVector3D currentPos = QVector3D(p.x(), p.y(), 0.0f);

            QVector3D direction = currentPos - m_DragPos;

            if (direction.length() > 0.5) // avoid teleporting
            {
                m_DragPos = m_DragPos + 0.1*direction;
            }
            else
            {
                m_DragPos = QVector3D(p.x(), p.y(), 0.0f);
            }
        }
    }
    break;
    }

    m_lastPos = p;
    m_lastTime = currentTime;
}
开发者ID:anhnp82,项目名称:CutSharp,代码行数:72,代码来源:trackball.cpp

示例13: QGLSphere

/*!
    \internal
*/
void SphereMesh::createGeometry()
{
    // We cache a maximum of 10 levels of detail for lod animations.
    // Create a new geometry node for this level of detail if necessary.
    QGLSceneNode *geometry = d->lodGeometry.value(d->lod, 0);
    if (!geometry) {
        QGLBuilder builder;
        builder.newSection(QGL::Faceted);
        builder << QGLSphere(2.0f, d->lod);
        geometry = builder.finalizedSceneNode();
        geometry->setParent(this);
        d->lodGeometry.insert(d->lod, geometry);
    }
    Q_ASSERT_X(geometry != 0, Q_FUNC_INFO, "Could not create/find geometry!");
    if (d->currentSphere != geometry)
    {
        if (d->currentSphere)
            d->topNode->removeNode(d->currentSphere);
        d->topNode->addNode(geometry);
        d->currentSphere = geometry;
    }

    // Set the radius as a scale on the modelview transformation.
    // This way, we don't have to regenerate the geometry every
    // frame if the radius is being animated.
    if (d->radius != 1.0f)
    {
        if (!d->scale)
        {
            d->scale = new QGraphicsScale3D(d->topNode);
            d->topNode->addTransform(d->scale);
        }
        if (d->scale->scale().x() != d->radius)
        {
            d->scale->setScale(QVector3D(d->radius, d->radius, d->radius));
        }
    }
    else
    {
        // If there is already a scale set it to be the identity scale.
        // This case is optimised for in QGraphicsScale.  Removing it from
        // the transform list is too expensive, especially if the size is
        // being animated, and the next frame will recreate it.
        if (d->scale)
            d->scale->setScale(QVector3D(1, 1, 1));
    }

    // Also rotate the geometry into the correct axis orientation.
    const QVector3D Y_AXIS = QVector3D(0, 1, 0);  // for Qt::XAxis we rotate around Y
    const QVector3D X_AXIS = QVector3D(1, 0, 0);  // for Qt::YAxis we rotate around X
    if (d->axis != Qt::ZAxis && !d->rot)
    {
        d->rot = new QGraphicsRotation3D(d->topNode);
        d->topNode->addTransform(d->rot);
    }
    if (d->axis == Qt::XAxis && d->rot->axis().y() != Y_AXIS.y())
    {
        d->rot->setAxis(Y_AXIS);
        d->rot->setAngle(90.0f);
    }
    else if (d->axis == Qt::YAxis && d->rot->axis().x() != X_AXIS.x())
    {
        d->rot->setAxis(X_AXIS);
        d->rot->setAngle(-90.0f);
    }
    else if (d->axis == Qt::ZAxis && d->rot && d->rot->angle() != 0.0f)
    {
        d->rot->setAngle(0.0f);
        d->rot->setAxis(QVector3D(0, 0, 0));
    }

    if (!d->sceneSet)
    {
        setScene(new SphereScene(d->topNode));
        d->sceneSet = true;
    }
}
开发者ID:Distrotech,项目名称:qt3d,代码行数:80,代码来源:spheremesh.cpp

示例14: Renderable3DEntity

bool DigitizerTreeItem::addData(const QList<FIFFLIB::FiffDigPoint>& tDigitizer, Qt3DCore::QEntity* parent)
{
    //Clear all data
    m_lSpheres.clear();

//    if(!m_pRenderable3DEntity.isNull()) {
//        m_pRenderable3DEntity->deleteLater();
//    }

    m_pRenderable3DEntity = new Renderable3DEntity(parent);

    //Create digitizers as small 3D spheres
    QVector3D pos;
    QColor colDefault(100,100,100);

    for(int i = 0; i < tDigitizer.size(); ++i) {
        Renderable3DEntity* pSourceSphereEntity = new Renderable3DEntity(m_pRenderable3DEntity);

        pos.setX(tDigitizer[i].r[0]);
        pos.setY(tDigitizer[i].r[1]);
        pos.setZ(tDigitizer[i].r[2]);

        Qt3DExtras::QSphereMesh* sourceSphere = new Qt3DExtras::QSphereMesh();

        if (tDigitizer[i].kind == FIFFV_POINT_CARDINAL) {
            sourceSphere->setRadius(0.002f);
        } else {
            sourceSphere->setRadius(0.001f);
        }
        pSourceSphereEntity->addComponent(sourceSphere);
        pSourceSphereEntity->setPosition(pos);

        Qt3DExtras::QPhongMaterial* material = new Qt3DExtras::QPhongMaterial();

        switch (tDigitizer[i].kind) {
        case FIFFV_POINT_CARDINAL:
            colDefault = Qt::yellow;
            material->setAmbient(colDefault);
            break;
        case FIFFV_POINT_HPI:
            colDefault = Qt::red;
            material->setAmbient(colDefault);
            break;
        case FIFFV_POINT_EEG:
            colDefault = Qt::green;
            material->setAmbient(colDefault);
            break;
        case FIFFV_POINT_EXTRA:
            colDefault = Qt::blue;
            material->setAmbient(colDefault);
            break;
        default:
            colDefault = Qt::white;
            material->setAmbient(colDefault);
            break;
        }

        pSourceSphereEntity->addComponent(material);

        pSourceSphereEntity->setParent(m_pRenderable3DEntity);

        m_lSpheres.append(pSourceSphereEntity);
    }

    QList<QStandardItem*> items = this->findChildren(MetaTreeItemTypes::PointColor);

    for(int i = 0; i < items.size(); ++i) {
        if(MetaTreeItem* item = dynamic_cast<MetaTreeItem*>(items.at(i))) {
            QVariant data;
            data.setValue(colDefault);
            item->setData(data, MetaTreeItemRoles::PointColor);
        }
    }

    return true;
}
开发者ID:louiseichhorst,项目名称:mne-cpp,代码行数:76,代码来源:digitizertreeitem.cpp

示例15: isMoving

void BookPage::update( const float timeStep ) {
    bool moving = isMoving();

    if (pulling==false) {
        if (!incing && expulling==true) {
            if (pageTurn>0.2) currentPageDir *= -1.0f;
        }

        if (!incing) {
            secondVector += QVector3D( currentPageDir, 0, 0)* timeStep*12.0f;
            secondVector.normalize();
            mainVector += secondVector*timeStep*4.0f;
            mainVector.normalize();

        } else {
            pullDirX += pullDirInc[0] * timeStep;
            pullDirY += pullDirInc[1] * timeStep;
            pullDirInc[0] -= pullDirInc[0] * timeStep*2.0f;
            pullDirInc[1] -= pullDirInc[1] * timeStep*2.0f;
            pullDirInc[0] -= pullDirX * timeStep*5.0f;
            pullDirInc[1] -= pullDirY * timeStep*5.0f;



            if ((pullDir2DLength-exPullDir2DLength)<0.007f || pageTurn>0.95f) {
                // check turn here.
                if ((pullFromCenter==false && pageTurn>0.1f) || (pullFromCenter==true && pageTurn>0.8f)) {
                    currentPageDir *= -1.0f;
                    incing = false;
                }

                if (pullDir2DLength<0.02f) {
                    incing = false;
                    pulling = false;
                    pullDirX = 0;
                    pullDirY = 0;
                    secondVector = QVector3D( currentPageDir, 0, 0);
                    mainVector = secondVector;
                }
            }
        }
    }

    if (pulling || incing) {

        if (pullFromCenter == false && pullDirX<0) {

            dividerPosX = pullSourceX + pullDirX;
            dividerPosY = pullSourceY + pullDirY;

            QVector3D todiv = QVector3D( dividerPosX, dividerPosY - 0.5f, 0);
            QVector3D tosource = QVector3D( pullSourceX, pullSourceY - 0.5f, 0);
            if (todiv.length()>tosource.length()) {
                //todiv.
                todiv.normalize();
                todiv *= tosource.length();
                dividerPosX = todiv.x();
                dividerPosY = todiv.y();
            }



            pullDirX = dividerPosX - pullSourceX;
            pullDirY = dividerPosY - pullSourceY;


            //pullDirX

            //float pulllength = sqrtf( pullDirX * pullDirX + pullDirY * pullDirY );

            // dividerpos limitations -> dividerdir can be different from pulldir's normal



            float pullnorm[2];
            pullnorm[0] = -pullDirY;
            pullnorm[1] = pullDirX;


            float divpos1[2];
            float divpos2[2];
            pageTurn = 1.0f;

            float steps = dividerPosY / -pullnorm[1];
            divpos1[0] = dividerPosX + steps * pullnorm[0];
            divpos1[1] = dividerPosY + steps * pullnorm[1];
            if (-(divpos1[0]-0.3f)*3.0f<pageTurn) pageTurn = -(divpos1[0]-0.3f)*3.0f;


            if (divpos1[0] < 0.0f) { divpos1[0] = 0.0f; divpos1[1] = 0.0f; }
            if (divpos1[0]>1.0f) {
                steps = (divpos1[0]-1.0f) / pullnorm[0];
                divpos1[1] -= steps * pullnorm[1];
                divpos1[0] -= steps * pullnorm[0];
            }




            steps = (1.0f-dividerPosY) / pullnorm[1];
//.........这里部分代码省略.........
开发者ID:ltomuta,项目名称:open-book,代码行数:101,代码来源:bookpage.cpp


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