Kuesa Music Box QML Example¶
Demonstrates the use of the Kuesa API to import a glTF2 file and play animations.
QtQuick and Qt3D integration¶
The music-box example relies on the regular QtQuick and Qt 3D APIs 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 11 |
|
Filename: music-box/qml/main.qml
SceneEntity¶
Kuesa provides the [SceneEntity ] element which holds collections of Qt 3D assets accessible by name.
1 2 3 4 5 6 |
|
Filename: music-box/qml/MainScene.qml
Importing a glTF2 File¶
In order to load a glTF2 file, Kuesa provides the [GLTF2Importer ] element. If the sceneEntity property is set to a valid [SceneEntity ] instance, Qt 3D assets generated while parsing the file will be automatically added to the various asset collections.
1 2 3 4 |
|
Filename: music-box/qml/MainScene.qml
Extracting and running Animations¶
We know in advance the name of the animations bundled in the glTF2 file. If you haven't authored the file yourself, you can use the Kuesa Studio gltfInspector to introspect it, list the animations and preview them.
Given a list of animation names:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Filename: music-box/qml/MainScene.qml
We can generate [AnimationPlayer ] to control them.
1 2 3 4 5 6 7 8 9 10 |
|
Filename: music-box/qml/MainScene.qml
Upon importing the glTF file, we can rely on the status change to trigger the animation playback.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Filename: music-box/qml/MainScene.qml
Updated on 2023-07-03 at 11:02:17 +0000