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:
parent
10b6309f79
commit
ff74744556
@ -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)
|
||||||
@ -242,6 +252,30 @@ 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");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user