Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Mesh non Visibile

Mesh non Visibile

Scheduled Pinned Locked Moved Unsolved Italian
2 Posts 1 Posters 738 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by
    #1

    Buon Giorno,scrivo perchè ho un problema voglio fare vedere un mia Mesh ma non riesco a visualizzarla e non mi da nessun tipo di errore vi posto i vari file:

    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 ]
        }
    }
     
    

    File.pro

    QT += 3dextras widgets 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras
    CONFIG += c++11
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += main.cpp
    
    RESOURCES += qml.qrc\
    
    
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    DISTFILES += \       
        main.qml \
    
    SUBDIRS += \
        untitled1.pro
    
    

    Il programma si avvia mi appare la finestra ma non si vede la mesh che è posizionata sulla root

    Nio74N 1 Reply Last reply
    0
    • Nio74N Nio74

      Buon Giorno,scrivo perchè ho un problema voglio fare vedere un mia Mesh ma non riesco a visualizzarla e non mi da nessun tipo di errore vi posto i vari file:

      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 ]
          }
      }
       
      

      File.pro

      QT += 3dextras widgets 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras
      CONFIG += c++11
      
      # The following define makes your compiler emit warnings if you use
      # any feature of Qt which as been marked deprecated (the exact warnings
      # depend on your compiler). Please consult the documentation of the
      # deprecated API in order to know how to port your code away from it.
      DEFINES += QT_DEPRECATED_WARNINGS
      
      # You can also make your code fail to compile if you use deprecated APIs.
      # In order to do so, uncomment the following line.
      # You can also select to disable deprecated APIs only up to a certain version of Qt.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += main.cpp
      
      RESOURCES += qml.qrc\
      
      
      
      # Additional import path used to resolve QML modules in Qt Creator's code model
      QML_IMPORT_PATH =
      
      # Additional import path used to resolve QML modules just for Qt Quick Designer
      QML_DESIGNER_IMPORT_PATH =
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      DISTFILES += \       
          main.qml \
      
      SUBDIRS += \
          untitled1.pro
      
      

      Il programma si avvia mi appare la finestra ma non si vede la mesh che è posizionata sulla root

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

      @Nio74

      Possibile che sia che devo per forza dargli una texture?

      Aiutooo

      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