Qt 3D:Scene3D QML 范例

This example demonstrates visualizing a 3D scene from a Qt Quick application. The 3D scene contains a single active camera and a single active light source. Visualized data is assumed to be at a fixed location.

运行范例

要运行范例从 Qt Creator ,打开 欢迎 模式,然后选择范例从 范例 。更多信息,拜访 构建和运行范例 .

可视化 3D 场景

We set up the 3D scene and specify the entity to animate in main.qml :

        Scene3D {
            id: scene3d
            anchors.fill: parent
            anchors.margins: 10
            focus: true
            aspects: ["input", "logic"]
            cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
            AnimatedEntity {}
        }
					

We specify the active camera in scene3d/AnimatedEntity.qml :

    Camera {
        id: camera
        projectionType: CameraLens.PerspectiveProjection
        fieldOfView: 45
        nearPlane : 0.1
        farPlane : 1000.0
        position: Qt.vector3d( 0.0, 0.0, 40.0 )
        upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
        viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
    }
					

文件: