osg之矩阵(二)

来源:互联网 发布:专业美工软件 编辑:程序博客网 时间:2024/06/04 23:31

1.导出一个旋转之后的模型

void ExportANode(){     osg::ref_ptr<osg::Node> node=osgDB::readNodeFile("cow.osg");     osg::ref_ptr<osg::MatrixTransform> max=new osg::MatrixTransform;     max->addChild(node);     max->setMatrix(osg::Matrix::translate(50.0,0.0,0.0));     osgDB::ReaderWriter::WriteResult result=osgDB::Registry::instance()->writeNode(*max,"TrCow.osg",osgDB::Registry::instance()->getOptions());     if (result.success())     {         osg::notify(osg::NOTICE)<<"Write Node Success"<<std::endl;     }}int main(){    ExportANode();    return 0;}

2.读取一个模型,使用setPosition方法,看模型能否跑到原点的位置

int main(){    osg::ref_ptr<osgViewer::Viewer> viewer=new osgViewer::Viewer;    osg::ref_ptr<osg::PositionAttitudeTransform> pat=new osg::PositionAttitudeTransform;    osg::ref_ptr<osg::Group> group=new osg::Group;    group->addChild(osgDB::readNodeFile("glider.osg"));    pat->addChild(osgDB::readNodeFile("TrCow.osg"));    pat->setPosition(osg::Vec3d(0,0,0));    group->addChild(pat);    viewer->setSceneData(group);    return viewer->run();}

事实证明:并不起作用。

原创粉丝点击