Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D and QGeometryData
Forum Updated to NodeBB v4.3 + New Features

Qt3D and QGeometryData

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roeber
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ceora
      wrote on last edited by
      #2

      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@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved