Kuesa Car-Scene QML Example¶
Demonstrates the use of the Kuesa API to import a glTF2 file and extract assets from it.
QtQuick and Qt3D integration¶
The car-scene 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 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Filename: car-scene/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: car-scene/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 5 |
|
Filename: car-scene/qml/MainScene.qml
Extracting Assets from Collections¶
Usually, you will want to interact with some elements of your scene. The [Asset ] element allows to retrieve an asset by name. If the asset for a given name really exist in the specified collection, the node property allows you to access the underlying asset instance.
You can use the Kuesa Studio gltfInspector to introspect a glTF2 scene files and find the names of the various assets it contains.
For instance you might want to select a Camera by name.
1 2 3 4 5 |
|
Filename: car-scene/qml/MainScene.qml
Once retrieved, you can create binding on some of the Camera properties.
1 2 3 4 5 |
|
Filename: car-scene/qml/MainScene.qml
Similarly you could retrieve a Material asset
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Filename: car-scene/qml/MainScene.qml
And create a binding on its properties to control the appearance of elements in the scene that use that material.
1 2 |
|
Filename: car-scene/qml/MainScene.qml
Playing Animations¶
The [AnimationPlayer ] allows to control the playback of animation clips that can be retrieve by name.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Filename: car-scene/qml/MainScene.qml
Adding Post Processing Effects¶
First you need to instantiate the effects you want to use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Filename: car-scene/qml/MainScene.qml
Once you have created the effects, they need to be added to the [ForwardRenderer ] FrameGraph. The order in which they are added dictates the order in which they are applied.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Filename: car-scene/qml/MainScene.qml
Updated on 2023-07-03 at 11:02:17 +0000