Back of 3d model appears transparent in qt 5.7
-
Hi All!
I have created a sample to load 3d models. I am able to load the model.
However, when I rotate the model, the back appears to be transparent and dark.
How do I fix this?Here is the code,
int main(int ac, char **av) { QApplication app(ac, av); Qt3DExtras::Qt3DWindow view; view.defaultFramegraph()->setClearColor(QColor("#9E9D9D")); // 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.04f, 1.0f, 0.0f)); camera->setPosition(QVector3D(0.0f, 2.5f, 2.1f)); 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); Qt3DRender::QDirectionalLight *light = new Qt3DRender::QDirectionalLight(); light->setColor(Qt::white); light->setIntensity(1.0f); light->setWorldDirection(QVector3D(0.0f, -0.5f, -1.0f)); SceneWalker sceneWalker(sceneLoader); QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, &sceneWalker, &SceneWalker::onStatusChanged); sceneLoaderEntity->addComponent(sceneLoader); sceneLoaderEntity->addComponent(light); QStringList args = QCoreApplication::arguments(); QUrl sourceFileName; if (args.count() <= 1) { QWidget *container = new QWidget(); QFileDialog dialog; dialog.setFileMode(QFileDialog::AnyFile); sourceFileName = dialog.getOpenFileUrl(container, QStringLiteral("Open a scene file")); } else { sourceFileName = QUrl::fromLocalFile(args[1]); } if (sourceFileName.isEmpty()) return 0; sceneLoader->setSource(sourceFileName); view.setRootEntity(sceneRoot); view.show(); return app.exec(); }
I am using qt 5.7 on windows. I have followed assimp-cpp sample of qt.