Exemplo n.º 1
0
void ViewportWidget::buildPane() {
    QGLBuilder builder;

    if (_bgr) {
        delete _bgr;
        _bgr = NULL;
    }

    builder.newSection();

    QGraphicsTranslation3D *trans = new QGraphicsTranslation3D();
    QGraphicsRotation3D *rot = new QGraphicsRotation3D();
    trans->setTranslate(QVector3D(0.0f, 0.0f, -1.0f));
    rot->setAxis(QVector3D(1, 0, 0));
    rot->setAngle(180);

    qreal size = 7.3f;
    builder.addPane(QSizeF(size, size * (qreal)SCREEN_HEIGHT /
                           (qreal)SCREEN_WIDTH));
    _bgr = builder.finalizedSceneNode();
    _bgr->addTransform(trans)   ;
    _bgr->addTransform(rot);
    _bgrImage = QImage(SCREEN_WIDTH, SCREEN_HEIGHT, QImage::Format_RGB888);
    _texture = new QGLTexture2D();
    _texture->setImage(_bgrImage);
}
/*!
    \internal
*/
QGraphicsTransform3D *QGraphicsRotation3D::clone(QObject *parent) const
{
    Q_D(const QGraphicsRotation3D);
    QGraphicsRotation3D *copy = new QGraphicsRotation3D(parent);
    copy->setOrigin(d->origin);
    copy->setAxis(d->axis);
    copy->setAngle(d->angle);
    return copy;
}
Exemplo n.º 3
0
Arquivo: boid.cpp Projeto: AFFvn/boids
QGLSceneNode * Boid::boidObject()
{
    static QGLSceneNode *v = 0;
    if (!v)
    {
        QGLBuilder build;
        build << QGLSphere(2.0f);
        v = build.finalizedSceneNode();
        v->setObjectName("Boid");
        QGraphicsRotation3D * rot = new QGraphicsRotation3D(v);
        rot->setAngle(90.0f);
        rot->setAxis(QVector3D(1, 0, 0));
        v->addTransform(rot);
        v->setY(-v->boundingBox().minimum().y());
    }
    return v;
}
Exemplo n.º 4
0
QGLSceneNode *Tank::tankObject()
{
#ifndef QT_NO_DEBUG
    // NOT THREADSAFE, NOT RE-ENTRANT
    Q_ASSERT(QThread::currentThread() == qApp->thread());
#endif
    static QGLSceneNode *theTank = 0;
    if (!theTank)
    {
        QGLBuilder build;
        build << QGLCylinder(1.0f, 1.0f, 1.0f, 32);
        theTank = build.finalizedSceneNode();
        theTank->setObjectName("Tank Component");
        QGraphicsRotation3D *rot = new QGraphicsRotation3D(theTank);
        rot->setAxis(QVector3D(1, 0, 0));
        rot->setAngle(-90.0f);
        theTank->addTransform(rot);
        theTank->setY(-theTank->boundingBox().minimum().y());
    }
    return theTank;
}