Show
Ignore:
Timestamp:
01/10/07 22:05:26 (7 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgshaders
osgshaderterrain
osgshadow
osgshadowtexture

Files:
1 modified

Legend:

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

    r5786 r5956  
    77#include <osg/Stencil> 
    88#include <osg/CullFace> 
    9  
    10 #include <osgProducer/Viewer> 
     9#include <osg/Geometry> 
     10 
     11#include <osgGA/TrackballManipulator> 
     12 
     13#include <osgViewer/Viewer> 
    1114 
    1215#include <osgShadow/OccluderGeometry> 
     
    1417#include <osgDB/ReadFile> 
    1518 
     19#include <iostream> 
    1620 
    1721class ComputeBoundingBoxVisitor : public osg::NodeVisitor 
     
    125129 
    126130    // construct the viewer. 
    127     osgProducer::Viewer viewer(arguments); 
    128  
    129     // set up the value with sensible default event handlers. 
    130     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    131  
    132     // get details on keyboard and mouse bindings used by the viewer. 
    133     viewer.getUsage(*arguments. getApplicationUsage()); 
     131    osgViewer::Viewer viewer; 
    134132 
    135133    // if user request help write it out to cout. 
     
    190188        osg::Vec3 centerBase( (bb.xMin()+bb.xMax())*0.5f, (bb.yMin()+bb.yMax())*0.5f, bb.zMin()-bb.radius()*0.1f ); 
    191189         
    192         geode->addDrawable( createTexturedQuadGeometry( centerBase-widthVec*1.5f-depthVec*1.5f,  
    193                                                         widthVec*3.0f, depthVec*3.0f) ); 
     190        geode->addDrawable( osg::createTexturedQuadGeometry( centerBase-widthVec*1.5f-depthVec*1.5f,  
     191                                                             widthVec*3.0f, depthVec*3.0f) ); 
    194192        newGroup->addChild(geode); 
    195193         
     
    382380    viewer.setSceneData(group.get()); 
    383381 
     382 
     383    viewer.setCameraManipulator(new osgGA::TrackballManipulator()); 
     384 
     385 
     386    osg::notify(osg::NOTICE)<<"Warning: Stencil buffer required, but not yet switched on."<<std::endl; 
     387 
     388 
    384389    // create the windows and run the threads. 
    385390    viewer.realize(); 
     
    387392    while (!viewer.done()) 
    388393    { 
    389       // wait for all cull and draw threads to complete. 
    390       viewer.sync(); 
    391  
    392394        if (updateLightPosition) 
    393395        { 
     
    403405            light->setPosition(lightpos); 
    404406            occluder->computeShadowVolumeGeometry(lightpos, *shadowVolume); 
    405        } 
    406  
    407       // update the scene by traversing it with the the update visitor which will 
    408       // call all node update callbacks and animations. 
    409       viewer.update(); 
    410           
    411       // fire off the cull and draw traversals of the scene. 
    412       viewer.frame(); 
    413     } 
    414      
    415     // wait for all cull and draw threads to complete. 
    416     viewer.sync(); 
    417  
    418     // run a clean up frame to delete all OpenGL objects. 
    419     viewer.cleanup_frame(); 
    420  
    421     // wait for all the clean up frame to complete. 
    422     viewer.sync(); 
    423  
     407        } 
     408 
     409        viewer.frame(); 
     410    } 
     411     
    424412    return 0; 
    425413}