Immense Particles Refactor Part B
authorAlan Alpert <alan.alpert@nokia.com>
Tue, 7 Jun 2011 09:39:38 +0000 (19:39 +1000)
committerAlan Alpert <alan.alpert@nokia.com>
Tue, 7 Jun 2011 09:43:41 +0000 (19:43 +1000)
Examples work again. Also augmented Wander and PointAttractor with
physics modes.

37 files changed:
examples/declarative/particles/allsmiles/plain.qml [new file with mode: 0644]
examples/declarative/particles/allsmiles/smile.qml
examples/declarative/particles/allsmiles/smilefactory.qml
examples/declarative/particles/allsmiles/spriteparticles.qml
examples/declarative/particles/allsmiles/spritestateparticles.qml
examples/declarative/particles/allsmiles/spritevariedparticles.qml
examples/declarative/particles/allsmiles/ultraparticles.qml
examples/declarative/particles/asteroid/asteroid.qml
examples/declarative/particles/asteroid/blackhole.qml
examples/declarative/particles/custom/blurparticles.qml [new file with mode: 0644]
examples/declarative/particles/custom/content/smile.png [new file with mode: 0644]
examples/declarative/particles/modelparticles/bubbles.qml
examples/declarative/particles/modelparticles/gridsplosion.qml
examples/declarative/particles/modelparticles/package.qml
examples/declarative/particles/modelparticles/stream.qml
examples/declarative/particles/snow/content/Button.qml [moved from examples/declarative/particles/snow/snow2.qml with 72% similarity]
examples/declarative/particles/snow/snow.qml
examples/declarative/particles/snow/snow3.qml [deleted file]
examples/declarative/particles/spaceexplorer/spaceexplorer.qml
examples/declarative/particles/trails/dynamicemitters.qml
examples/declarative/particles/trails/fireballs.qml
examples/declarative/particles/trails/layered.qml
examples/declarative/particles/trails/list.qml
examples/declarative/particles/trails/overburst.qml
examples/declarative/particles/trails/portal.qml
examples/declarative/particles/trails/rainbow.qml
examples/declarative/particles/trails/shimmer.qml
examples/declarative/particles/trails/swarm.qml [deleted file]
examples/declarative/particles/trails/trails.qml
examples/declarative/particles/trails/turbulence.qml
examples/declarative/particles/trails/velocityfrommotion.qml
src/declarative/particles/qsgmaskextruder.cpp
src/declarative/particles/qsgparticleaffector_p.h
src/declarative/particles/qsgpointattractor.cpp
src/declarative/particles/qsgpointattractor_p.h
src/declarative/particles/qsgwander.cpp
src/declarative/particles/qsgwander_p.h

diff --git a/examples/declarative/particles/allsmiles/plain.qml b/examples/declarative/particles/allsmiles/plain.qml
new file mode 100644 (file)
index 0000000..1b456b0
--- /dev/null
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle{
+    color: "goldenrod"
+    width: 2000
+    height: 2000
+    ParticleSystem{id: sys}
+    ImageParticle{
+        id: up
+        system: sys
+        image: "content/singlesmile.png"
+    }
+    Emitter{
+        anchors.centerIn: parent
+        system: sys
+        particlesPerSecond: 1000
+        particleSize: 20
+        particleDuration: 10000
+        speed: AngledDirection{angleVariation: 360; magnitudeVariation: 100;}
+    }
+    MouseArea{
+        anchors.fill: parent
+        onClicked: up.autoRotation = !up.autoRotation
+    }
+}
index e37e8fa..9ce0e3a 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
+    id: root
     color: "white"
     width: 310
     height: 300
     ParticleSystem{ id: sys }
-    Picture{
+    CustomParticle{
         system: sys
-        anchors.fill: parent
-        image: "content/singlesmile.png"
-        onceOff: true
-    }
-    ColoredParticle{
-        system: sys
-        image: "content/particle.png"
-        color: "black"
-        alpha: 0.4
-        sizeTable: "content/sizeInOut.png"
+        property real maxWidth: root.width
+        property real maxHeight: root.height
+        ShaderEffectSource{
+            id: pictureSource
+            sourceItem: picture
+            hideSource: true
+        }
+        Image{
+            id: picture
+            source: "content/singlesmile.png"
+        }
+        ShaderEffectSource{
+            id: particleSource
+            sourceItem: particle
+            hideSource: true
+        }
+        Image{
+            id: particle
+            source: "content/particle.png"
+        }
+        vertexShader:"
+            attribute highp vec2 vPos;
+            attribute highp vec2 vTex;
+            attribute highp vec4 vData; //  x = time,  y = lifeSpan, z = size,  w = endSize
+            attribute highp vec4 vVec; // x,y = constant speed,  z,w = acceleration
+            attribute highp float r;
+
+            uniform highp float maxWidth;
+            uniform highp float maxHeight;
+
+            uniform highp mat4 qt_ModelViewProjectionMatrix;                              
+            uniform highp float timestamp;
+            uniform lowp float qt_Opacity;
+
+            varying highp vec2 fTex;                                
+            varying highp vec2 fTex2;                                
+            varying lowp float fFade;
+
+            void main() {                                           
+                fTex = vTex;                                        
+                fTex2 = vec2(vPos.x / maxWidth, vPos.y / maxHeight);
+                highp float size = vData.z;
+                highp float endSize = vData.w;
+
+                highp float t = (timestamp - vData.x) / vData.y;
+
+                highp float currentSize = mix(size, endSize, t * t);
+
+                if (t < 0. || t > 1.)
+                currentSize = 0.;
+
+                highp vec2 pos = vPos
+                - currentSize / 2. + currentSize * vTex          // adjust size
+                + vVec.xy * t * vData.y         // apply speed vector..
+                + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+                gl_Position = qt_ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0, 1);
+
+                highp float fadeIn = min(t * 10., 1.);
+                highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+                fFade = fadeIn * fadeOut * qt_Opacity;
+            }
+        "
+        property variant particleTexture: particleSource
+        property variant pictureTexture: pictureSource
+        fragmentShader: "
+            uniform sampler2D particleTexture;
+            uniform sampler2D pictureTexture;
+            varying highp vec2 fTex;
+            varying highp vec2 fTex2;
+            varying highp float fFade;
+            void main() {
+                gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, fTex).w * fFade;
+        }"
     }
-    TrailEmitter{
+    Emitter{
         id: emitter
         system: sys
         emitting: false
@@ -67,7 +133,7 @@ Rectangle{
         maxParticles: 1200
         anchors.fill: parent
         particleSize: 32
-        speed: PointVector{ xVariation: 12; yVariation: 12 }
+        speed: PointDirection{ xVariation: 12; yVariation: 12 }
     }
     MouseArea{
         anchors.fill: parent
index 47becb5..262644e 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "goldenrod"
     width: 400
     height: 400
     ParticleSystem{id:sys}
-    DeformableParticle{
+    ImageParticle{
         system: sys
         particles: ["goingLeft", "goingRight"]
         image: "content/singlesmile.png"
@@ -54,12 +54,12 @@ Rectangle{
         rotationSpeed: 90
         autoRotation: true
     }
-    DeformableParticle{
+    ImageParticle{
         system: sys
         particles: ["goingDown"]
         image: "content/squarefacespriteXX.png"
         rotation: 180
-        yVector: PointVector{ y: 0.5; yVariation: 0.25; xVariation: 0.25; }
+        yVector: PointDirection{ y: 0.5; yVariation: 0.25; xVariation: 0.25; }
     }
     Timer{
         running: true
@@ -79,38 +79,38 @@ Rectangle{
         interval: 8400
         onTriggered: emitC.emitting = true;
     }
-    TrailEmitter{
+    Emitter{
         id: emitA
         x: 0
         y: 120
         system: sys
         emitting: false
         particle: "goingRight"
-        speed: PointVector{ x: 100 }
+        speed: PointDirection{ x: 100 }
         particleDuration: 4000
         particlesPerSecond: 2
         particleSize: 32
     }
-    TrailEmitter{
+    Emitter{
         id: emitB
         x: 400
         y: 240
         system: sys
         emitting: false
         particle: "goingLeft"
-        speed: PointVector{ x: -100 }
+        speed: PointDirection{ x: -100 }
         particleDuration: 4000
         particlesPerSecond: 2
         particleSize: 32
     }
-    TrailEmitter{
+    Emitter{
         id: emitC
         x: 0
         y: 360
         system: sys
         emitting: false
         particle: "goingDown"
-        speed: PointVector{ x: 100 }
+        speed: PointDirection{ x: 100 }
         particleDuration: 4000
         particlesPerSecond: 2
         particleSize: 32
index 4bcb708..1f385f2 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "goldenrod"
     width: 400
     height: 400
-    ColoredParticle{
+    ImageParticle{
         id: test
         particles: ["Test"]
         image: "content/particle.png"
@@ -55,23 +55,23 @@ Rectangle{
         color: "#336666CC"
         colorVariation: 0.0
     }
-    SpriteParticle{
+    ImageParticle{
         id: single
         particles: ["Face"]
         system: sys
         z: 2
         anchors.fill: parent
-        Sprite{
+        sprites: Sprite{
             source: "content/squarefacesprite.png"
             frames: 6
             duration: 120
         }
     }
-    Mask{
+    MaskShape{
         id: mask
         source: "content/smileMask.png"
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         particle: "Test"
         anchors.fill: parent
@@ -82,7 +82,7 @@ Rectangle{
         particleSize: 10
         shape: mask
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         particle: "Face"
         anchors.fill: parent
@@ -90,7 +90,7 @@ Rectangle{
         particlesPerSecond: 60
         particleDuration: 1440
         emitting: true
-        speed: PointVector{xVariation: 10; yVariation: 10;}
+        speed: PointDirection{xVariation: 10; yVariation: 10;}
         particleSize: 30
         particleSizeVariation: 10
         shape: mask
index 6a61487..0818686 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "goldenrod"
@@ -109,7 +109,7 @@ Rectangle{
         z:4
     }
     ParticleSystem{ id: sys }
-    SpriteParticle{
+    ImageParticle{
         anchors.fill: parent
         id: particles
         system: sys
@@ -168,13 +168,13 @@ Rectangle{
             duration: 10000
         }]
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         particlesPerSecond: 16
         particleDuration: 10000
         emitting: true
-        speed: AngleVector{angle: 90; magnitude: 60; angleVariation: 5}
-        acceleration: PointVector{ y: 10 }
+        speed: AngledDirection{angle: 90; magnitude: 60; angleVariation: 5}
+        acceleration: PointDirection{ y: 10 }
         particleSize: 30
         particleSizeVariation: 10
         width: parent.width
index c1b7730..e6aeacc 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "goldenrod"
     width: 800
     height: 800
     ParticleSystem{ id: sys }
-    SpriteParticle{
+    ImageParticle{
         system: sys
         anchors.fill: parent
         sprites: [Sprite{
@@ -92,15 +92,15 @@ Rectangle{
             duration: 120
         }]
     }
-    TrailEmitter{
+    Emitter{
         id: particleEmitter
         system: sys
         width: parent.width
         particlesPerSecond: 16
         particleDuration: 8000
         emitting: true
-        speed: AngleVector{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
-        acceleration: PointVector{ y: 10 }
+        speed: AngledDirection{angle: 90; magnitude: 300; magnitudeVariation: 100; angleVariation: 5}
+        acceleration: PointDirection{ y: 10 }
         particleSize: 30
         particleSizeVariation: 10
     }
index 85bbdba..f2b6f8d 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "white"
@@ -48,7 +48,7 @@ Rectangle{
     ParticleSystem{ 
         id: sys 
     }
-    UltraParticle{
+    ImageParticle{
         sprites: [
             Sprite{
                 name: "licking"
@@ -80,14 +80,14 @@ Rectangle{
         factor: 0.1
         system: sys
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         anchors.centerIn: parent
         id: particles
         particlesPerSecond: 200
         particleDuration: 6000
         emitting: true
-        speed: AngleVector{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+        speed: AngledDirection{angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
         particleSize: 40
         particleEndSize: 80
     }
index b5b4f67..223ea81 100644 (file)
@@ -38,8 +38,8 @@
 **
 ****************************************************************************/
 
-import Qt.labs.particles 2.0
-import Qt.labs.particles 2.0 as Qlp
+import QtQuick.Particles 2.0
+import QtQuick.Particles 2.0 as Qlp
 import QtQuick 2.0
 
 Item {
@@ -65,14 +65,14 @@ Item {
         }
 
     }
-    ColoredParticle {
+    ImageParticle {
         system: sys
         particles: ["starfield"]
         image: "content/star.png"
         colorVariation: 0.3
         color: "white"
     }
-    TrailEmitter {
+    Emitter {
         id: starField
         system: sys
         particle: "starfield"
@@ -82,25 +82,25 @@ Item {
 
         anchors.centerIn: parent
 
-        //acceleration: AngleVector{angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
-        acceleration: PointVector{ xVariation: 200; yVariation: 200; }
+        //acceleration: AngledDirection{angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed?
+        acceleration: PointDirection{ xVariation: 200; yVariation: 200; }
 
         particleSize: 0
         particleEndSize: 80
         particleSizeVariation: 10
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         particle: "meteor"
         particlesPerSecond: 12
         particleDuration: 5000
         emitting: true
-        acceleration: PointVector{ xVariation: 80; yVariation: 80; }
+        acceleration: PointDirection{ xVariation: 80; yVariation: 80; }
         particleSize: 15
         particleEndSize: 300
         anchors.centerIn: parent
      }
-    SpriteParticle{
+    ImageParticle{
         system: sys
         particles: ["meteor"]
         sprites:[Sprite{
@@ -168,7 +168,7 @@ Item {
 
         }
     }
-    ColoredParticle{
+    ImageParticle{
         z:0 
         system: sys
         particles: ["exhaust"]
@@ -191,7 +191,7 @@ Item {
 
         colorVariation: 0.2
     }
-    TrailEmitter{
+    Emitter{
         id: trailsNormal2
         system: sys
         particle: "exhaust"
@@ -202,10 +202,10 @@ Item {
         y: holder.y
         x: holder.x 
 
-        speed: PointVector{ xVariation: 40; yVariation: 40; }
+        speed: PointDirection{ xVariation: 40; yVariation: 40; }
         speedFromMovement: 16
 
-        acceleration: PointVector{ xVariation: 10; yVariation: 10; }
+        acceleration: PointDirection{ xVariation: 10; yVariation: 10; }
 
         particleSize: 4
         particleSizeVariation: 4
index 68d5835..f2c9d0a 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     id: root
@@ -65,7 +65,7 @@ Rectangle{
         }
     }
 
-    TrailEmitter{
+    Emitter{
         particle: "stars"
         system: particles
         particlesPerSecond: 40
@@ -73,10 +73,10 @@ Rectangle{
         emitting: true
         particleSize: 30
         particleSizeVariation: 10
-        speed: PointVector{ x: 220; xVariation: 40 }
+        speed: PointDirection{ x: 220; xVariation: 40 }
         height: parent.height
     }
-    TrailEmitter{
+    Emitter{
         particle: "roids"
         system: particles
         particlesPerSecond: 10
@@ -84,14 +84,14 @@ Rectangle{
         emitting: true
         particleSize: 30
         particleSizeVariation: 10
-        speed: PointVector{ x: 220; xVariation: 40 }
+        speed: PointDirection{ x: 220; xVariation: 40 }
         height: parent.height
     }
     ParticleSystem{
         id: particles
         anchors.fill: parent
     }
-    ColoredParticle{
+    ImageParticle{
         id: stars
         particles: ["stars"]
         system: particles
@@ -99,7 +99,7 @@ Rectangle{
         color: "white"
         colorVariation: 0.1
     }
-    SpriteParticle{
+    ImageParticle{
         id: roids
         particles: ["roids"]
         system: particles
@@ -112,7 +112,7 @@ Rectangle{
             speedModifiesDuration: -0.1
         }
     }
-    ColoredParticle{
+    ImageParticle{
         id: shot
         particles: ["shot"]
         system: particles
@@ -121,7 +121,7 @@ Rectangle{
         color: "#0FF06600"
         colorVariation: 0.3
     }
-    ColoredParticle{
+    ImageParticle{
         id: engine
         particles: ["engine"]
         system: particles
@@ -166,7 +166,7 @@ Rectangle{
             drag.axis: Drag.XandYAxis
             drag.target: ship
         }
-        TrailEmitter{
+        Emitter{
             particle: "engine"
             system: particles
             particlesPerSecond: 200
@@ -175,18 +175,18 @@ Rectangle{
             particleSize: 10
             particleEndSize: 4
             particleSizeVariation: 4
-            speed: PointVector{ x: -128; xVariation: 32 }
+            speed: PointDirection{ x: -128; xVariation: 32 }
             height: parent.height
             width: 20
         }
-        TrailEmitter{
+        Emitter{
             particle: "shot"
             system: particles
             particlesPerSecond: 32
             particleDuration: 2000
             emitting: spacePressed
             particleSize: 40
-            speed: PointVector{ x: 256; }
+            speed: PointDirection{ x: 256; }
             x: parent.width
             y: parent.height/2
         }
diff --git a/examples/declarative/particles/custom/blurparticles.qml b/examples/declarative/particles/custom/blurparticles.qml
new file mode 100644 (file)
index 0000000..7d0f9cc
--- /dev/null
@@ -0,0 +1,125 @@
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Rectangle{
+    color: "white"
+    width: 240
+    height: 360
+    ParticleSystem{
+        id: sys
+    }
+    Emitter{
+        system:sys
+        height: parent.height
+        particlesPerSecond: 1
+        particleDuration: 12000
+        speed: PointDirection{x:20;}
+        particleSize: 64
+    }
+    ShaderEffectSource{
+        id: theSource
+        sourceItem: theItem
+        hideSource: true
+    }
+    Image{
+        id: theItem
+        source: "content/smile.png"
+    }
+
+    CustomParticle{
+        system: sys 
+        //TODO: Someway that you don't have to rewrite the basics for a simple addition
+        vertexShader:"
+            attribute highp vec2 vPos;
+            attribute highp vec2 vTex;
+            attribute highp vec4 vData; //  x = time,  y = lifeSpan, z = size,  w = endSize
+            attribute highp vec4 vVec; // x,y = constant speed,  z,w = acceleration
+            attribute highp float r;
+
+            uniform highp mat4 qt_ModelViewProjectionMatrix;                              
+            uniform highp float timestamp;
+            uniform lowp float qt_Opacity;
+
+            varying highp vec2 fTex;                                
+            varying lowp float fFade;
+            varying lowp float fBlur;
+
+            void main() {                                           
+                fTex = vTex;                                        
+                highp float size = vData.z;
+                highp float endSize = vData.w;
+
+                highp float t = (timestamp - vData.x) / vData.y;
+
+                highp float currentSize = mix(size, endSize, t * t);
+
+                if (t < 0. || t > 1.)
+                currentSize = 0.;
+
+                highp vec2 pos = vPos
+                - currentSize / 2. + currentSize * vTex          // adjust size
+                + vVec.xy * t * vData.y         // apply speed vector..
+                + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+
+                gl_Position = qt_ModelViewProjectionMatrix * vec4(pos.x, pos.y, 0, 1);
+
+                highp float fadeIn = min(t * 10., 1.);
+                highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
+
+                fFade = fadeIn * fadeOut * qt_Opacity;
+                fBlur = max(0.2 * t, t * r);
+            }
+        "
+        property variant source: theSource
+        property variant blurred: ShaderEffectSource {
+        smooth: true
+        sourceItem: ShaderEffectItem {
+            width: theItem.width
+            height: theItem.height
+            property variant delta: Qt.size(0.0, 1.0 / height)
+            property variant source: ShaderEffectSource {
+                smooth: true
+                sourceItem: ShaderEffectItem {
+                    width: theItem.width
+                    height: theItem.height
+                    property variant delta: Qt.size(1.0 / width, 0.0)
+                    property variant source: theSource
+                    fragmentShader: "
+                        uniform sampler2D source;
+                        uniform highp vec2 delta;
+                        varying highp vec2 qt_TexCoord0;
+                        void main() {
+                            gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+                                         + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+                                         + 0.2466 * texture2D(source, qt_TexCoord0)
+                                         + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+                                         + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+                        }"
+                }
+            }
+            fragmentShader: "
+                uniform sampler2D source;
+                uniform highp vec2 delta;
+                varying highp vec2 qt_TexCoord0;
+                void main() {
+                    gl_FragColor = 0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta)
+                                 + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta)
+                                 + 0.2466 * texture2D(source, qt_TexCoord0)
+                                 + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta)
+                                 + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta);
+                }"
+            }
+        }
+        fragmentShader: "
+            uniform sampler2D source;
+            uniform sampler2D blurred;
+            varying highp vec2 fTex;
+            varying highp float fBlur;
+            varying highp float fFade;
+            void main() {
+                gl_FragColor = mix(texture2D(source, fTex), texture2D(blurred, fTex), min(1.0,fBlur*3.0)) * fFade;
+            }"
+
+    }
+}
+
diff --git a/examples/declarative/particles/custom/content/smile.png b/examples/declarative/particles/custom/content/smile.png
new file mode 100644 (file)
index 0000000..3d66d72
Binary files /dev/null and b/examples/declarative/particles/custom/content/smile.png differ
index 80d03a9..d0eb3ea 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "../../modelviews/listview/content" as OtherDemo
 import "content/script.js" as Script
 import "content"
@@ -56,21 +56,22 @@ Item{
     ParticleSystem{ 
         id: sys;
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         particle: "A"
         width: parent.width/2
         x: parent.width/4
         y:parent.height
-        speed: PointVector{ y: -64; yVariation: 16 }
+        speed: PointDirection{ y: -64; yVariation: 16 }
         particlesPerSecond: 1
         particleDuration: 8000
     }
-    Drift{
+    Wander{
         system: sys
-        xDrift: 200
+        xVariance: 400
+        pace: 200
     }
-    DataParticle{
+    ModelParticle{
         id: mp
         z: 0
         system: sys
index d45ef39..fe2dd26 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "content"
 
 Item{
@@ -48,13 +48,14 @@ Item{
     height: 240
     property bool inGrid: false
     ParticleSystem{ id: sys }
-    TrailEmitter{
+    Emitter{
         system: sys
         id: burster;
         emitting: false
         particlesPerSecond: 1000
-        particleDuration: 500
-        speed: PointVector{xVariation: 400; yVariation: 400}
+        particleDuration: 50000
+        maxParticles: 100;
+        speed: PointDirection{xVariation: 400; yVariation: 400}
         anchors.centerIn: parent
         Timer{
             interval: 1000
@@ -69,7 +70,7 @@ Item{
             onTriggered: {inGrid = true;}// sys.running = false;}
         }
     }
-    ColoredParticle{
+    ImageParticle{
         system: sys
         image: "../trails/content/particle.png"
         color: "black"
@@ -80,17 +81,14 @@ Item{
         width: 120
         height: 120
     }
-    DataParticle{
+    ModelParticle{
         system: sys
         model: theModel.parts.particles
+        fade: false
     }
     Friction{
         system: sys
-        factor: 1
-    }
-    Stasis{
-        system: sys
-        targetLife: 400
+        factor: 5
     }
     VisualDataModel{
         id: theModel
index d5c104b..6487380 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "content"
 
 Rectangle {
@@ -69,7 +69,7 @@ Rectangle {
         width: 200; height:200
         model: visualModel.parts.list
     }
-    DataParticle{
+    ModelParticle{
         x: 200; width: 200; height:200
         model: visualModel.parts.grid
         system: sys
@@ -80,11 +80,11 @@ Rectangle {
         id: sys
         anchors.fill: parent
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         width: 100
         x: 50
-        speed: PointVector{ y: 40 }
+        speed: PointDirection{ y: 40 }
         particleDuration: 5000
         particlesPerSecond: 1.6
     }
index 0ad807b..73107ad 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "content/script.js" as Script
 import "content"
 
@@ -68,13 +68,13 @@ Item{
         overwrite: false
         startTime: 12000//Doesn't actually work with the loading time though...
     }
-    TrailEmitter{
+    Emitter{
         id: emitter
         system: sys
         height: parent.height - 132/2
         x: -132/2
         y: 132/2
-        speed: PointVector{ x: 32; xVariation: 8 }
+        speed: PointDirection{ x: 32; xVariation: 8 }
         particlesPerSecond: 0.5
         particleDuration: 120000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
         particle: "photos"
@@ -85,7 +85,7 @@ Item{
         height: parent.height
         width: 1000
     }
-    ColoredParticle{
+    ImageParticle{
         system: sys
         particles: ["fireworks"]
         image: "../trails/content/star.png"
@@ -125,7 +125,7 @@ Item{
     }
     property Item alertItem;
     function alert(){
-        resetter.active = false
+        //resetter.active = false
         force.active = true;
         alertItem = alertDelegate.createObject(root);
         alertItem.x = root.width/2 - alertItem.width/2
@@ -142,31 +142,27 @@ Item{
         interval: 800
         onTriggered: {
             force.active = false
-            resetter.active = true;
+            //resetter.active = true;
             mp.take(alertItem, true);
             centerEmitter.burst(1);
         }
     }
-    Attractor{
+    PointAttractor{
         id: force
         system: sys
         x: root.width/2
         y: root.height/2
-        strength: -30000
+        strength: -10000
         active: false
         anchors.centerIn: parent
         width: parent.width/2
         height: parent.height/2
         particles:["photos"]
+        physics: PointAttractor.Position
     }
-    Reset{
-        id: resetter
-        system: sys
-        particles:["photos"]
-    }
-    TrailEmitter{
+    Emitter{
         id: centerEmitter
-        speed: PointVector{ x: 32; xVariation: 8;}
+        speed: PointDirection{ x: 32; xVariation: 8;}
         particlesPerSecond: 0.5
         particleDuration: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
         maxParticles: 20
@@ -177,7 +173,7 @@ Item{
 
         //TODO: Zoom in effect
     }
-    TrailEmitter{
+    Emitter{
         id: spawnFireworks
         particle: "fireworks"
         system: sys
@@ -191,8 +187,8 @@ Item{
         emitting: false
         particleSize: 32
         particleEndSize: 8
-        speed: AngleVector{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
-        acceleration: PointVector{ y: 160 }
+        speed: AngledDirection{ magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
+        acceleration: PointDirection{ y: 160 }
     }
     Item{ x: -1000; y: -1000 //offscreen
         Repeater{//Load them here, add to system on completed
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
 
-Rectangle{
-    width: 360
-    height: 540
-    ParticleSystem{ id: particles }
-    SpriteParticle{
-        system: particles
-        Sprite{
-            name: "snow"
-            source: "content/flake-01.png"
-            frames: 51
-            duration: 40
+Rectangle {
+    id: container
+
+    property string text: "Button"
+    signal clicked
+
+    width: buttonLabel.width + 20; height: buttonLabel.height + 20
+    smooth: true
+    property color myCol: "#999999"
+    border { width: 1; color: Qt.darker(myCol) }
+    radius: 8
+
+    gradient: Gradient {
+        GradientStop {
+            position: 0.0
+            color: {
+                if (mouseArea.pressed)
+                    return Qt.darker(myCol)
+                else
+                    return Qt.lighter(myCol)
+            }
         }
+        GradientStop { position: 1.0; color: myCol }
     }
-    Drift{ 
-        system: particles
-        anchors.fill: parent
-        xDrift: 400;
-    }
-    TrailEmitter{
-        system: particles
-        particlesPerSecond: 20
-        particleDuration: 7000
-        emitting: true
-        speed: PointVector{ y:80; yVariation: 40; }
-        acceleration: PointVector{ y: 4 }
-        particleSize: 20
-        particleSizeVariation: 10
-        width: parent.width
-        height: 100
+
+    MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
+
+    Text {
+        id: buttonLabel; text: container.text; anchors.centerIn: container; color: "black"; font.pixelSize: 24
     }
 }
index 25d2e14..2be2438 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
+import "content"
 
 Rectangle{
     width: 360
     height: 540
     ParticleSystem { id: particles }
-    SpriteParticle {
+    ImageParticle {
         system: particles
-        Sprite{
+        sprites: Sprite{
             name: "snow"
             source: "content/flake-01.png"
             frames: 51
@@ -55,21 +56,38 @@ Rectangle{
         }
     }
     Wander { 
+        id: wanderer
         system: particles
         anchors.fill: parent
-        xVariance: 40;
-        pace: 40;
+        xVariance: 360/(wanderer.physics+1);
+        pace: 100*(wanderer.physics+1);
     }
-    TrailEmitter {
+    Emitter {
         system: particles
         particlesPerSecond: 20
         particleDuration: 7000
         emitting: true
-        speed: PointVector{ y:80; yVariation: 40; }
-        acceleration: PointVector{ y: 4 }
+        speed: PointDirection{ y:80; yVariation: 40; }
+        acceleration: PointDirection{ y: 4 }
         particleSize: 20
         particleSizeVariation: 10
         width: parent.width
         height: 100
     }
+    Row{
+        anchors.bottom: parent.bottom
+        anchors.horizontalCenter: parent.horizontalCenter
+        Button{
+            text:"dx/dt"
+            onClicked: wanderer.physics = Wander.Position;
+        }
+        Button{
+            text:"dv/dt"
+            onClicked: wanderer.physics = Wander.Velocity;
+        }
+        Button{
+            text:"da/dt"
+            onClicked: wanderer.physics = Wander.Acceleration;
+        }
+    }
 }
diff --git a/examples/declarative/particles/snow/snow3.qml b/examples/declarative/particles/snow/snow3.qml
deleted file mode 100644 (file)
index 080bc4d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-**     the names of its contributors may be used to endorse or promote
-**     products derived from this software without specific prior written
-**     permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.particles 2.0
-
-Rectangle{
-    width: 360
-    height: 540
-    id: root
-    ParticleSystem{ id: particles }
-    SpriteParticle{
-        system: particles
-        sprites: Sprite{
-            name: "snow"
-            source: "content/flake-01.png"
-            frames: 51
-            duration: 40
-        }
-    }
-    Drift{
-        system: particles
-        anchors.fill: parent
-        xDrift: 200
-    } 
-    SpeedLimit{
-        system: particles
-        anchors.fill: parent
-        speedLimit: 100
-    }
-    TrailEmitter{
-        system: particles
-        particlesPerSecond: 20
-        particleDuration: 7000
-        emitting: true
-        speed: PointVector{ y:80; yVariation: 40; }
-        acceleration: PointVector{ y: 4 }
-        particleSize: 20
-        particleSizeVariation: 10
-        width: parent.width
-        height: 40
-    }
-}
index 091ca0a..f303bb4 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "content/helpers.js" as Helpers
 
 Rectangle{
@@ -75,7 +75,7 @@ Rectangle{
     property bool fakeMoving: false
     property real fakeMovementDir: 0
 
-    TrailEmitter{
+    Emitter{
         particle: "stars2"
         system: background
         particlesPerSecond: 60
@@ -86,7 +86,7 @@ Rectangle{
         anchors.fill: parent
     }
     ParticleSystem{ id: background }
-    ColoredParticle{
+    ImageParticle{
         particles: ["stars2"]
         system: background
         anchors.fill: parent
@@ -197,7 +197,7 @@ Rectangle{
 
 
     ParticleSystem{ id: foreground }
-    ColoredParticle{
+    ImageParticle{
         particles: ["stars"]
         anchors.fill: parent
         system: foreground
@@ -205,7 +205,7 @@ Rectangle{
         color: "white"
         colorVariation: 0.1
     }
-    ColoredParticle{
+    ImageParticle{
         particles: ["shot"]
         anchors.fill: parent
         system: foreground
@@ -214,7 +214,7 @@ Rectangle{
         color: "orange"
         colorVariation: 0.3
     }
-    ColoredParticle{
+    ImageParticle{
         id: engine
         particles: ["engine"]
         anchors.fill: parent
@@ -238,30 +238,31 @@ Rectangle{
 
         colorVariation: 0.2
     }
-    SpriteParticle{
+    ImageParticle{
         particles: ["powerups"]
         anchors.fill: parent
         system: foreground
-        Sprite{
+        sprites:[Sprite{
             name: "norm"
             source: "content/powerupScore.png"
             frames: 35
             duration: 40
             to: {"norm":1, "got":0}
-        }
+        },
         Sprite{
             name: "got"
             source: "content/powerupScore_got.png"
             frames: 22
             duration: 40
             to: {"null":1}
-        }
+        },
         Sprite{
             name: "null"
             source: "content/powerupScore_gone.png"
             frames: 1
             duration: 1000
         }
+        ]
     }
     SpriteGoal{
         x: rocket.x - 30
@@ -273,8 +274,9 @@ Rectangle{
         onAffected: if(!gameOver) score += 1000
         system: foreground
     }
-    GravitationalSingularity{
+    PointAttractor{
         id: gs1; x: vorteX; y: vorteY; strength: 800000;
+        proportionalToDistance: PointAttractor.Quadratic;
         system: foreground
     }
     Kill{
@@ -285,8 +287,9 @@ Rectangle{
         system: foreground
     }
 
-    GravitationalSingularity{
+    PointAttractor{
         id: gs2; x: vorteX2; y: vorteY2; strength: 800000;
+        proportionalToDistance: PointAttractor.Quadratic;
         system: foreground
     }
     Kill{
@@ -297,8 +300,9 @@ Rectangle{
         system: foreground
     }
 
-    GravitationalSingularity{
+    PointAttractor{
         id: gs3; x: vorteX3; y: vorteY3; strength: 800000;
+        proportionalToDistance: PointAttractor.Quadratic;
         system: foreground
     }
     Kill{
@@ -308,8 +312,9 @@ Rectangle{
         height: holeSize * 2
         system: foreground
     }
-    GravitationalSingularity{
+    PointAttractor{
         id: gs4; x: vorteX4; y: vorteY4; strength: 800000;
+        proportionalToDistance: PointAttractor.Quadratic;
         system: foreground
     }
     Kill{
@@ -319,7 +324,7 @@ Rectangle{
         height: holeSize * 2
         system: foreground
     }        
-    TrailEmitter{
+    Emitter{
         particle: "powerups"
         system: foreground
         particlesPerSecond: 1
@@ -329,7 +334,7 @@ Rectangle{
         particleSizeVariation: 10
         anchors.fill: parent
     }
-    TrailEmitter{
+    Emitter{
         particle: "stars"
         system: foreground
         particlesPerSecond: 40
@@ -374,7 +379,7 @@ Rectangle{
             drag.axis: Drag.XandYAxis
             drag.target: rocket
         },
-        TrailEmitter{
+        Emitter{
             system: foreground
             particle: "engine"
             particlesPerSecond: 100
@@ -383,7 +388,7 @@ Rectangle{
             particleSize: 10
             particleEndSize: 4
             particleSizeVariation: 4
-            speed: PointVector{
+            speed: PointDirection{
                 x: -128 * Math.cos(rocket.rotation * (Math.PI / 180))
                 y: -128 * Math.sin(rocket.rotation * (Math.PI / 180))
             }
@@ -392,14 +397,14 @@ Rectangle{
             width: 4
             
         }, 
-        TrailEmitter{
+        Emitter{
             system: foreground
             particle: "shot"
             particlesPerSecond: 16
             particleDuration: 1600
             emitting: !gameOver && shoot
             particleSize: 40
-            speed: PointVector{
+            speed: PointDirection{
                 x: 256 * Math.cos(rocket.rotation * (Math.PI / 180))
                 y: 256 * Math.sin(rocket.rotation * (Math.PI / 180))
             }
index 8ea0272..8e55503 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     id: root
@@ -49,7 +49,7 @@ Rectangle{
     ParticleSystem{
         id: sys
     }
-    ColoredParticle{
+    ImageParticle{
         system: sys
         image: "content/particle.png"
         color: "white"
@@ -58,9 +58,9 @@ Rectangle{
     }
     Component{
         id: emitterComp
-        TrailEmitter{
+        Emitter{
             id: container
-            TrailEmitter{
+            Emitter{
                 id: emitMore
                 system: sys
                 emitting: true
@@ -68,7 +68,7 @@ Rectangle{
                 particleDuration: 600
                 particleSize: 16
                 particleEndSize: 8
-                speed: AngleVector{angleVariation:360; magnitude: 60}
+                speed: AngledDirection{angleVariation:360; magnitude: 60}
             }
 
             property int life: 2600
index 116a233..cd81168 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle {
     id: root
@@ -52,7 +52,7 @@ Rectangle {
     }
 
     /*
-    ColoredParticle{
+    ImageParticle{
         id: fireball
         anchors.fill: parent
         particles: ["E"]
@@ -62,7 +62,7 @@ Rectangle {
         color: "#00ff400f"
     }
     */
-    ColoredParticle{
+    ImageParticle{
         id: smoke
         system: particles
         anchors.fill: parent
@@ -71,7 +71,7 @@ Rectangle {
         colorVariation: 0
         color: "#00111111"
     }
-    ColoredParticle{
+    ImageParticle{
         id: flame
         anchors.fill: parent
         system: particles
@@ -80,7 +80,7 @@ Rectangle {
         colorVariation: 0.1
         color: "#00ff400f"
     }
-    TrailEmitter{
+    Emitter{
         id: fire
         system: particles
         particle: "C"
@@ -91,8 +91,8 @@ Rectangle {
         particlesPerSecond: 350
         particleDuration: 3500
 
-        acceleration: PointVector{ y: -17; xVariation: 3 }
-        speed: PointVector{xVariation: 3}
+        acceleration: PointDirection{ y: -17; xVariation: 3 }
+        speed: PointDirection{xVariation: 3}
 
         particleSize: 24
         particleSizeVariation: 8
@@ -109,8 +109,8 @@ Rectangle {
         particlesPerParticlePerSecond: 1
         particleDuration: 2000
 
-        speed: PointVector{y:-17*6; yVariation: -17; xVariation: 3}
-        acceleration: PointVector{xVariation: 3}
+        speed: PointDirection{y:-17*6; yVariation: -17; xVariation: 3}
+        acceleration: PointDirection{xVariation: 3}
 
         particleSize: 36
         particleSizeVariation: 8
@@ -145,14 +145,14 @@ Rectangle {
         emissionWidth: 16
         emissionHeight: 16
 
-        speed: PointVector{yVariation: 16; xVariation: 16}
-        acceleration: PointVector{y: -16}
+        speed: PointDirection{yVariation: 16; xVariation: 16}
+        acceleration: PointDirection{y: -16}
 
         particleSize: 24
         particleSizeVariation: 8
         particleEndSize: 8
     }
-    TrailEmitter{
+    Emitter{
         id: balls
         system: particles
         particle: "E"
@@ -163,8 +163,8 @@ Rectangle {
         particlesPerSecond: 2
         particleDuration: 7000
 
-        speed: PointVector{y:-17*4*2; xVariation: 6*6}
-        acceleration: PointVector{y: 17*2; xVariation: 6*6}
+        speed: PointDirection{y:-17*4*2; xVariation: 6*6}
+        acceleration: PointDirection{y: 17*2; xVariation: 6*6}
 
         particleSize: 12
         particleSizeVariation: 4
index 38eb8e6..b2895dd 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     id: root
@@ -55,30 +55,26 @@ Rectangle{
         id: sys
         startTime: 4000
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         y:root.height + 20
         width: root.width
         particlesPerSecond: 200
         particleDuration: 4000
-        speed: PointVector{ y: -120; }
+        speed: PointDirection{ y: -120; }
     }
-    SpriteParticle{
+    ImageParticle{
         system: sys
         visible: !cloneMode
-        Sprite{
-            source: "content/particle2.png"
-        }
+        image: "content/particle2.png"
     }
-    SpriteParticle{
+    ImageParticle{
         system: sys
         visible: cloneMode
         z: 0
-        Sprite{
-            source: "content/particle3.png"
-        }
+        image: "content/particle3.png"
     }
-    SpriteParticle{
+    ImageParticle{
         system: sys
         clip: true
         visible: cloneMode
@@ -86,8 +82,6 @@ Rectangle{
         height: 240
         width: root.width
         z: 1
-        Sprite{
-            source: "content/particle.png"
-        }
+        image: "content/particle.png"
     }
 }
index 2ab579f..7874590 100644 (file)
 // highlight bar is moved between items. + Particles.
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import "content"
 
 Rectangle {
     width: 200; height: 300
     color: "black"
     ParticleSystem{ id: particles }
-    ColoredParticle{
+    ImageParticle{
         anchors.fill: parent
         system: particles
         z: 10
@@ -92,7 +92,7 @@ Rectangle {
             y: listView.currentItem.y;
             //Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } }
             Behavior on y { NumberAnimation {id: anim} }
-            TrailEmitter{
+            Emitter{
                 anchors.fill: parent
                 system: particles;
                 emitting: anim.running
index 6ca1597..ed9313d 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "black"
     width: 360
     height: 540
     ParticleSystem{ id: sys }
-    ColoredParticle{
+    ImageParticle{
         system: sys
         id: cp
         image: "content/particle.png"
         colorVariation: 0.4
         color: "#000000FF"
     }
-    TrailEmitter{
+    Emitter{
         //burst on click
         id: bursty
         system: sys
@@ -63,7 +63,7 @@ Rectangle{
         particlesPerSecond: 16000
         particleDuration: 1000
         maxParticles: 4000
-        acceleration: AngleVector{angleVariation: 360; magnitude: 360; }
+        acceleration: AngledDirection{angleVariation: 360; magnitude: 360; }
         particleSize: 8
         particleEndSize: 16
         particleSizeVariation: 4
index dba2e59..ae9b447 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     id: root
@@ -54,7 +54,7 @@ Rectangle{
         id: particles 
         startTime: 2000
     }
-    ColoredParticle{
+    ImageParticle{
         particles: ["center","edge"]
         anchors.fill: parent
         system: particles
@@ -62,7 +62,7 @@ Rectangle{
         colorVariation: 0.1
         color: "#009999FF"
     }
-    TrailEmitter{
+    Emitter{
         anchors.fill: parent
         particle: "center"
         system: particles
@@ -72,15 +72,15 @@ Rectangle{
         particleSize: 20
         particleSizeVariation: 2
         particleEndSize: 0
-        shape: Ellipse{fill: false}
-        speed: DirectedVector{
+        shape: EllipseShape{fill: false}
+        speed: TargetedDirection{
             targetX: root.width/2 
             targetY: root.height/2
             proportionalMagnitude: true
             magnitude: 0.5
         }
     }
-    TrailEmitter{
+    Emitter{
         anchors.fill: parent
         particle: "edge"
         system: particles
@@ -90,15 +90,15 @@ Rectangle{
         particleSize: 20
         particleSizeVariation: 2
         particleEndSize: 0
-        shape: Ellipse{fill: false}
-        speed: DirectedVector{
+        shape: EllipseShape{fill: false}
+        speed: TargetedDirection{
             targetX: root.width/2 
             targetY: root.height/2
             proportionalMagnitude: true
             magnitude: 0.1
             magnitudeVariation: 0.1
         }
-        acceleration: DirectedVector{
+        acceleration: TargetedDirection{
             targetX: root.width/2 
             targetY: root.height/2
             targetVariation: 200
index 6c64929..543a9b6 100644 (file)
@@ -38,7 +38,7 @@
 **
 ****************************************************************************/
 
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 import QtQuick 2.0
 
 Rectangle {
@@ -48,7 +48,7 @@ Rectangle {
     color: "black"
 
     ParticleSystem{ id: particles }
-    ColoredParticle{
+    ImageParticle{
         system: particles
         colorVariation: 0.5
         alpha: 0
@@ -57,7 +57,7 @@ Rectangle {
         colorTable: "content/colortable.png"
         sizeTable: "content/colortable.png"
     }
-    TrailEmitter{
+    Emitter{
         system: particles
         particlesPerSecond: 500
         particleDuration: 2000
@@ -72,8 +72,8 @@ Rectangle {
 
         speedFromMovement: 20
 
-        speed: PointVector{ xVariation: 5; yVariation: 5;}
-        acceleration: PointVector{ xVariation: 5; yVariation: 5;}
+        speed: PointDirection{ xVariation: 5; yVariation: 5;}
+        acceleration: PointDirection{ xVariation: 5; yVariation: 5;}
 
         particleSize: 16
         //particleEndSize: 8
index 06f599d..b3157f6 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     width: 360
@@ -53,7 +53,7 @@ Rectangle{
         id: particles 
         running: false
     }
-    ColoredParticle{
+    ImageParticle{
         anchors.fill: parent
         system: particles
         image: "content/star.png"
@@ -61,7 +61,7 @@ Rectangle{
         alpha: 0
         colorVariation: 0.6
     }
-    TrailEmitter{
+    Emitter{
         anchors.fill: parent
         system: particles
         particlesPerSecond: 2000
diff --git a/examples/declarative/particles/trails/swarm.qml b/examples/declarative/particles/trails/swarm.qml
deleted file mode 100644 (file)
index 083f9e8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-**     the names of its contributors may be used to endorse or promote
-**     products derived from this software without specific prior written
-**     permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.particles 2.0 as QLP
-
-Rectangle{
-    width: 200
-    height: 200
-    color: "black"
-    QLP.ParticleSystem{ id: ps }
-    QLP.ColoredParticle{
-        system: ps
-        particles: ["star1","star2"]
-        anchors.fill: parent
-        clip: true
-        image: "content/star.png"
-    }
-    QLP.Swarm{ 
-        system: ps
-        leaders: ["star2"]; 
-        anchors.fill: parent
-        strength: 128
-    }
-    QLP.TrailEmitter{
-        anchors.fill: parent
-        system: ps
-        particle: "star1"
-        particlesPerSecond: 100
-        particleDuration: 2000
-    }
-    QLP.TrailEmitter{
-        anchors.fill: parent
-        system: ps
-        particle: "star2"
-        particlesPerSecond: 0.4
-        particleDuration: 10000
-        particleSize: 64
-        particleEndSize: 32
-    }
-}
index 58d369c..6ee8a6e 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     color: "black"
     width: 360
     height: 540
     ParticleSystem{ id: sys }
-    ColoredParticle{
+    ImageParticle{
         system: sys
         id: cp
         image: "content/particle.png"
         color: "#00FFFFFF"
         colorVariation: 0.4
     }
-    TrailEmitter{
+    Emitter{
     //burst on click
         id: bursty
         system: sys
         emitting: false
         particlesPerSecond: 2000
         particleDuration: 500
-        acceleration: AngleVector{ angle: 90; angleVariation: 360; magnitude: 640; }
+        acceleration: AngledDirection{ angle: 90; angleVariation: 360; magnitude: 640; }
         particleSize: 8
         particleEndSize: 16
         particleSizeVariation: 4
     }
-    TrailEmitter{
+    Emitter{
         system: sys
         speedFromMovement: 4.0
         emitting: ma.pressed
@@ -73,7 +73,7 @@ Rectangle{
         y: ma.mouseY
         particlesPerSecond: 400
         particleDuration: 2000
-        acceleration: AngleVector{ angle: 90; angleVariation: 22; magnitude: 32; }
+        acceleration: AngledDirection{ angle: 90; angleVariation: 22; magnitude: 32; }
         particleSize: 8
         particleEndSize: 16
         particleSizeVariation: 8
index 7da5046..bde25bc 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle{
     width: 360
@@ -66,21 +66,21 @@ Rectangle{
         frequency: 64
         gridSize: 16
     }
-    ColoredParticle{
+    ImageParticle{
         particles: ["smoke"]
         system: ps
         image: "content/particle.png"
         color: "#11111111"
         colorVariation: 0
     }
-    ColoredParticle{
+    ImageParticle{
         particles: ["flame"]
         system: ps
         image: "content/particle.png"
         color: "#11ff400f"
         colorVariation: 0.1
         }
-    TrailEmitter{
+    Emitter{
         anchors.centerIn: parent
         system: ps
         particle: "flame"
@@ -90,8 +90,8 @@ Rectangle{
         particleSize: 20
         particleEndSize: 10
         particleSizeVariation: 10
-        acceleration: PointVector{ y: -40 }
-        speed: AngleVector{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
+        acceleration: PointDirection{ y: -40 }
+        speed: AngledDirection{ angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
     }
     FollowEmitter{
         id: smoke1
@@ -107,8 +107,8 @@ Rectangle{
         particleSize: 16
         particleEndSize: 8
         particleSizeVariation: 8
-        acceleration: PointVector{ y: -40 }
-        speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+        acceleration: PointDirection{ y: -40 }
+        speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
     }
     FollowEmitter{
         id: smoke2
@@ -123,7 +123,7 @@ Rectangle{
         particleSize: 36
         particleEndSize: 24
         particleSizeVariation: 8
-        acceleration: PointVector{ y: -40 }
-        speed: AngleVector{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
+        acceleration: PointDirection{ y: -40 }
+        speed: AngledDirection{ angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
     }
 }
index 3692410..d2e4ed2 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 2.0
+import QtQuick.Particles 2.0
 
 Rectangle {
 
@@ -75,7 +75,7 @@ Rectangle {
     }
 
     ParticleSystem{ id: sys1 }
-    ColoredParticle{
+    ImageParticle{
         system: sys1
         image: "content/particle.png"
         color: "cyan"
@@ -105,7 +105,7 @@ Rectangle {
         }
         colorVariation: 0.3
     }
-    TrailEmitter{
+    Emitter{
         id: trailsNormal
         system: sys1
 
@@ -116,15 +116,15 @@ Rectangle {
         y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
         x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
 
-        speed: PointVector{xVariation: 4; yVariation: 4;}
-        acceleration: PointVector{xVariation: 10; yVariation: 10;}
+        speed: PointDirection{xVariation: 4; yVariation: 4;}
+        acceleration: PointDirection{xVariation: 10; yVariation: 10;}
         speedFromMovement: 8
 
         particleSize: 8
         particleSizeVariation: 4
     }
     ParticleSystem { id: sys2 }
-    ColoredParticle{
+    ImageParticle{
         color: "cyan"
         system: sys2
         alpha: 0
@@ -144,7 +144,7 @@ Rectangle {
         colorVariation: 0.5
         image: "content/star.png"
     }
-    TrailEmitter{
+    Emitter{
         id: trailsStars
         system: sys2
 
@@ -155,15 +155,15 @@ Rectangle {
         y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
         x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
 
-        speed: PointVector{xVariation: 4; yVariation: 4;}
-        acceleration: PointVector{xVariation: 10; yVariation: 10;}
+        speed: PointDirection{xVariation: 4; yVariation: 4;}
+        acceleration: PointDirection{xVariation: 10; yVariation: 10;}
         speedFromMovement: 8
 
         particleSize: 22
         particleSizeVariation: 4
     }
     ParticleSystem { id: sys3; }
-    ColoredParticle{
+    ImageParticle{
         image: "content/particle.png"
         system: sys3
         color: "orange"
@@ -185,7 +185,7 @@ Rectangle {
         colorVariation: 0.2
 
     }
-    TrailEmitter{
+    Emitter{
         id: trailsNormal2
         system: sys3
 
@@ -197,14 +197,14 @@ Rectangle {
 
         speedFromMovement: 16
 
-        speed: PointVector{xVariation: 4; yVariation: 4;}
-        acceleration: PointVector{xVariation: 10; yVariation: 10;}
+        speed: PointDirection{xVariation: 4; yVariation: 4;}
+        acceleration: PointDirection{xVariation: 10; yVariation: 10;}
 
         particleSize: 12
         particleSizeVariation: 4
     }
     ParticleSystem { id: sys4; }
-    ColoredParticle{
+    ImageParticle{
         system: sys4
         image: "content/star.png"
         color: "green"
@@ -225,7 +225,7 @@ Rectangle {
 
         colorVariation: 0.5
     }
-    TrailEmitter{
+    Emitter{
         id: trailsStars2
         system: sys4
 
@@ -237,8 +237,8 @@ Rectangle {
         x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx
 
         speedFromMovement: 16
-        speed: PointVector{xVariation: 2; yVariation: 2;}
-        acceleration: PointVector{xVariation: 10; yVariation: 10;}
+        speed: PointDirection{xVariation: 2; yVariation: 2;}
+        acceleration: PointDirection{xVariation: 10; yVariation: 10;}
 
         particleSize: 22
         particleSizeVariation: 4
index 3fe28b3..d9a4639 100644 (file)
@@ -53,7 +53,7 @@ QSGMaskExtruder::QSGMaskExtruder(QObject *parent) :
 QPointF QSGMaskExtruder::extrude(const QRectF &r)
 {
     ensureInitialized(r);
-    if(!m_mask.count())
+    if(!m_mask.count() || m_img.isNull())
         return r.topLeft();
     const QPointF p = m_mask[rand() % m_mask.count()];
     //### Should random sub-pixel positioning be added?
@@ -63,6 +63,8 @@ QPointF QSGMaskExtruder::extrude(const QRectF &r)
 bool QSGMaskExtruder::contains(const QRectF &bounds, const QPointF &point)
 {
     ensureInitialized(bounds);//###Current usage patterns WILL lead to different bounds/r calls. Separate list?
+    if(m_img.isNull())
+        return false;
     QPoint p = point.toPoint() - bounds.topLeft().toPoint();
     return m_img.rect().contains(p) && (bool)m_img.pixelIndex(p);
 }
@@ -70,14 +72,19 @@ bool QSGMaskExtruder::contains(const QRectF &bounds, const QPointF &point)
 void QSGMaskExtruder::ensureInitialized(const QRectF &r)
 {
     if(m_lastWidth == r.width() && m_lastHeight == r.height())
-        return;
+        return;//Same as before
     m_lastWidth = r.width();
     m_lastHeight = r.height();
 
+    m_img = QImage();
     m_mask.clear();
     if(m_source.isEmpty())
         return;
     m_img = QImage(m_source.toLocalFile());
+    if(m_img.isNull()){
+        qWarning() << "MaskShape: Cannot load" << qPrintable(m_source.toLocalFile());
+        return;
+    }
     m_img = m_img.createAlphaMask();
     m_img = m_img.convertToFormat(QImage::Format_Mono);//Else LSB, but I think that's easier
     m_img = m_img.scaled(r.size().toSize());//TODO: Do they need aspect ratio stuff? Or tiling?
index 1572ad8..b299158 100644 (file)
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
 
 QT_MODULE(Declarative)
 
-
 class QSGParticleAffector : public QSGItem
 {
     Q_OBJECT
index 3c3ca33..4c67523 100644 (file)
@@ -45,6 +45,7 @@
 QT_BEGIN_NAMESPACE
 QSGPointAttractorAffector::QSGPointAttractorAffector(QSGItem *parent) :
     QSGParticleAffector(parent), m_strength(0.0), m_x(0), m_y(0)
+  , m_physics(Velocity), m_proportionalToDistance(Linear)
 {
 }
 
@@ -52,15 +53,36 @@ bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
 {
     if(m_strength == 0.0)
         return false;
-    qreal dx = m_x - d->curX();
-    qreal dy = m_y - d->curY();
+    qreal dx = m_y - d->curX();
+    qreal dy = m_x - d->curY();
     qreal r = sqrt((dx*dx) + (dy*dy));
     qreal theta = atan2(dy,dx);
-    qreal ds = (m_strength / r) * dt;
+    qreal ds = 0;
+    switch(m_proportionalToDistance){
+    case Quadratic:
+        ds = (m_strength / qMax(1.,r*r)) * dt;
+        break;
+    case Linear://also default
+    default:
+        ds = (m_strength / qMax(1.,r)) * dt;
+    }
     dx = ds * cos(theta);
     dy = ds * sin(theta);
-    d->setInstantaneousSX(d->pv.sx + dx);
-    d->setInstantaneousSY(d->pv.sy + dy);
+    switch(m_physics){
+    case Position:
+        d->pv.x = (d->pv.x + dx);
+        d->pv.y = (d->pv.y + dy);
+        break;
+    case Acceleration:
+        d->setInstantaneousAX(d->pv.ax + dx);
+        d->setInstantaneousAY(d->pv.ay + dy);
+        break;
+    case Velocity: //also default
+    default:
+        d->setInstantaneousSX(d->pv.sx + dx);
+        d->setInstantaneousSY(d->pv.sy + dy);
+    }
+
     return true;
 }
 QT_END_NAMESPACE
index d4f7159..3ca29df 100644 (file)
@@ -57,7 +57,23 @@ class QSGPointAttractorAffector : public QSGParticleAffector
     Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
     Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
     Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
+    Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+    Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
+    Q_ENUMS(PhysicsAffects)
+    Q_ENUMS(Proportion)
+
 public:
+    enum Proportion{
+        Linear,
+        Quadratic
+    };
+
+    enum PhysicsAffects {
+        Position,
+        Velocity,
+        Acceleration
+    };
+
     explicit QSGPointAttractorAffector(QSGItem *parent = 0);
 
     qreal strength() const
@@ -75,6 +91,16 @@ public:
         return m_y;
     }
 
+    PhysicsAffects physics() const
+    {
+        return m_physics;
+    }
+
+    Proportion proportionalToDistance() const
+    {
+        return m_proportionalToDistance;
+    }
+
 signals:
 
     void strengthChanged(qreal arg);
@@ -83,6 +109,10 @@ signals:
 
     void yChanged(qreal arg);
 
+    void physicsChanged(PhysicsAffects arg);
+
+    void proportionalToDistanceChanged(Proportion arg);
+
 public slots:
 void setStrength(qreal arg)
 {
@@ -107,12 +137,30 @@ void setY(qreal arg)
         emit yChanged(arg);
     }
 }
+void setPhysics(PhysicsAffects arg)
+{
+    if (m_physics != arg) {
+        m_physics = arg;
+        emit physicsChanged(arg);
+    }
+}
+
+void setProportionalToDistance(Proportion arg)
+{
+    if (m_proportionalToDistance != arg) {
+        m_proportionalToDistance = arg;
+        emit proportionalToDistanceChanged(arg);
+    }
+}
+
 protected:
     virtual bool affectParticle(QSGParticleData *d, qreal dt);
 private:
 qreal m_strength;
 qreal m_x;
 qreal m_y;
+PhysicsAffects m_physics;
+Proportion m_proportionalToDistance;
 };
 
 QT_END_NAMESPACE
index e6787f2..6e56d6a 100644 (file)
@@ -44,7 +44,8 @@
 QT_BEGIN_NAMESPACE
 
 QSGWanderAffector::QSGWanderAffector(QSGItem *parent) :
-    QSGParticleAffector(parent)
+    QSGParticleAffector(parent), m_xVariance(0), m_yVariance(0), m_pace(0)
+    , m_physics(Velocity)
 {
     m_needsReset = true;
 }
@@ -81,6 +82,7 @@ void QSGWanderAffector::reset(int systemIdx)
 
 bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
 {
+    /*TODO: Add a mode which does basically this - picking a direction, going in it (random speed) and then going back
     WanderData* d = getData(data->systemIndex);
     if (m_xVariance != 0.) {
         if ((d->x_vel > d->x_peak && d->x_var > 0.0) || (d->x_vel < -d->x_peak && d->x_var < 0.0)) {
@@ -106,5 +108,37 @@ bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
 
     p->y += dy;
     return true;
+    */
+    qreal dx = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
+    qreal dy = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
+    qreal newX, newY;
+    switch(m_physics){
+    case Position:
+        newX = data->curX() + dx;
+        if(m_xVariance > qAbs(newX) )
+            data->pv.x += dx;
+        newY = data->curY() + dy;
+        if(m_yVariance > qAbs(newY) )
+            data->pv.y += dy;
+        break;
+    default:
+    case Velocity:
+        newX = data->curSX() + dx;
+        if(m_xVariance > qAbs(newX) )
+            data->setInstantaneousSX(newX);
+        newY = data->curSY() + dy;
+        if(m_yVariance > qAbs(newY) )
+            data->setInstantaneousSY(newY);
+        break;
+    case Acceleration:
+        newX = data->pv.ax + dx;
+        if(m_xVariance > qAbs(newX) )
+            data->setInstantaneousAX(newX);
+        newY = data->pv.ay + dy;
+        if(m_yVariance > qAbs(newY) )
+            data->setInstantaneousAY(newY);
+        break;
+    }
+    return true;
 }
 QT_END_NAMESPACE
index 45c8ca8..783efc8 100644 (file)
@@ -63,11 +63,19 @@ struct WanderData{
 class QSGWanderAffector : public QSGParticleAffector
 {
     Q_OBJECT
+    Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
     Q_PROPERTY(qreal xVariance READ xVariance WRITE setXVariance NOTIFY xVarianceChanged)
     Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
-    Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
+    Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+    Q_ENUMS(PhysicsAffects)
 
 public:
+    enum PhysicsAffects {
+        Position,
+        Velocity,
+        Acceleration
+    };
+
     explicit QSGWanderAffector(QSGItem *parent = 0);
     ~QSGWanderAffector();
     virtual void reset(int systemIdx);
@@ -86,6 +94,12 @@ public:
     {
         return m_pace;
     }
+
+    PhysicsAffects physics() const
+    {
+        return m_physics;
+    }
+
 protected:
     virtual bool affectParticle(QSGParticleData *d, qreal dt);
 signals:
@@ -96,6 +110,9 @@ signals:
 
     void paceChanged(qreal arg);
 
+
+    void physicsChanged(PhysicsAffects arg);
+
 public slots:
 void setXVariance(qreal arg)
 {
@@ -121,12 +138,22 @@ void setPace(qreal arg)
     }
 }
 
+
+void setPhysics(PhysicsAffects arg)
+{
+    if (m_physics != arg) {
+        m_physics = arg;
+        emit physicsChanged(arg);
+    }
+}
+
 private:
     WanderData* getData(int idx);
     QHash<int, WanderData*> m_wanderData;
     qreal m_xVariance;
     qreal m_yVariance;
     qreal m_pace;
+    PhysicsAffects m_physics;
 };
 
 QT_END_NAMESPACE