|
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> root = new osg::Group;
osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("cow.osg");
root->addChild(node1);
osg::ref_ptr<osg::Node> node2 = dynamic_cast<osg::Node*>(node1->clone(osg::CopyOp:EEP_COPY_ALL));
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
osg::Matrix m ;
m.makeTranslate(osg::Vec3(400.0f,0.0f,0.0f));
m.makeRotate(90.0f,1.0f,0.0f,0.0f);
mt->setMatrix(m);
mt->addChild(node2);
root->addChild(mt);
viewer->setSceneData(root);
viewer->realize();
viewer->run();
return 0;
}
想问一下我的这段代码有问题吗?为什么拷贝出来的节点node2为什么只能进行旋转变换而不能进行平移变换? |
|