Debian Codegraph @

tests/manual/boundingvolumes/AnimatedEntity.qml

raw
1 // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import Qt3D.Core 2.16
5 import Qt3D.Render 2.16
6 import Qt3D.Input 2.0
7 import Qt3D.Extras 2.16
8
9 import QtQuick 2.0 as QQ2
10
11
12 Entity {
13 id: sceneRoot
14
15 Camera {
16 id: camera
17 projectionType: CameraLens.PerspectiveProjection
18 fieldOfView: 45
19 nearPlane : 0.1
20 farPlane : 1000.0
21 position: Qt.vector3d( 0.0, 0.0, 40.0 )
22 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
23 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
24 }
25
26 FirstPersonCameraController { camera: camera }
27
28 components: [
29 RenderSettings {
30 id: renderSettings
31 activeFrameGraph: ForwardRenderer {
32 camera: camera
33 clearColor: "transparent"
34 }
35 },
36 InputSettings { }
37 ]
38
39 // normal entity, BV computed from geometry
40 Entity {
41 id: sphereEntity1
42 components: [
43 SphereMesh { radius: 4 },
44 PhongMaterial { diffuse: "blue" },
45 Transform { translation: Qt.vector3d(mainAnimation.x, 9, 0) }
46 ]
47 }
48
49 // override BV of the entity with one from another (non-rendered) geometry
50 Entity {
51 id: sphereEntity2
52 components: [
53 SphereMesh { radius: 4 },
54 PhongMaterial { diffuse: "red" },
55 Transform { translation: Qt.vector3d(mainAnimation.x, -9, 0) },
56 BoundingVolume { view: SphereGeometryView { radius: 2 } }
57 ]
58 }
59
60 // override BV with known specific values (can also be done by using a separate BoundingVolume)
61 Entity {
62 id: sphereEntity3
63 components: [
64 SphereMesh {
65 radius: 4
66 minPoint: Qt.vector3d(-.5, -.5, -.5)
67 maxPoint: Qt.vector3d(.5, .5, .5)
68 },
69 PhongMaterial { diffuse: "green" },
70 Transform { translation: Qt.vector3d(mainAnimation.x, 0 , 0) }
71 ]
72 }
73
74 QQ2.SequentialAnimation {
75 id: mainAnimation
76
77 property real x: 0
78 loops: QQ2.Animation.Infinite
79 running: true
80
81 QQ2.NumberAnimation {
82 target: mainAnimation
83 property: "x"
84 duration: 2000
85 from: -25
86 to: 25
87 easing.type: Easing.InOutQuad
88 }
89
90 QQ2.NumberAnimation {
91 target: mainAnimation
92 property: "x"
93 duration: 2000
94 from: 25
95 to: -25
96 easing.type: Easing.InOutQuad
97 }
98 }
99 }