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. QtQuick3D scene node geometry
QtWS25 Last Chance

QtQuick3D scene node geometry

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 3.5k Views
  • 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.
  • A Offline
    A Offline
    AlricDoRei
    wrote on last edited by
    #1

    Using QtQuick3D/Qt3D module, got one problem with getting geometry data from scene nodes.
    I am creating a simple scene with one scene node(cube mesh in this example):
    @ QGLBuilder builder;
    builder << QGLCube();
    sceneNode = builder.finalizedSceneNode();@

    I am trying to use this for vertices, but it doesn't work. It is an infinite loop, which provides wrong data (example: Iter->x() = 4.2039e-44, Iter->y() = 2.27723e-39 and Iter->z() = 861307000.0).
    @ QVector3DArray::iterator Iter;
    for(Iter=sceneNode->geometry().vertices().begin(); Iter!=sceneNode->geometry().vertices().begin(); Iter=Iter.Next())
    {
    //Taking coordinates from each vertex
    }@
    How I can get all data from scene node(vertices,normals,texture coordinates, etc)?
    I need to get every x,y,z coordinate and write all collected data to file.

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

      If you've copied and pasted that code verbatim, you've got a typo in there: you mean to say .end() for the second clause in the for statement, and instead you've repeated begin().
      e.g. @Iter!=sceneNode->geometry().vertices().begin()@ should be
      @Iter!=sceneNode->geometry().vertices().end()@
      (I assume).

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kmedghaith
        wrote on last edited by
        #3

        Hi,
        I think that when you do a
        @builder.finalizedSceneNode()@
        the data is uploaded to the card and
        @sceneNode->geometry()@
        is empty.

        Try to use nested nodes to build your scene like this documentation example :
        @
        QGLBuilder builder;
        builder << CarWheel(5.0f); // some car wheel geometry
        QGLSceneNode * wheel = builder.finalizedSceneNode();
        QGLSceneNode * frontLeft = new QGLSceneNode(m_sceneRoot);
        frontLeft->addNode(wheel);
        frontLeft->setPosition(QVector3D(1.0f, 2.0f, 0.0f));
        QGLSceneNode * frontRight = new QGLSceneNode(m_sceneRoot);
        frontRight->addNode(wheel);
        frontRight->setPosition(QVector3D(-1.0f, 2.0f, 0.0f));
        QGLSceneNode * backLeft = new QGLSceneNode(m_sceneRoot);
        backLeft->addNode(wheel);
        backLeft->setPosition(QVector3D(1.0f, -2.0f, 0.0f));
        QGLSceneNode * backRight = new QGLSceneNode(m_sceneRoot);
        backRight->addNode(wheel);
        backRight->setPosition(QVector3D(-1.0f, -2.0f, 0.0f));
        @

        Regards.
        G.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlricDoRei
          wrote on last edited by
          #4

          [quote author="kmedghaith" date="1323764400"]Hi,
          I think that when you do a
          @builder.finalizedSceneNode()@
          the data is uploaded to the card and
          @sceneNode->geometry()@
          is empty.

          Try to use nested nodes to build your scene like this documentation example :
          @
          QGLBuilder builder;
          builder << CarWheel(5.0f); // some car wheel geometry
          QGLSceneNode * wheel = builder.finalizedSceneNode();
          QGLSceneNode * frontLeft = new QGLSceneNode(m_sceneRoot);
          frontLeft->addNode(wheel);
          frontLeft->setPosition(QVector3D(1.0f, 2.0f, 0.0f));
          QGLSceneNode * frontRight = new QGLSceneNode(m_sceneRoot);
          frontRight->addNode(wheel);
          frontRight->setPosition(QVector3D(-1.0f, 2.0f, 0.0f));
          QGLSceneNode * backLeft = new QGLSceneNode(m_sceneRoot);
          backLeft->addNode(wheel);
          backLeft->setPosition(QVector3D(1.0f, -2.0f, 0.0f));
          QGLSceneNode * backRight = new QGLSceneNode(m_sceneRoot);
          backRight->addNode(wheel);
          backRight->setPosition(QVector3D(-1.0f, -2.0f, 0.0f));
          @

          Regards.
          G.[/quote]

          Using this:
          @ QGeometryData m_sceneRoot;
          QGLBuilder builder;
          builder << QGLCube(5.0f); // some car wheel geometry
          QGLSceneNode * wheel = builder.finalizedSceneNode();
          QGLSceneNode * frontLeft = new QGLSceneNode(m_sceneRoot);
          frontLeft->addNode(wheel);
          frontLeft->setPosition(QVector3D(1.0f, 2.0f, 0.0f));
          QGLSceneNode * frontRight = new QGLSceneNode(m_sceneRoot);
          frontRight->addNode(wheel);
          frontRight->setPosition(QVector3D(-1.0f, 2.0f, 0.0f));
          QGLSceneNode * backLeft = new QGLSceneNode(m_sceneRoot);
          backLeft->addNode(wheel);
          backLeft->setPosition(QVector3D(1.0f, -2.0f, 0.0f));
          QGLSceneNode * backRight = new QGLSceneNode(m_sceneRoot);
          backRight->addNode(wheel);
          backRight->setPosition(QVector3D(-1.0f, -2.0f, 0.0f));
          if(!wheel->geometry().vertices().isEmpty())
          QMessageBox::information(this,"Info","Not Empty",QMessageBox::Ok);@

          Geometry data is still empty.

          It is not empty when I use:
          @ QGLBuilder builder;
          QGeometryData triangle;
          QVector3D a(2, 2, 0);
          QVector3D b(-2, 2, 0);
          QVector3D c(0, -2, 0);
          triangle.appendVertex(a, b, c);

          // When adding geometry, QGLBuilder automatically creates lighting normals
          builder << triangle;
          
          // obtain the scene from the builder
          sceneNode = builder.finalizedSceneNode();
          if(!triangle.vertices().isEmpty())
                  QMessageBox::information(this,"Info","Not Empty",QMessageBox::Ok);@
          

          How I can draw the number of vertices and normals when loading 3d model from .obj or .3ds file?
          I am using
          @QGLAbstractScene *abstr = QGLAbstractScene::loadScene(...);@
          then:
          @sceneNode = abstr->mainNode();@
          3D model is loading without any problems, but sceneNode->geometry is still empty.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            voondo
            wrote on last edited by
            #5

            I know this post is a bit old but I'm encountering the same problem, did you find a solution ?

            1 Reply Last reply
            0
            • V Offline
              V Offline
              voondo
              wrote on last edited by
              #6

              Replying to myself : as explained here http://permalink.gmane.org/gmane.comp.lib.qt.3d/126 :

              bq. Very often when you build an object it has more than one scene node in it, hence the builder returns always a single root node, under which are the other nodes containing the actual geometry.

              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