Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How load .obj into QMesh via c++
QtWS25 Last Chance

How load .obj into QMesh via c++

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3d qmeshload mesh
4 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Traldera
    wrote on 29 Nov 2019, 14:39 last edited by
    #1

    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 :)

    B 1 Reply Last reply 29 Nov 2019, 20:51
    0
    • T Traldera
      29 Nov 2019, 14:39

      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 :)

      B Offline
      B Offline
      beecksche
      wrote on 29 Nov 2019, 20:51 last edited by beecksche
      #2

      @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.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Traldera
        wrote on 30 Nov 2019, 16:20 last edited by
        #3

        @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 :)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AhmedAhmedEG
          wrote on 7 Feb 2024, 17:01 last edited by
          #4

          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.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved