Revision control
Copy as Markdown
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example morphing
\ingroup quick3d-examples
\title Qt Quick 3D - Morphing Example
\examplecategory {3D}
\brief Demonstrates how to control morphing animations in Qt Quick 3D.
\image morphing.png
{3D head model with morphing sliders for mouth, ears, and
cubify}
This example shows how to control morphing animation on a model that has been imported from an external tool.
\section1 Creating a mesh
The mesh for the model was created using the Blender 3D modeling tool. In addition to the base
shape, the mesh contains three morph targets (called \e {shape keys} in Blender).
\image blender.jpg
{Blender interface with monkey head model and shape key controls}
It was exported from Blender as a glTF file, and imported using \l{Balsam Asset Import Tool}{balsam}.
\section1 Controlling the morph targets
Normally, morphing is controlled by a \l {Qt Quick Timeline Overview}{timeline animation} or a
property animation. In this example, we use sliders instead, to make it possible to experiment
freely with combining different weights:
\snippet morphing/main.qml sliders
(\c RealSlider is a simple slider that provides a floating point value. It is borrowed from the effects example.)
We define a \l{MorphTarget} for each of the the targets in the mesh. Morph targets are the objects we bind to to control the morphing. Typically, they will be animated, but in this example we bind to the slider values:
\snippet morphing/main.qml morphtargets
Finally we create a model and bind the morph targets to the targets in the mesh:
\snippet morphing/main.qml model
Note that the targets are matched by their position in the list: the names are not significant.
*/