Can I reload/refresh 3d model on mouse click?
Solved
General and Desktop
-
Hi All,
I am developing a 3d model loader in Qt 5.7 on Windows.
I have been successful in loading the model. The model has jpg textures.
I want to be able to reload the model (say, on a button click), whenever I replace the texture image on disk.Here is the code that loads the model,
ASErr RenderView() { view->setVisible(false); view->defaultFramegraph()->setClearColor(Qt::black); // Root entity Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // Scene Camera Qt3DRender::QCamera *camera = view->camera(); camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); camera->setAspectRatio(view->width() / view->height()); camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); camera->setViewCenter(QVector3D(0.0f, 1.1f, 0.0f)); camera->setPosition(QVector3D(0.0f, 2.5f, 2.0f)); camera->setNearPlane(0.001f); camera->setFarPlane(100.0f); // For camera controls Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(sceneRoot); camController->setCamera(camera); // Scene loader Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot); Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity); sceneWalker = new SceneWalker(sceneLoader); QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, sceneWalker, &SceneWalker::onStatusChanged); sceneLoaderEntity->addComponent(sceneLoader); std::string url = GetUrl(); QUrl sourceFileName(url.c_str()); if (sourceFileName.isEmpty()) return 0; sceneLoader->setSource(sourceFileName); view->setRootEntity(sceneRoot); view->show(); return 0; }
Here, view is a pointer to Qt3DExtras::Qt3DWindow.
I have followed the assimp-cpp sample from Qt.How can I refresh my model on button click so that it refreshes the textures?
-