Show
Ignore:
Timestamp:
11/28/08 15:36:39 (6 years ago)
Author:
robert
Message:

From Jeremy Moles, updates to osgwidget examples.

Merged by Robert Osfield from OpenSceneGraph-osgWidget-dev

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgwidgetwindow/osgwidgetwindow.cpp

    r8867 r9289  
    4343 
    4444                return true; 
     45        } 
     46}; 
     47 
     48// This is the more "traditional" method of creating a callback. 
     49struct CallbackObject: public osgWidget::Callback { 
     50        CallbackObject(osgWidget::EventType evType): 
     51        osgWidget::Callback(evType) { 
     52        } 
     53 
     54        virtual bool operator()(osgWidget::Event& ev) { 
     55                std::cout << "here" << std::endl; 
     56                 
     57                return false; 
    4558        } 
    4659}; 
     
    6679                osgWidget::WindowManager::WM_USE_LUA | 
    6780                osgWidget::WindowManager::WM_USE_PYTHON | 
    68                 osgWidget::WindowManager::WM_PICK_DEBUG | 
    69                 osgWidget::WindowManager::WM_NO_BETA_WARN 
     81                osgWidget::WindowManager::WM_PICK_DEBUG 
    7082        ); 
    7183 
     
    8294        static std::string data = "lol ur face!"; 
    8395 
    84         box->addCallback(osgWidget::Callback(&windowClicked, osgWidget::EVENT_MOUSE_PUSH, &data)); 
    85         box->addCallback(osgWidget::Callback(&windowScrolled, osgWidget::EVENT_MOUSE_SCROLL)); 
     96        /* 
     97        box->addCallback(new osgWidget::Callback(&windowClicked, osgWidget::EVENT_MOUSE_PUSH, &data)); 
     98        box->addCallback(new osgWidget::Callback(&windowScrolled, osgWidget::EVENT_MOUSE_SCROLL)); 
    8699        box->addCallback(osgWidget::Callback( 
    87100                &Object::windowClicked, 
     
    89102                osgWidget::EVENT_MOUSE_PUSH 
    90103        )); 
     104        */ 
     105 
     106        box->addCallback(new CallbackObject(osgWidget::EVENT_MOUSE_PUSH)); 
    91107 
    92108        // Create some of our "testing" Widgets; included are two Widget subclasses I made 
     
    125141        // to the WindowManager. This demonstrates the usages of OSG's ->clone() support, 
    126142        // though that is abstracted by our META_UIObject macro. 
    127         osgWidget::Window* boxCopy = osg::clone(box,"newBox"); 
     143        osgWidget::Window* boxCopy = osg::clone(box, "newBox", osg::CopyOp::DEEP_COPY_ALL); 
    128144 
    129145        // Move our copy to make it visible. 
     
    145161        // creation. 
    146162        // std::cout << *box << std::endl << *boxCopy << std::endl; 
    147  
    148         // Add our event handler; is this better as a MatrixManipulator? Add a few other 
    149         // helpful ViewerEventHandlers. 
    150         viewer.addEventHandler(new osgWidget::MouseHandler(wm)); 
    151         viewer.addEventHandler(new osgWidget::KeyboardHandler(wm)); 
    152         viewer.addEventHandler(new osgViewer::StatsHandler()); 
    153         viewer.addEventHandler(new osgViewer::WindowSizeHandler()); 
    154         viewer.addEventHandler(new osgGA::StateSetManipulator( 
    155                 viewer.getCamera()->getOrCreateStateSet() 
    156         )); 
    157163 
    158164        // Setup our OSG objects for our scene; note the use of the utility function 
     
    163169        // some of the other examples to see this in action... 
    164170        osg::Group*  group  = new osg::Group(); 
    165         osg::Camera* camera = osgWidget::createInvertedYOrthoCamera(1280.0f, 1024.0f); 
     171        osg::Camera* camera = osgWidget::createOrthoCamera(1280.0f, 1024.0f); 
    166172        osg::Node*   model  = osgDB::readNodeFile("cow.osg"); 
     173 
     174        // Add our event handler; is this better as a MatrixManipulator? Add a few other 
     175        // helpful ViewerEventHandlers. 
     176        viewer.addEventHandler(new osgWidget::MouseHandler(wm)); 
     177        viewer.addEventHandler(new osgWidget::KeyboardHandler(wm)); 
     178        viewer.addEventHandler(new osgWidget::ResizeHandler(wm, camera)); 
     179        viewer.addEventHandler(new osgWidget::CameraSwitchHandler(wm, camera)); 
     180        viewer.addEventHandler(new osgViewer::StatsHandler()); 
     181        viewer.addEventHandler(new osgViewer::WindowSizeHandler()); 
     182        viewer.addEventHandler(new osgGA::StateSetManipulator( 
     183                viewer.getCamera()->getOrCreateStateSet() 
     184        )); 
    167185 
    168186        // Set our first non-UI node to be something other than the mask we created our