Debian Codegraph @

tests/manual/spritegrid/main.qml

raw
1 // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import Qt3D.Core 2.0
5 import Qt3D.Render 2.0
6 import Qt3D.Input 2.0
7 import Qt3D.Extras 2.10
8 import QtQuick 2.5
9
10 Entity {
11 id: sceneRoot
12
13 Camera {
14 id: camera
15 projectionType: CameraLens.PerspectiveProjection
16 fieldOfView: 45
17 aspectRatio: 16/9
18 nearPlane : 0.1
19 farPlane : 1000.0
20 position: Qt.vector3d( 0.0, 0.0, 20.0 )
21 upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
22 viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
23 }
24
25 OrbitCameraController { camera: camera }
26
27 RenderSettings {
28 id : external_forward_renderer
29 activeFrameGraph : ForwardRenderer {
30 camera: camera
31 clearColor: "lightgrey"
32 }
33 }
34
35 // Event Source will be set by the Qt3DQuickWindow
36 InputSettings { id: inputSettings }
37
38 components: [external_forward_renderer, inputSettings]
39
40 PlaneMesh {
41 id: mesh
42 }
43
44 SpriteGrid {
45 id: spriteGrid
46 rows: 2
47 columns: 6
48 texture: textureLoader
49 }
50
51 SpriteSheet {
52 id:spriteSheet
53 texture: textureLoader
54
55 SpriteItem { x: 0; y: 0; width: 250; height: 172 }
56 SpriteItem { x: 276; y: 0; width: 250; height: 172 }
57 SpriteItem { x: 550; y: 0; width: 250; height: 172 }
58 SpriteItem { x: 826; y: 0; width: 250; height: 172 }
59 SpriteItem { x: 1100; y: 0; width: 250; height: 172 }
60 SpriteItem { x: 1376; y: 0; width: 250; height: 172 }
61 SpriteItem { x: 0; y: 198; width: 250; height: 172 }
62 SpriteItem { x: 276; y: 198; width: 250; height: 172 }
63 SpriteItem { x: 550; y: 198; width: 250; height: 172 }
64 SpriteItem { x: 826; y: 198; width: 250; height: 172 }
65 SpriteItem { x: 1100; y: 198; width: 250; height: 172 }
66 SpriteItem { x: 1376; y: 198; width: 250; height: 172 }
67 }
68
69 Transform {
70 id: transform1
71 scale: 8
72 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
73 translation: Qt.vector3d(-6, 0, 0)
74 }
75
76 TextureMaterial {
77 id: material1
78 texture: TextureLoader {
79 id: textureLoader
80 source: "spritegrid.png"
81 mirrored: false
82 }
83 textureTransform: spriteGrid.textureTransform
84 }
85
86 Entity {
87 components: [ mesh, material1, transform1 ]
88 }
89
90
91 Transform {
92 id: transform2
93 scale: 8
94 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
95 translation: Qt.vector3d(6, 0, 0)
96 }
97
98 TextureMaterial {
99 id: material2
100 texture: material1.texture
101 textureTransform: spriteSheet.textureTransform
102 }
103
104 Entity {
105 components: [ mesh, material2, transform2 ]
106 }
107
108
109 Transform {
110 id: transform3
111 scale3D: Qt.vector3d(12, 4, 4)
112 rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 90)
113 translation: Qt.vector3d(0, -6, 0)
114 }
115
116 TextureMaterial {
117 id: material3
118 texture: material1.texture
119 }
120
121 Entity {
122 components: [ mesh, material3, transform3 ]
123 }
124
125
126 Timer {
127 interval: 1000
128 repeat: true
129 running: true
130 onTriggered: {
131 spriteGrid.currentIndex = (spriteGrid.currentIndex + 1) % (spriteGrid.rows * spriteGrid.columns)
132 spriteSheet.currentIndex = (spriteSheet.currentIndex + 1) % (spriteSheet.sprites.length)
133 }
134 }
135 }