矩阵变换

  1. 矩阵缩放
  2. 矩阵旋转
  3. 矩阵平移
#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();
}
posted @ 2021-08-25 17:04  暹罗吹雪  阅读(44)  评论(0编辑  收藏  举报