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. PLY Object Does Not Show

PLY Object Does Not Show

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 1.9k Views 2 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.
  • O Offline
    O Offline
    ofmrew
    wrote on last edited by
    #1

    I created a .ply file, which I tested with MeshLab, but does not display in Qt:

    int main(int argc, char *argv[])
    {
    QGuiApplication a(argc, argv);
    QUrl data = QUrl::fromLocalFile("/XXX/flyingwedge/flyingwedge.ply");
    qDebug() << data.fileName();
    Qt3DExtras::Qt3DWindow view;
    Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
    Qt3DCore::QEntity *flyingwedge = new Qt3DCore::QEntity(rootEntity);
    Qt3DRender::QMaterial *material = new Qt3DExtras::QMetalRoughMaterial(rootEntity);
    Qt3DRender::QMesh *flyingwedgeMesh = new Qt3DRender::QMesh;
    flyingwedgeMesh->setMeshName("FlyingWedge");
    flyingwedgeMesh->setSource(data);
    Qt3DCore::QTransform *flyingwedgeTransform = new Qt3DCore::QTransform;
    flyingwedgeTransform->setScale3D(QVector3D(10.0, 10.0, 10.0));
    Qt3DRender::QFrontFace *frontFace = new Qt3DRender::QFrontFace(rootEntity);
    frontFace->setDirection(Qt3DRender::QFrontFace::CounterClockWise);
    flyingwedge->addComponent(flyingwedgeMesh);
    flyingwedge->addComponent(material);
    flyingwedge->addComponent(flyingwedgeTransform);
    Qt3DRender::QCamera *camera = view.camera();
    camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    camera->setPosition(QVector3D(0, 0, 40.0f));
    camera->setViewCenter(QVector3D(0, 0, 0));
    view.setRootEntity(rootEntity);
    view.show();
    return a.exec();
    }
    Another program that is identical to this program shows a torus mesh object fine. What am I missing?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should add which version of Qt you are using and one which platform it is.

      Might be a silly question but are you sure of the path of your .ply file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        You should add which version of Qt you are using and one which platform it is.

        Might be a silly question but are you sure of the path of your .ply file ?

        O Offline
        O Offline
        ofmrew
        wrote on last edited by
        #3

        @SGaist Hello again.
        Linux Mint, At least version 5.9. It seems to find the file when I debug and I get no error message. Is there a way to determine that the ply file was read?

        The .ply file is:
        ply
        format ascii 1.0
        element vertex 5
        property float32 x
        property float32 y
        property float32 z
        element face 5
        property list uint8 int32 vertex_index
        end_header
        0 0 0
        10 5 0
        10 -5 0
        9 4 2
        9 -4 2
        3 0 4 3
        3 0 3 1
        4 4 2 1 3
        3 0 2 4
        3 0 1 2

        Anything else I can provide. I am at a loss at this point.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ofmrew
          wrote on last edited by
          #4

          Update. I suspect that the problem in with the URL. I added:

          QUrl data = QUrl::fromLocalFile("/home/XXX/flyingwedge/flyingwedge.ply");
          qDebug() << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();
          

          and got:

          true "/home/XXX/flyingwedge/flyingwedge.ply" false "flyingwedge.ply"
          QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

          Which says the file does not exist. I guess that @SGaist was correct. Any pointer to the correct way to specify the path for the URL will be greatly appreciated.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            ofmrew
            wrote on last edited by
            #5

            I moved the file up one level and it works. Why I do not know, but I am no longer stymied; I can proceed.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Glad you found a solution and thanks for sharing !

              Happy coding

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • O Offline
                O Offline
                ofmrew
                wrote on last edited by
                #7

                It is three years later and I returned to this project, but it no longer works. What has changed to make ply files no longer create the correct meshes. Is there an example of a program the works correctly when a ply mesh is imported? Thanks.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  You should consider providing a minimal compilable example showing the issue.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    ofmrew
                    wrote on last edited by
                    #9

                    This is similar to the one posted previously but shorter.

                    int main(int argc, char *argv[])
                    {
                        QGuiApplication a(argc, argv);
                        Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
                        Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity);
                        QUrl data = QUrl::fromLocalFile("/home/bobwilliams/flyingwedge.ply");
                        qDebug() << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();
                        QFileInfo info("/home/bobwilliams/triangle.ply");
                        qDebug() << info.exists();
                        Qt3DCore::QEntity *triangleEntity = new Qt3DCore::QEntity(rootEntity);
                        Qt3DRender::QMesh *triangleMesh = new Qt3DRender::QMesh;
                        triangleMesh->setMeshName("Triangle");
                        triangleMesh->setSource(data);
                        triangleEntity->addComponent(triangleMesh);
                        triangleEntity->addComponent(material);
                    
                        Qt3DExtras::Qt3DWindow view;
                        Qt3DRender::QCamera *camera = view.camera();
                        camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
                        camera->setPosition(QVector3D(0, 0, 40.0f));
                        camera->setViewCenter(QVector3D(0, 0, 0));
                    
                        view.setRootEntity(rootEntity);
                        view.show();
                        return a.exec();
                    }
                    

                    I get:
                    Starting /home/bobwilliams/build-untitled1-Desktop_Qt_5_8_0_GCC_64bit-Debug/untitled1...
                    true "/home/bobwilliams/flyingwedge.ply" true "flyingwedge.ply"
                    true
                    Qt3D.Core.Nodes: void Qt3DCore::QEntity::addComponent(Qt3DCore::QComponent*) Qt3DRender::QMesh(0x1516f10)
                    Qt3D.Core.Nodes: void Qt3DCore::QEntity::addComponent(Qt3DCore::QComponent*) Qt3DExtras::QPhongMaterial(0x1500000)
                    QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

                    Does that help. I just checked and I am on 5.8 but I cannot update to the latest 5.x version.

                    O 1 Reply Last reply
                    0
                    • O ofmrew

                      This is similar to the one posted previously but shorter.

                      int main(int argc, char *argv[])
                      {
                          QGuiApplication a(argc, argv);
                          Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
                          Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial(rootEntity);
                          QUrl data = QUrl::fromLocalFile("/home/bobwilliams/flyingwedge.ply");
                          qDebug() << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();
                          QFileInfo info("/home/bobwilliams/triangle.ply");
                          qDebug() << info.exists();
                          Qt3DCore::QEntity *triangleEntity = new Qt3DCore::QEntity(rootEntity);
                          Qt3DRender::QMesh *triangleMesh = new Qt3DRender::QMesh;
                          triangleMesh->setMeshName("Triangle");
                          triangleMesh->setSource(data);
                          triangleEntity->addComponent(triangleMesh);
                          triangleEntity->addComponent(material);
                      
                          Qt3DExtras::Qt3DWindow view;
                          Qt3DRender::QCamera *camera = view.camera();
                          camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
                          camera->setPosition(QVector3D(0, 0, 40.0f));
                          camera->setViewCenter(QVector3D(0, 0, 0));
                      
                          view.setRootEntity(rootEntity);
                          view.show();
                          return a.exec();
                      }
                      

                      I get:
                      Starting /home/bobwilliams/build-untitled1-Desktop_Qt_5_8_0_GCC_64bit-Debug/untitled1...
                      true "/home/bobwilliams/flyingwedge.ply" true "flyingwedge.ply"
                      true
                      Qt3D.Core.Nodes: void Qt3DCore::QEntity::addComponent(Qt3DCore::QComponent*) Qt3DRender::QMesh(0x1516f10)
                      Qt3D.Core.Nodes: void Qt3DCore::QEntity::addComponent(Qt3DCore::QComponent*) Qt3DExtras::QPhongMaterial(0x1500000)
                      QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

                      Does that help. I just checked and I am on 5.8 but I cannot update to the latest 5.x version.

                      O Offline
                      O Offline
                      ofmrew
                      wrote on last edited by
                      #10

                      @ofmrew I have egg on my face. I if you look at the .ply file you will see that I violated the rule that the vertices be in the range [-1 -1 -1] to [1 1 1]. Made the change and it worked.

                      1 Reply Last reply
                      2
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Glad you found out and thanks for sharing !

                        Since you have it working now, please mark your thread as solved using the "Topic Tools" button or the three dotted menu on the right of the answer you deem correct so that other forum users may know a solution has been found :-)

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        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