I think maybe you should use the SmoothedAnimation velocity property, which woud be degrees per second? You'll also have to change the Easing to linear.
Sent: Wednesday, April 27, 2016 at 1:38 PM
From: "Ramy Atalla via Interest" <interest@qt-project.org>
To: "Qt Project" <interest@qt-project.org>
Subject: Re: [Interest] [Qt3d] Does the duration of NumberAnimation update when you change its value?
From: "Ramy Atalla via Interest" <interest@qt-project.org>
To: "Qt Project" <interest@qt-project.org>
Subject: Re: [Interest] [Qt3d] Does the duration of NumberAnimation update when you change its value?
Hi DR. Sean
Thanks for reply.
I tried both methods none of them works, Overall I think I have a problem controlling the animation (start/stop/restart).
I have a slider which generates a value between 0-5000 for the duration of the animation, On value change of the slider it calls a function which does the follow:
(1)stops the animation(doesn't work,however console log for animation.running updates to false).
(2)updates the value of the property "carspeed".
(3) restarts the animation(doesn't work,however console log for animation.running updates to true).
I know there is something implemented wrong.If I initialize the animation running:true it won't stop and if I initialize it to running:false it won't start.
Car.qml (one wheel and one rim transform)
Transform {id: wheel1Transformproperty real userAngle: 0.0translation:Qt.vector3d(-1.35, 0.368, 1.8)rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), userAngle)}Transform {id: rim1Transformproperty real userAngle: 0.0translation:Qt.vector3d(-1.40, 0.368, 1.8)rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), userAngle)}
Car.qml (wheeling and rim rotation animation)
property alias wheelanimationControl : wheelanimationMainproperty real carspeed:2000QQ2.SequentialAnimation {id :wheelanimationMainrunning: falseloops: QQ2.Animation.InfiniteQQ2.NumberAnimation {id:wheelanimationtargets:[ wheel1Transform, rim1Transform,wheel2Transform , rim2Transform,wheel3Transform , rim3Transform,wheel4Transform , rim4Transform]properties: "userAngle"duration: carspeedfrom: 0to: 360alwaysRunToEnd:false// onDurationChanged: wheelanimationMain.restart()}}Car.qml (the function that the slider will use)function sliderValue(){console.log("before",wheel1Transform.userAngle,wheelanimationMain.running,slider.value, rootcar.carspeed)wheelanimationMain.stop();wheelanimationMain.running=false; // redundant steprootcar.carspeed = slider.value;wheelanimationMain.restart();wheelanimationMain.running=true; // redundant stepconsole.log("after",wheel1Transform.userAngle,wheelanimationMain.running,slider.value, rootcar.carspeed)}Slider.qmlimport QtQuick 2.5import QtQuick.Controls 1.4Item {id :rootwidth: 300height: 80Rectangle {id: rectangle1x: 696y: 30width: 300height: 80color: "#202020"radius: 1border.color: "#ffffff"opacity: 0.5}
Text {id: text1x: 705y: 33color: "#ffffff"text: qsTr("Speed")horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenterfont.pixelSize: 13}
MouseArea {id: mouseArea1x: 696y: 30width: 300height: 80onClicked: root.visible=falsecursorShape: Qt.PointingHandCursor}
Car{ id:car }Slider{id:sliderx: 716y: 68width: 263height: 22maximumValue: 5000stepSize: 100updateValueWhileDragging :trueonValueChanged: car.sliderValue()}
Label {x: 910y: 45width: 63height: 16color: "#ffffff"text: Math.floor(slider.value/10)+" MPH"horizontalAlignment: Text.AlignHCenter}
Rectangle {id: rectangle2x: 600y: 30width: 80height: 80color: "#202020"radius: 1border.color: "#ffffff"opacity: 0.5}
Text {id: text2x: 600y: 33color: "#ffffff"text: qsTr("run")horizontalAlignment: Text.AlignHCenterverticalAlignment: Text.AlignVCenterfont.pixelSize: 13}
MouseArea {id: mouseArea2x: 600y: 30width: 80height: 80onClicked: car.wheelanimationControl.running=true;cursorShape: Qt.PointingHandCursor}
}Thanks,Ramy
---------------------------------------------------------------
Hi,
Hi,
I don't think this works unless you stop/restart the animation which is not
ideal. A work around is to have a simple NumberAnimation changing a "progress"
value, then in your actual property that you wish to animate, multiply this
progress property by your rotationSpeed property. It requires some extra
gymnastics to cope with non-integer numbers of rotations per cycle of the
progress property.
Something like this should do it (not tested):
Entity {
id: root
property real progress: 0.0
property real rotationSpeed: 10.0
property real angle: previousAngle + ( progress * rotationSpeed )
property real previousAngle: 0.0
function updatePreviousRotation() {
root.previousAngle = root.angle;
}
SequentialAnimation {
running: true
loops: Animation.Infinite
NumberAnimation {
from: 0; to: 1
duration: 1000
}
ScriptAction { script: updatePreviousRotation() }
}
}
This is a limitation of what can be expressed with the Qt Quick 2 animation
framework at present. When we look at adding an animation aspect to Qt 3D for
Qt 5.8 or 5.9, this is one of the things I want to address along with morph
target, key frame and skeletal animations. More likely for 5.9 given we're
already well into the development cycle for 5.8 and we're still putting all
efforts into 5.7.
Hope this helps,
Sean
--
Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
ideal. A work around is to have a simple NumberAnimation changing a "progress"
value, then in your actual property that you wish to animate, multiply this
progress property by your rotationSpeed property. It requires some extra
gymnastics to cope with non-integer numbers of rotations per cycle of the
progress property.
Something like this should do it (not tested):
Entity {
id: root
property real progress: 0.0
property real rotationSpeed: 10.0
property real angle: previousAngle + ( progress * rotationSpeed )
property real previousAngle: 0.0
function updatePreviousRotation() {
root.previousAngle = root.angle;
}
SequentialAnimation {
running: true
loops: Animation.Infinite
NumberAnimation {
from: 0; to: 1
duration: 1000
}
ScriptAction { script: updatePreviousRotation() }
}
}
This is a limitation of what can be expressed with the Qt Quick 2 animation
framework at present. When we look at adding an animation aspect to Qt 3D for
Qt 5.8 or 5.9, this is one of the things I want to address along with morph
target, key frame and skeletal animations. More likely for 5.9 given we're
already well into the development cycle for 5.8 and we're still putting all
efforts into 5.7.
Hope this helps,
Sean
--
Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
---------------------------------------------------------------
Hi,
I am trying to do a rotation animation and control the rotation speed by changing the value of the duration, But it doesn't work . My question is it feasible or there another way ?
QQ2.NumberAnimation {
id:wheelanimation
property int carspeed:0
targets: [wheel1Transform , rim1Transform,wheel2Transform , rim2Transform,wheel3Transform , rim3Transform,wheel4Transform , rim4Transform]
property: "userAngle"
duration: carspeed
from: 0
to: 360
loops: QQ2.Animation.Infinite
running: true
}
QQ2.NumberAnimation {
duration: 100
loops: QQ2.Animation.Infinite
target: wheelanimation
property: "carspeed"
from: 0.0
to: 3000
running: true
}
Thanks
Ramy
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest