Added View::computeIntersection implementation for a node withing a scene graph.

This commit is contained in:
Robert Osfield
2007-01-10 10:09:05 +00:00
parent 4d4b342e97
commit 4954262eb0
8 changed files with 69 additions and 106 deletions

View File

@@ -33,7 +33,7 @@ class OSGUTIL_EXPORT LineSegmentIntersector : public Intersector
/** Convinience constructor for supporting picking in WINDOW, or PROJECTION coorindates
* In WINDOW coordinates creates a start value of (x,y,0) and end value of (x,y,1).
* In PROJECTION coordinates (clip space cube) creates a start value of (x,y,1) and end value of (x,y,-1).
* In PROJECTION coordinates (clip space cube) creates a start value of (x,y,-1) and end value of (x,y,1).
* In VIEW and MODEL coordinates creates a start value of (x,y,0) and end value of (x,y,1).*/
LineSegmentIntersector(CoordinateFrame cf, double x, double y);

View File

@@ -41,22 +41,12 @@ class OSGVIEWER_EXPORT Scene : public virtual osg::Referenced
osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
osgGA::EventQueue* getEventQueue() { return _eventQueue.get(); }
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
EventHandlers& getEventHandlers() { return _eventHandlers; }
const EventHandlers& getEventHandlers() const { return _eventHandlers; }
void setDatabasePager(osgDB::DatabasePager* dp);
osgDB::DatabasePager* getDatabasePager() { return _databasePager.get(); }
const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
virtual void frameAdvance();
virtual void frameEventTraversal();
virtual void frameUpdateTraversal();
public:
@@ -72,13 +62,7 @@ class OSGVIEWER_EXPORT Scene : public virtual osg::Referenced
osg::ref_ptr<osgUtil::UpdateVisitor> _updateVisitor;
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
osg::ref_ptr<osgDB::DatabasePager> _databasePager;
EventHandlers _eventHandlers;
};

View File

@@ -64,12 +64,8 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
* directly on to the computeIntersections method. */
bool computeIntersections(float x,float y, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified node.
* Note, when a master cameras has slaves and no viewport itself its coordinate frame will be in clip space i.e. -1,-1 to 1,1,
* while if its has a viewport the coordintates will be relative to its viewport dimensions.
* Mouse events handled by the view will automatically be attached into the master camera window/clip coords so can be passed
* directly on to the computeIntersections method. */
bool computeIntersections(float x,float y, osg::Node* node, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
/** Compute intersections between a ray through the specified master cameras window/eye coords and a specified nodePath's subgraph. */
bool computeIntersections(float x,float y, osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
virtual void requestRedraw();
@@ -91,7 +87,6 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
typedef std::map<osg::ref_ptr<osg::Camera>, osg::ref_ptr<osgUtil::SceneView> > CameraSceneViewMap;
CameraSceneViewMap _cameraSceneViewMap;
};
}

View File

@@ -16,6 +16,7 @@
#include <osgViewer/GraphicsWindow>
#include <osgViewer/View>
#include <osgGA/EventVisitor>
namespace osgViewer {
@@ -132,8 +133,9 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
unsigned int _numThreadsOnBarrier;
osg::observer_ptr<osg::Camera> _cameraWithFocus;
osg::observer_ptr<osg::Camera> _cameraWithFocus;
osg::ref_ptr<osgGA::EventVisitor> _eventVisitor;
};