C++/Qt3d binding Sequential Animation based on a variable

  • Hi all,

    I am new in qml and qt3d development I have found a problem that so far I haven't overcome and it is driving me nuts. My intention is to have a Animation or transformation that is continuously updated by a variablle.

    I have successfully loaded a .stl file using qt3d which I can apply a few transformations and animations, I have some data that comes from a C++ class that is being received properly according to the values displayed. However if I enter in an infinite loop SequentialAnimation I would expect my animation to be updated by the new values that I am receiving periodically, as I am printing them out I can see they are different but when I apply a rotation it seems that only uses the one that read only once when it was loaded.
    I have also tried to create a java function that returned the updated value by calling it in my to: NumberAnimation, however it didn't work. The behaviour was identical as shown bellow, it rotates only once until it reaches the value initially loaded.
    I would truly appreciate any inputs on this, I wonder if NumberAnimation only accepts constant values and probably there could be a better way to do it.

    Thank you in advance,

    Here is my code:

    @Image {

    source: "background.jpg"
    width: 800
    height: 600
    property variant m_external: 10 //Periodically updated variable
        width: 800
        height: 600
       camera: Camera { eye: Qt.vector3d(210,100,190)}
               id: y6
               mesh: Mesh { source : "y6.stl"; options: "ForceSmooth"}
                Light {}
                   transform: [
                          Rotation3D {id: swivel1; angle: -90; axis: Qt.vector3d(1,0,0)},
                          Rotation3D {id: swivel2; angle: 0; axis: Qt.vector3d(0,1,0)},
                          Rotation3D {id: swivel3; angle: 0; axis: Qt.vector3d(0,0,1)}
                                running: true
                                loops: Animation.Infinite
                                NumberAnimation {target: swivel2; property: "angle"; to : m_external; duration: 1000; easing.type: "OutQuad"}


  • Try SmoothedAnimation.
    It recalculates itself when limits change.

  • Thanks sDubitskiy, I replaced my NumberAnimation line by the following:
    @ SmoothedAnimation{target:swivel2; property : "angle"; to: m_external; duration: 1000; easing.type: "Linear"}@
    And didn't work. I think I am going to transfer my code to qt3d instead that looks more intuitive to me, as I don't know how to solve this relatively simple problem with qml.

Log in to reply