一、代码
#include<osgViewer/Viewer>
#include<osgDB/ReadFile>
#include<osg/MatrixTransform>
int main()
{
//设置观察器
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
//设置一个group
osg::ref_ptr<osg::Group> root = new osg::Group;
//保存模型的节点
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("glider.osg");
//变换矩阵
osg::ref_ptr<osg::MatrixTransform> matrix = new osg::MatrixTransform;
matrix->addChild(node);
//z轴移动5单位
matrix->setMatrix(osg::Matrix::translate(0.0,0.0,5.0)*osg::Matrix::rotate(osg::inDegrees(45.0), 0.0, 0.0, 1.0)*osg::Matrix::scale(7.0,7.0,7.0));
//将node节点和矩阵节点加入group中
//root->addChild(node);
root->addChild(matrix);
//缩放
//osg::ref_ptr<osg::Node> node2 = osgDB::readNodeFile("cow.osg");
osg::ref_ptr<osg::MatrixTransform> matrix2 = new osg::MatrixTransform;
matrix2->addChild(node);
//缩放5倍
matrix2->set