Important: Please read the Qt Code of Conduct -

Loading OBJ Files from Resource

  • I have a QWidgets application which loads an OBJ file from a resource into a Qt3DRender::QMesh instance.

    When running the application via QtCreator in debug and release mode, the OBJ mesh is displayed correctly in my QWidget (via the Qt3DExtras::Qt3DWindow).

    However, if I run the application in its installation directory on a local machine (i.e. C:\Program Files\MyApp\MyApp.exe) then the OBJ files are not loaded and the QWidget is empty.

    I've ensured that all the relevant resource-related files are part of the installation image and I've also copied across the OBJ files to the installation dir. Unfortunately none of this solves the issue.

    What could I be missing?

    For reference, the code for creating and loading the 3D stuff is as follows:

    // Create the view
    m_view = new Qt3DExtras::Qt3DWindow();
    // Create the container widget
    m_container = QWidget::createWindowContainer(m_view);
    // Add the container to the layout
    // Create a root entity
    m_root = new Qt3DCore::QEntity;
    // Update scene camera
    m_camera = m_view->camera();
    m_camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    m_camera->setPosition(QVector3D(0, 0, 8.0f));
    m_camera->setUpVector(QVector3D(0, 1, 0));
    m_camera->setViewCenter(QVector3D(0, 0, 0));
    // Set up the scene lighting
    m_light = new Qt3DCore::QEntity(m_root);
    m_point = new Qt3DRender::QPointLight(m_light);
    m_lightTransform = new Qt3DCore::QTransform(m_light);
    m_model = new Qt3DCore::QEntity(m_root);
    m_mesh = new Qt3DRender::QMesh();
    m_material = new Qt3DExtras::QPhongMaterial;
    m_transform = new Qt3DCore::QTransform;
    m_transform->setRotation(QQuaternion::fromEulerAngles(0.0, 0.0, 0.0));

  • @webzoid said in Loading OBJ Files from Resource:

    C:\Program Files\MyApp\MyApp.exe

    I guess you are on windows. did you use windeployqt.exe to build your installation folder?

  • @VRonin Indeed, I did.

  • Lifetime Qt Champion


    You might be missing the Qt3DAnimation .dll. There's a patch in review for windeployqt for that.

  • @SGaist Unfortunately this doesn't solve the issue.

  • Lifetime Qt Champion

    Do you have the geometryloaders, renderplugins and sceneparsers plugins deployed ?

  • @SGaist I had the renderplugins and sceneparsers but not the geometryloaders.

    Having now copied across the relevant files into a geometryloaders directory, this now works perfectly.

    Thank you!

Log in to reply