// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example customshapes
    \ingroup quick3dphysics-examples
    \title Qt Quick 3D Physics - Custom Shapes Example
    \brief Demonstrates using different shapes.
    \image customshapes-example.jpg

    This example demonstrates loading and spawning several rigid body meshes as well as animating them.
    The scene consists of a dice tower, a weave, a cup and a handful of dices. The cup is animated to collect spawning
    dices and put them in the dice tower. The dices will then roll down and out on the weave.

    \section1 QML

    This is the full qml code for the example:

    \snippet customshapes/main.qml window

    \section2 Enivronment
    As usual it contains a DynamicsWorld and a View3D. In the View3D we have our environment which sets up a lightprobe:

    \snippet customshapes/main.qml environment

    \section2 Textures
    We define four textures which will be used for the skybox, the weave and the numbers on the dice:

    \snippet customshapes/main.qml textures

    \section2 Scene
    We have a Node which contains our scene with the camera and a directional light:

    \snippet customshapes/main.qml scene

    \section2 Weave
    We add the weave which is a StaticRigidBody consisting of a model with a weave texture and a HeightFieldShape for collision.

    \snippet customshapes/main.qml cloth

    \section2 Cup
    We define the cup as a DynamicRigidBody with a Model and a TriangleMeshShape as the collision shape. It has a Behavior on the \c eulerRotation
    and \c position properties as these are part of an animation.

    \snippet customshapes/main.qml cup

    \section2 Tower
    The tower is just a StaticRigidBody with a Model and a TriangleMeshShape for collision.

    \snippet customshapes/main.qml tower

    \section2 Dices
    To generate the dices we use a Component and a Repeater3D. The Component contains a DynamicRigidBody with a ConvexMeshShape and a Model.
    The position, color, scale and mesh source are randomly generated for each die.

    \snippet customshapes/main.qml dices

    \section2 Animation
    To make the dices move from the cup to the dice tower we animate the cup and move it up and then tip it over. This is done using a SequentialAnimation:

    \snippet customshapes/main.qml animation

    \section2 Controller
    Finally a WasdController is added to be able to control the camera using a keyboard:

    \snippet customshapes/main.qml controller
*/
