Demonstrates the use of the Kuesa Runtime API to create a real world application.
This demo is structured around a single screen Depending on the user actions, we enter one of 3 modes
The demo has a strong split between the UI defined in QML and logic handling done in C++.
The UI is provided through a dedicated QML file.
When it comes to the logic handling, it's implemented through a dedicated controller. The controller takes care of providing a KuesaUtils::SceneConfiguration defining which glTF file to load, which camera to use for rendering as well as the a list of Kuesa::AnimationPlayers to control animations or Kuesa::TransformTrackers to retrieve the screen positions of 3D entities.
Additionally, the controller relies on KuesaUtils::SceneConfiguration::loadingDone and KuesUtils::SceneConfiguration::unloadingDone to retrieve Kuesa assets from the Kuesa::SceneEntity collections upon loading and clearing any reference to such object upon unloading.
Through the use of properties and upon those being modified by the UI, the controller will react and might launch animations
This is the entry point of our Application.
First we instantiate an ApplicationWindow
ApplicationWindow { id: mainRoot title: "Drill-Experience" visible: true visibility: ApplicationWindow.Maximized Material.theme: Material.Dark Material.accent: Material.Blue menuBar: ToolBar { Label { text: mainRoot.title font.pixelSize: 20 anchors.centerIn: parent } } Item { id: contentItem anchors.fill: parent DrillScene { id: view3D anchors.fill: parent } UserManualUI { controller: view3D.controller anchors.fill: parent } } } ...
The Drill-Experience example relies on the new simplified Kuesa::View3D API introduced in Kuesa 1.3.
View3D { id: view3D focus: true asynchronous: true backgroundColor: "transparent" opacity: ready ? 1.0 : 0.0 // Controllers // Readonly properties to expose controllers for external access readonly property ScreenController controller: _controller ScreenController { id: _controller } // We rely on the controller providing the scene configuration // This provides the source, camera, trackers, animation players... activeScene: controller.sceneConfiguration Entity { components: [ MouseHandler { id: mouseHandler sourceDevice: MouseDevice {} // Use progress to control the orbit animation when in user manual mode property real progressOffset property bool isPressed: false onPressed: { isPressed = true; idleDetectionTimer.restart() // Switch to the User Manual mode when pressing the screen // while on the status screen if (controller.mode === ScreenController.StatusMode) { controller.mode = ScreenController.UserManualMode } else if (controller.mode === ScreenController.UserManualMode){ // Record camera curve offset progressOffset = controller.positionOnCameraOrbit + mouse.x / view3D.width } else { // GuidedDrillingMode controller.nextStep(); } } onReleased: isPressed = false; onPositionChanged: { // Move camera along orbit curve if (isPressed) controller.positionOnCameraOrbit = Math.min(1.0, Math.max(0, progressOffset - (mouse.x / view3D.width))) } } ] } QQ2.Timer { id: idleDetectionTimer running: controller.mode !== ScreenController.StatusMode interval: 5 * 60 * 1000 // 5 minutes onTriggered: controller.mode = ScreenController.StatusMode } } ...
This is the QML file in charge of setting up the 3D View.
Kuesa::View3D is a subclass of the SceneEntity element which holds collections of Qt 3D assets accessible by name.
This elements acts as the root elements of our DrillScene element. The KuesaUtils::View3DScene::activeScene property is bound to the sceneConfiguraiton instanced returned by the controller. This ensure that when we switch screen and controller, we automatically switch to another SceneConfiguration.
// Controllers // Readonly properties to expose controllers for external access readonly property ScreenController controller: _controller ScreenController { id: _controller } // We rely on the controller providing the scene configuration // This provides the source, camera, trackers, animation players... activeScene: controller.sceneConfiguration
It is instantiated in the main.qml file
DrillScene { id: view3D anchors.fill: parent }
Files:
Images: