Beispiel #1
0
void BrainiacDisplay::paintGL(QGLPainter *painter)
{
    QVector3DArray vertices;
    static qreal size=1000.0f;
    static qreal width=10.0f;
    vertices.append(size,0,size);
    vertices.append(size,0,-size);
    vertices.append(-size,0,-size);
    vertices.append(-size,0,size);

    int count=0;
    for(qreal i=0.0f; i<size*2.f; i+=width) {
        vertices.append(-size+i,0,size);
        vertices.append(-size+i,0,-size);
        vertices.append(size,0,-size+i);
        vertices.append(-size,0,-size+i);
        count++;
    }

    painter->clearAttributes();
    painter->setStandardEffect(QGL::FlatColor);
    painter->setVertexAttribute(QGL::Position, vertices);
    painter->setColor(QColor(30,30,30));
    painter->draw(QGL::LineLoop,4,0);
    painter->draw(QGL::Lines,count*4,4);

    painter->clearAttributes();
    vertices.clear();

    static qreal crossLength=150.0f;

    if(m_showCoordCross) {
        vertices.append(0,1,0);
        vertices.append(crossLength,1,0);
        vertices.append(0,0,0);
        vertices.append(0,crossLength,0);
        vertices.append(0,1,0);
        vertices.append(0,1,crossLength);

        painter->setStandardEffect(QGL::FlatColor);
        painter->setVertexAttribute(QGL::Position, vertices);

        painter->setColor(BrainiacGlobals::defaultXColor);
        painter->draw(QGL::Lines,2,0);
        painter->setColor(BrainiacGlobals::defaultYColor);
        painter->draw(QGL::Lines,2,2);
        painter->setColor(BrainiacGlobals::defaultZColor);
        painter->draw(QGL::Lines,2,4);
    }
}
Beispiel #2
0
ImageViewer::ImageViewer(int w, int h)
{
    // the body
    QGLBuilder builder;
    builder.newSection(QGL::Faceted);
    builder.addPane(QSizeF(w, h));
    body = builder.finalizedSceneNode();
    body->setMaterial(new QGLMaterial());
    body->setEffect(QGL::FlatReplaceTexture2D);

    // prev button
    QVector3DArray vertices;
    vertices.append(-w * 0.4, 0, 0.01);
    vertices.append(-w * 0.3, -h * 0.1, 0.01);
    vertices.append(-w * 0.3, h * 0.1, 0.01);
    QGeometryData triangle;
    triangle.appendVertexArray(vertices);
    QGLBuilder prevBuilder;
    prevBuilder.newSection(QGL::Faceted);
    prevBuilder.addTriangles(triangle);
    prevBtn = prevBuilder.finalizedSceneNode();
    prevBtn->setEffect(QGL::FlatColor);

    // next button
    vertices.clear();
    vertices.append(w * 0.4, 0, 0);
    vertices.append(w * 0.3, h * 0.1, 0.01);
    vertices.append(w * 0.3, -h * 0.1, 0.01);
    triangle.clear();
    triangle.appendVertexArray(vertices);
    QGLBuilder nextBuilder;
    nextBuilder.newSection(QGL::Faceted);
    nextBuilder.addTriangles(triangle);
    nextBtn = nextBuilder.finalizedSceneNode();
    nextBtn->setEffect(QGL::FlatColor);
}