Mesh not Visible



  • 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



  • @Nio74

    Is that possible because I have to apply a texture?

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.