1、osgUtil::SceneView生成渲染树根节点
osgUtil/SceneView.cpp
void SceneView::setDefaults(unsigned int options)
{
_renderStage = new RenderStage;
_cullVisitor->setStateGraph(_renderStage .get());
}
2、cull遍历到drawable节点时,添加到渲染树相应部分
osgUtil/CullVisitor.cpp
void CullVisitor::apply(osg::Drawable& drawable)
{
addDrawableAndDepth(&drawable,&matrix,depth);
}
osgUtil/CullVisitor
inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth)
{
_currentRenderBin->addStateGraph(_currentStateGraph);
_currentStateGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth));
}
3、遍历到其它节点比如(Group)时,会移动渲染树的当前节点
osgUtil/CullVisitor
inline void pushStateSet(const osg::StateSet* ss)

本文详细介绍了osg库中如何通过osgUtil::SceneView生成渲染树的根节点,并在cull遍历过程中将drawable添加到合适位置,同时解释了遍历到Group节点时渲染树当前节点的变动情况。
最低0.47元/天 解锁文章
917

被折叠的 条评论
为什么被折叠?



