osgEarth 2.1.1
Public Member Functions | Public Attributes

anonymous_namespace{NodeUtils.cpp}::ComputeVisitor Struct Reference

List of all members.

Public Member Functions

 ComputeVisitor ()
void run (osg::Node *node, const osg::Vec3d &centerECEF)
void apply (osg::Geode &geode)
void apply (osg::Transform &xform)

Public Attributes

unsigned _pass
osg::Vec3d _centerECEF
osg::Vec3f _normalECEF
float _maxNormalLen
float _maxRadius2
std::vector< osg::Matrixd > _matrixStack

Detailed Description

Definition at line 133 of file NodeUtils.cpp.


Constructor & Destructor Documentation

anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::ComputeVisitor ( ) [inline]

Definition at line 135 of file NodeUtils.cpp.

            : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), 
              _maxRadius2(0.0f) { }

Member Function Documentation

void anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::apply ( osg::Geode &  geode) [inline]

Definition at line 155 of file NodeUtils.cpp.

        {            
            if ( _pass == 1 )
            {
                osg::Matrixd local2world;
                if ( !_matrixStack.empty() )
                    local2world = _matrixStack.back();

                osg::TemplatePrimitiveFunctor<ComputeMaxNormalLength> pass1;
                pass1.set( _normalECEF, local2world, &_maxNormalLen );

                for( unsigned i=0; i<geode.getNumDrawables(); ++i )
                    geode.getDrawable(i)->accept( pass1 );
            }

            else // if ( _pass == 2 )
            {
                osg::Vec3d center = _matrixStack.empty() ? _centerECEF : _centerECEF * osg::Matrixd::inverse(_matrixStack.back());

                osg::TemplatePrimitiveFunctor<ComputeMaxRadius2> pass2;
                pass2.set( center, &_maxRadius2 );
                for( unsigned i=0; i<geode.getNumDrawables(); ++i )
                    geode.getDrawable(i)->accept( pass2 );
            }
        }
void anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::apply ( osg::Transform &  xform) [inline]

Definition at line 181 of file NodeUtils.cpp.

        {
            osg::Matrixd matrix;
            if (!_matrixStack.empty()) matrix = _matrixStack.back();
            xform.computeLocalToWorldMatrix( matrix, this );
            _matrixStack.push_back( matrix );
            traverse(xform);
            _matrixStack.pop_back();
        }
void anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::run ( osg::Node *  node,
const osg::Vec3d &  centerECEF 
) [inline]

Definition at line 139 of file NodeUtils.cpp.

        {
            _centerECEF = centerECEF;
            _normalECEF = _centerECEF;
            _normalECEF.normalize();
            _maxNormalLen = _centerECEF.length();

            _pass = 1;
            node->accept( *this );

            _centerECEF = _normalECEF * _maxNormalLen;

            _pass = 2;
            node->accept( *this );
        }

Member Data Documentation

osg::Vec3d anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_centerECEF

Definition at line 192 of file NodeUtils.cpp.

std::vector<osg::Matrixd> anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_matrixStack

Definition at line 196 of file NodeUtils.cpp.

float anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_maxNormalLen

Definition at line 194 of file NodeUtils.cpp.

float anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_maxRadius2

Definition at line 195 of file NodeUtils.cpp.

osg::Vec3f anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_normalECEF

Definition at line 193 of file NodeUtils.cpp.

unsigned anonymous_namespace{NodeUtils.cpp}::ComputeVisitor::_pass

Definition at line 191 of file NodeUtils.cpp.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines