Hi Robert

Yes  VTP calls  setEventVisitor

m_pOsgViewer->setEventVisitor(NULL);

in
bool vtScene::Init(int argc, char** argv, bool bStereo, int iStereoMode)

Code is listed below marked as //*******CALLED HERE





/**
 * Initialize the vtlib library, including the display and scene graph.
 * You should call this function only once, before any other vtlib calls.
 *
 * \param argc, argv Command-line arguments.
 * \param bStereo True for a stereo display output.
 * \param iStereoMode Currently for vtosg, supported values are 0 for
 *              Anaglyphic (red-blue) and 1 for Quad-buffer (shutter glasses).
 */
bool vtScene::Init(int argc, char** argv, bool bStereo, int iStereoMode)
{
        VTLOG1("vtScene::Init\n");

        // Redirect cout messages (where OSG sends its messages) to our own log
        previous_cout =  std::cout.rdbuf(&g_Trap);
        previous_cerr = std::cerr.rdbuf(&g_Trap);

#if 0
        // If you encounter trouble in OSG that you want to debug, enable this
        //  to get a LOT of diagnostic messages from OSG.
        osg::setNotifyLevel(osg::INFO);
#endif

        m_pDefaultCamera = new vtCamera;
        m_pDefaultWindow = new vtWindow;
        SetCamera(m_pDefaultCamera);
        AddWindow(m_pDefaultWindow);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

        m_pOsgViewer = new osgViewer::Viewer(arguments);

        m_pOsgViewer->setDisplaySettings(osg::DisplaySettings::instance());
        if (bStereo)
        {
                osg::DisplaySettings* displaySettings = 
m_pOsgViewer->getDisplaySettings();
                displaySettings->setStereo(true);
                osg::DisplaySettings::StereoMode mode;
                if (iStereoMode == 0) mode = osg::DisplaySettings::ANAGLYPHIC;
                if (iStereoMode == 1) mode = osg::DisplaySettings::QUAD_BUFFER;
                if (iStereoMode == 2) mode = 
osg::DisplaySettings::HORIZONTAL_SPLIT;
                if (iStereoMode == 3) mode = 
osg::DisplaySettings::VERTICAL_SPLIT;
                displaySettings->setStereoMode(mode);
        }
#ifdef __DARWIN_OSX__
        // Kill multi-threading on OSX until wxGLContext properly implemented 
on that platform
        m_pOsgViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
#endif

        // We can't use displaySettings->setNumMultiSamples here to enable anti-
        // aliasing, because it has to be done eariler (at the time the OpenGL
        // context is made).

#ifdef VTP_USE_OSG_STATS
        osgViewer::StatsHandler* pStatsHandler = new osgViewer::StatsHandler;
        pStatsHandler->setKeyEventPrintsOutStats(0);
        pStatsHandler->setKeyEventTogglesOnScreenStats('x'); // I dont think 
this is used for anything else at the moment
        m_pOsgViewer->addEventHandler(pStatsHandler);
#endif

        // Kill the event visitor (saves a scenegraph traversal)
        // This will need to be restored if we need to use FRAME events etc. in 
the scenegraph
        m_pOsgViewer->setEventVisitor(NULL);//*******CALLED HERE

        if (bStereo)
        {
                // displaySettings->getScreenDistance(); default is 0.5
                // m_pOsgSceneView->getFusionDistanceMode(); default is 
PROPORTIONAL_TO_SCREEN_DISTANCE
                // m_pOsgSceneView->getFusionDistanceValue(); default is 1.0
                // The FusionDistanceValue is only used for 
USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.

                // We use real-world units for fusion distance value
                
m_pOsgViewer->setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE, 
100.0f);
        }

        // From the OSG mailing list: You must specify the lighting mode in
        // setDefaults() and override the default options. If you call
        // setDefaults() with the default options, a headlight is added to the
        // global state set of the SceneView.  With the default options applied,
        // I have tried subsequently calling setLightingMode(NO_SCENE_LIGHT)
        // and setLight(NULL), but I still get a headlight.
        m_pOsgViewer->setLightingMode(osg::View::NO_LIGHT);
        
m_pOsgViewer->getCamera()->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
        
m_pOsgViewer->getCamera()->setCullingMode(m_pOsgViewer->getCamera()->getCullingMode()
 & ~osg::CullSettings::SMALL_FEATURE_CULLING);

        // We maintain a node between OSG's viewer/camera and the vtlib Root, to
        //  control global state
        m_StateRoot = new osg::Group;
        m_pOsgViewer->setSceneData(m_StateRoot);

        // By default, things are lit, unless they ask not to be
        m_StateRoot->getOrCreateStateSet()->setMode(GL_LIGHTING, 
osg::StateAttribute::ON);

        //m_StateRoot->addCullCallback(new MyCull);
        //m_StateRoot->setUpdateCallback(new MyUpdate);
        //m_StateRoot->setEventCallback(new MyEvent);

        m_bInitialized = true;

        _initialTick = _timer.tick();
        _frameTick = _initialTick;

        return true;
}



Thank you!

Cheers,
Herman

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75053#75053





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to