Show
Ignore:
Timestamp:
10/27/08 17:16:28 (5 years ago)
Author:
robert
Message:

From Chris Denham, default scene that tests the use of in scene graph Camera which has a RELATIVE_RF ReferenceFrame?.

Files:
1 modified

Legend:

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

    r8551 r9065  
    4646#include <osg/Camera> 
    4747#include <osg/io_utils> 
     48#include <osg/ShapeDrawable> 
    4849 
    4950#include <osgText/Text> 
     
    108109    float x = ea.getX(); 
    109110    float y = ea.getY(); 
     111#if 0 
     112    osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y); 
     113    osgUtil::IntersectionVisitor iv(picker.get()); 
     114    view->getCamera()->accept(iv); 
     115    if (picker->containsIntersections()) 
     116    { 
     117        intersections = picker->getIntersections(); 
     118#else 
    110119    if (view->computeIntersections(x,y,intersections)) 
    111120    { 
     121#endif 
    112122        for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); 
    113123            hitr != intersections.end(); 
     
    242252    // read the scene from the list of file specified commandline args. 
    243253    osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments); 
    244       
     254 
     255    if (!scene) 
     256    { 
     257        osg::Group* group = new osg::Group(); 
     258 
     259        osg::Geode* sphere = new osg::Geode(); 
     260        sphere->setName("Sphere"); 
     261        sphere->addDrawable(new osg::ShapeDrawable(new osg::Sphere())); 
     262 
     263        osg::Geode* cube = new osg::Geode(); 
     264        cube->setName("Cube"); 
     265        cube->addDrawable(new osg::ShapeDrawable(new osg::Box())); 
     266 
     267        osg::Camera* camera = new osg::Camera(); 
     268        camera->setRenderOrder(osg::Camera::POST_RENDER); 
     269        camera->setClearMask(GL_DEPTH_BUFFER_BIT); 
     270        //camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); 
     271 
     272        group->addChild(sphere); 
     273        group->addChild(camera); 
     274        camera->addChild(cube); 
     275 
     276        scene = group; 
     277    } 
     278 
    245279    // if not loaded assume no arguments passed in, try use default mode instead. 
    246280    if (!scene) scene = osgDB::readNodeFile("fountain.osg"); 
     
    314348        // set the scene to render 
    315349        viewer.setSceneData(group.get()); 
    316  
     350     
    317351        return viewer.run(); 
    318352    }