Loading OBJ Files from Resource
-
I have a
QWidgets
application which loads an OBJ file from a resource into aQt3DRender::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(); m_view->defaultFrameGraph()->setClearColor(bg); // Create the container widget m_container = QWidget::createWindowContainer(m_view); // Add the container to the layout this->layout()->addWidget(m_container); // 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_point->setColor("silver"); m_point->setIntensity(1); m_light->addComponent(m_point); m_lightTransform = new Qt3DCore::QTransform(m_light); m_lightTransform->setTranslation(m_camera->position()); m_light->addComponent(m_lightTransform); m_model = new Qt3DCore::QEntity(m_root); m_mesh = new Qt3DRender::QMesh(); m_mesh->setSource(QUrl("qrc:/Resources/Models/MyModel.obj")); m_material = new Qt3DExtras::QPhongMaterial; m_material->setDiffuse(QColor(Qt::darkGray)); m_transform = new Qt3DCore::QTransform; m_transform->setScale(1.0); m_transform->setRotation(QQuaternion::fromEulerAngles(0.0, 0.0, 0.0)); m_model->addComponent(m_mesh); m_model->addComponent(m_transform); m_model->addComponent(m_material); m_view->setRootEntity(m_root);
-
Hi,
You might be missing the Qt3DAnimation .dll. There's a patch in review for
windeployqt
for that. -
Do you have the
geometryloaders
,renderplugins
andsceneparsers
plugins deployed ?