Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why object not shown up in my Qt3D test



  • Hi all, I am new to Qt3D and want to have a trail for fun.

    I get an example and it works with mesh load from toyplane.obj, then I tried with a more complex model building_04.obj, it won't show up although I tried to tune camera with aspectRatio, near or farPlane, position ,etc ( I have to admit I am not familiar with what it means. ). toyplane.obj is got from the official example, building_04.obj is from https://free3d.com/3d-model/buildinghouse-04-40137.html ( I hope to upload files but it said I don't have privilege ).

    Thanks for your help.

    main.cpp:

    #include <Qt3DQuickExtras/qt3dquickwindow.h>
    #include <QGuiApplication>
    
    int main(int argc, char* argv[])
    {
        QGuiApplication app(argc, argv);
        Qt3DExtras::Quick::Qt3DQuickWindow view;
        view.setSource(QUrl("qrc:/main.qml"));
        view.show();
    
        return app.exec();
    }
    

    main.qml:

    import QtQuick 2.2 as QQ2
    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: 100
            aspectRatio: 16/9
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0.0, 0.0, -50.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, 0.5, 0)
                    camera: camera
                }
            },
            // Event Source will be set by the Qt3DQuickWindow
            InputSettings { }
        ]
        PhongMaterial {
            id: material
        }
    
        Mesh {
            id: myMesh
            //source: "qrc:/toyplane.obj"
            source: "qrc:/building_04.obj"
        }
    
        Entity {
            id: topplane
    
    
            components: [myMesh, material]
        }
    
    }
    

    The result is, with toyplane.obj, it looks like:
    0_1539237451300_6d17b16d-592f-41e0-bc27-e2d54ca51ff1-image.png

    With building_o4.obj, nothing but a blank background
    0_1539237593132_4e1c1a3d-3b35-46c5-8730-b3b8a4013b60-image.png


Log in to reply