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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick3D
import QtQuick3D.Particles3D
Item {
anchors.fill: parent
View3D {
anchors.fill: parent
environment: SceneEnvironment {
clearColor: "#101010"
backgroundMode: SceneEnvironment.Color
antialiasingMode: AppSettings.antialiasingMode
antialiasingQuality: AppSettings.antialiasingQuality
}
PerspectiveCamera {
id: camera
position: Qt.vector3d(0, 100, 600)
clipFar: 2000
}
PointLight {
position: Qt.vector3d(200, 600, 400)
brightness: 40
ambientColor: Qt.rgba(0.2, 0.2, 0.2, 1.0)
}
Model {
source: "#Rectangle"
y: -200
scale: Qt.vector3d(30, 15, 15)
eulerRotation.x: -90
materials: [
DefaultMaterial {
diffuseColor: Qt.rgba(1.0, 1.0, 1.0, 1.0)
}
]
}
Node {
id: rotatingNode
position.y: 150
position.z: -200
NumberAnimation on eulerRotation.y {
running: true
loops: Animation.Infinite
from: 0
to: 360
duration: 10000
}
Model {
x: 300
source: "#Cube"
scale: Qt.vector3d(1.5, 1.5, 1.5)
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.9, 0.9, 0.6, 1.0)
}
eulerRotation.x: rotatingNode.eulerRotation.y
eulerRotation.z: 20
}
Model {
x: -300
source: "#Sphere"
scale: Qt.vector3d(2.5, 2.5, 2.5)
materials: DefaultMaterial {
diffuseColor: Qt.rgba(0.9, 0.6, 0.6, 1.0)
opacity: 0.4
}
}
}
//! [particle system]
ParticleSystem3D {
id: psystem
// Start so that the snowing is in full steam
startTime: 15000
//! [particle system]
//! [sprite particle]
SpriteParticle3D {
id: snowParticle
sprite: Texture {
source: "images/snowflake.png"
}
maxAmount: 1500 * sliderIntensity.sliderValue
color: "#ffffff"
colorVariation: Qt.vector4d(0.0, 0.0, 0.0, 0.5);
fadeInDuration: 1000
fadeOutDuration: 1000
}
//! [sprite particle]
//! [particle emitter]
ParticleEmitter3D {
id: emitter
particle: snowParticle
position: Qt.vector3d(0, 1000, -350)
depthBias: -100
scale: Qt.vector3d(15.0, 0.0, 15.0)
shape: ParticleShape3D {
type: ParticleShape3D.Sphere
}
particleRotationVariation: Qt.vector3d(180, 180, 180)
particleRotationVelocityVariation: Qt.vector3d(50, 50, 50);
particleScale: 2.0
particleScaleVariation: 0.5;
velocity: VectorDirection3D {
direction: Qt.vector3d(0, sliderVelocityY.sliderValue, 0)
directionVariation: Qt.vector3d(0, sliderVelocityY.sliderValue * 0.4, 0)
}
emitRate: sliderEmitRate.sliderValue * sliderIntensity.sliderValue
lifeSpan: 15000
}
//! [particle emitter]
//! [particle affectors]
Wander3D {
enabled: checkBoxWanderEnabled.checked
globalAmount: Qt.vector3d(sliderWanderGlobalAmount.sliderValue, 0, sliderWanderGlobalAmount.sliderValue)
globalPace: Qt.vector3d(sliderWanderGlobalPace.sliderValue, 0, sliderWanderGlobalPace.sliderValue)
uniqueAmount: Qt.vector3d(sliderWanderUniqueAmount.sliderValue, 0, sliderWanderUniqueAmount.sliderValue)
uniquePace: Qt.vector3d(sliderWanderUniquePace.sliderValue, 0, sliderWanderUniquePace.sliderValue)
uniqueAmountVariation: sliderWanderUniqueAmountVariation.sliderValue
uniquePaceVariation: sliderWanderUniquePaceVariation.sliderValue
}
PointRotator3D {
enabled: checkBoxRotatorEnabled.checked
pivotPoint: Qt.vector3d(0, 0, -350)
direction: Qt.vector3d(0, 1, 0)
magnitude: sliderRotatorMagnitude.sliderValue
}
//! [particle affectors]
}
}
SettingsView {
CustomLabel {
text: "Intensity of snowfall"
}
CustomSlider {
id: sliderIntensity
sliderValue: 5
fromValue: 1
toValue: 20
}
CustomLabel {
text: "Emit Rate"
}
CustomSlider {
id: sliderEmitRate
sliderValue: 50
fromValue: 1
toValue: 100
}
CustomLabel {
text: "Start Velocity Y"
}
CustomSlider {
id: sliderVelocityY
sliderValue: -100
fromValue: -50
toValue: -500
}
CustomLabel {
text: "System Rotation"
}
CustomSlider {
id: sliderRotation
sliderValue: 0
fromValue: -90
toValue: 90
onSliderValueChanged: {
psystem.eulerRotation.z = sliderValue;
}
}
CustomCheckBox {
id: checkBoxWanderEnabled
text: "Wander: enabled"
checked: true
}
CustomLabel {
text: "Wander: globalAmount"
}
CustomSlider {
id: sliderWanderGlobalAmount
sliderValue: 50
fromValue: 0
toValue: 100
}
CustomLabel {
text: "Wander: globalPace"
}
CustomSlider {
id: sliderWanderGlobalPace
sliderValue: 0.2
fromValue: 0
toValue: 2.0
}
CustomLabel {
text: "Wander: uniqueAmount"
}
CustomSlider {
id: sliderWanderUniqueAmount
sliderValue: 50
fromValue: 0
toValue: 100
}
CustomLabel {
text: "Wander: uniquePace"
}
CustomSlider {
id: sliderWanderUniquePace
sliderValue: 0.2
fromValue: 0
toValue: 2.0
}
CustomLabel {
text: "Wander: uniqueAmountVariation"
}
CustomSlider {
id: sliderWanderUniqueAmountVariation
sliderValue: 0.5
fromValue: 0.0
toValue: 1.0
}
CustomLabel {
text: "Wander: uniquePaceVariation"
}
CustomSlider {
id: sliderWanderUniquePaceVariation
sliderValue: 0.5
fromValue: 0.0
toValue: 1.0
}
CustomCheckBox {
id: checkBoxRotatorEnabled
text: "PointRotator: enabled"
checked: true
}
CustomLabel {
text: "PointRotator: magnitude"
}
CustomSlider {
id: sliderRotatorMagnitude
sliderValue: 0.0
fromValue: -100.0
toValue: 100.0
}
}
LoggingView {
anchors.bottom: parent.bottom
particleSystems: [psystem]
}
}
|