Show
Ignore:
Timestamp:
01/06/07 22:35:57 (7 years ago)
Author:
robert
Message:

Ported osgcopy, osgcubemap, osgdelaunay, osgdepthpartion, osgdistortion, osgfadetext, osgforest and osgfxbrowser to osgViewer

Files:
1 modified

Legend:

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

    r5054 r5923  
    1 //C++ source file - Open Producer - Copyright (C) 2002 Don Burns 
    2 //Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL) 
    3 //as published by the Free Software Foundation. 
    4  
    5 // Simple example of use of Producer::RenderSurface 
    6 // The myGraphics class is a simple sample of how one would implement 
    7 // graphics drawing with Producer::RenderSurface 
    8  
    91#include <osgUtil/UpdateVisitor> 
    102 
     
    146#include <osg/PositionAttitudeTransform> 
    157 
    16 #include <osgProducer/Viewer> 
     8#include <osgGA/TrackballManipulator> 
     9 
     10#include <osgViewer/Viewer> 
    1711 
    1812#include "DepthPartitionNode.h" 
     
    6357    // use an ArgumentParser object to manage the program arguments. 
    6458    osg::ArgumentParser arguments(&argc,argv); 
    65      
    66     // set up the usage document, in case we need to print out how to use this program. 
    67     arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); 
    68     arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard example of using osgProducer::CameraGroup."); 
    69     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] ..."); 
    70     arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    7159 
    7260    // construct the viewer. 
    73     osgProducer::Viewer viewer(arguments); 
    74  
    75     // set up the value with sensible default event handlers. 
    76     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    77  
    78     // if user request help write it out to cout. 
    79     if (arguments.read("-h") || arguments.read("--help")) 
    80     { 
    81         arguments.getApplicationUsage()->write(std::cout); 
    82         return 1; 
    83     } 
    84  
    85     // any option left unread are converted into errors to write out later. 
    86     arguments.reportRemainingOptionsAsUnrecognized(); 
    87  
    88     // report any errors if they have occured when parsing the program aguments. 
    89     if (arguments.errors()) 
    90     { 
    91         arguments.writeErrorMessages(std::cout); 
    92         return 1; 
    93     } 
    94  
     61    osgViewer::Viewer viewer; 
    9562 
    9663    bool needToSetHomePosition = false; 
     
    11481    viewer.setSceneData(dpn.get()); 
    11582 
     83    viewer.setCameraManipulator(new osgGA::TrackballManipulator); 
     84 
    11685    if (needToSetHomePosition) 
    11786    { 
    118         viewer.getKeySwitchMatrixManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0)); 
    119     } 
    120  
    121     // create the windows and run the threads. 
    122     viewer.realize(); 
    123  
    124     while( !viewer.done() ) 
    125     { 
    126         // wait for all cull and draw threads to complete. 
    127         viewer.sync(); 
    128  
    129         // update the scene by traversing it with the the update visitor which will 
    130         // call all node update callbacks and animations. 
    131         viewer.update(); 
    132           
    133         // fire off the cull and draw traversals of the scene. 
    134         viewer.frame(); 
    135          
     87        viewer.getCameraManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0)); 
    13688    } 
    13789     
    138     // wait for all cull and draw threads to complete before exit. 
    139     viewer.sync(); 
     90    // depth partion node is only supports single window/single threaded at present. 
     91    viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); 
    14092 
    141     // run a clean up frame to delete all OpenGL objects. 
    142     viewer.cleanup_frame(); 
    143  
    144     // wait for all the clean up frame to complete. 
    145     viewer.sync(); 
    146  
    147     return 0; 
     93    return viewer.run(); 
    14894} 
    14995