ogre Animation Track

轨迹动画(Animation Track),是 OGRE 所支持的几种动画模式(包括骨骼动画)中的一种。通过让节点(node)沿着一条预设了关键帧(Key Frame)的轨迹移动来实现节点的动画。

OGRE 中创建和实施轨迹动画的步骤大致如下:

1. 在主程序类的 Application :: createScene ( ) 场景创建方法中进行以下工作:

Animation * Ogre::SceneManager::createAnimation (
const String & name, // 动画名称
Real length // 动画长度(秒)
) [virtual]

(2) 使用 createTrack 方法为动画创建轨迹动画:
AnimationTrack * Ogre::Animation::createTrack (
unsigned short handle, // 分配给轨迹动画的索引句柄,用于以后可能的调用
Node * node // 指定要沿着这条轨迹运动的节点
)

(3) 使用 createKeyFrame 方法为轨迹动画创建一系列关键帧:
KeyFrame * Ogre::AnimationTrack::createKeyFrame (
Real timePos // 时间位置

 
(4) 使用 setTranslate 、 setScale 、 setRotation 三个方法来设置关键帧每个时间位置上节点的位置、缩放、旋转属性:
void Ogre::KeyFrame::setTranslate ( const Vector3 & trans ) 
void Ogre::KeyFrame::setScale ( const Vector3 & scale ) 
void Ogre::KeyFrame::setRotation ( const Quaternion & rot ) 
 
(5) 使用 createAnimationState 方法创建一个动画状态来追踪这个轨迹:
AnimationState * Ogre::SceneManager::createAnimationState ( const String & animName ) [virtual] 
 
(6) 使用 setEnabled 方法来激活动画状态:
void Ogre::AnimationState::setEnabled ( bool enabled )

2. 在接收器类的 Listener::frameStarted(const FrameEvent& evt) 方法中刷新动画状态:
void Ogre::AnimationState::addTime ( Real offset )

原文地址:https://www.cnblogs.com/minggoddess/p/1907183.html