예제 #1
0
TransformerGraph::GraphDescription TransformerGraph::getGraphDescription(osg::Node& transformer)
{
    GraphDescription result;
    DescriptionVisitor visitor(result);
    transformer.accept(visitor);
    return result;
}
예제 #2
0
void
OcclusionQueryVisitor::addOQN( osg::Node& node )
{
    VertexCounter vc( _occluderThreshold );
    node.accept( vc );
    if (vc.exceeded())
    {
        // Insert OQN(s) above this node.
        unsigned int np = node.getNumParents();
        while (np--)
        {
            osg::Group* parent = dynamic_cast<osg::Group*>( node.getParent( np ) );
            if (parent != NULL)
            {
                osg::ref_ptr<osg::OcclusionQueryNode> oqn = new osg::OcclusionQueryNode();
                oqn->addChild( &node );
                parent->replaceChild( &node, oqn.get() );

                oqn->setName( getNextOQNName() );
                // Set all OQNs to use the same query StateSets (instead of multiple copies
                //   of the same StateSet) for efficiency.
                oqn->setQueryStateSet( _state.get() );
                oqn->setDebugStateSet( _debugState.get() );
            }
        }
    }
}
예제 #3
0
파일: Selection.cpp 프로젝트: joevandyk/osg
void osgManipulator::computeNodePathToRoot(osg::Node& node, osg::NodePath& np)
{
    np.clear();
    osg::ref_ptr<FindNodePathToRootVisitor> visitor = new FindNodePathToRootVisitor(np);
    node.accept(*visitor);
    np.pop_back();
    std::reverse(np.begin(), np.end());
}
예제 #4
0
void AnimationPathCallback::update(osg::Node& node)
{
    AnimationPath::ControlPoint cp;
    if (_animationPath->getInterpolatedControlPoint(getAnimationTime(),cp))
    {
        AnimationPathCallbackVisitor apcv(cp,_pivotPoint,_useInverseMatrix);
        node.accept(apcv);
    }
}
예제 #5
0
    virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*)
    {
        if ( ea.getEventType() == ea.PUSH )
        {
            // mouse click from [-1...1]
            float nx = ea.getXnormalized();
            float ny = ea.getYnormalized();

            // clicked point in clip space:
            osg::Vec3d pn( nx, ny, -1 ); // on near plane
            osg::Vec3d pf( nx, ny,  1 ); // on far plane

            OE_NOTICE << "clip: nx=" << nx << ", ny=" << ny << std::endl;
            
            // take the view matrix as-is:
            osg::Matrix view = _view->getCamera()->getViewMatrix();

            // adjust projection matrix to include entire earth:
            double fovy, ar, zn, zf;
            _view->getCamera()->getProjectionMatrix().getPerspective(fovy, ar, zn, zf);
            osg::Matrix proj;
            proj.makePerspective(fovy, ar, 1.0, 1e10);

            // Invert the MVP to transform points from clip to model space:
            osg::Matrix MVP = view * proj;
            osg::Matrix invMVP;
            invMVP.invert(MVP);

            pn = pn * invMVP;
            pf = pf * invMVP;

            OE_NOTICE << "model: near = " << pn.x() << ", " << pn.y() << ", " << pn.z() << std::endl;
            OE_NOTICE << "model: far  = " << pf.x() << ", " << pf.y() << ", " << pf.z() << std::endl;

            // Intersect in model space.
            osgUtil::LineSegmentIntersector* lsi = new osgUtil::LineSegmentIntersector(
                osgUtil::Intersector::MODEL, pn, pf );

            lsi->setIntersectionLimit( lsi->LIMIT_NEAREST );

            osgUtil::IntersectionVisitor iv( lsi ); 
            
            _node->accept( iv );

            if ( lsi->containsIntersections() )
            {
                osg::Vec3d p = lsi->getIntersections().begin()->getWorldIntersectPoint();
                OE_NOTICE << "i = " << p.x() << ", " << p.y() << ", " << p.z() << std::endl;
            }
        }
        return false;
    }
void GLObjectsVisitor::compile(osg::Node& node)
{
    if (_renderInfo.getState())
    {
        node.accept(*this);

        if (_lastCompiledProgram.valid())
        {
            osg::State* state = _renderInfo.getState();
            osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
            extensions->glUseProgram(0);
            _renderInfo.getState()->setLastAppliedProgramObject(0);
        }
    }
}
예제 #7
0
void GLObjectsVisitor::compile(osg::Node& node)
{
    if (_renderInfo.getState())
    {
        node.accept(*this);

        if (_lastCompiledProgram.valid())
        {
            osg::State* state = _renderInfo.getState();
            osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
            extensions->glUseProgram(0);
            _renderInfo.getState()->setLastAppliedProgramObject(0);
        }

        if (_checkGLErrors!=osg::State::NEVER_CHECK_GL_ERRORS) _renderInfo.getState()->checkGLErrors("after GLObjectsVisitor::compile(osg::Node& node)");
    }
}
예제 #8
0
    bool BaseDotVisitor::run( osg::Node& root, std::ostream* fout ) {
    setTraversalMode( TRAVERSE_ALL_CHILDREN );
    if ( fout && *fout ) {
      root.accept( *this );

      *fout << "digraph osg_scenegraph { "<<_rankdir<< std::endl;

      *fout << _nodes.str() << _edges.str();

      *fout << "}" << std::endl;

      _nodes.clear();
      _edges.clear();
      _objectMap.clear();

      return true;
    }

    return false;
  }
예제 #9
0
 static void remove(::osg::Node &node,osg::Node *remove)
 {
     NodeRemover remover(remove);
     node.accept(remover);
 }
예제 #10
0
 static void set(::osg::Node &node,float size)
 {
     TextSizeSetter setter(size);
     node.accept(setter);
 }
예제 #11
0
 static void set(::osg::Node &node,bool active)
 {
     AnnotationSetter setter(active);
     node.accept(setter);
 }
예제 #12
0
 static std::vector<std::string> find(::osg::Node &node)
 {
     FindFrameNames finder;
     node.accept(finder);
     return finder.getNames();
 }