예제 #1
0
StereoView::StereoView(QWidget *parent)
    : QGLView(parent)
{
    scene = new QGLSceneNode(this);

    QGLSceneNode *teapot;
    QGLSceneNode *cube;

    {
        QGLBuilder builder;
        builder << QGLTeapot();
        teapot = builder.finalizedSceneNode();
    }

    {
        QGLBuilder builder;
        builder.newSection(QGL::Faceted);
        builder << QGLCube(1.0f);
        cube = builder.finalizedSceneNode();
    }

    cube->setPosition(QVector3D(-1.0f, 0.0f, 2.0f));
    scene->addNode(teapot);
    scene->addNode(cube);

    QGLMaterial *china = new QGLMaterial(this);
    china->setAmbientColor(QColor(192, 150, 128));
    china->setSpecularColor(QColor(60, 60, 60));
    china->setShininess(128);
    scene->setMaterial(china);
    scene->setEffect(QGL::LitMaterial);

    camera()->setEye(QVector3D(0.0f, 0.0f, 15.0f));
    camera()->setEyeSeparation(0.2f);
}
예제 #2
0
/* Creates the scene of balls */
void ModelBall::createScene() {
    qsrand(QDateTime::currentMSecsSinceEpoch());
    QGLMaterial *material = new QGLMaterial();
    material->setColor(Qt::blue);
    material->setSpecularColor(QColor(SPECULAR_COLOR));
    material->setAmbientColor(QColor(AMBIENT_COLOR));
    material->setEmittedLight(QColor(EMITTED_LIGHT_COLOR));
    material->setShininess(SHININESS);
    for (int i = 0; i < ANIMATION_BALLS; i++) {
        _nodes.append(createNode(material));
        _phase[i] = 2 * M_PI / ANIMATION_BALLS * i - M_PI;
    }
    _mainNode = _nodes.first();
}
예제 #3
0
void loadProperty(const QString &property, QTextStream &value) {
    if (property == "material") {
        QGLMaterial *mat = new QGLMaterial();
        QString name, file;
        value >> name >> file;

        if (file != "-") {
            QGLTexture2D *tex = new QGLTexture2D();
            tex->setImage(QImage(dataDir + file));
            mat->setTexture(tex);
            mat->setTextureCombineMode(QGLMaterial::Decal);
        }

        int r, g, b;
        value >> r >> g >> b; if (r != -1) mat->setAmbientColor(QColor(r, g, b));
        value >> r >> g >> b; if (r != -1) mat->setDiffuseColor(QColor(r, g, b));
        value >> r >> g >> b; if (r != -1) mat->setSpecularColor(QColor(r, g, b));
        qreal shin; value >> shin; mat->setShininess(shin);

        palette.insert(name, mat);

    } else if (property == "size") {
예제 #4
0
/*!
  Initializes the Qt3D materials used in the application.
*/
void GameView::initializeMaterials()
{
    m_MaterialCollection = new QGLMaterialCollection(this);

    QGLTexture2D *lightTexture = new QGLTexture2D;
    lightTexture->setImage(QImage(":/reflectionmap.png"));

    QColor ambientColor = QColor(64, 64, 190);

    QGLMaterial *material = new QGLMaterial;
    material->setObjectName("PauseButtonMaterial");
    QGLTexture2D *texture = new QGLTexture2D;
    texture->setImage(QImage(":/pause_button.png"));
    material->setTexture(texture);
    m_MaterialCollection->addMaterial(material);

    // Black hole material
    material = new QGLMaterial;
    material->setObjectName("BlackHoleMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/BlackHole.jpg"));
    material->setTexture(texture);
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/bh_sprial.png"));
    material->setTexture(texture, 1);
    material->setTextureCombineMode(QGLMaterial::Replace);
    m_MaterialCollection->addMaterial(material);


    // Black hole center material
    material = new QGLMaterial;
    material->setObjectName("BlackHoleFrontMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/bh_sprial.png"));
    material->setTexture(texture);
    material->setTexture(lightTexture, 1);
    m_MaterialCollection->addMaterial(material);

    // Platform material
    material = new QGLMaterial;
    material->setObjectName("PlatformMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/platformtex.png"));
    material->setTexture(texture);
    m_MaterialCollection->addMaterial(material);

    // Blok material
    material = new QGLMaterial;
    material->setObjectName("BlokMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/SimpleBlock.png"));
    material->setTexture(texture);
    material->setTexture(lightTexture, 1);
    material->setAmbientColor(ambientColor);
    material->setShininess(0.2f);
    m_MaterialCollection->addMaterial(material);

    // Ball materials
    material = new QGLMaterial;
    material->setObjectName("BallMaterial1");
    material->setAmbientColor(ambientColor);
    material->setDiffuseColor(QColor(255, 255, 64));
    material->setTexture(texture, 0);
    material->setTexture(lightTexture, 1);
    material->setShininess(1.0f);
    material->setSpecularColor(material->diffuseColor());
    m_MaterialCollection->addMaterial(material);

    material = new QGLMaterial;
    material->setObjectName("BallMaterial2");
    material->setAmbientColor(ambientColor);
    material->setDiffuseColor(QColor(255, 64, 64));
    material->setTexture(texture, 0);
    material->setTexture(lightTexture, 1);
    material->setShininess(1.0f);
    material->setSpecularColor(material->diffuseColor());
    m_MaterialCollection->addMaterial(material);

    material = new QGLMaterial;
    material->setObjectName("BallMaterial3");
    material->setDiffuseColor(QColor(64, 64, 255));
    material->setAmbientColor(ambientColor);
    material->setTexture(texture, 0);
    material->setTexture(lightTexture, 1);
    material->setShininess(1.0f);
    material->setSpecularColor(material->diffuseColor());
    m_MaterialCollection->addMaterial(material);

    material = new QGLMaterial;
    material->setObjectName("BallMaterial4");
    material->setDiffuseColor(QColor(64, 255, 64));
    material->setAmbientColor(ambientColor);
    material->setTexture(texture, 0);
    material->setTexture(lightTexture,1);
    material->setShininess(1.0f);
    material->setSpecularColor(material->diffuseColor());
    m_MaterialCollection->addMaterial(material);

    material = new QGLMaterial;
    material->setObjectName("LightFlareMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/flare.png"));
    material->setTexture(texture);
    m_MaterialCollection->addMaterial(material);

    material = new QGLMaterial;
    material->setObjectName("FontMaterial");
    texture = new QGLTexture2D;
    texture->setImage(QImage(":/scorefont.png"));
    material->setTexture(texture);
    m_MaterialCollection->addMaterial(material);
}