1.若要实现变换,先创建变换矩阵节点(MatrixTransform),在变换矩阵中实现相应空间变换。
2.再将模型节点放入变换矩阵中(这时变换矩阵会根据自己已经设定好的变换处理加入的节点)
3.最后将变换矩阵节点放入根节点中,从而渲染。
注:矩阵相乘一般不满足交换律,所有前后顺序不能任意变动,否则会出现不同的效果
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/MatrixTransform>
int main()
{
osgViewer::Viewer viewer;
//创建根节点
osg::ref_ptr<osg::Group> root = new osg::Group();
//创建滑翔机节点
osg::ref_ptr<osg::Node> glider = osgDB::readNodeFile(