|
本帖最后由 wangys8363 于 2013-9-24 11:42 编辑
我是按照官方的那个animation例子程序用那个finder来控制FBX动画的播放的,我在程序初始化的时候就已经把FBX读入了,而且已经调用了accept函数,也就是finder已经对应上了FBX的动画,我只是用了nodemask把这个动画隐藏了起来,再我想要用的时候才再用nodemask把他显示出来,可就是这样,我在想显示fbx的时候,还是要等5秒左右才显示出来,这是什么情况啊,是本来就很卡么?还是我程序写的不对?
这是初始化的时候的代码:- // 加入走路动作
- group = new osg::Group();
- osg::Group* node1 = dynamic_cast<osg::Group*>(osgDB::readNodeFile("E:/osg/OpenSceneGraph-3.0.1/build/bin/3.FBX")); //dynamic_cast<osgAnimation::AnimationManager*>(osgDB::readNodeFile(psr[1]));
- osg::ref_ptr<osg::MatrixTransform> node = new osg::MatrixTransform;
- node->addChild(node1);
- osg::Matrix m = node->getMatrix();
- node->setMatrix(m*osg::Matrix::scale(0.5,0.5,0.5));
- // AnimationManagerFinder finder;
- node->accept(finder);
- if (finder._am.valid()) {
- node->setUpdateCallback(finder._am.get());
- AnimtkViewerModelController::setModel(finder._am.get());
- } else {
- osg::notify(osg::WARN) << "no osgAnimation::AnimationManagerBase found in the subgraph, no animations available" << std::endl;
- }
- // node->setNodeMask(0x0001);
- // node->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF);
- group->addChild(node);
- AnimtkViewerModelController& mc = AnimtkViewerModelController::instance();
- mc.play();
- group->setNodeMask(0);
- osg::Vec3 center(0.0f,0.0f,0.0f);
- float radius = 100.0f;
- const osg::BoundingSphere& bs = group->getBound();
- float size = radius/bs.radius()*0.4f;
- positioned = new osg::MatrixTransform;
- positioned->setDataVariance(osg::Object::STATIC);
- positioned->setMatrix(osg::Matrix::translate(-bs.center())*
- osg::Matrix::scale(size,size,size)*
- osg::Matrix::rotate(osg::inDegrees(90.0f),1.0f,0.0f,0.0f));
- positioned->addChild(group);
- xform = new osg::PositionAttitudeTransform;
- xform->addChild(positioned);
- // xform->setNodeMask(0);
- /* osg::Vec3d position(0.0,0.0,27.0);
- osg::Vec3 endPos(100.0,100.0,0.0);
- double delta_x,delta_y;
- delta_x = endPos.x()/4;
- delta_y = endPos.y()/4;
- double rot = atan2(delta_x, delta_y);
- osg::Quat quat(rot,osg::Vec3d(0.0,0.0,1.0));
- xform->setPosition(position);
- xform->setAttitude(quat);*/
- m_MainBody->addChild(xform);
复制代码 |
|