本文整理汇总了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();
}
示例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;
}
示例3: onSurfaceTranslationZChanged
void FsSurfaceTreeItem::onSurfaceTranslationZChanged(float fTransZ)
{
QVector3D position = m_pRenderable3DEntity->position();
position.setZ(fTransZ);
m_pRenderable3DEntity->setPosition(position);
m_pRenderable3DEntityNormals->setPosition(position);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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() );
}
示例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;
}
示例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();
}
示例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())));
}
示例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();
}
示例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");
}
}
}
}
示例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;
}
示例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);
}
示例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());
}