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. Loading Custom mesh QT 3D
Forum Updated to NodeBB v4.3 + New Features

Loading Custom mesh QT 3D

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 643 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.
  • J Offline
    J Offline
    JVRS
    wrote on last edited by
    #1

    Hello,
    I'm trying to load a custom mesh with an OBJ file that i have in my computer. I used the example project from QT 3d Basic shapes c++ and tried to replace the sphere by a custom mesh, the problem is that the selected mesh doesn't load.
    0_1529403330569_Captura de ecrã de 2018-06-19 11-14-42.png

    Where is what i have:

        QUrl url;
        url.setPath("/home/jvrs/ProjetosQT/3dviewer/Triss_h20.obj");
    
        Qt3DRender::QMesh *m_mesh = new Qt3DRender::QMesh();
        m_mesh->setSource(url);
    
        // Sphere shape data
    //    Qt3DExtras::QSphereMesh *sphereMesh = new Qt3DExtras::QSphereMesh();
    //    sphereMesh->setRings(20);
    //    sphereMesh->setSlices(20);
    //    sphereMesh->setRadius(2);
    
        // Sphere mesh transform
        Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform();
    
        sphereTransform->setScale(1.1f);
        sphereTransform->setTranslation(QVector3D(-0.0f, -0.0f, 0.0f));
    
        Qt3DExtras::QPhongMaterial *sphereMaterial = new Qt3DExtras::QPhongMaterial();
        sphereMaterial->setDiffuse(QColor(QRgb(0xa69929)));
    
        // Sphere
        m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity);
        m_sphereEntity->addComponent(m_mesh);
        m_sphereEntity->addComponent(sphereMaterial);
        m_sphereEntity->addComponent(sphereTransform);
    

    Here the file i want to load is located at /home/jvrs/ProjetosQT/3dviewer/Triss_h20.obj, which is not the same path where the application is.
    Best Regards,
    Joaquim

    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