| 1 | #include <osg/Image> |
|---|
| 2 | #include <osg/Geometry> |
|---|
| 3 | #include <osg/Texture2D> |
|---|
| 4 | |
|---|
| 5 | #include <osgGA/TrackballManipulator> |
|---|
| 6 | |
|---|
| 7 | #include <osgWidget/VncClient> |
|---|
| 8 | |
|---|
| 9 | #include <osgViewer/Viewer> |
|---|
| 10 | #include <osgViewer/ViewerEventHandlers> |
|---|
| 11 | |
|---|
| 12 | #include <iostream> |
|---|
| 13 | #include <osg/io_utils> |
|---|
| 14 | |
|---|
| 15 | #include <osgDB/ReadFile> |
|---|
| 16 | |
|---|
| 17 | class EscapeHandler : public osgGA::GUIEventHandler |
|---|
| 18 | { |
|---|
| 19 | public: |
|---|
| 20 | |
|---|
| 21 | EscapeHandler() {} |
|---|
| 22 | |
|---|
| 23 | bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) |
|---|
| 24 | { |
|---|
| 25 | if (ea.getHandled()) return false; |
|---|
| 26 | |
|---|
| 27 | switch(ea.getEventType()) |
|---|
| 28 | { |
|---|
| 29 | case(osgGA::GUIEventAdapter::KEYUP): |
|---|
| 30 | { |
|---|
| 31 | if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Escape) |
|---|
| 32 | { |
|---|
| 33 | osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); |
|---|
| 34 | if (view) view->getViewerBase()->setDone(true); |
|---|
| 35 | |
|---|
| 36 | return true; |
|---|
| 37 | } |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | default: |
|---|
| 41 | return false; |
|---|
| 42 | } |
|---|
| 43 | return false; |
|---|
| 44 | } |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | int main(int argc,char** argv) |
|---|
| 48 | { |
|---|
| 49 | osg::ArgumentParser arguments(&argc, argv); |
|---|
| 50 | osgViewer::Viewer viewer(arguments); |
|---|
| 51 | |
|---|
| 52 | osgWidget::GeometryHints hints(osg::Vec3(1.0f,0.0f,0.0f), |
|---|
| 53 | osg::Vec3(1.0f,0.0f,0.0f), |
|---|
| 54 | osg::Vec3(0.0f,0.0f,1.0f), |
|---|
| 55 | osg::Vec4(1.0f,1.0f,1.0f,1.0f), |
|---|
| 56 | osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO); |
|---|
| 57 | |
|---|
| 58 | osg::ref_ptr<osg::Group> group = new osg::Group; |
|---|
| 59 | |
|---|
| 60 | for(int i=1; i<arguments.argc(); ++i) |
|---|
| 61 | { |
|---|
| 62 | if (!arguments.isOption(i)) |
|---|
| 63 | { |
|---|
| 64 | osg::ref_ptr<osgWidget::VncClient> vncClient = new osgWidget::VncClient; |
|---|
| 65 | if (vncClient->connect(arguments[i], hints)) |
|---|
| 66 | { |
|---|
| 67 | group->addChild(vncClient.get()); |
|---|
| 68 | |
|---|
| 69 | hints.position.x() += 1.1f; |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | viewer.setSceneData(group.get()); |
|---|
| 75 | |
|---|
| 76 | viewer.addEventHandler(new osgViewer::StatsHandler); |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | viewer.addEventHandler(new EscapeHandler); |
|---|
| 81 | viewer.setKeyEventSetsDone(0); |
|---|
| 82 | |
|---|
| 83 | return viewer.run(); |
|---|
| 84 | } |
|---|