osg::NodeCallback里的osgUtil::CullVisitor什么作用?
class CameraTrackCallback: public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
if( nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
{
osgUtil::CullVisitor* cv = static_cast(nv);
osg::Vec3f centre,up,eye;
cv->getRenderStage()->getCamera()->getViewMatrixAsLookAt(eye,centre,up);
osg::MatrixTransform* mt = static_cast(node);
mt->setMatrix( osg::Matrix::translate( eye.x(), eye.y(), mt->getMatrix().getTrans().z() ) );
}
traverse(node, nv);
}
};
CullVisitor主要作用是节点裁剪,用以减少节点的绘制数量
页:
[1]