|
楼主 |
发表于 2014-4-3 15:38:33
|
显示全部楼层
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("cow.osg");
osg::ref_ptr<osg:ositionAttitudeTransform> pat1 = new osg::PositionAttitudeTransform() ;
pat1->setPosition(osg::Vec3(-10.0f,0.0f,0.0f));
pat1->addChild(node);
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform();
mt->setMatrix(osg::Matrix::translate(osg::Vec3(15,0,0))*
osg::Matrix::scale(3,3,3)*
osg::Matrix::rotate(osg::inDegrees(-180.0f),0,0,1));
mt->addChild(node.get());
root->addChild(pat1.get());
root->addChild(mt.get());
osgUtil::Optimizer optimizer ;
optimizer.optimize(root.get()) ;
viewer->setSceneData(root.get());
viewer->setUpViewInWindow(50,50,1000,700,0);
viewer->realize();
viewer->run();
return 0 ; |
|