Kuesa Runtime

Kuesa Iro-Materials-Gallery QML Example

Demonstrates the appearance of the different Kuesa Iro Materials that can be bundled in a glTF file.

QtQuick and Qt3D integration

The iro-materials-gallery 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.

 Item {
     id: mainRoot

     // 3D Content

     Item {
         id: baseUI
         anchors.fill: parent

         Scene3D {
             id: scene3D
             anchors.fill: parent
             focus: true
             multisample: true
             aspects: ["input", "animation", "logic"]

             // Root Scene Entity
             MainScene {
                 id: sceneContent
                 onClickedAt: {
                     inspectorView.x = x
                     inspectorView.y = y
                 }
             }
         }
     }

     MaterialInspector {
         id: inspectorView
     }
 }
         ...

SceneEntity

Kuesa provides the SceneEntity element which holds collections of Qt 3D assets accessible by name.

 import Qt3D.Core 2.12
 import Qt3D.Render 2.12
 import Qt3D.Input 2.12
 import Qt3D.Extras 2.12
 import QtQuick 2.12

 import Kuesa 1.2 as Kuesa
 import Kuesa.Effects 1.1 as KuesaFX
 import Kuesa.Utils 1.3 as KuesaUtils

 Kuesa.SceneEntity {
     id: root3D
     signal clickedAt(int x, int y)

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.

The GLTF2Importer takes care of intantiating the Kuesa Iro Materials

     Kuesa.GLTF2Importer {
         id: gltf2importer
         sceneEntity: root3D
         assignNames: true
         source: "qrc:/iro-materials-gallery.gltf"
         options.generateTangents: true
     }

Handling Picking

We want to display the material properties of the sphere on which we click. To do that, we can simply use the ObjectPicker element provided by Qt3D.

         ObjectPicker {
             onClicked: {
                 _materialInspector.inspect(pick)
                 root3D.clickedAt(pick.position.x, pick.position.y)
             }
         }

We can react to the clicked signal and call some C++ function to perform some introspection and retrieve material properties.

Files:

Images: