Search code examples
c++qtqt3d

How can I access the entity tree created by QSceneLoader?


I am trying to access the geometry and material of a mesh loaded with QSceneLoader, but I dont know how.

The doc says

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.

but it doesnt say how to access that tree. The .component() function seems to be a solution, but it needs an entity name wich I dont have.

I found a file with tests for QSceneLoader using the .component() function (here)[https://code.woboq.org/qt5/qt3d/tests/auto/render/qsceneloader/tst_qsceneloader.cpp.html ], but they seem to build the entity tree manually or something.

I could use the Qmesh Class, but QSceneLoader supports far more file formats including fbx and glTF, wich I want to support.

If this is not possible, an alternative is also appreciated.


Solution

  • I finally found a working solution in this post:

    Qt3d Using QSceneLoader with qt 5.8

    The SceneWalker does exactly what i need.