osgAnimation.RunActionosgAnimation.RunAction是OpenSceneGraph库中的一个类,用于在动画序列中执行一个动作。该动作可以包括任何实现了osgAnimation.AnimationAction接口的类,并可以在osgAnimation.UpdateMatrixTransform节点中使用。
osgAnimation::RunAction(osgAnimation::AnimationAction* action = nullptr);
action: 执行的动作类指针,默认为nullptrosgAnimation.RunAction对象void osgAnimation::RunAction::setAction(osgAnimation::AnimationAction* action);
action: 执行的动作类指针osgAnimation::AnimationAction* osgAnimation::RunAction::getAction() const;
auto myAction = new MyAnimationAction();
auto runAction = new osgAnimation::RunAction(myAction);
auto matTransform = new osgAnimation::UpdateMatrixTransform();
matTransform->addAction(runAction);
上述示例中,创建了一个自定义的动作类MyAnimationAction,然后将其作为参数传给osgAnimation.RunAction构造函数,创建一个osgAnimation.RunAction对象runAction,最后将runAction添加到osgAnimation.UpdateMatrixTransform节点的动作列表中。在调用UpdateMatrixTransform节点的update()函数时,runAction对象将自动执行MyAnimationAction类中实现的动作逻辑。