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 :)
-
@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 :) -
Hi from the future! to anyone still facing this problem, basically the QMesh will only load the file and create geometry when it gets placed in a scene in a node and the scene window is shown on the screen, then the QMesh will load the geometry, also the status will have a wrong naming of "Status.ReadCorruptData" which is the same as "Status.Ready", both have the value 2, that status is not even mentioned in the documentation, so it's probably a faulty naming.