Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Mesh not Visible
Qt 6.11 is out! See what's new in the release blog

Mesh not Visible

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 2.2k Views 2 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by
    #1

    Hi all, I'm trying to make my * .stl file appear in the same directory as the project but I do not see these are my fie:

    Main.cpp

    #include <Qt3DQuickExtras/qt3dquickwindow.h>
    #include <Qt3DQuick/QQmlAspectEngine>
    
    #include <QGuiApplication>
    #include <QtQml>
    
    int main(int argc, char **argv)
    {
        QGuiApplication app(argc, argv);
        Qt3DExtras::Quick::Qt3DQuickWindow view;
    
        // Expose the window as a context property so we can set the aspect ratio
        view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
        view.setSource(QUrl("qrc:/main.qml"));
        view.setWidth(800);
        view.setHeight(600);
        view.show();
    
        return app.exec();
    }
    
    

    Main.qml

    import Qt3D.Core 2.0
    import Qt3D.Render 2.0
    import Qt3D.Input 2.0
    import Qt3D.Extras 2.0
    
    Entity {
        id: sceneRoot
    
        Camera {
            id: camera
            projectionType: CameraLens.PerspectiveProjection
            fieldOfView: 25
            aspectRatio: _window.width / _window.height
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0, 0.0, 20.0 )
            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
            viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
        }
    
        OrbitCameraController {
            camera: camera
        }
    
        components: [
            RenderSettings {
                activeFrameGraph: ForwardRenderer {
                    clearColor: Qt.rgba(0, 0.5, 1, 1)
                    camera: camera
                }
            },
            InputSettings { }
        ]
    
        PhongMaterial {
            id: carMaterial
        }
    
        Mesh {
            id: carMesh
            source: "SferaStl.stl"
        }
    
        Entity {
            id: carEntity
            components: [ carMesh, carMaterial ]
        }
    }
    
    

    this is the result:
    alt text

    Nio74N 1 Reply Last reply
    0
    • Nio74N Nio74

      Hi all, I'm trying to make my * .stl file appear in the same directory as the project but I do not see these are my fie:

      Main.cpp

      #include <Qt3DQuickExtras/qt3dquickwindow.h>
      #include <Qt3DQuick/QQmlAspectEngine>
      
      #include <QGuiApplication>
      #include <QtQml>
      
      int main(int argc, char **argv)
      {
          QGuiApplication app(argc, argv);
          Qt3DExtras::Quick::Qt3DQuickWindow view;
      
          // Expose the window as a context property so we can set the aspect ratio
          view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view);
          view.setSource(QUrl("qrc:/main.qml"));
          view.setWidth(800);
          view.setHeight(600);
          view.show();
      
          return app.exec();
      }
      
      

      Main.qml

      import Qt3D.Core 2.0
      import Qt3D.Render 2.0
      import Qt3D.Input 2.0
      import Qt3D.Extras 2.0
      
      Entity {
          id: sceneRoot
      
          Camera {
              id: camera
              projectionType: CameraLens.PerspectiveProjection
              fieldOfView: 25
              aspectRatio: _window.width / _window.height
              nearPlane : 0.1
              farPlane : 1000.0
              position: Qt.vector3d( 0, 0.0, 20.0 )
              upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
              viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
          }
      
          OrbitCameraController {
              camera: camera
          }
      
          components: [
              RenderSettings {
                  activeFrameGraph: ForwardRenderer {
                      clearColor: Qt.rgba(0, 0.5, 1, 1)
                      camera: camera
                  }
              },
              InputSettings { }
          ]
      
          PhongMaterial {
              id: carMaterial
          }
      
          Mesh {
              id: carMesh
              source: "SferaStl.stl"
          }
      
          Entity {
              id: carEntity
              components: [ carMesh, carMaterial ]
          }
      }
      
      

      this is the result:
      alt text

      Nio74N Offline
      Nio74N Offline
      Nio74
      wrote on last edited by
      #2

      @Nio74

      Is that possible because I have to apply a texture?

      Help, there's no one doing things like that?

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

        I am having the exact same problem with nearly identical code as yours. The only difference is that I am loading a .PLY file. If (when!) I figure this out I will let you know immediately.

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

          Ok, I was able to get it to work in C++ but I haven't tried it with QML yet. I THINK the problem lies in the path to the object file. When I gave it the explicit path with:

          m_suzanneMesh->setSource(QUrl::fromLocalFile("C:/Qt/Examples/Qt-5.10.1/qt3d/scene3d/Suzanne.ply"));

          instead of

          m_suzanneMesh->setSource(QUrl(QStringLiteral("qrc:/new/prefix1/Suzanne.ply")));

          it magically worked. My theory is that when the model loader has a problem finding the file it doesn't report anything to that effect, it just goes ahead and displays an empty mesh.

          Hope that helps!

          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