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


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

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


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

示例1: keyPressEvent

void Quiddiards::keyPressEvent(QKeyEvent *event){
	switch (event->key()) {
	case Qt::Key_F2:
		actStart();
		break;
	case Qt::Key_P:
		actPause();
		break;
	case Qt::Key_Escape:
	case Qt::Key_Q:
		close();
		break;
	case Qt::Key_Space:
	case Qt::Key_Enter:
	case Qt::Key_Return:
		break;
	case Qt::Key_W:{
		/* forward cueball */
		QVector3D n = -eye;
		n.setZ(0);
		n.normalize();
		n += cueball.getVelocity();
		if (n.length() > cueball.getSpeed()){
			n = cueball.getSpeed()*n.normalized();
		}
		cueball.setVelocity(n);
		break;
	}
	case Qt::Key_A:
		phi += 10;
		break;
	case Qt::Key_S:{
		QVector3D n = eye;
		n.setZ(0);
		n.normalize();
		n += cueball.getVelocity();
		if (n.length() > cueball.getSpeed()){
			n = cueball.getSpeed()*n.normalized();
		}
		cueball.setVelocity(n);
		break;
	}
	case Qt::Key_D:
		phi -= 10;
		break;
	case Qt::Key_Tab:
		//camera = CAMERA((camera + 1) % 2);
		break;
	default:
		return;
	}
	update();
}
开发者ID:silencious,项目名称:Quiddiards,代码行数:53,代码来源:quiddiards.cpp

示例2: calculatePorosity

void Particles::calculatePorosity()
{
    int N = particles.size()/100;
    if (N==0)
        return;
    int cnt = 1;
    calculateBoundingBox();
    float l = (boundsMax - boundsMin).length()/135.0;
    qDebug() << "l = " << l;
    for (int i=0;i<N;i++) {
        QVector3D p;
        p.setX(Util::floatRandom(boundsMin.x(), boundsMax.x()));
        p.setY(Util::floatRandom(boundsMin.y(), boundsMax.y()));
        p.setZ(Util::floatRandom(boundsMin.z(), boundsMax.z()));
        for (int j=0;j<particles.size();j++) {
            if ((particles[j]->getPos() - p).lengthSquared()<l*l) {
                cnt++;
                j=particles.size();
                break;
            }
        }
        if (rand()%100>=99)
            qDebug() << cnt / (float)i;
    }
    m_calculatedPorosity = (float)cnt/(float)N;
//    qDebug() << m_calculatedPorosity << "   " << N << " / " << cnt;

}
开发者ID:leuat,项目名称:GeometryLibrary,代码行数:28,代码来源:particle.cpp

示例3: onSurfaceTranslationZChanged

void FsSurfaceTreeItem::onSurfaceTranslationZChanged(float fTransZ)
{
    QVector3D position = m_pRenderable3DEntity->position();
    position.setZ(fTransZ);
    m_pRenderable3DEntity->setPosition(position);
    m_pRenderable3DEntityNormals->setPosition(position);
}
开发者ID:louiseichhorst,项目名称:mne-cpp,代码行数:7,代码来源:fssurfacetreeitem.cpp

示例4: BoundingVolume

void Qt3DGeometryTab::computeBoundingVolume(const Qt3DGeometryAttributeData &vertexAttr,
                                            const QByteArray &bufferData)
{
    m_boundingVolume = BoundingVolume();
    QVector3D v;
    for (unsigned int i = 0; i < vertexAttr.count; ++i) {
        const char *c = bufferData.constData() + vertexAttr.byteOffset + i * vertexAttr.byteStride;
        switch (vertexAttr.vertexBaseType) {
        case Qt3DRender::QAttribute::Float:
        {
            // cppcheck-suppress invalidPointerCast
            auto f = reinterpret_cast<const float *>(c);
            v.setX(*f);
            ++f;
            v.setY(*f);
            ++f;
            v.setZ(*f);
            break;
        }
        default:
            qWarning() << "Vertex type" << vertexAttr.vertexBaseType << "not implemented yet";
            return;
        }
        m_boundingVolume.addPoint(v);
    }
}
开发者ID:xhaakon,项目名称:GammaRay,代码行数:26,代码来源:qt3dgeometrytab.cpp

示例5: update

void BulletComponent::update(float delta)
{
    EnemyComponent *enemy = target->getComponent<EnemyComponent>();

    if(enemy != nullptr) {
        destination = target->getPosition();
    }
    QVector3D dir = -(this->getEntity()->getPosition() - destination);
    if(dir.length() < 10) {
        if(enemy != nullptr) {
            enemy->takeDamage(damage);
            QVector3D v = getEntity()->getPosition();
            v.setX(v.x() / 768);
            v.setY(v.y() / 624);
            v.setZ(0);

            FMODManager::getInstance()->setCurrentEvent("event:/hit");
            FMODManager::getInstance()->setEventInstancePosition(v);
            FMODManager::getInstance()->setEventInstanceVolume(0.4);
            FMODManager::getInstance()->setParameterValue("pitch", 0.3 + (qrand() % 200) * 0.001);
            FMODManager::getInstance()->startEventInstance();
        }

        this->getEntity()->release();
    } else {
        dir.normalize();
        this->getEntity()->setPosition(this->getEntity()->getPosition() + dir * speed * delta);
    }
}
开发者ID:znoraka,项目名称:SexyDwarfEngine,代码行数:29,代码来源:bulletcomponent.cpp

示例6: 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

示例7: SetMember

void Transform::SetMember(QVector3D& member,const QVariant& data)
{
    QList<QVariant> dataList(data.toList());
    member.setX( dataList[0].toFloat() );
    member.setY( dataList[1].toFloat() );
    member.setZ( dataList[2].toFloat() );
}
开发者ID:ProjectDestiny,项目名称:Portafolio,代码行数:7,代码来源:transform.cpp

示例8: cp

DisplayWindow *FourierDCT::invert(ComplexArray *ca, QString title, QImage::Format format, QWidget *p)
{
	int w = ca->shape()[1];
	int h = ca->shape()[2];
	perform(ca, true);
	ColorParser cp(format);
	QImage result(w, h, format);
	result.fill(Qt::black);
	if (format == QImage::Format_Indexed8) {
		QVector<QRgb> colors;
		colors.reserve(256);
		for (int i = 0; i < 256; i++) {
			colors << qRgb(i, i, i);
		}
		result.setColorTable(colors);
	}
	for (unsigned int i = 1; i < ca->shape()[0]; i += 2) {
		qreal min = 0;
		qreal max = 0;
		for (unsigned int j = 0; j < ca->shape()[1]; j++) {
			for (unsigned int k = 0; k < ca->shape()[2]; k++) {
				Complex c = (*ca)[i][j][k];
				qreal real = c.real();
				if (real > max) {
					max = real;
				} else if (real < min) {
					min = real;
				}
			}
		}

		for (unsigned int j = 0; j < ca->shape()[1]; j++) {
			for (unsigned int k = 0; k < ca->shape()[2]; k++) {
				Complex c = (*ca)[i][j][k];
				qreal p = (c.real() - min) / (max - min) * 255.0;
				{
					QVector3D oldPixel = cp.pixel(k, j, result);
					QVector3D newPixel;
					switch (i / 2) {
						case 0:
							newPixel.setX(p);
							break;
						case 1:
							newPixel.setY(p);
							break;
						case 2:
							newPixel.setZ(p);
							break;
						default:
							break;
					}
					cp.setPixel(k, j, result, cp.merge(oldPixel, newPixel));
				}
			}
		}
	}
	result = result.rgbSwapped();
	PhotoWindow *pw = new PhotoWindow(result, title + ", IFDCT", p);
	return pw;
}
开发者ID:janisozaur,项目名称:pod,代码行数:60,代码来源:fourierdct.cpp

示例9: boundingRect

void SSTask::drawMeshes3D( const QSizeF& mapSize ) const
{
	QRectF boundingRect(QPointF( -mapSize.width()/2.0, -mapSize.height()/2.0), mapSize);
	glBegin(GL_TRIANGLES);
	mutex.lockForRead();
	for(int i = 0; i < m_meshes_cache.size(); i++){
		Triangle3D t = m_meshes_cache.at(i);
		if(!boundingRect.contains(t.v1.toPointF()) 
			|| !boundingRect.contains(t.v2.toPointF()) 
			|| !boundingRect.contains(t.v3.toPointF()))
			continue;

		QVector3D normal = QVector3D::crossProduct(t.v2 - t.v1, t.v3 - t.v1);
		if(normal.z() < 0){
			t = Triangle3D(t.v3, t.v2, t.v1);
			normal.setZ( - normal.z());
		}
		glNormal3d(normal.x(), normal.y(), normal.z());
		glVertex3d(t.v1.x(), t.v1.y(), t.v1.z());
		glVertex3d(t.v2.x(), t.v2.y(), t.v2.z());
		glVertex3d(t.v3.x(), t.v3.y(), t.v3.z());
	}
	mutex.unlock();
	glEnd();
}
开发者ID:YANG-H,项目名称:straight-skeleton,代码行数:25,代码来源:sstask.cpp

示例10: result

DisplayWindow *ContrastFilter::apply(QString windowBaseName)
{
	QImage result(mImg.size(), mFormat);
	if (mFormat == QImage::Format_Indexed8 || mFormat == QImage::Format_Mono) {
		result.setColorTable(mImg.colorTable());
	}
	ColorParser cp(mFormat);
	float c = std::tan((float)mValue / 100.0f);
	qDebug() << "contrast:" << c;
	QVector<int> lut;
	lut.reserve(256);
	for (int i = 0; i < 256; i++) {
		lut << qBound(0, (int)(c * (i - 127) + 127), 255);
	}
	for (int x = 0; x < mImg.width(); x++) {
		for (int y = 0; y < mImg.height(); y++) {
			QVector3D colorVec = cp.pixel(x, y, mImg);
			colorVec.setX(lut.at((int)colorVec.x()));
			colorVec.setY(lut.at((int)colorVec.y()));
			colorVec.setZ(lut.at((int)colorVec.z()));
			cp.setPixel(x, y, result, colorVec);
		}
	}
	// parent's parent should be MainWindow
	return new PhotoWindow(result, windowBaseName + ", " + name(), q_check_ptr(qobject_cast<QWidget *>(parent()->parent())));
}
开发者ID:janisozaur,项目名称:pod,代码行数:26,代码来源:contrastfilter.cpp

示例11: QGLWidget

HeightmapWidget::HeightmapWidget(QWidget *parent) :
        QGLWidget(parent)
{
    // Load heightmap
    QImage img = QImage(":/heightmap.png");

    vertices_by_x = img.width();
    vertices_by_z = img.height();
    quads_by_x = vertices_by_x - 1;
    quads_by_z = vertices_by_z - 1;

    QVector3D vertice;
    for(int z = 0; z < vertices_by_z; ++z)
    {
        for(int x = 0; x < vertices_by_x; ++x)
        {
            QRgb color = img.pixel(x, z);

            vertice.setX((MAP_SIZE * x / vertices_by_x) - MAP_SIZE / 2);
            vertice.setY(2.0 * qGray(color) / 255);
            vertice.setZ((MAP_SIZE * z / vertices_by_z) - MAP_SIZE / 2);

            m_vertices.push_back(vertice);
        }
    }

    // Timer settings
    connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL()));
    timer.start(20);
    frame_count = 0;
    last_count = 0;
    last_time = QTime::currentTime();
}
开发者ID:Clav36,项目名称:Robotech_Gestion_Deplacements,代码行数:33,代码来源:heightmapwidget.cpp

示例12: initTrees

/**
 * @brief GameWindow::initTrees, Lorsque le fichier binaire est vide, initialise les arbres des différentes saisons pour la fenêtre.
 */
void GameWindow::initTrees()
{
    tree = new GameObject**[FileManager::NB_TERRAIN];
    tree[Saison::PRINTEMPS] = new GameObject*[NB_ARBRES];
    tree[Saison::ETE] = new GameObject*[NB_ARBRES];
    tree[Saison::AUTOMNE] = new GameObject*[NB_ARBRES];
    tree[Saison::HIVER] = new GameObject*[NB_ARBRES];

    for(unsigned int j = 0 ; j < FileManager::NB_TERRAIN ; j++){
        for(unsigned int i = 0 ; i < NB_ARBRES ; i++){
            QVector3D pos;

            int rand_x, rand_y, id;

            rand_x = rand() % nb_vertex_width;
            rand_y = rand() % nb_vertex_height;
            id = rand_y * nb_vertex_width + rand_x;

            pos.setX(p[id].x); pos.setY(p[id].y); pos.setZ(p[id].z);

            if(j == Saison::PRINTEMPS){
                tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/island_tree.ply");
            }else if(j == Saison::ETE){
                tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/summertree.ply");
            }else if(j == Saison::AUTOMNE){
                tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/autumntree.ply");
            }else if(j == Saison::HIVER){
                tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/wintertree.ply");
            }
        }
    }
}
开发者ID:BeNeNuTs,项目名称:TP4,代码行数:35,代码来源:gamewindow.cpp

示例13:

QVector3D& cube::createVectorByPoint(PointDDD& a,PointDDD& b)
{
    QVector3D *tmp = new QVector3D();
    tmp->setX(b.getX() - a.getX());
    tmp->setY(b.getY() - a.getY());
    tmp->setZ(b.getZ() - a.getZ());
    return *tmp;
}
开发者ID:heroboec,项目名称:cube2,代码行数:8,代码来源:cube.cpp

示例14: in

	/*!
	Zooms in (moves) closer to an object.
	\param sceneNode    Object sceneNode
	\param time         Time (milliseconds) that takes to move to the new position
	*/
	void Camera::zoomInToObject(Ogre::SceneNode* sceneNode, float time)
	{
		if (_zoomOffTimerId != 0)
		{
			killTimer(_zoomOffTimerId);
		}

		QVector3D nodePos =  UtilFunctions::ogreVector3ToQVector3d(sceneNode->getPosition());
		QVector3D direction = _position - nodePos;
		direction.normalize();
		QVector3D position = nodePos/* + direction * 1000*/;
		position.setY(nodePos.y() + 450);
		position.setZ(nodePos.z() + 800);
		QVector3D targetPos = nodePos;
		targetPos.setZ(position.z() - 1000);
		this->moveTo(position, targetPos, time);
	}
开发者ID:Cnotinfor,项目名称:TopQX_3D,代码行数:22,代码来源:Camera.cpp

示例15: getView

void Vizkit3DWidget::getCameraView(QVector3D& lookAtPos, QVector3D& eyePos, QVector3D& upVector)
{
    osg::Vec3d eye, lookAt, up;

    osgViewer::View *view = getView(0);
    assert(view);
    view->getCamera()->getViewMatrixAsLookAt(eye, lookAt, up);

    eyePos.setX(eye.x());
    eyePos.setY(eye.y());
    eyePos.setZ(eye.z());
    lookAtPos.setX(lookAt.x());
    lookAtPos.setY(lookAt.y());
    lookAtPos.setZ(lookAt.z());
    upVector.setX(up.x());
    upVector.setY(up.y());
    upVector.setZ(up.z());
}
开发者ID:arneboe,项目名称:gui-vizkit3d,代码行数:18,代码来源:Vizkit3DWidget.cpp


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