#include<osgViewer\Viewer>
#include<osg\Node>
#include<osg\Geode>
#include<osg\Group>
#include<osg\MatrixTransform>
#include<osgDB\ReadFile>
#include<osgDB\WriteFile>
#include<osgUtil\Optimizer>
int main()
{
//创建Viewer对象,场景浏览器
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
//创建场景组节点
osg::ref_ptr<osg::Group> root = new osg::Group();
//创建一个节点,读取牛的模型
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("cow.osg");
//创建矩阵变换节点mt1
osg::ref_ptr<osg::MatrixTransform> mt1 = new osg::MatrixTransform();
//创建一个矩阵
osg::Matrix m;
//在X方向平移10个单位
m.makeTranslate(osg::Vec3(10.0f, 0.0f, 0.0f));
//绕X轴旋转45度
m.makeRotate(45.0f, 1.0f, 0.0f, 0.0f);
//设置矩阵
mt1->setMatrix(m);
//添加子节点
mt1->addChild(node.get());
//创建矩阵变换节点mt2
osg::ref_ptr<osg::MatrixTransform> mt2 = new osg::MatrixTransform();
//创建一个矩阵
osg::Matr
OSG学习:矩阵变换节点示例
最新推荐文章于 2020-11-27 00:57:31 发布