- 矩阵缩放
- 矩阵旋转
- 矩阵平移
#include <Windows.h>
#include <osg\Node>
#include <osg\Group>
#include <osg\Geometry>
#include <osg\MatrixTransform>
#include <osgViewer/Viewer>
int main()
{
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> group = new osg::Group();
group->addChild(osgDB::readNodeFile("cow.osg"));
viewer.setSceneData(group);
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform();
osg::Matrix matrix;
matrix *= osg::Matrix::scale(osg::Vec3(10.0, 10.0, 10.0));//缩放
matrix *= osg::Matrix::rotate(osg::DegreesToRadians(45.0), osg::Z_AXIS);//旋转
matrix *= osg::Matrix::translate(osg::Vec3(0.0, 0.0, 3.0));//平移
mt->setMatrix(matrix);
mt->addChild(osgDB::readNodeFile("glider.osg"));
group->addChild(mt);
viewer.setUpViewInWindow(100, 100, 500, 400);
return viewer.run();
}