Qt3DAnimation::QMorphingAnimation Class
class Qt3DAnimation::QMorphingAnimation一个实现混合形状变形动画的类。更多内容...
| 头文件: | #include <qmorphinganimation.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3danimation) target_link_libraries(mytarget PRIVATE Qt6::3danimation) |
| qmake: | QT += 3danimation |
| 在 QML 中: | MorphingAnimation |
| 继承自: | Qt3DAnimation::QAbstractAnimation |
| 状态: | 技术预览 |
该类处于技术预览阶段,内容可能会有变动。
公共类型
| enum | Method { Normalized, Relative } |
属性
|
|
公共函数
| QMorphingAnimation(QObject *parent = nullptr) | |
| void | addMorphTarget(Qt3DAnimation::QMorphTarget *target) |
| QEasingCurve | easing() const |
| QVector<float> | getWeights(int positionIndex) |
| float | interpolator() const |
| Qt3DAnimation::QMorphingAnimation::Method | method() const |
| QVector<Qt3DAnimation::QMorphTarget *> | morphTargetList() |
| void | removeMorphTarget(Qt3DAnimation::QMorphTarget *target) |
| void | setMorphTargets(const QVector<Qt3DAnimation::QMorphTarget *> &targets) |
| void | setWeights(int positionIndex, const QVector<float> &weights) |
| Qt3DRender::QGeometryRenderer * | target() const |
| QString | targetName() const |
| QVector<float> | targetPositions() const |
公共槽位
| void | setEasing(const QEasingCurve &easing) |
| void | setMethod(Qt3DAnimation::QMorphingAnimation::Method method) |
| void | setTarget(Qt3DRender::QGeometryRenderer *target) |
| void | setTargetName(const QString name) |
| void | setTargetPositions(const QVector<float> &targetPositions) |
信号
| void | easingChanged(const QEasingCurve &easing) |
| void | interpolatorChanged(float interpolator) |
| void | methodChanged(Qt3DAnimation::QMorphingAnimation::Method method) |
| void | targetChanged(Qt3DRender::QGeometryRenderer *target) |
| void | targetNameChanged(const QString &name) |
| void | targetPositionsChanged(const QVector<float> &targetPositions) |
详细说明
Qt3DAnimation::QMorphingAnimation 类实现将混合形状(blend-shape)变形动画应用到目标QGeometryRenderer 上。QMorphingAnimation会将morph targets 中的正确QAttributes 设置到目标QGeometryRenderer::geometry 中,并计算当前位置的插值器。 属性之间的实际混合必须在材质中实现。Qt3DAnimation::QMorphPhongMaterial 实现了一种支持 Phong 光照模型形态转换的材质。混合发生在两个属性之间——“base”和“target”。 “base”和“target”属性的名称取自形态目标名称,其中“base”属性保留其原有名称,而“target”属性名称则在原名后附加“Target”。插值器可设置为所用材质的QParameter 。动画中的所有形态目标都应包含与基础几何体中名称相同的属性。
成员类型文档
enum QMorphingAnimation::Method
此枚举用于指定变形方法。
| 常量 | 值 | 描述 |
|---|---|---|
Qt3DAnimation::QMorphingAnimation::Normalized | 0 | 混合应使用归一化公式:V' = Vbase * (1.0 - sum(Wi)) + sum[Vi * Wi] |
Qt3DAnimation::QMorphingAnimation::Relative | 1 | 混合应使用相对公式;V' = Vbase + sum[Vi * Wi] |
属性文档
easing : QEasingCurve
保存插值器在形态目标之间的平滑曲线。
访问函数:
| QEasingCurve | easing() const |
| void | setEasing(const QEasingCurve &easing) |
通知信号:
| void | easingChanged(const QEasingCurve &easing) |
[read-only] interpolator : float
用于存储基属性与目标属性之间的插值器。
访问函数:
| float | interpolator() const |
通知信号:
| void | interpolatorChanged(float interpolator) |
method : Method
存储变形方法。默认值为“相对”。
访问函数:
| Qt3DAnimation::QMorphingAnimation::Method | method() const |
| void | setMethod(Qt3DAnimation::QMorphingAnimation::Method method) |
通知信号:
| void | methodChanged(Qt3DAnimation::QMorphingAnimation::Method method) |
target : Qt3DRender::QGeometryRenderer*
保存要应用变形动画的目标 QGeometryRenderer。
访问函数:
| Qt3DRender::QGeometryRenderer * | target() const |
| void | setTarget(Qt3DRender::QGeometryRenderer *target) |
通知器信号:
| void | targetChanged(Qt3DRender::QGeometryRenderer *target) |
targetName : QString
存储目标几何体的名称。这是一个便捷属性,可帮助更轻松地将目标几何体与变形动画进行匹配。该名称通常与目标 QGeometryRenderer 的父实体名称相同,但并非必须如此。
访问函数:
| QString | targetName() const |
| void | setTargetName(const QString name) |
通知器信号:
| void | targetNameChanged(const QString &name) |
targetPositions : QVector<float>
存储变形目标的位置值。列表中的每个位置都指定了具有相同索引的对应变形目标的位置。这些值必须按升序排列。值可以是正数或负数,且没有预定义的单位。
访问函数:
| QVector<float> | targetPositions() const |
| void | setTargetPositions(const QVector<float> &targetPositions) |
通知信号:
| void | targetPositionsChanged(const QVector<float> &targetPositions) |
成员函数文档
[explicit] QMorphingAnimation::QMorphingAnimation(QObject *parent = nullptr)
使用parent 创建一个新的QMorphingAnimation。
void QMorphingAnimation::addMorphTarget(Qt3DAnimation::QMorphTarget *target)
在动画末尾添加新的变形“target ”。
QVector<float> QMorphingAnimation::getWeights(int positionIndex)
在positionIndex 处返回形态权重。
QVector<Qt3DAnimation::QMorphTarget *> QMorphingAnimation::morphTargetList()
返回形态目标列表。
void QMorphingAnimation::removeMorphTarget(Qt3DAnimation::QMorphTarget *target)
从动画中删除形态target 。
void QMorphingAnimation::setMorphTargets(const QVector<Qt3DAnimation::QMorphTarget *> &targets)
将“targets ”的形态设置为“动画”。旧的目标将被清除。
void QMorphingAnimation::setWeights(int positionIndex, const QVector<float> &weights)
在positionIndex 上设置 morphweights 。
© 2026 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.