Failed to render a OSG pointcloud with normals using QOpenGLFrameBufferObject



  • Hi, everyone. I am currently working on a project that connects OpenSceneGraph and Qt Quick, especially to render a pointcloud with normals binding to each vertex. After searching a lot of references and materials, I decided to use QOpenGLFrameBufferObject according to the official example "textureinsgnode". I can now render the vertices in the pointcloud, however, the normals information seem to be missing (The result is a pure white pointcloud). My question is how to get my normals rendered? Some important code snippets are shown below:
    //constructing the pointcloud geometry in OSG
    geometry->setVertexArray(vertices);
    geometry->setNormalArray(normals, osg::Array::BIND_PER_VERTEX);
    pointIdx = new osg::DrawElementsUInt(osg::PrimitiveSet::POINTS);
    qint64 verticesSize = vertices->size();
    for (size_t i = 0; i < verticesSize; ++i)
    pointIdx->push_back(i);
    geometry->addPrimitiveSet(pointIdx);

    //constructing the framebufferobject in osgQuickRenderer.cpp
    QOpenGLFramebufferObject *osgQViewerRenderer::createFramebufferObject(const QSize &size)
    {
    qDebug()<<"create framebuffobject "<<size.width()<<"x"<<size.height();
    QOpenGLFramebufferObjectFormat format;
    format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
    format.setSamples(4);
    return new QOpenGLFramebufferObject(size, format);
    }

    What am I missing? Any suggestion would be appreciated, thanks!


Log in to reply
 

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