how to display osgviewer inside c++ gui

classic Classic list List threaded Threaded
5 messages Options
Ekkim Ekkim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to display osgviewer inside c++ gui

hi
i am working with visual studio
in the gui i have to execute by button event a function to display the terrain in the same window, i wrote the following code but the terrain is displayed in a new window !
please i need some help to display the terrain in the same window

the code executed by the button event is :


private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {

                         
        //osgEarth::Util::Viewpoint* viewer =new osgEarth::Util::Viewpoint();
        osgViewer::Viewer* viewer = new osgViewer::Viewer();
        osg::Group* root = new osg::Group();
        osg::Node* loadedModel = osgDB::readNodeFile("./data/Alg_level1.earth");//zone
        osgEarth::MapNode* map = osgEarth::MapNode::findMapNode(loadedModel);
        map->getOrCreateStateSet()->setMode(GL_LIGHTING ,osg::StateAttribute::ON );
        root->addChild(map);

        osg::ref_ptr<osg::Node> object = osgDB::readNodeFile("./data/cessnafire.osg.10000.scale");
       
        const SpatialReference* srs = SpatialReference::create("wgs84");

        GeoTransform* xform= new GeoTransform();

        xform->setTerrain( map->getTerrain());

        GeoPoint point(srs , 3.13 , 37.53,100000);

        xform->setPosition(point);

        xform->addChild(object);

        root->addChild(xform);

        osgEarth::Util::EarthManipulator* manip = new osgEarth::Util::EarthManipulator();
        viewer->setCameraManipulator (manip);
       
        viewer->setUpViewInWindow(50, 50, 512, 512);
        viewer->setSceneData(root);
        viewer->run();
                 }


thank you for help !!
2LR 2LR
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to display osgviewer inside c++ gui

What GUI are you using?

I suggest you take a look at the OpenSceneGraph source examples. In particular, look at the osgviewerFLTK.cpp example. They show how to embed an osgviewer into an existing window controlled by another GUI, in this case, FLTK.

Keep in mind that doing this will make the osgviewer run single-threaded.

If you need to embed the osgviewer into something like Windows Forms, that is a bit more involved. The OpenSceneGraph 3.0 cookbook by Rui Wang shows how this is done. If you don't have access to this resource, I can post the example...

HTH

Shayne

Ekkim Ekkim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to display osgviewer inside c++ gui

i am using CLR

and  i need to embed the osgviewer into Windows Forms,can you give the example..

thanks HTH Shayne
2LR 2LR
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to display osgviewer inside c++ gui

While I think your request is beyond the scope of the osgEarth forum and is more applicable for the OpenSceneGraph community, I will go ahead and post the code to embed an osgviewer inside Windows Forms...

Shayne

cliTest.cpp

MyForm.cpp

MyForm.h

osgWindow.cpp

osgWindow.h
Ekkim Ekkim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to display osgviewer inside c++ gui

its work
thanks 2LR
Loading...