Thank you very much.  The keyswitchManipulator does exactly what I had
in mind.
My only problem now is that before I added the
KeySwitchMatrixManipulator to the view, I created a custom
KeyBoardMouseEventHandler that worked with the viewer.  Now that I added
the KeySwitchMatrixManipulator, I can't get my KeyBoardMouseEventHandler
to control my scene.  

I'm sure I just have to add a addEventHandler to the right place but I
can't seem to get it to work.



Code snippet:
------------------------------------------------------------------------
---------------------------------
        //Add Camera Manipulator
        keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
        viewer_->setCameraManipulator( keyswitchManipulator.get() );

        osgGA::NodeTrackerManipulator::TrackerMode trackerMode =
osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION;
        osgGA::NodeTrackerManipulator::RotationMode rotationMode =
osgGA::NodeTrackerManipulator::TRACKBALL;
    

        //Add Earth as the default camera focus
        FindNamedNodeVisitor fnnv("Earth");
        root_->accept(fnnv);

        if (!fnnv._foundNodes.empty())
        {
        // set up the node tracker.
        osgGA::NodeTrackerManipulator* tm = new
osgGA::NodeTrackerManipulator;
        tm->setTrackerMode( trackerMode );
        tm->setRotationMode( rotationMode );
          tm->setTrackNode( fnnv._foundNodes.front().get() );

        unsigned int num =
keyswitchManipulator->getNumMatrixManipulators();
        keyswitchManipulator->addMatrixManipulator( 'e', "earth", tm);
        keyswitchManipulator->selectMatrixManipulator( num );
        }
        
        ///////////////////////////////////////////
        //New Keyboard/Mouse Event Handler code
        //////////////////////////////////////////

    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new
osgGA::StateSetManipulator(viewer_->getCamera()->getStateSet());
    viewer_->addEventHandler(statesetManipulator.get());

    // add the KeyBoardMouseEventHandler
    kbmeh = new KeyBoardMouseEventHandler();

    //Add Event Handler for Mouse and KeyBoard
    viewer_->addEventHandler(kbmeh.get());

    viewer_->setSceneData(root_);
------------------------------------------------------------------------
-----------------------------------





-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert
Osfield
Sent: Saturday, August 11, 2007 1:09 AM
To: [email protected]
Subject: Re: [osg-users] osgplanets modification Question


Hi Nelson,

The osgplanet example already does what you are after... it attaches
multiple NodeTrackerManipulators, one for each planet of interest, then
a KeySwitchMatrixManipulator is used at the top to select which planet
to view.  Please have a look at the code.

Robert.

On 8/11/07, Cysneros, Nelson SPAWAR <[EMAIL PROTECTED]> wrote:
>
>
> On the osgplanet example, if I wanted to view any selected planet and 
> have it be my center of focus, while still being part of the overall 
> simulation, what would be the best way to do this?
>
>
> 1.  Attach a camera to every planet, and when selected pass the camera

> to the main view.
>
>         osgViewer::Viewer viewer;
>         viewer->setSceneData(root);
>
>         //after selecting planet
>         viewer->setCamera(newPlanetCamera);
>
>
> 2. Point the default camera to the selected Planets
>
>          osg::Vec3 eye( viewPoint->getX(), viewPoint->getY(),
> viewPoint->getZ());
>          osg::Vec3 center(0,0,0);
>          osg::Vec3 up(0,0,5000000);
>
> viewer->getCamera()->setViewMatrixAsLookAt(eye,center,up);
>
>
> 3. Is their a better way to do this?  Any examples?
>
>
>
> Thank you
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to