osg学习第一篇:矩阵
2015-02-06 23:14
351 查看
基础的物体的移动,调用translate进行平移操作,调用setUpdateCallback回调函数在每一帧调用的时候更新。
AnimationPathCallback为setUpdateCallbac中的一个绕轴旋转的函数
效果图如下:
AnimationPathCallback为setUpdateCallbac中的一个绕轴旋转的函数
效果图如下:
#include <iostream> #include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/GUIEventAdapter> #include <osgViewer/ViewerEventHandlers> #include <osg/MatrixTransform> osg::ref_ptr<osg::Node> MatrixOperation() { osg::ref_ptr<osg::Group> group = new osg::Group; osg::ref_ptr<osg::MatrixTransform> max = new osg::MatrixTransform; osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("glider.osg"); osg::ref_ptr<osg::MatrixTransform> max1 = new osg::MatrixTransform; osg::ref_ptr<osg::MatrixTransform> max2 = new osg::MatrixTransform; osg::ref_ptr<osg::MatrixTransform> max3 = new osg::MatrixTransform; max1->addChild(node.get()); max1->setMatrix(osg::Matrix::translate(5.0,0,0)); max->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(5.0,0,0),osg::Z_AXIS,2.0)); max->addChild(max1.get()); max3->addChild(node.get()); max2->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(0,0,0),osg::Z_AXIS,5.0)); max2->addChild(max3.get()); // group->addChild(node.get()); group->addChild(max.get()); group->addChild(max2.get()); return group; } int main() { osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer; viewer->setSceneData(MatrixOperation().get()); return viewer->run(); }
相关文章推荐
- osg学习第二篇:矩阵(二)
- 推荐矩阵代数学习资料
- 第一篇学习笔记:《学习计划》
- 第一篇,先激励一下自己,转载某黑客论坛上的经典学习文章
- 嵌入式LINUX学习第一篇(1)
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】如何通过vnc图形界面远程控制Linux主机
- OpenGL学习笔记-OpenGL的变换和矩阵
- C++/GDI+ 学习笔记(四)——实用技巧——颜色矩阵(ColorMatrix)
- 关于JDBC的学习总结,新手写的第一篇学习帖子
- arm9学习第一篇(2)
- servlet学习(第一篇)
- 在CSDN的第一篇,今天的VC6学习心得
- lalala~ 我的第一篇linux学习笔记_如何查看系统模块
- 学习矩阵之 马尔可夫过程
- C++学习笔记第一篇(转)
- 【Rebol 学习笔记】第一篇:编写一个简单的 CGI 程序
- 第一篇报到来了,以后将陆续发最近的学习文章
- asp.net ajax的学习第一篇
- Matlab学习笔记(2)矩阵与魔方
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――mount方式