|
下面是osg2.0中的一个例子osgviewerMFC,我稍微做了改动,希望读入的模型能够移动,
但是却达不到想要的效果,模型依然居中,该如何解决呢?
void cOSG::InitSceneGraph(void)
{
// Init the main Root Node/Group
mRoot = new osg::Group;
// Load the Model from the model name
mModel = osgDB::readNodeFile(m_ModelName);
osg::ref_ptr<osg::MatrixTransform> mt=new osg::MatrixTransform;
osg::Matrix m;
m.makeTranslate(20.f,0.f,0.f); //平移20
mt->setMatrix(m);
mt->addChild(mModel.get());
// Optimize the model
osgUtil::Optimizer optimizer;
optimizer.optimize(mt.get());
optimizer.reset();
// Add the model to the scene
mRoot->addChild(mt.get());
} |
|