讲解一些旋转矩阵
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> max2=new osg::MatrixTransform;
max2->addChild(node);
max2->setMatrix(osg::Matrix::translate(5.0,0.0,0.0));
max->addChild(max2);
max->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(0.0,0.0,0.0),osg::Z_AXIS,1.0));
group->addChild(node);
group->addChild(max);
return group;
}
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer=new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group=new osg::Group;
viewer->setSceneData(MatrixOperation());
return viewer->run();
}
思考:为什么要建立两个osg::MatrixTransform而不是建立一个。如何仅仅建立一个osg::MatrixTransform会是什么样的效果
osg::ref_ptr<osg::MatrixTransform> max=new osg::MatrixTransform;
max->addChild(node);
max->setMatrix(osg::Matrix::translate(5.0,0.0,0.0));
max->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(0.0,0.0,0.0),osg::Z_AXIS,1.0));
就像上面这样会是什么样的效果?