OSG 回调函数 执行过程

来源:互联网 发布:mac能做pe启动盘 编辑:程序博客网 时间:2024/05/21 17:56

 

NodeCallBack

//当你为你的节点设置了回调函数node.setUpdateCallback(new UpdateCallback());
void ViewerBase::frame(double simulationTime){    updateTraversal();}//回调函数的执行过程void Viewer::updateTraversal(){         .........    _scene->updateSceneGraph(*_updateVisitor);//_updateVisitor为osgUtil::UpdateVisitor,用来负责场景更新遍历         .........}void Scene::updateSceneGraph(osg::NodeVisitor& updateVisitor){    if (getSceneData())    {        updateVisitor.setImageRequestHandler(getImagePager());        getSceneData()->accept(updateVisitor);    }}void Node::accept(osg::NodeVisitor& nv) {    if (nv.validNodeMask(*this))   {      nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath();    }     } void UpdateVisitor::apply(osg::Group& node){ handle_callbacks_and_traverse(node); }inline void handle_callbacks_and_traverse(osg::Node& node){     handle_callbacks(node.getStateSet());     osg::NodeCallback* callback = node.getUpdateCallback();     if (callback) (*callback)(&node,this);     else if (node.getNumChildrenRequiringUpdateTraversal()>0) traverse(node);}   

Date: 2013-07-31T21:06+0800

Author: Sunday

Org version 7.9.2 withEmacs version 24