Skip to content

Kuesa simple-qml QML Example

Demonstrates the use of the Kuesa API to import a glTF2 file.

simple-qml-example.png

QtQuick and Qt3D integration

The simple-qml example relies on the [View3D ] helper element to instantiate a QtQuick based application that combines Qt 3D based content with a 2D UI overlay.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Item {
    id: mainRoot

    // 3D Content
    KuesaUtils.View3D {
        id: scene3D
        anchors.fill: parent
        focus: true
        multisample: true
        // showDebugOverlay: true

Filename: simple-qml/main.qml

Importing a glTF2 File

In order to load a glTF2 file, Kuesa provides the [GLTF2Importer ] element. This element is hidden within the View3D but can be easily leverage by setting the [source ] property.

1
        source: "file:" + _assetDir + "/car.gltf"

Filename: simple-qml/main.qml

ViewConfiguration

Kuesa provides the [ViewConfiguration ] element to easily configure one or more views of the same scene. Each ViewConfiguration can define its own list of [TransformTrackers ], [PlaceholderTrackers ] and [Post Processing Effects ].

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
        views: [
            KuesaUtils.ViewConfiguration {
                cameraName: "CamSweep_Orientation"
                transformTrackers: [
                    Kuesa.TransformTracker { id: motorTracker; name: "TriggerMotorInfo" },
                    Kuesa.TransformTracker { id: motorEntityTracker; name: "MotorBlock" }
                ]
                clearColor: "white"
            },
            KuesaUtils.ViewConfiguration {
                cameraName: "CamDefault_Orientation"
                viewportRect: Qt.rect(0.8,0.05,0.15, 0.15)
                clearColor: "white"
            }
        ]

Filename: simple-qml/main.qml

Handling Animations

[View3D ] allows to specify one or more [AnimationPlayers ] on the [animations ] property;

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
        // Adding animation
        property bool running: true
        animations: [
            Kuesa.AnimationPlayer { name: "MatMotorBlockAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running; id: mainAnimation },
            Kuesa.AnimationPlayer { name: "TriggerMotorInfoAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "DoorLeftAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "DoorRightAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "HoodAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "SweepCamAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "SweepCamCenterAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running },
            Kuesa.AnimationPlayer { name: "SweepCamPitchAction"; loops: Kuesa.AnimationPlayer.Infinite; running: scene3D.running }
        ]

Filename: simple-qml/main.qml


Updated on 2023-07-03 at 11:02:17 +0000