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. Is there a simple way to make a triangle in Qt3D?
Forum Updated to NodeBB v4.3 + New Features

Is there a simple way to make a triangle in Qt3D?

Scheduled Pinned Locked Moved Solved General and Desktop
qt3d
5 Posts 3 Posters 1.4k Views 3 Watching
  • 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.
  • M Offline
    M Offline
    Mitchal Dichter
    wrote on last edited by
    #1

    The examples from Qt I've found are for much more complex shapes in Qt3DExtras, which has quick ways to make cone, cube, cylinder, plane, sphere, and torus shapes, but not a triangle.

    For some context, I'm displaying very simple models of buildings in a Qt3DWindow. The software is for modeling buildings, such as the air quality in the building based on the HVAC system and how well sealed the building is. Below is an example building geometry for a Small Office representative building modified from a model created by Pacific Northwest National Laboratory (PNNL).

    alt text

    As you can see, these models have relatively few triangles and are not computationally intensive to display.

    After much trial and error, I was able to create triangles, but it is reliant on setting QT3D_RENDERER to opengl. This wouldn't be a problem, except this doesn't work on macOS. In fact, the Qt window crashes.

    I would prefer to use the new RHI rendering backend in Qt 6, which I'm sure is a whole lot more robust than what I cobbled together.

    So does anyone know how to make a triangle in Qt3D that is as simple and reliable as the cone, cube, cylinder, plane, sphere, and torus shapes in Qt3DExtras?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      While a bit old, I think this thread might help you get started.

      Just in case, Qt3D is being deprecated in favor of QtQuick3D so you might want to take a look at it before going further.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mitchal Dichter
        wrote on last edited by Mitchal Dichter
        #3

        Well that explains it. If Qt3D is being deprecated, it's better to switch to Qt Quick 3D. Part of the reason I used Qt3D was because there were a lot more examples online, which makes sense since it's older.

        Just a little searching of Qt Quick 3D showed support for Metal 1.2 or higher, which is what macOS 15 Sequoia uses. I think I found an example already for making a triangle in Qt Quick 3D.

        I only use cylinders, spheres, and triangles in the 3D viewer, and I'm sure Qt Quick 3D will have those too. As long as Qt Quick 3D can handle dynamically generated vertices from the user changing the building geometry while the application is open, Qt Quick 3D should work just fine.

        I'll post again when I get something working, or get stuck.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mitchal Dichter
          wrote on last edited by Mitchal Dichter
          #4

          To follow up, Qt3D is deprecated, but there is still some maintenance going on. OpenGL is still supported on Windows 11, so that shouldn't be a problem for years since so many windows applications rely on OpenGL, and will continue to rely on it.

          Future software with 3D content in Qt should use Direct3D, Metal, and Vulkan for Windows, macOS, and Ubuntu and stay away from OpenGL. I hope Qt will always design Qt Quick 3D to abstract these away from the user.

          I was surprised to find that there are built in meshes in Qt Quick 3D for cube, cone, sphere, cylinder, and rectangle, but not a triangle. This is similar to Qt3D, which has an easy way to make a torus, but not a triangle.
          https://www.qt.io/product/qt6/qml-book/ch12-qtquick3d-basics#the-built-in-meshes

          A major problem for Qt applications when OpenGL is no longer available, like on macOS already, is Qt3D is available under the GNU LGPL and GPL, but Qt Quick 3D is only available under the GNU GPL and not the GNU LGPL. Changing from the GNU LGPL to the GNU GPL will be fundamentally incompatible for a lot of software.

          One last thing is Qt Quick 3D is meant to use QML to define stuff, which is really different from Qt3D defining stuff in code.

          Conclusion
          I don't understand what the intended use case of 3D content in Qt is. Qt for purely 2D stuff seems fine, but 3D doesn't seem like the best choice for any application. From basic CAD programs, where the user values easy high level programming at the expense of low quality 3D content, to things like Blender and video games, which prioritize high quality 3D content at the expense of very difficult low level programming, the 3D ecosystem of Qt doesn't seem to fit into either of those extremes, nor any application in between.

          Making simple 3D stuff in Qt requires a lot of difficult low level programming, and I can't imagine creating high quality 3D content using Direct3D, Metal, or Vulkan through Qt would be easier than working directly with Direct3D, Metal, and Vulkan and skipping Qt altogether.

          If I do end up including a simple CAD model viewer that I want to work on Windows, macOS, and Ubuntu, I'd rather take my 3D triangles, project them onto a 2D view, and then simulate panning, rotating, and zooming in 3D by capturing mouse events and updating the projection. I'm sure the code would be a horrible embarrassment for a modest number of triangles, but it would work well enough when there's on the order of hundreds of planar polygons.

          Pl45m4P 1 Reply Last reply
          2
          • M Mitchal Dichter has marked this topic as solved on
          • M Mitchal Dichter

            To follow up, Qt3D is deprecated, but there is still some maintenance going on. OpenGL is still supported on Windows 11, so that shouldn't be a problem for years since so many windows applications rely on OpenGL, and will continue to rely on it.

            Future software with 3D content in Qt should use Direct3D, Metal, and Vulkan for Windows, macOS, and Ubuntu and stay away from OpenGL. I hope Qt will always design Qt Quick 3D to abstract these away from the user.

            I was surprised to find that there are built in meshes in Qt Quick 3D for cube, cone, sphere, cylinder, and rectangle, but not a triangle. This is similar to Qt3D, which has an easy way to make a torus, but not a triangle.
            https://www.qt.io/product/qt6/qml-book/ch12-qtquick3d-basics#the-built-in-meshes

            A major problem for Qt applications when OpenGL is no longer available, like on macOS already, is Qt3D is available under the GNU LGPL and GPL, but Qt Quick 3D is only available under the GNU GPL and not the GNU LGPL. Changing from the GNU LGPL to the GNU GPL will be fundamentally incompatible for a lot of software.

            One last thing is Qt Quick 3D is meant to use QML to define stuff, which is really different from Qt3D defining stuff in code.

            Conclusion
            I don't understand what the intended use case of 3D content in Qt is. Qt for purely 2D stuff seems fine, but 3D doesn't seem like the best choice for any application. From basic CAD programs, where the user values easy high level programming at the expense of low quality 3D content, to things like Blender and video games, which prioritize high quality 3D content at the expense of very difficult low level programming, the 3D ecosystem of Qt doesn't seem to fit into either of those extremes, nor any application in between.

            Making simple 3D stuff in Qt requires a lot of difficult low level programming, and I can't imagine creating high quality 3D content using Direct3D, Metal, or Vulkan through Qt would be easier than working directly with Direct3D, Metal, and Vulkan and skipping Qt altogether.

            If I do end up including a simple CAD model viewer that I want to work on Windows, macOS, and Ubuntu, I'd rather take my 3D triangles, project them onto a 2D view, and then simulate panning, rotating, and zooming in 3D by capturing mouse events and updating the projection. I'm sure the code would be a horrible embarrassment for a modest number of triangles, but it would work well enough when there's on the order of hundreds of planar polygons.

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by
            #5

            @Mitchal-Dichter said in Is there a simple way to make a triangle in Qt3D?:

            working directly with Direct3D, Metal, and Vulkan and skipping Qt

            Even though this is a Qt Forum here and Qt is in fact a great framework, sometimes you better look for something else.
            In your case, if you plan to render everything directly, you could also pick an immediate GUI, like ImGUI together with a Vulkan (on mac through MoltenVK), D3D or OpenGL backend.
            Fee free to post some updates on this or showcase your approach later :)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0

            • Login

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