Changeset 8267

Show
Ignore:
Timestamp:
04/30/08 23:59:47
Author:
robert
Message:

Completed viewer examples

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/08_viewer/8e_eventhandlers/8e_eventhandlers.cpp

    r8120 r8267  
    44#include <iostream> 
    55 
     6class MyEventHandler : public osgGA::GUIEventHandler 
     7{ 
     8public: 
     9 
     10    MyEventHandler() {} 
     11 
     12    /** Handler event.*/     
     13    bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); 
     14 
     15    /** Get the keyboard and mouse usage of this manipulator.*/ 
     16    virtual void getUsage(osg::ApplicationUsage& usage) const; 
     17}; 
     18 
     19 
     20bool MyEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) 
     21{ 
     22    std::cout<<"MyEventHandler::handle(ea,aa) - please implement me!"<<std::endl; 
     23    return false; 
     24} 
     25 
     26void MyEventHandler::getUsage(osg::ApplicationUsage& usage) const 
     27{ 
     28    std::cout<<"MyEventHandler::getUsage(usage) - please implement me!"<<std::endl; 
     29} 
     30 
    631int main( int argc, char **argv ) 
    732{ 
    8     std::cout<<"TODO "<<argv[0]<<std::endl; 
     33    // This exercise explores the implementation 
     34    // and use of custom EventHandlers 
     35    // 
     36    // The shell of a custom EventHandler has been 
     37    // written for you above, please implement the 
     38    // the handle and getUsage methods so that they 
     39    // report and respond to: 
     40    // 
     41    // 1. Frame events, reporting frame number and frame time 
     42    // 2. Mouse mouse events, reporting x, y location and input range 
     43    // 3. Keyboard press and release events 
     44    // 4. Implement a model pick operation in response to press 'p' 
     45    // 
     46    // Hint, example osgpick provides an example of picking. 
     47 
     48    osgViewer::Viewer viewer; 
    949     
    10     return 0; 
     50    viewer.addEventHandler(new MyEventHandler); 
     51     
     52    viewer.setSceneData(osgDB::readNodeFile("fountain.osg")); 
     53     
     54    if (!viewer.getSceneData()) 
     55    { 
     56        std::cout<<"No file loaded."<<std::endl; 
     57        return 1; 
     58    } 
     59     
     60    return viewer.run(); 
    1161} 
  • OpenSceneGraph-TrainingMaterials/trunk/Sources/Exercises/08_viewer/8f_slavecameras/8f_slavecameras.cpp

    r8120 r8267  
    66int main( int argc, char **argv ) 
    77{ 
    8     std::cout<<"TODO "<<argv[0]<<std::endl; 
    9      
     8    // The example fleshes out how one  
     9    // creates a viewer with a master camera 
     10    // that controls a set of slave cameras. 
     11    // 
     12    // You task is: 
     13    // 
     14    // 1. Construct a viewer, and load  
     15    //    and assign the model cessnafire.org 
     16    //    to it and then add the osgViewer::StatsHandler 
     17    //    to the viewer.   
     18    //    Run the usual run loop to check that the model  
     19    //    has loaded correctly, press 's' to check the  
     20    //    viewer stats. 
     21    // 
     22    // 2. Modify the viewer code so that you query and 
     23    //    report the dimensions of screen 0.  (Hint use  
     24    //    GraphicsContext::getWindowSystemInterface() ). 
     25    //    Run and test the viewer/reporting code 
     26    // 
     27    // 3. Create a single GraphicsContext that is full size 
     28    //    of the screen, but with the window decoration enabled. 
     29    //    Assign the context to the viewers master Camera. 
     30    //    Run and test the viewer. 
     31    //     
     32    // 4. Remove the context form the master camera, and then 
     33    //    create two slave cameras, the first having a viewport 
     34    //    the occupies the left hand side of the window, and 
     35    //    a second slave camera tha occupies the right. 
     36    //    Run and test the viewer. 
     37    // 
     38    // 5. Modify the slave projection matrix offset of the two 
     39    //    slave cameas to create a single power wall style joinged view. 
     40    //    Toggle on stats to view the camera stats.  
     41    // 
     42    // 5. Reset the projection matrix offset back to indentity and  
     43    //    modify the slave view matrix offset of the two 
     44    //    slave cameas to create a single cylinderical style display. 
     45    //    Toggle on stats to view the camera stats.  
     46    // 
     47    // 5. Chnage the window creation code so that it uses two graphics 
     48    //    windows, one per slave rather than a single window.  
     49 
    1050    return 0; 
    1151}