Hi,
I use Qt5.8 Qt3D2 C++ API and load a 3d file with Qt3DRender::sceneLoader (e.g. ply or .obj).
I can see it in my view; works fine.

However, now I want to read (copy, modify) the geometry, materials etc.
that come with this loaded object.
Unfortunately, in the entity tree m_rootEntity->components()
there appears only one component with the url as referrer
There is no component with any geometry and/or material, etc.
Same happens, if I explicitly look for entities, buffers, materials, etc by casting via
"myEntity->findChildren<QGeometryRenderer *>()" and similar.

All this works fine, when I create my own mesh via vertexBuffers and indexBuffers attributes, add material etc.

I spent days now investigating this with loaded objects.
Also tried mesh->setSource(url) but same result, except that I even don't get it visible in the view.

I dont know how to access the internals of the model (geometry, material, transformations).
In the sparse docu of scene loader it is indicated that:

"Given a 3D source file, the Qt3DRender::QSceneLoader will try to parse it and build a tree of Qt3DCore::QEntity objects with proper Qt3DRender::QGeometryRenderer, Qt3DCore::QTransform and Qt3DRender::QMaterial components."


=> How? Where is this tree? There have been some similar questions on stackoverflow as well. No answer yet.

Is the tree deleted after transferring it to the graphics card?
It also does not matter whether I access the entity tree before or after show() although it seems that reading is triggered only the time the show() command is executed.

Here is the code snippets I use:

mainwindow.h

class MainWindow : public QMainWindow
{
Q_OBJECT
public: ...
private:
         Qt3DExtras::Qt3DWindow *view = new Qt3DExtras::Qt3DWindow();
         Qt3DCore::QEntity *m_meshEntity = new Qt3DCore::QEntity(nullptr);;
         Qt3DCore::QEntity *m_rootEntity;

...
mainwindow.cpp
...
         m_meshEntity = new Qt3DCore::QEntity();
         m_rootEntity = new Qt3DCore::QEntity();

Qt3DRender::QSceneLoader *loader = new Qt3DRender::QSceneLoader(m_meshEntity);

         QString fileName = "../3dModels/globe2.obj";
         QUrl url = QUrl::fromLocalFile(fileName);

         QObject::connect(loader, &Qt3DRender::QSceneLoader::statusChanged,
this, [](Qt3DRender::QSceneLoader::Status s){ qDebug() << s; return false;});


         loader->setSource(url);

         m_meshEntity->addComponent(loader);

         m_meshEntity->setParent(m_rootEntity);
         view->setRootEntity(m_rootEntity);
         view->show();


Any ideas? I hope I have just missed something...


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to