|
楼主 |
发表于 2012-3-8 10:21:48
|
显示全部楼层
本帖最后由 pkfcLee 于 2012-3-8 11:34 编辑
如图所示,我想将一个模型沿图中弧线旋转90度(即从点A沿半径为20的圆弧线轨迹运动到B点);
我的做法是建立一个PAT节点,将模型加入根节点
osg::ref_ptr<osg:ositionAttitudeTransform> PAT =
new osg::PositionAttitudeTransform();
PAT->setPosition(osg::Vec3(20.0,0.0,0.0));
root->addChild(PAT.get());
然后设置路劲path
其中Vec3 xoz(0.0,1.0,0.0);
path1->insert(0.0,
osg::AnimationPath::ControlPoint(osg::Vec3(20.0,0.0,0.0), osg:uat(0.0,xoz)));
path1->insert(10.0,
osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,20.0), osg::Quat(-osg::PI_2,xoz)));
结果是模型沿直线从A点运动到B点,并且绕自身Y轴旋转了90度。
后来我将xoz沿X方向平移了-20单位,
Matrix mat.makeTranslate(osg::Vec3(-20.0,0.0,0.0));
Vec3 Aixs= xoz*mat;
path1->insert(0.0,
osg::AnimationPath::ControlPoint(osg::Vec3(20.0,0.0,0.0), osg::Quat(0.0,Aixs)));
path1->insert(10.0,
osg::AnimationPath::ControlPoint(osg::Vec3(0.0,0.0,20.0), osg::Quat(-osg::PI_2,Aixs)));
结果是模型沿直线从A点运动到B点,并且绕自身X轴旋转了90度。
请教一下,应该如何设置才能实现我想要得(即从点A沿半径为20的圆弧线轨迹运动到B点)运动。谢谢!
|
|