Show
Ignore:
Timestamp:
01/10/07 14:52:22 (8 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgparticleeffects
osgphotoalbum
osgpick
osgpoints
osgpointsprite
osgprecipitation
osgprerender
osgprerendercubemap
osgreflect
osgscalarbar
osgscribe
osgsequence
osgplanets

Files:
1 modified

Legend:

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

    r5636 r5954  
    2323#include <osgText/Text> 
    2424 
    25 #include <osgProducer/Viewer> 
     25#include <osgViewer/Viewer> 
    2626 
    2727#include "ImageReaderWriter.h" 
     28 
     29#include <iostream> 
    2830 
    2931using namespace osg; 
     
    676678 
    677679    // construct the viewer. 
    678     osgProducer::Viewer viewer(arguments); 
    679  
    680     // set up the value with sensible default event handlers. 
    681     //viewer.setUpViewer(osgProducer::Viewer::ESCAPE_SETS_DONE); 
    682     viewer.setUpViewer(); 
     680    osgViewer::Viewer viewer; 
    683681 
    684682    // register the handler to add keyboard and mosue handling. 
    685683    SlideEventHandler* seh = new SlideEventHandler(); 
    686     viewer.getEventHandlerList().push_front(seh); 
    687  
    688  
    689     // get details on keyboard and mouse bindings used by the viewer. 
    690     viewer.getUsage(*arguments.getApplicationUsage()); 
     684    viewer.addEventHandler(seh); 
    691685 
    692686    // read any time delay argument. 
     
    741735    // now the windows have been realized we switch off the cursor to prevent it 
    742736    // distracting the people seeing the stereo images. 
    743     float fovx = 1.25f; 
    744     float fovy = 1.0f; 
    745     for( unsigned int i = 0; i < viewer.getNumberOfCameras(); i++ ) 
    746     { 
    747         Producer::Camera* cam = viewer.getCamera(i); 
    748         //Producer::RenderSurface* rs = cam->getRenderSurface(); 
    749         //rs->useCursor(false); 
    750         fovx = cam->getLensHorizontalFov(); 
    751         fovy = cam->getLensVerticalFov(); 
    752     } 
    753  
     737    double fovy, aspectRatio, zNear, zFar; 
     738    viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); 
     739 
     740    fovy = osg::DegreesToRadians(fovy); 
     741    double fovx = atan(tan(fovy*0.5)*aspectRatio)*2.0; 
     742     
    754743    float radius = 1.0f; 
    755744    float width = 2*radius*tan(fovx*0.5f); 
     
    769758    viewer.setSceneData(album->getScene()); 
    770759 
    771  
    772760    // set up the SlideEventHandler. 
    773761    seh->set(album.get(),timeDelayBetweenSlides,autoSteppingActive); 
    774762     
    775  
    776     // create the windows and run the threads. 
    777763    viewer.realize(); 
    778764     
    779     osg::Matrix homePosition; 
    780     homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f)); 
    781          
    782     while( !viewer.done() ) 
    783     { 
    784         // wait for all cull and draw threads to complete. 
    785         viewer.sync(); 
    786  
    787         // update the scene by traversing it with the the update visitor which will 
    788         // call all node update callbacks and animations. 
    789         viewer.update(); 
    790           
    791         //viewer.setView(homePosition); 
    792  
    793         // fire off the cull and draw traversals of the scene. 
    794         viewer.frame(); 
    795          
    796     } 
    797      
    798     // wait for all cull and draw threads to complete. 
    799     viewer.sync(); 
    800  
    801     // run a clean up frame to delete all OpenGL objects. 
    802     viewer.cleanup_frame(); 
    803  
    804     // wait for all the clean up frame to complete. 
    805     viewer.sync(); 
    806      
    807     return 0; 
    808 } 
    809  
     765    // switch off the cursor 
     766    osgViewer::Viewer::Windows windows; 
     767    viewer.getWindows(windows); 
     768    for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); 
     769        itr != windows.end(); 
     770        ++itr) 
     771    { 
     772        (*itr)->useCursor(false); 
     773    } 
     774 
     775 
     776    return viewer.run(); 
     777} 
     778