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. How to load *.ply content properly
Forum Updated to NodeBB v4.3 + New Features

How to load *.ply content properly

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.6k 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.
  • C Offline
    C Offline
    cangooroo3D
    wrote on last edited by cangooroo3D
    #1

    Hello everybody,

    i am quite new to work with 3D content in qt and i got a question regarding the proper loading of *.ply formats. I created a small example, based on the basicshapes-example from qt, just loading my personal .ply file, instead of using the predefined 3D-meshes.

    // code
    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);
    Qt3DExtras::Qt3DWindow *view = new Qt3DExtras::Qt3DWindow();
    view->defaultFrameGraph()->setClearColor(QColor(QRgb(0x4d4d4f)));
    QWidget *container = QWidget::createWindowContainer(view);
    QSize screenSize = view->screen()->size();
    container->setMinimumSize(QSize(200, 100));
    container->setMaximumSize(screenSize);

    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    hLayout->addWidget(container, 1);
    
    widget->setWindowTitle(QStringLiteral("Basic shapes"));
    
    Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect;
    view->registerAspect(input);
    
    // Root entity
    Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity();
    
    // Camera
    Qt3DRender::QCamera *cameraEntity = view->camera();
    
    cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 100000.0f);
    cameraEntity->setPosition(QVector3D(-30000, 0, 20000.0f));
    cameraEntity->setUpVector(QVector3D(0, 0, 1));
    cameraEntity->setViewCenter(QVector3D(0, 0, 10000));
    
    Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(rootEntity);
    Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight(lightEntity);
    light->setColor("white");
    light->setIntensity(1);
    lightEntity->addComponent(light);
    Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity);
    lightTransform->setTranslation(cameraEntity->position());
    lightEntity->addComponent(lightTransform);
    
    //Loading .ply data
    QUrl data = QUrl::fromLocalFile("demo_data.ply");
    qDebug() << data << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();
    
    Qt3DRender::QMesh *bodyMesh = new Qt3DRender::QMesh();
    bodyMesh->setMeshName("bodyMesh");
    bodyMesh->setSource(data);
    
    Qt3DCore::QTransform *bodyTransform = new Qt3DCore::QTransform;
    bodyTransform->setScale3D(QVector3D(10.0, 10.0, 10.0));
    
    Qt3DExtras::QPhongMaterial *bodyMaterial = new Qt3DExtras::QPhongMaterial();
    bodyMaterial->setDiffuse(QColor(QRgb(0x928327)));
    
    Qt3DCore::QEntity *plyEntity = new Qt3DCore::QEntity(rootEntity);
    plyEntity->addComponent(bodyMesh);
    plyEntity->addComponent(bodyMaterial);
    plyEntity->addComponent(bodyTransform);
    
    // Set root object of the scene
    view->setRootEntity(rootEntity);
    
    // Show window
    widget->show();
    widget->resize(1200, 800);
    
    return app.exec();
    

    }

    This works fine on my machine, in Visual Studio as well as using the executable directly. Now I want to take this small programm to another windows machine. The original basicshapes example runs perfectly fine on the other machine, my version does not. The 3D content is not loaded, the Qt3DRender::QMesh::Status function returns a 3 (An error occurred while loading the mesh). So it seems to be a problem on loading the *.ply file, which is stored in the same folder as the executable. The line

    qDebug() << data << data.isValid() << data.toLocalFile() << QFileInfo(data.toLocalFile()).exists() << data.fileName();

    says "true" for the QFileInfo(data.toLocalFile()).exists() part.

    So I don't know, why the 3D data cannot be loaded. Any suggestions? Any additional libs I need to add?

    Thanks a lot,

    c.

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

      Hi and welcome to devnet,

      Did you do a complete deployment of your application using windeployqt ? You might be missing some plugins otherwise.

      By the way, what version of Qt are you using ?

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

      C 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        Did you do a complete deployment of your application using windeployqt ? You might be missing some plugins otherwise.

        By the way, what version of Qt are you using ?

        C Offline
        C Offline
        cangooroo3D
        wrote on last edited by
        #3

        @SGaist Man, you saved my day. I didn't know this one and it completely worked so far. Thank's a lot!!

        1 Reply Last reply
        0
        • Pl45m4P Pl45m4 referenced this topic on

        • Login

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