Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How load .obj into QMesh via c++



  • I am trying to learn Qt3D more specifically the 3D API classes that can work in tandem with opengl for scene creation and management.

    However i seem to be stuck at the most basic stage; how to load models from files.

    My actual aim here is to get a pipeline in place where i can load files into a class, then pull out data to place into VAO/VBOs for rendering in my custom rendering pipeline (openGL). After following the opengl tutorials i can easily render things generated completely by code, but I'm having a lot of trouble understanding Qt's 3D stuff, its very different from Unity/UE4 which is my background. Am i even correct in thinking i can load via QMesh then pull out the attribute data from that?

    Anyway, the actual loading issue, I've tried the following:

    	mesh = new Qt3DRender::QMesh();
    	QUrl src {"qrc:///CubeLoadTest/cube.obj"};// did not work
    	QUrl src{":/CubeLoadTest/cube.obj"};//did not work
    	mesh->setSource(src);
    

    After this QMesh::Status remains at None.

    Any help or direction to learning resource would be much appreciated :)



  • @Traldera

    Is the cube.obj a file from the examples or your one of your own file?

    There are some Qt3D Examples which includes .obj files.



  • @beecksche
    Its one of my own, its just a simple cube with UVs made in blender, nothing fancy at all - i seriously doubt the asset is the problem unless Qt has some weird requirements?
    Is the code snipped i posted actually correct then? I could try one of the .obj files from the examples, although i want to keep this on the c++ side (ie no QML)
    Thanks again :)


Log in to reply