查看osg坐标系,camare默认姿态:http://www.cnblogs.com/lyggqm/p/8073688.html

首先搞清楚osg的坐标系以及osg::camare的默认姿态

下代码面实现了,在场景里放一只牛。相机使用动画漫游器

在动画中添加三个方向来观察牛。具体三方向姿态请参考代码

#include <iostream>
#include <osg/MatrixTransform>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA\AnimationPathManipulator>
#include <osgDB\ReadFile> int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
osgViewer::Viewer viewer(arguments); viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
osg::Group* root = new osg::Group(); root->addChild(osgDB::readNodeFile("cow.osg"));
viewer.setSceneData(root); //使用动画漫游器
osgGA::AnimationPathManipulator *animationPathMp = new osgGA::AnimationPathManipulator();
//给动画漫游器添加关键帧
osg::AnimationPath* _animationPath = new osg::AnimationPath; //当出于模型右边,既x方向20处,为了看见模型
//要使相机沿着Y轴顺时针旋转90度
osg::Quat q1(osg::DegreesToRadians(90.0), osg::Y_AXIS);
osg::Quat q2(osg::DegreesToRadians(90.0), osg::X_AXIS);
q1 *= q2; osg::Quat q3(osg::DegreesToRadians(-90.0), osg::X_AXIS);
osg::Quat q4(osg::DegreesToRadians(180.0), osg::Y_AXIS);
q3 *= q4; osg::Quat q5(osg::DegreesToRadians(-90.0), osg::Z_AXIS); _animationPath->insert(0.0, osg::AnimationPath::ControlPoint(osg::Vec3d(, , ), q1));
_animationPath->insert(4.0, osg::AnimationPath::ControlPoint(osg::Vec3d(, , ), q3));
_animationPath->insert(8.0, osg::AnimationPath::ControlPoint(osg::Vec3d(, , ), q5));
//设置路径是回摆的
_animationPath->setLoopMode(osg::AnimationPath::SWING);
animationPathMp->setAnimationPath(_animationPath);
viewer.setCameraManipulator(animationPathMp); return viewer.run();
}

[osg]OSG相机添加动画路径的更多相关文章

  1. OSG 自定义数据类型 关键帧动画

    OSG 自定义数据类型 关键帧动画 转自:http://blog.csdn.net/zhuyingqingfen/article/details/12651017 /* 1.创建一个AnimManag ...

  2. [Swift通天遁地]八、媒体与动画-(4)给相机添加CoreImage滤镜效果

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. [翻译] AnimatedPath 动画路径(持续更新)

    AnimatedPath动画路径 感谢原作者分享精神,有空补上使用教程 https://github.com/twotoasters/AnimatedPath AnimatedPath explore ...

  4. ios 添加动画的方法

    转自文顶顶大神的博客:http://www.cnblogs.com/wendingding/p/3751519.html ios 开发UI中,经常会用添加动画效果的需求,下面就总结一下,添加动画的三种 ...

  5. (转)Unity3d使用心得(1):ModelImporter的使用、在代码中添加动画片段。

    在使用 Unity3d 倒入Fbx模型的时候,动画的动画片段需要自己手动添加模型多了以后会是一个不小的工作量. Unity3d支持 编辑器脚本来控制资源导入的过程.添加一个 AssetPostproc ...

  6. Java 给PPT添加动画效果(预设动画/自定义动画)

    PPT幻灯片中对形状可设置动画效果,常见的动画效果为内置的固定类型,即动画效果和路径是预先设定好的固定模板,但在设计动画效果时,用户也可以按照自己的喜好自定义动画动作路径.下面,通过Java后端程序代 ...

  7. windows7下python3.4.3 添加库路径(转)

    1, 动态的添加库路径.在程序运行过程中修改sys.path的值,添加自己的库路径import syssys.path.append(r'your_path') 2, 在Python安装目录下的\Li ...

  8. PopupWindow添加动画效果

    1.定义PopupWindow弹出与消失的两个动画文件,放在anim文件夹下 popup_enter.xml <?xml version="1.0" encoding=&qu ...

  9. Android开发UI之补间动画-布局添加动画

    布局添加动画 使用步骤: 1.获取到布局的id RelativeLayout ly=(RelativeLayout)findViewById(R.id.layout); 2.设置动画样式 ScaleA ...

随机推荐

  1. URL的解析,C语言实现

    源: URL的解析,C语言实现 c语言实现urlencode和decode

  2. CentOS ping: unknown host 解决方法

    如果ping命令返回如下错误,那主要的可能性就是系统的DNS设置有误 [root@CentOS5 ~]# ping www.sina.com.cn ping: unknown host www.sin ...

  3. 简易DVD查询系统

    ==========DVD管理系统========== 这是DVD任务管理器的主界面: package day20181224; import java.text.ParseException; im ...

  4. Fedora 全局代理上网设置

    1.首先新建一个bash文件 vim /etc/profile.d/proxy.sh 加入以下内容 (有账号密码) export HTTP_PROXY="http://username:pa ...

  5. python简说(六)判断

    非空即真,非0即真True '1' [1] {k-v}False '' None [] {}

  6. Junit 的Assertions的使用

    import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.anyOf; import ...

  7. 5.sql2008分组与嵌套

    1.Group by基本介绍;2.Having的使用;3.分组综合应用;4.子查询基本介绍;5.In/Exists/Any/Some/All;6.子查询综合应用; 1.Group by基本介绍:依据B ...

  8. POJ 2018 Best Cow Fences(二分最大区间平均数)题解

    题意:给出长度>=f的最大连续区间平均数 思路:二分这个平均数,然后O(n)判断是否可行,再调整l,r.判断方法是,先求出每个数对这个平均数的贡献,再求出长度>=f的最大贡献的区间,如果这 ...

  9. A^B mod C (快速幂+快速乘+取模)题解

    A^B mod C Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,B,C<2^63). ...

  10. Asp.net 之 window 操作命令

    命令:cmd  打开执行窗口 命令:inetmgr.打开iis管理器 命令:dcomcnfg 打开组件服务 命令:regedit   打开注册表