[Interest] [Qt3d] Does the duration of NumberAnimation update when you change its value?

Sean Harmer sean.harmer at kdab.com
Wed Apr 27 09:44:15 CEST 2016


On Tuesday 26 April 2016 22:27:16 Oleg Evseev wrote:
> Hi, Ramy and Sean
> 
> > Something like this should do it (not tested)
> 
> Thank you, Sean. Correct it little bit, tested, it works:
> 
> Entity {
> 
>         id: mainEntity
> 
>         property real progress: 0.0
> 
>         property real rotationSpeed: -1.0
> 
>         property real angle: previousAngle + ( progress * 360.0 *
> rotationSpeed  )
> 
>         property real previousAngle: 0.0
> 
> 
>         function updatePreviousRotation() {
> 
>             mainEntity.previousAngle = mainEntity.angle % 360;
> 
>         }
> 
> 
>         TorusMesh { id: mesh; radius: 5; minorRadius: 1; rings: 100;
> slices: 20 }
> 
>         PhongMaterial { id: material }
> 
> 
> //for some reason in this test project using just "angle" leads to
> ReferenceError,
> // but in another project it's all right to use Entity properties in
> Transform without Entity id
> 
>         Transform {id: transform; rotation:  fromEulerAngles(0,
> mainEntity.angle, 0) }
> 
> 
>         SequentialAnimation {
> 
>             running: true
> 
>             loops: Animation.Infinite
> 
> 
>             NumberAnimation {
> 
>                 target: mainEntity; property: "progress"
> 
>                 from: 0.0; to: 1.0
> 
>                 duration: 1000
> 
>             }
> 
> 
>             ScriptAction {
> 
>                 script: {
> 
>                     mainEntity.updatePreviousRotation();
> 
>                     mainEntity.rotationSpeed += 0.1;
> 
>                 }
> 
>             }
> 
>         components: [ mesh, material, transform ]    }
> }
> 
> 
> rotationSpeed defines cycles per second.
> 
> But now I have another related question. To compute rotationSpeed from
> vehicle linear speed one needs wheel radius. If I use different vehicle
> models with distinct size of wheels, I need to know sizes of a mesh
> (something like size of 3d model collision box).
> Is there a way to get mesh cube size?

At the moment, no. This is something we may well add for 5.8. For now you'll 
need to calculate it yourself or pass it in as metadata somehow.

Cheers,

Sean

> 
> Regards, Oleg

-- 
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts



More information about the Interest mailing list