Qt3DAnimation::QAnimationController Class

class Qt3DAnimation::QAnimationController

动画控制器类更多

头文件: #include <QAnimationController>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3danimation)
target_link_libraries(mytarget PRIVATE Qt6::3danimation)
qmake: QT += 3danimation
在 QML 中: AnimationController
继承: QObject
状态:已废弃

属性

公共功能

QAnimationController(QObject *parent = nullptr)
int activeAnimationGroup() const
void addAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)
QList<Qt3DAnimation::QAnimationGroup *> animationGroupList()
Qt3DCore::QEntity *entity() const
int getAnimationIndex(const QString &name) const
Qt3DAnimation::QAnimationGroup *getGroup(int index) const
float position() const
float positionOffset() const
float positionScale() const
bool recursive() const
void removeAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)
void setAnimationGroups(const QList<Qt3DAnimation::QAnimationGroup *> &animationGroups)

公共插槽

void setActiveAnimationGroup(int index)
void setEntity(Qt3DCore::QEntity *entity)
void setPosition(float position)
void setPositionOffset(float offset)
void setPositionScale(float scale)
void setRecursive(bool recursive)

信号

void activeAnimationGroupChanged(int index)
void entityChanged(Qt3DCore::QEntity *entity)
void positionChanged(float position)
void positionOffsetChanged(float offset)
void positionScaleChanged(float scale)
void recursiveChanged(bool recursive)

详细说明

Qt3DAnimation::QAnimationController 类控制动画的选择和播放。该类可用于从 树中查找所有动画,并从同名动画中创建 。用户可通过设置活动动画来选择当前由动画控制器控制的动画组。然后,在使用 和 值缩放和偏移所提供的位置值后,动画位置将传播到该组。Qt3DCore::QEntity QAnimationGroups positionScale positionOffset

注意: 动画控制器没有内部计时器,而是由用户负责及时更新位置属性。

属性文档

activeAnimationGroup : int

保存当前激活的动画组。

访问功能

int activeAnimationGroup() const
void setActiveAnimationGroup(int index)

通知信号

void activeAnimationGroupChanged(int index)

entity : Qt3DCore::QEntity*

保存收集和分组的实体动画。如果控制器已持有动画,则会将其清除。

访问功能:

Qt3DCore::QEntity *entity() const
void setEntity(Qt3DCore::QEntity *entity)

通知信号

void entityChanged(Qt3DCore::QEntity *entity)

position : float

保持动画的当前位置。设置位置后,它将通过positionScale/positionOffset 进行缩放和偏移,并传播到活动动画组。

访问功能:

float position() const
void setPosition(float position)

通知信号:

void positionChanged(float position)

positionOffset : float

保存动画的位置偏移。

访问功能:

float positionOffset() const
void setPositionOffset(float offset)

通知信号:

void positionOffsetChanged(float offset)

positionScale : float

保存动画的位置比例。

访问功能:

float positionScale() const
void setPositionScale(float scale)

通知信号

void positionScaleChanged(float scale)

recursive : bool

表示从实体收集动画时是否递归搜索实体树。如果设为 true,则也会从实体的子实体中搜索动画。如果设为 false,则只搜索传递给控制器的实体。

访问功能:

bool recursive() const
void setRecursive(bool recursive)

Notifier 信号:

void recursiveChanged(bool recursive)

成员函数 文档

QAnimationController::QAnimationController(QObject *parent = nullptr)

使用parent 构建一个新的 QAnimationController。

void QAnimationController::addAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)

将给定的animationGroup 添加到控制器。

QList<Qt3DAnimation::QAnimationGroup *> QAnimationController::animationGroupList()

返回控制器当前持有的动画组列表。

[invokable] int QAnimationController::getAnimationIndex(const QString &name) const

返回name 动画的索引。如果未找到具有给定名称的AnimationGroup ,则返回-1。

注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE

[invokable] Qt3DAnimation::QAnimationGroup *QAnimationController::getGroup(int index) const

返回带有给定indexAnimationGroup

注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE

void QAnimationController::removeAnimationGroup(Qt3DAnimation::QAnimationGroup *animationGroup)

从控制器中删除给定的animationGroup

void QAnimationController::setAnimationGroups(const QList<Qt3DAnimation::QAnimationGroup *> &animationGroups)

设置控制器的animationGroups 。旧组将被清除。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.