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)