Qt3D Opacity control on primitives?



  • How to I set level of opacity when rendering QGLSphere or QGLCube primitives?

    I'm building geometry using QGLBuilder:
    @
    QGLBuilder builder;
    builder << QGL::Faceted;

    if ( currentShape == sphere )
        builder << QGLSphere(0.99,3);  // size of 1, smooth
    else if ( currentShape == cube )
        builder << QGLCube(1.0);  // size of 1, smooth
    
    // Finalise geometry and get QGLSceneNode pointer.
    QGLSceneNode *thisNode = builder.finalizedSceneNode();
    

    @



  • Figured it out... use alpha blending with color.

    @
    void CubeView::initializeGL(QGLPainter *painter)
    {
    glEnable(GL_BLEND);
    }
    @

    and setAlpha in paintGL...

    @
    QColor colour = QColor(VisualDataItem->getFinalColour());
    colour.setAlpha(127);
    painter->setFaceColor(QGL::AllFaces, colour);

    VisualDataItem->getNode()->draw(painter);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.