2

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
Florian Blume
  • 3,237
  • 17
  • 37
Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 1
    How do you set the file URL? Using `QUrl::fromLocalFile`? If you just pass the file URL as a string it won't work. Also, if the path is relative, call `.absolutePath()` on your URL object. Other than that it would be nice if you could provide a [minimally working example](https://stackoverflow.com/help/mcve), which should be easily creatable in your case - this would make it easier to solve your problem. – Florian Blume Oct 08 '18 at 08:04
  • @FlorianBlume Thanks. I'm passing `fileUrl` from `FileDialog` in QML to my C++ code. My URL object in C++ is of type `QUrl` and it doesn't have `.absolutePath() ` method, I'm not sure why. – Megidd Oct 08 '18 at 08:18
  • 1
    Well, if you use the `FileDialog`'s URL then you should be fine. I have a project setup that can load objects exactly your way. Can you somehow provide the object that you try to import so I can see if I can load it? – Florian Blume Oct 08 '18 at 08:42
  • @FlorianBlume Thanks. I'm using [this STL file](http://upload.wikimedia.org/wikipedia/commons/9/93/Utah_teapot_%28solid%29.stl) – Megidd Oct 08 '18 at 09:04
  • @FlorianBlume With regard to minimally working example, actually the whole project is available [here](https://github.com/qt-labs/qt3d-editor) and import method starts at [this line of code](https://github.com/qt-labs/qt3d-editor/blob/master/editorlib/src/editorsceneitemmodel.cpp#L616) – Megidd Oct 08 '18 at 09:07
  • 2
    Ok, well the file looks ok. I'll try to open it in the project, as well. – Florian Blume Oct 08 '18 at 09:12
  • 1
    @FlorianBlume The core of my problem is that: I'm trying to run [the project](https://github.com/qt-labs/qt3d-editor) with the latest Qt version i.e. 5.11, but unfortunately the import functionality only works with Qt 5.9.4 and lower! I cannot figure out why – Megidd Oct 08 '18 at 09:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181469/discussion-between-florian-blume-and-user3405291). – Florian Blume Oct 08 '18 at 10:24

1 Answers1

0

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

Imported STL

Megidd
  • 7,089
  • 6
  • 65
  • 142