1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick3D
import QtQuick3D.Particles3D
Item {
id: mainWindow
readonly property real tentacleEmitRate: 120
readonly property real cameraDistance: sliderCameraDistance.sliderValue
property real cameraDistanceSmoothed: cameraDistance
property real tentacleWideness: 0
anchors.fill: parent
// Animate tentacle movement
SequentialAnimation {
loops: Animation.Infinite
running: true
NumberAnimation {
target: mainWindow
property: "tentacleWideness"
to: 30
duration: 6000
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: mainWindow
property: "tentacleWideness"
to: -30
duration: 6000
easing.type: Easing.InOutQuad
}
}
Behavior on cameraDistanceSmoothed {
SmoothedAnimation {
velocity: 100
duration: 1000
}
}
// Background ocean gradient
Rectangle {
anchors.fill: parent
gradient: Gradient {
GradientStop {
color: "#005060"
position: 0.0
}
GradientStop {
color: "#000000"
position: 1.0
}
}
}
View3D {
anchors.fill: parent
environment: SceneEnvironment {
backgroundMode: SceneEnvironment.Transparent
antialiasingMode: AppSettings.antialiasingMode
antialiasingQuality: AppSettings.antialiasingQuality
}
// Camera rotating the spider
Node {
PerspectiveCamera {
id: camera
position: Qt.vector3d(0, 0, mainWindow.cameraDistanceSmoothed)
}
NumberAnimation on eulerRotation.y {
loops: Animation.Infinite
from: 0
to: 360
duration: 20000
}
SequentialAnimation on eulerRotation.x {
loops: Animation.Infinite
NumberAnimation {
to: -50
duration: 6000
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 0
duration: 6000
easing.type: Easing.InOutQuad
}
}
}
PointLight {
position: Qt.vector3d(0, 400, 0)
brightness: 200
}
// Body of the spider
Model {
id: spiderBody
source: "#Sphere"
scale: Qt.vector3d(1.0, 0.6, 1.2)
PrincipledMaterial {
id: spiderMaterial
baseColor: tentacleParticle.color
metalness: 1.0
roughness: 0.6
normalMap: Texture {
source: "images/leather_n.png"
}
normalStrength: 0.8
}
materials: [ spiderMaterial ]
Model {
source: "#Cone"
scale: Qt.vector3d(0.4, 0.5, 0.5)
position: Qt.vector3d(20, 10, -20)
eulerRotation: Qt.vector3d(-40, -80, 0)
materials: [ spiderMaterial ]
}
Model {
source: "#Cone"
scale: Qt.vector3d(0.4, 0.5, 0.5)
position: Qt.vector3d(-20, 10, -20)
eulerRotation: Qt.vector3d(-40, 80, 0)
materials: [ spiderMaterial ]
}
SequentialAnimation on y {
loops: Animation.Infinite
NumberAnimation {
to: 100
duration: 2500
easing.type: Easing.InOutQuad
}
NumberAnimation {
to: 0
duration: 2500
easing.type: Easing.InOutQuad
}
}
// System for tentacles particles
ParticleSystem3D {
id: psystemTentacles
SpriteParticle3D {
id: tentacleParticle
sprite: Texture {
source: "images/dot.png"
}
maxAmount: 8 * mainWindow.tentacleEmitRate * 1.5
color: "#000000"
colorVariation: Qt.vector4d(0.0, 0.0, 0.0, 0.2)
fadeInEffect: SpriteParticle3D.FadeNone
fadeOutDuration: 800
billboard: true
SequentialAnimation {
running: true
loops: Animation.Infinite
ColorAnimation {
target: tentacleParticle
property: "color"
to: "#202000"
duration: 2000
}
ColorAnimation {
target: tentacleParticle
property: "color"
to: "#200000"
duration: 2000
}
ColorAnimation {
target: tentacleParticle
property: "color"
to: "#000020"
duration: 2000
}
ColorAnimation {
target: tentacleParticle
property: "color"
to: "#002000"
duration: 2000
}
}
blendMode: SpriteParticle3D.Screen
}
// Emitters for all 8 tentacles
component TentacleEmitter: Node {
id: tentacleNode
property real movementAmount: 1.0
ParticleEmitter3D {
z: 55
eulerRotation.x: 80 + mainWindow.tentacleWideness * tentacleNode.movementAmount
system: psystemTentacles
particle: tentacleParticle
velocity: VectorDirection3D {
direction: Qt.vector3d(0, 300, 0)
}
particleScale: 6.0
particleEndScale: 0.5
emitRate: mainWindow.tentacleEmitRate
lifeSpan: 1500
}
}
TentacleEmitter {
eulerRotation.y: 0.5 * 45
movementAmount: 1.8
}
TentacleEmitter {
eulerRotation.y: 1.5 * 45
movementAmount: 1.3
}
TentacleEmitter {
eulerRotation.y: 2.5 * 45
movementAmount: 1.5
}
TentacleEmitter {
eulerRotation.y: 3.5 * 45
movementAmount: 2.2
}
TentacleEmitter {
eulerRotation.y: 4.5 * 45
movementAmount: 1.6
}
TentacleEmitter {
eulerRotation.y: 5.5 * 45
movementAmount: 1.1
}
TentacleEmitter {
eulerRotation.y: 6.5 * 45
movementAmount: 1.5
}
TentacleEmitter {
eulerRotation.y: 7.5 * 45
movementAmount: 2.1
}
Gravity3D {
direction: Qt.vector3d(0, 1, 0)
magnitude: -300
}
Wander3D {
globalAmount: Qt.vector3d(15, 15, 15)
globalPace: Qt.vector3d(1.0, 1.0, 1.0)
fadeInDuration: 1000
Vector3dAnimation on globalPaceStart {
loops: Animation.Infinite
duration: 8000
from: Qt.vector3d(0, 0, 0)
to: Qt.vector3d(5 * Math.PI * 2, 3 * Math.PI * 2, Math.PI * 2)
}
}
}
// Emitters for dust/smoke particles
ParticleEmitter3D {
id: smokeEmitter
system: psystemDust
particle: smokeParticle
particleScale: 10
particleScaleVariation: 5
particleEndScale: 60
particleEndScaleVariation: 30
particleRotationVariation: Qt.vector3d(0, 0, 180)
particleRotationVelocityVariation: Qt.vector3d(0, 0, 40)
emitRate: sliderDustEmitRate.sliderValue
lifeSpan: 3000
lifeSpanVariation: 1000
velocity: VectorDirection3D {
direction: Qt.vector3d(0, 0, 200)
directionVariation: Qt.vector3d(50, 50, 50)
}
}
ParticleEmitter3D {
id: dustEmitter
system: psystemDust
particle: dustParticle
emitRate: sliderDustEmitRate.sliderValue * 0.5
lifeSpan: 3000
lifeSpanVariation: 1000
particleScale: 10.0
particleScaleVariation: 5.0
particleEndScale: 30.0
particleEndScaleVariation: 10.0
particleRotationVariation: Qt.vector3d(20, 20, 180)
particleRotationVelocityVariation: Qt.vector3d(5, 5, 50)
velocity: VectorDirection3D {
direction: Qt.vector3d(0, 0, 100)
directionVariation: Qt.vector3d(20, 20, 20)
}
}
}
// System for dust/smoke particles
ParticleSystem3D {
id: psystemDust
SpriteParticle3D {
id: smokeParticle
sprite: Texture {
source: "images/smoke_sprite.png"
}
maxAmount: 200
spriteSequence: SpriteSequence3D {
frameCount: 15
interpolate: true
}
billboard: true
color: tentacleParticle.color
fadeInEffect: SpriteParticle3D.FadeNone
fadeOutEffect: Particle3D.FadeOpacity
fadeOutDuration: 1500
blendMode: SpriteParticle3D.Screen
}
SpriteParticle3D {
id: dustParticle
sprite: Texture {
source: "images/dust.png"
}
maxAmount: 100
color: "#ffffff"
colorVariation: Qt.vector4d(0.4, 0.4, 0.4, 0.4)
billboard: true
fadeInDuration: 200
fadeOutDuration: 1500
blendMode: SpriteParticle3D.Screen
}
}
// System for bubbles particles
ParticleSystem3D {
id: psystemBubbles
position: Qt.vector3d(0, 100, -200)
SpriteParticle3D {
id: bubbleParticle
sprite: Texture {
source: "images/sphere.png"
}
maxAmount: 300
color: "#80ffffff"
colorVariation: Qt.vector4d(0.0, 0.0, 0.0, 0.2)
fadeInDuration: 1000
fadeOutDuration: 1000
blendMode: SpriteParticle3D.Screen
billboard: true
}
ParticleEmitter3D {
particle: bubbleParticle
scale: Qt.vector3d(12, 12, 12)
particleScale: 2.0
particleScaleVariation: 1.0
particleEndScale: 1.0
particleEndScaleVariation: 0.5
emitRate: 100
lifeSpan: 3000
shape: ParticleShape3D {
type: ParticleShape3D.Sphere
}
velocity: VectorDirection3D {
direction: Qt.vector3d(0, 0, 200)
directionVariation: Qt.vector3d(20, 20, 100)
}
}
}
}
SettingsView {
CustomLabel {
text: "Camera Distance"
}
CustomSlider {
id: sliderCameraDistance
sliderValue: 400
fromValue: 200
toValue: 800
}
CustomLabel {
text: "Mystical Dust"
}
CustomSlider {
id: sliderDustEmitRate
sliderValue: 20
fromValue: 0
toValue: 50
}
}
LoggingView {
anchors.bottom: parent.bottom
particleSystems: [psystemTentacles, psystemBubbles, psystemDust]
}
}
|