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

This commit is contained in:
Robert Osfield 2008-10-27 16:16:28 +00:00
parent 10b6309f79
commit ff74744556

View File

@ -45,6 +45,7 @@
#include <osg/MatrixTransform> #include <osg/MatrixTransform>
#include <osg/Camera> #include <osg/Camera>
#include <osg/io_utils> #include <osg/io_utils>
#include <osg/ShapeDrawable>
#include <osgText/Text> #include <osgText/Text>
@ -107,8 +108,17 @@ void PickHandler::pick(osgViewer::View* view, const osgGA::GUIEventAdapter& ea)
std::string gdlist=""; std::string gdlist="";
float x = ea.getX(); float x = ea.getX();
float y = ea.getY(); float y = ea.getY();
#if 0
osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, x, y);
osgUtil::IntersectionVisitor iv(picker.get());
view->getCamera()->accept(iv);
if (picker->containsIntersections())
{
intersections = picker->getIntersections();
#else
if (view->computeIntersections(x,y,intersections)) if (view->computeIntersections(x,y,intersections))
{ {
#endif
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin();
hitr != intersections.end(); hitr != intersections.end();
++hitr) ++hitr)
@ -241,7 +251,31 @@ int main( int argc, char **argv )
// read the scene from the list of file specified commandline args. // read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments); osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
if (!scene)
{
osg::Group* group = new osg::Group();
osg::Geode* sphere = new osg::Geode();
sphere->setName("Sphere");
sphere->addDrawable(new osg::ShapeDrawable(new osg::Sphere()));
osg::Geode* cube = new osg::Geode();
cube->setName("Cube");
cube->addDrawable(new osg::ShapeDrawable(new osg::Box()));
osg::Camera* camera = new osg::Camera();
camera->setRenderOrder(osg::Camera::POST_RENDER);
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
//camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
group->addChild(sphere);
group->addChild(camera);
camera->addChild(cube);
scene = group;
}
// if not loaded assume no arguments passed in, try use default mode instead. // if not loaded assume no arguments passed in, try use default mode instead.
if (!scene) scene = osgDB::readNodeFile("fountain.osg"); if (!scene) scene = osgDB::readNodeFile("fountain.osg");
@ -313,7 +347,7 @@ int main( int argc, char **argv )
// set the scene to render // set the scene to render
viewer.setSceneData(group.get()); viewer.setSceneData(group.get());
return viewer.run(); return viewer.run();
} }