示例#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;
}
示例#3
0
文件: boid.cpp 项目: 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;
}
示例#4
0
文件: tank.cpp 项目: Distrotech/qt3d
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;
}