Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing Qt 3D Sean Harmer Paul Lemire

Similar presentations


Presentation on theme: "Introducing Qt 3D Sean Harmer Paul Lemire"— Presentation transcript:

1 Introducing Qt 3D Sean Harmer sean.harmer@kdab.com Paul Lemire

2 Entity Component System Drawing with Qt 3D Handling Input
Topics What is Qt 3D? Entity Component System Drawing with Qt 3D Handling Input Controlling the Renderer The Future of Qt 3D

3 The Leading C++ Cross-Platform Framework
Cross-Platform Class Library One Technology for All Platforms Integrated Development Tools Shorter Time-to-Market Cross-Platform IDE, Qt Creator Productive development environment Used by over 800,000 developers in 70+ industries Proven & tested technology – since 1994

4 Ecosystems and whole SDKs
Qt is used for… Application Development on Desktop, Mobile and Embedded Creating Powerful Devices Device GUIs, Ecosystems and whole SDKs

5 Qt Applications Are Native Applications
Qt / Windows Windows GDI Windows Kernel PC HW Qt / OSX Cocoa Mac Kernel MacHW Qt / Embedded X11, Wayland, EGLFS Linux Kernel Embedded HW Qt / Android Android NDK Android Kernel Android HW

6 What is Qt 3D? Not only about 3D graphics!
Multi-purpose – not “just” a game engine Soft real-time simulation engine Designed to be scalable Extensible and flexible An open collaboration between KDAB and The Qt Company

7 Simulation Engine The Qt 3D Core is not inherently about 3D graphics
Supports multiple domains at once: AI, Logic, Audio, etc. Of course it contains a 3D renderer too! Allows you to write complex simulation systems: Mechanical Robotics Physics … and yes games too 

8 Scalability Qt 3D has a strong Frontend / Backend split
Frontend is lightweight and on the main thread Bags of properties Backend executed on secondary thread Where the real simulation runs Non-blocking frontend / backend communication Backend maximises throughput via a thread pool

9 Extensibility & Flexibility
Domains added via independent aspects If something not already fitting your needs An Entity Component System is used to combine behaviour in your own objects No deep inheritance hierarchy More on this soon… Qt 3D provides both C++ and QML APIs Integrates with rest of Qt Pull simulation data from a database or over the network?

10 Entity Component System (ECS)
ECS is an architectural pattern Popular in game engines (they are simulation engines too) Favours composition over inheritance An Entity is a general purpose object An Entity gets behaviour by combining data Data comes from typed Components

11 Entity Component System (ECS)

12 Entity Component System (ECS)

13 Why an ECS? Traditional Object Oriented Design Big class hierarchies
Inflexible – assumptions baked at design time Features tend to migrate to base class (bloated) Let’s analyse a simple example: Space Invaders!

14 Why an ECS?

15 Why an ECS?

16 Why an ECS?

17 Why an ECS?

18 Why an ECS?

19 Why an ECS?

20 Why an ECS?

21 Why an ECS?

22 Why an ECS? ECS Pros: Avoids deep, wide, complex inheritance hierarchies Flexible – can change object behaviour at runtime (add/remove components) Extensible – add more component types later Qt 3D ECS is high performance by Aspects (Systems) offloading work to backend ECS Cons: Often new to OOP programmers – takes a while to adjust thinking More objects – Entity plus Components

23 What does Qt 3D Provide in Qt 5.7?
Qt3DCore ECS framework; dependency-aware, tasking thread pool; frontend / backend communications Qt3DRender 3D Rendering framework; Material/Effect/Technique subsystem; Frame Graph (renderer configuration) Qt3DInput Basic Mouse and Keyboard input; Advanced input device mapping Qt3DLogic Execute code per-frame

24 What does Qt 3D Provide in Qt 5.7?
Qt3DExtras Higher level helpers: Materials, Standard geometric shapes, Window integrations Scene3D Custom Qt Quick 2 Item to composite Qt 3D content with Qt Quick 2D UI

25 Hello Donut Example (C++)
Good practice having Qt3DCore::QEntity to represent the scene One Qt3DCore::QEntity per “object” in the scene Objects given behaviour by attaching Qt3DCore::QComponent subclasses For an Qt3DCore::QEntity to be drawn it needs: A mesh geometry describing its shape A material describing its surface appearance

26 Hello Donut Example (QML)
Good practice having Entity to represent the scene One Entity per “object” in the scene Objects given behaviour by attaching component subclasses For an Entity to be drawn it needs: A mesh geometry describing its shape A material describing its surface appearance

27 C++ vs QML API QML API is a mirror of the C++ API C++ class names like rest of Qt Qt 3D uses namespaces to avoid collisions QML element names don’t have Q prefix Qt3DCore::QNode vs Node Qt3DCore::QEntity vs Entity

28 Qt 3D Simulation Simulation executed by Qt3DCore::QAspectEngine Qt3DCore::QAbstractAspect subclass instances registered with the engine Behaviour comes from aspects processing component data Aspects represent a domain of the simulation Qt 3D provides (so far): Qt3DRender::QRenderAspect Qt3DInput::QInputAspect Qt3DLogic::QLogicAspect Aspects have no API of their own – all on components

29 Drawing with Qt 3D: Transforms
Scene graph provides spatial representation of the simulation Qt3DCore::QEntity: simulated object Qt3DCore::QTransform: where it is, the scale it has, the orientation it has Hierarchical transforms are controlled by the parent/child relationship Analogous to QWidget, QQuickItem, QGraphicsItem etc. To render a 3D scene we need a point of view on it: Provided by Qt3DRender::QCamera

30 Drawing with Qt 3D: Geometries
Render aspect draws entities with a shape Qt3DRender::QGeometryRenderer’s geometry property specifies the shape Qt 3D provides convenience subclasses of Qt3DRender::QGeometryRenderer: Qt3DExtras::QSphereMesh Qt3DExtras::QCuboidMesh Qt3DExtras::QPlaneMesh Qt3DExtras::QTorusMesh Qt3DExtras::QConeMesh Qt3DExtras::QCylinderMesh Qt3DRender::QMesh loads from file Easy to provide your own geometries

31 Drawing with Qt 3D: Materials
With only a geometry, an entity will appear black The Qt3DRender::Qmaterial component provides a surface appearance Qt 3D provides convenience subclasses: Qt3DExtras::QPhongMaterial Qt3DExtras::QPhongAlphaMaterial Qt3DExtras::QDiffuseMapMaterial Qt3DExtras::QGoochMaterial Easy to provide your own materials

32 Drawing with Qt 3D: Textures
Many materials vary across the surface Handled using textures A collection of one or more images Subclasses of Qt3DRender::QAbstractTexture provide various types of texture: 1D – useful for lookup functions 2D – most common type 3D – typically volumetric data Arrays of 2D… Qt3DRender::QTextureLoader supports all texture types loaded from DDS files.

33 Drawing with Qt 3D: Lights
The built-in materials work with lights Provided by subclasses of Qt3DRender::QAbstractLight component Point light Directional light Spotlight Lights do not get rendered, we only see their effect on other entities

34 Handling Input Input Events Subclasses of Qt3DInput::QAbstractPhysicalDevice represent devices Qt3DInput::QKeyboardDevice, Qt3DInput::QMouseDevice Basic Input Qt3DInput::QKeyboardHandler component – supports focus Qt3DInput::QMouseHandler component Advanced Input Qt3DInput::QLogicalDevice Maps physical devices Supports collections of actions and analog axis values Qt3DRender::ObjectPicker component provides high level picking

35 Controlling the Renderer
Why do we need to control the renderer? There is no one ideal algorithm for all types of application Such control usually means writing low level C++ code Qt 3D provides a concept called the frame graph: Tree structure describing rendering algorithm Several node types for selecting the camera, render target, layers of entities, viewport dimensions, render state, material etc. Data-driven – can be changed dynamically at run time No low level C++ required Flexible enough to describe almost any rendering algorithm Still high performance Big topic warranting its own presentation!

36 Integrating Qt 3D with Qt Quick
How to composite Qt 3D and Qt Quick 2: Provide your Qt Quick 2 scene Provide your Qt 3D scene Wrap your Qt 3D scene in a Scene3D custom Qt Quick 2 item That’s it... Almost Control focus Which aspects are registered Antialiasing

37 The Future of Qt 3D Qt 3D Core Efficiency improvements Backend thread pool and job improvement – recursive jobs Qt 3D Render Use Qt Quick or QPainter to render into a texture Level of detail (LOD) support for meshes Billboards – camera facing entities Text support – 2D and 3D Additional materials – Physics Based Rendering (PBR Materials) Particle systems Asset conditioning

38 The Future of Qt 3D Qt 3D Input Additional device types Enumerated inputs – 8 way hat switches or dials Higher level axis types – calculate position, velocity, acceleration New aspects: Collision detection aspect Animation aspect Physics aspect Geometry processor aspect AI, 3D positional audio, …

39 The Future of Qt 3D: Tooling
Scene Editor

40 The Future of Qt 3D: Tooling
Qt 3D Profiler / debugger

41 The Future of Qt 3D: Tooling
Introspection in GammaRay –

42 More information Qt documentation Mailing lists: IRC: #qt-3d on freenode Conferences: Qt World Summit QtCon Professional support / consulting KDAB Qt 3D training course coming soon…

43 Thank you for listening!
Any Questions? Thank you for listening!


Download ppt "Introducing Qt 3D Sean Harmer Paul Lemire"

Similar presentations


Ads by Google