Importing objects in Qt3D doesn't work but the

2020-04-20 21:30发布

问题:

I have a Qt3D application which imports STL file formats:

m_sceneLoaderEntity = new Qt3DCore::QEntity();
m_sceneLoaderEntity->setObjectName("New imported entity");

Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(m_sceneLoaderEntity);

sceneLoader->setSource(fileUrl); // fileUrl is input

m_sceneLoaderEntity->addComponent(sceneLoader);

My application builds and runs without any problem with Qt 5.9.0, 5.9.1, 5.9.2, 5.9.3 and 5.9.4. So far so good.

My application build fine with Qt 5.9.5, 5.9.6 and Qt 5.11.0, but when runs, it cannot import STL files and does NOT give any error message! Can anybody give me a hint?


I understand that Qt3D uses assimp to import STL files. I tried to replace Qt 5.11.0 assimp dynamic library, i.e. libassimpsceneimport.so, with that of Qt 5.9.4, but it didn't work:

m3g1dd@linux:~/Qt5.11.0/5.11.0/gcc_64/plugins/sceneparsers> ls -lhrtci
total 17M
1613482572 -rwxrwxr-x 1 m3g1dd m3g1dd 172K Jun 10 08:41 libgltfsceneimport.so
1613482571 -rwxrwxr-x 1 m3g1dd m3g1dd 226K Jun 10 08:41 libgltfsceneexport.so
1613596422 -rwxr-xr-x 1 m3g1dd m3g1dd 6.8M Oct  8 10:00 libassimpsceneimport.so.Qt5.9.4
1613482570 -rwxrwxr-x 1 m3g1dd m3g1dd 9.8M Oct  8 10:00 libassimpsceneimport.so

回答1:

I downloaded and installed Qt 5.11.2 and my STL import code works fine as show below. But the imported STL has its Ambient, Diffuse and Specular colors set to white by default, which I thinks is related to an issue of assimp library mentioned on these:

https://bugreports.qt.io/browse/QTBUG-69385

https://github.com/assimp/assimp/issues/2059



标签: c++ qt qt3d