Play animations defined in glTF files. More...
Header: | #include <Kuesa/AnimationPlayer> |
Since: | Kuesa 1.0 |
Instantiated By: | AnimationPlayer |
Inherits: | Kuesa::KuesaNode |
Inherited By: |
This class was introduced in Kuesa 1.0.
enum | Status { None, Ready, Error } |
|
void | addTarget(Qt3DCore::QNode *target) |
QString | clip() const |
Qt3DAnimation::QClock * | clock() const |
int | currentLoop() const |
float | duration() const |
bool | isRunning() const |
int | loopCount() const |
QString | mapper() const |
float | normalizedTime() const |
void | removeTarget(Qt3DCore::QNode *target) |
Kuesa::AnimationPlayer::Status | status() const |
QVector<Qt3DCore::QNode *> | targets() const |
void | reset() |
void | restart(int delay = 0) |
void | run(float fromTimeFraction, float toTimeFraction) |
void | setClip(const QString &clip) |
void | setClock(Qt3DAnimation::QClock *clock) |
void | setLoopCount(int loops) |
void | setMapper(const QString &mapper) |
void | setNormalizedTime(float timeFraction) |
void | setRunning(bool running) |
void | start(int delay = 0) |
void | stop() |
void | clipChanged(const QString &clip) |
void | clockChanged(Qt3DAnimation::QClock *clock) |
void | currentLoopChanged(int currentLoop) |
void | durationChanged(float duration) |
void | loopCountChanged(int loops) |
void | mapperChanged(const QString &mapper) |
void | normalizedTimeChanged(float index) |
void | runningChanged(bool running) |
void | statusChanged(Kuesa::AnimationPlayer::Status status) |
AnimationPlayer is a utility class designed to easily control animations where the clip and mapping data is stored in a collections (typically loaded from glTF files).
Clip and mapper data are referenced by name. These will be used to look up actual assets in the appropriate collection.
AnimationPlayer internally uses an instance of Qt3DAnimation::QClipAnimator and mirrors it's api.
Additionally, AnimationPlayer can be used to map clip data to other target objects than those specified in a mapper. For example, an animation where the clip data affect transformation properties, can be applied to any Qt3DCore::QTransform instance, not just the one specified in the mapper data.
This enum type describes state of the player.
Constant | Value | Description |
---|---|---|
Kuesa::AnimationPlayer::None | 0 | Unknown state (default). |
Kuesa::AnimationPlayer::Ready | 1 | Both clip and mapper data have been found and are valid (included target nodes if they have been defined). |
Kuesa::AnimationPlayer::Error | 2 | An error occurred when looking for assets or trying to match clip and mapper properties. |
This property holds the name of the clip asset.
This will be used to lookup the asset in the AnimationClipCollection instance of the SceneEntity.
Access functions:
QString | clip() const |
void | setClip(const QString &clip) |
Notifier signal:
void | clipChanged(const QString &clip) |
intense of Qt3DAnimation::QClock used to control animation speed and direction
A Qt3DAnimation::QClock can be used to control the speed (by setting the playBackRate) and direction (like reversing by setting negative playBackRate values) of the animation.
This reflects the state of the internal Qt3DAnimation::QClipAnimator instance.
Access functions:
Qt3DAnimation::QClock * | clock() const |
void | setClock(Qt3DAnimation::QClock *clock) |
Notifier signal:
void | clockChanged(Qt3DAnimation::QClock *clock) |
duration of the animation in secconds
This property was introduced in Qt 1.1.
Access functions:
float | duration() const |
Notifier signal:
void | durationChanged(float duration) |
controls the number of time the animation should repeat.
If the value is 0 (default), the animation will run only once.
If the value is AnimationPlayer::Infinite, the animation will loop indefinitly until explicitly stopped.
Otherwise, it will repeat the specified number of times.
This reflects the state of the internal Qt3DAnimation::QClipAnimator instance.
Access functions:
int | loopCount() const |
void | setLoopCount(int loops) |
Notifier signal:
void | loopCountChanged(int loops) |
This property holds the name of the mapper asset.
This will be used to lookup the asset in the AnimationMappingCollection instance of the SceneEntity.
If empty (default), the name of the clip will be used as it is a common convention that they should match.
Access functions:
QString | mapper() const |
void | setMapper(const QString &mapper) |
Notifier signal:
void | mapperChanged(const QString &mapper) |
progress of the animation as a uniform value between 0. and 1.
This reflects the state of the internal Qt3DAnimation::QClipAnimator instance.
Access functions:
float | normalizedTime() const |
void | setNormalizedTime(float timeFraction) |
Notifier signal:
void | normalizedTimeChanged(float index) |
controls if the animation is running or not
This reflects the state of the internal Qt3DAnimation::QClipAnimator instance.
Access functions:
bool | isRunning() const |
void | setRunning(bool running) |
Notifier signal:
void | runningChanged(bool running) |
This property holds the current status of the player
Access functions:
Kuesa::AnimationPlayer::Status | status() const |
Notifier signal:
void | statusChanged(Kuesa::AnimationPlayer::Status status) |
See also GLTF2Importer::status().
[slot]
void AnimationPlayer::reset()Stops the animation and resets the normalised time to 0. The next time the animation plays it will start from 0 rather than the current normalised time.
[slot]
void AnimationPlayer::restart(int delay = 0)Sets the normalised to 0 and runs the animation after delay in msec. delay defaults to 0.
[slot]
void AnimationPlayer::run(float fromTimeFraction, float toTimeFraction)Run the animation from fromTimeFraction to toTimeFraction. Both times are normalized time.
[slot]
void AnimationPlayer::start(int delay = 0)Starts the animation after delay in msec. delay defaults to 0.
[slot]
void AnimationPlayer::stop()Stops the animation
AnimationPlayer::addTarget adds a node target as a target for the animation
If targets are added to the list, the mapping defined by the AnimationPlayer::mapper property will be ignored and the clip data will be mapped to the specified target nodes.
The target node needs to have properties which match the ones defined by the clips.
Note: When specifying targets, a valid object matching the specified AnimationPlayer::mapper property must exist (even though it won't be affected by the animation) as it will contain information required to establish valid mappings for the new targets.
Note: Kuesa::SceneEntity::transformForEntity can be useful to map animations that control transformations from one entity to another. The returned transform can be used as a target for the animation.
See also AnimationPlayer::removeTarget.
Removes a node target from the list of targets
See also AnimationPlayer::addTarget.
AnimationPlayer::targets returns the list of currently defined targets for animations
See also AnimationPlayer::addTarget and AnimationPlayer::removeTarget.