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. A weird bug? Why is there no spatial depth in my 3D scene?
Forum Updated to NodeBB v4.3 + New Features

A weird bug? Why is there no spatial depth in my 3D scene?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqt 5.7
29 Posts 5 Posters 14.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.
  • kshegunovK kshegunov

    Honestly, I'd be surprised if there was a difference between using cmake and qmake. And to be completely frank I don't know what might be the cause of the problem. My current best advice is to either bring the question to the mailing list, where hopefully one of the developers of Qt3D will pick it up (but after you check there's no open bugs on this), or try and wait for some other suggestion from other of our members here.

    Kind regards.

    F Offline
    F Offline
    Finn
    wrote on last edited by Finn
    #18

    I tried it on my private MacBook Pro with MacOS Sierra 10.12.1 and installed Qt5 via brew install qt5. The result is still the same. What on earth can be the reason that it is working for you guys and not for me? Do I need some other libraries or build options?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #19

      Sorry, as a noobie, I can't offer any insight, but I ran the code, and I'm getting the same as Finn. I'm on Qt 5.7 on Win 10.

      alt text

      Could it be CPU or GPU related? I'm on a 6coreAMD machine.

      F 1 Reply Last reply
      1
      • ? A Former User

        Sorry, as a noobie, I can't offer any insight, but I ran the code, and I'm getting the same as Finn. I'm on Qt 5.7 on Win 10.

        alt text

        Could it be CPU or GPU related? I'm on a 6coreAMD machine.

        F Offline
        F Offline
        Finn
        wrote on last edited by
        #20

        @Ian-Bray Thank you for your reply, this was very helpful! I would suggest that someone more experienced than me should report this as a bug.

        kshegunovK 1 Reply Last reply
        0
        • F Finn

          @Ian-Bray Thank you for your reply, this was very helpful! I would suggest that someone more experienced than me should report this as a bug.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #21

          @Finn said in A weird bug? Why is there no spatial depth in my 3D scene?:

          this was very helpfu

          Indeed, it was.

          I would suggest that someone more experienced than me should report this as a bug.

          There's nothing to it, you just describe the problem and attach the screenshots and the code from upstairs as a minimal reproducible example (preferably with a simple project file). As for the problem itself it may be helpful if we can squeeze some more information out. I may be running a newer (or older) version of Qt compared to you. Can you both state the full version (with patch number). I'm running Qt 5.7.2 built from git some time ago on a Linux 4.8.11 kernel.

          Read and abide by the Qt Code of Conduct

          ? 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @Finn said in A weird bug? Why is there no spatial depth in my 3D scene?:

            this was very helpfu

            Indeed, it was.

            I would suggest that someone more experienced than me should report this as a bug.

            There's nothing to it, you just describe the problem and attach the screenshots and the code from upstairs as a minimal reproducible example (preferably with a simple project file). As for the problem itself it may be helpful if we can squeeze some more information out. I may be running a newer (or older) version of Qt compared to you. Can you both state the full version (with patch number). I'm running Qt 5.7.2 built from git some time ago on a Linux 4.8.11 kernel.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #22

            @kshegunov

            I'm using qt-opensource-windows-x86-mingw530-5.7.0 on Win 10, if I get a chance I'll try it on Linux later.

            1 Reply Last reply
            1
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #23

              Sorry, this isn't going to be helpful. Just to report that both slabs of code crashed on Qt 5.7.1 GCC 64 on latest Mint.
              Possibly due to lack of RAM. Not sure.

              F 1 Reply Last reply
              0
              • ? A Former User

                Sorry, this isn't going to be helpful. Just to report that both slabs of code crashed on Qt 5.7.1 GCC 64 on latest Mint.
                Possibly due to lack of RAM. Not sure.

                F Offline
                F Offline
                Finn
                wrote on last edited by
                #24

                @Ian-Bray With Qt 5.7.1 the example works now perfectly fine for me.

                kshegunovK ? 2 Replies Last reply
                0
                • F Finn

                  @Ian-Bray With Qt 5.7.1 the example works now perfectly fine for me.

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #25

                  Then probably it's a bug that was fixed with the patch version in the meantime. Cheers!

                  Read and abide by the Qt Code of Conduct

                  ? 1 Reply Last reply
                  0
                  • F Finn

                    @Ian-Bray With Qt 5.7.1 the example works now perfectly fine for me.

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #26

                    @Finn Thanks Finn. I'll update later!

                    1 Reply Last reply
                    0
                    • kshegunovK kshegunov

                      Then probably it's a bug that was fixed with the patch version in the meantime. Cheers!

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #27

                      @kshegunov Must have been quite a big one. I ran the 3d Materials Example on 5.7.0 two days ago - it was horrible. I updated to 5.7.1 yesterday and ran it again - works perfect now.

                      kshegunovK 1 Reply Last reply
                      0
                      • ? A Former User

                        @kshegunov Must have been quite a big one. I ran the 3d Materials Example on 5.7.0 two days ago - it was horrible. I updated to 5.7.1 yesterday and ran it again - works perfect now.

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #28

                        Well, 5.7.0 was Qt3D's first official release, and the code hasn't matured as much as the other modules, so some bumps along the road are expected. My biggest beef with Qt3D actually is its very thin documentation, but I'm sure that'll improve with time.:)

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        1
                        • F Finn

                          I want to use Qt3D within Qt5.7 to plot a 3D scene (a chemical molecule) which I want to rotate.
                          The problem is that my 3D objects are not displayed according to their spatial positioning. The last created QEntity is always in the foreground, regardless of how I rotate the camera.
                          In the minimum working example below, the QEntity smallGreenSphere is always in the foreground even though it is spatially positioned behind bigRedSphere in the default view specified in the camera settings.
                          To rephrase the problem: My 3D scene has no depth.

                          Please note that smallGreenSphere is instantiated after bigRedSphere in the main.cpp file shown below:

                          #include <QGuiApplication>
                          #include <Qt3DCore>
                          #include <Qt3DRender>
                          #include <Qt3DExtras>
                          
                          Qt3DCore::QEntity* createTestScene() {
                          
                            Qt3DCore::QEntity* root = new Qt3DCore::QEntity;
                            Qt3DCore::QEntity* bigRedSphere = new Qt3DCore::QEntity(root);
                            Qt3DCore::QEntity* smallGreenSphere = new Qt3DCore::QEntity(root);
                          
                            Qt3DExtras::QSphereMesh* bigMesh = new Qt3DExtras::QSphereMesh;
                            bigMesh->setRadius(5);
                            bigMesh->setRings(100);
                            bigMesh->setSlices(20);
                          
                            Qt3DExtras::QSphereMesh* smallMesh = new Qt3DExtras::QSphereMesh;
                            smallMesh->setRadius(2);
                            smallMesh->setRings(100);
                            smallMesh->setSlices(20);
                          
                            Qt3DExtras::QPhongMaterial* redMaterial = new Qt3DExtras::QPhongMaterial;
                            redMaterial->setSpecular(Qt::white);
                            redMaterial->setShininess(10);
                            redMaterial->setAmbient(Qt::red);
                          
                            Qt3DExtras::QPhongMaterial* greenMaterial = new Qt3DExtras::QPhongMaterial;
                            greenMaterial->setSpecular(Qt::white);
                            greenMaterial->setShininess(10);
                            greenMaterial->setAmbient(Qt::green);
                          
                            Qt3DCore::QTransform* transform =  new Qt3DCore::QTransform;
                            transform->setTranslation(QVector3D(0,0,10));
                          
                            bigRedSphere->addComponent(redMaterial);
                            bigRedSphere->addComponent(bigMesh);
                          
                            smallGreenSphere->addComponent(greenMaterial);
                            smallGreenSphere->addComponent(smallMesh);
                            smallGreenSphere->addComponent(transform);
                          
                            return root;
                          }
                          
                          
                          int main(int argc, char* argv[]) {
                            
                            QGuiApplication app(argc, argv);
                            Qt3DExtras::Qt3DWindow view;
                            Qt3DCore::QEntity* scene = createTestScene();
                          
                            // camera
                            Qt3DRender::QCamera *camera = view.camera();
                            camera->lens()->setPerspectiveProjection(45, 16./9., 0.1,1000.);
                            camera->setPosition(QVector3D(30., 0, 60.));
                            camera->setViewCenter(QVector3D(0, 0, 0));
                          
                            // manipulator
                            Qt3DExtras::QOrbitCameraController* manipulator = new Qt3DExtras::QOrbitCameraController(scene);
                            manipulator->setLinearSpeed(50);
                            manipulator->setLookSpeed(180);
                            manipulator->setCamera(camera);
                          
                          view.setRootEntity(scene);
                          
                          view.show();
                          
                          return app.exec();
                          }
                          

                          This results in the following scene: Image of the result
                          Please note that I did not rotate anything manually and that this is the output of the code above.

                          If I now swap the order of instantiation in createTestScene() by

                          Qt3DCore::QEntity* smallGreenSphere = new Qt3DCore::QEntity(root);
                          Qt3DCore::QEntity* bigRedSphere = new Qt3DCore::QEntity(root);
                          

                          so that bigRedSphere is now instantiated after smallGreenSphere, the bigRedSphere is always in the foreground and the resulting scene (again without manual rotation) looks like this: Image of the result

                          This proves that the order of instantiation determines what sphere is displayed in the foreground.

                          How can I obtain the correct 3D view regardless of the order of instantiation? Do I have to use some different rendering technique?
                          Thanks in advance for your help and please consider that I am new to Qt, Qt3D, and rendering in your answer.

                          Pablo J. RoginaP Offline
                          Pablo J. RoginaP Offline
                          Pablo J. Rogina
                          wrote on last edited by
                          #29

                          For further reference this issue seems solved as described in this post.

                          Upvote the answer(s) that helped you solve the issue
                          Use "Topic Tools" button to mark your post as Solved
                          Add screenshots via postimage.org
                          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          2

                          • Login

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