Qt3D and QGeometryData



  • Hi,
    I'm new in programming with Qt3D. I have sucessfully added a QGLSceneNode build from the QGLBuilder class. But now I'm trying to create such a node without using the QGlBuilder class, because I need some simple lines (coordinate axis) which are not supported by the builder class, or? So I wrote the following:
    @ QGeometryData geom;
    geom.appendVertex(QVector3D(0, 0, 0), QVector3D(10, 0, 0));
    geom.appendVertex(QVector3D(0, 0, 0), QVector3D(0, 10, 0));
    geom.appendVertex(QVector3D(0, 0, 0), QVector3D(0, 0, 10));
    QGLMaterial *m = new QGLMaterial;
    m->setColor(Qt::red);
    m_coordinateAxis = new QGLSceneNode(geom);
    m_coordinateAxis->setMaterial(m);
    @
    But nothing appears on the screen. What's wrong?



  • use instead this:

    it' a part of my code to draw a 3d grid with axis( x,y,z)

    @QVector3DArray grid;
    QVector3DArray xAxis,yAxis,zAxis;
    painter->clearAttributes();
    //glLineWidth(0);
    painter->setStandardEffect(QGL::FlatColor);

    painter->setColor(QColor(125,125,125));

    for(int i=-8;i<=8;i++)
    {
    if (i==0)
    {
    xAxis.append(-8,i1,0);
    xAxis.append(8 ,i
    1,0);

          yAxis.append(i*1,-8,0);
          yAxis.append(i*1,8,0);
        }
      else
        {
          grid.append(-8,i*1,0);
          grid.append(8 ,i*1,0);//distanza(lunghezza linea, spaziatura, z)
    
          grid.append(i*1,-8,0);
          grid.append(i*1,8,0);
        }
    }
    

    zAxis.append(0,0,0);
    zAxis.append(0,0,1);

    painter->setVertexAttribute(QGL::Position , grid);
    painter->draw(QGL::Lines,grid.size());
    //Normal Lines

    //glLineWidth(2.5);//NOTE settare dimensione diversa x gli assi??
    painter->setVertexAttribute(QGL::Position , xAxis);
    painter->setColor(QColor(255,0,0));
    painter->draw(QGL::Lines,xAxis.size());
    //XAxis

    painter->setVertexAttribute(QGL::Position , zAxis);
    painter->setColor(QColor(0,0,255));
    painter->draw(QGL::Lines,zAxis.size());
    //zaxis

    painter->setVertexAttribute(QGL::Position , yAxis);
    painter->setColor(QColor(0,255,0));
    painter->draw(QGL::Lines,yAxis.size());
    painter->clearAttributes();
    //yaxis@


Log in to reply
 

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