VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgIntersector.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 #include <vrvOsg/DtOsgRenderer.h>
16 
17 #include <vrvCore/DtIntersector.h>
18 
19 #include <osgUtil/IntersectVisitor>
20 
21 #include <osg/Node>
22 #include <osgUtil/LineSegmentIntersector>
23 
24 #include <matrix/vlVector.h>
25 
26 namespace osgUtil
27 {
28  class Hit;
29 }
30 
31 namespace osgViewer
32 {
33  class View;
34 }
35 
36 namespace makVrv
37 {
38  class DtOsgRenderer;
39  class DtOsgIntersectionVisitor;
40 
51  {
52  public:
53  std::list<DtUniqueID> myExcludeIds;
54  std::list<osg::Node*> myExcludeNodes;
55  };
56 
57 
63  {
64  public:
67 
68  DtOsgIntersectorResult& operator=( const DtOsgIntersectorResult &orig );
69 
70  public:
71  // 3 points of the intersected triangle
72  std::vector<osg::Vec3> myHitTriangle;
73 
74  // matrix transform from world to triangle local coordinates
75  osg::Matrixd myLocalToWorld;
76  };
77 
83  {
84  public:
85 
86  // Abstract DtIntersector Implementation for OSG
87 
89  DtOsgIntersector( DtDe& de, int modelSet );
90 
92  virtual ~DtOsgIntersector();
93 
108  virtual bool findNearestIntersectionToPoint(double x, double y, double z,
109  double vx, double vy, double vz,
111  IntersectProperties properties=AllNodes,
112  std::vector<DtElementID>* ignoreList=0,
113  bool returnTriangle=false,
114  double maxIsectorLength=-1., bool useHighLod=false );
115 
123  virtual bool findAllIntersectionsThroughPoint( double x, double y, double z,
124  double vx, double vy, double vz, DtIntersections& intersections,
125  IntersectProperties properties=AllNodes,
126  std::vector<DtElementID>* ignoreList=0, bool sort=true, bool useHighLod=false );
127 
134  virtual bool findFirstIntersectWithLineSegment(
135  double x, double y, double z, double end_x, double end_y, double end_z,
136  DtIntersectorResult& intersection,
137  IntersectProperties properties=AllNodes,
138  std::vector<DtElementID>* ignoreList=0, bool useHighLod=false);
139 
146  virtual bool findAllIntersectWithLineSegment(
147  double x, double y, double z, double end_x, double end_y, double end_z,
148  DtIntersections& intersections,
149  IntersectProperties properties=AllNodes,
150  std::vector<DtElementID>* ignoreList=0, bool sort=true, bool useHighLod=false );
151 
157  virtual bool pick( DtChannel& channel, double mx, double my,
158  DtIntersectorResult& intersection,
159  IntersectProperties properties=AllNodes,
160  std::vector<DtElementID>* ignoreList=0);
161 
166  virtual bool pickAll( DtChannel* channel, double mx, double my,
167  DtIntersections& intersections, IntersectProperties properties=AllNodes,
168  std::vector<DtElementID>* ignoreList=0);
169 
170  public:
171 
172  // OSG-specific Interface
173 
187 
188 
189  typedef std::vector<DtOsgIntersectorResult> DtOsgIntersections;
190 
191 
211 
212  virtual bool findNearestIntersection(double x, double y, double z,
213  double vx, double vy, double vz, DtOsgIntersectorResult& intersection,
214  const DtSceneRootList& intersectionRoots,
215  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
216  DtOsgItersectorExclusions* excludeNodeList=0, bool returnHitTriangle=false,
217  double maxIsectorLength=-1.0, bool useHighLod=false );
218 
232  virtual bool findIntersectionsThroughPoint(double x, double y, double z,
233  double vx, double vy, double vz,
235  const DtSceneRootList& intersectionRoots,
236  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
237  DtOsgItersectorExclusions* exclusions=0, bool returnHitTriangle=false,
238  double maxIsectorLength=-1.0, bool sort=true, bool useHighLod=false );
239 
245  virtual bool intersectLineSegmentWithScene( double x, double y, double z,
246  double end_x, double end_y, double end_z,
247  DtOsgIntersectorResult& intersection,
248  const DtSceneRootList& intersectionRoots,
249  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
250  DtOsgItersectorExclusions* excludeNodeList=0,
251  bool returnHitTriangle=false, bool useHighLod=false );
252 
258  virtual bool intersectLineSegmentWithScene( double x, double y, double z,
259  double end_x, double end_y, double end_z,
260  DtOsgIntersector::DtOsgIntersections& intersections,
261  const DtSceneRootList& intersectionRoots,
262  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
263  DtOsgItersectorExclusions* excludeNodeList=0,
264  bool returnHitTriangle=false, bool sort=true, bool useHighLod=false );
265 
268  virtual bool pick( osgViewer::View& view, double mx, double my,
269  DtOsgIntersectorResult& intersection,
270  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
271  DtOsgItersectorExclusions* excludeNodeList=0,
272  bool returnHitTriangle=false );
273 
276  virtual bool pick( osgViewer::View& view, double mx, double my,
278  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
279  DtOsgItersectorExclusions* excludeNodeList=0,
280  bool returnHitTriangle=false );
281 
282  public:
283 
284  static osg::Node::NodeMask nodeMaskFromIntersectProperties(
285  IntersectProperties properties );
286 
287  static bool anyNodeInNodePath(std::list<osg::Node*>* n,
288  osg::NodePath const& path);
289 
290  protected:
291 
293  virtual float distanceToResult2(double x, double y, double z, DtOsgIntersectorResult& result);
294 
295  virtual bool calcEndpointsFromDirectionAndLength( double x, double y,
296  double z, double vx, double vy, double vz, double length,
297  const DtSceneRootList& intersectionRoots, DtVector& startPoint,
298  DtVector& endPoint ) const;
299 
300  void getExcludeNodesFromIgnoreList( std::vector<DtUniqueID>* ignoreList,
301  DtOsgItersectorExclusions& exclusions );
302 
305  osg::Vec3d worldIntersectPoint( const osgUtil::Hit& hit );
306 
307  osg::Vec3d worldIntersectPoint(
308  const osgUtil::LineSegmentIntersector::Intersection& hit );
309 
310  osg::Vec3d localToWorld( const osg::Vec3& local, const osg::Matrix& localToWorld );
311 
312  bool findIdFromNodePath( const osg::NodePath& nodePath, DtUniqueID& id );
313 
316  osg::Camera * getActiveCamera(osgViewer::View& view);
317 
320  void updateInstanceIntersectElementId(DtOsgIntersectorResult &result);
321 
323  bool fillResultFromHit(DtOsgIntersectorResult& result,
324  const osgUtil::LineSegmentIntersector::Intersection& hit,
325  bool returnHitTriangle ) ;
326 
329  void doLineSegmentIntersections(
330  osgUtil::IntersectionVisitor& collisionVisitor,
331  const DtSceneRootList& intersectionRoots, osg::Node::NodeMask mask);
332 
334  bool processLineSegmentIntersection(
335  osgUtil::LineSegmentIntersector::Intersections& hitList,
336  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
337  DtOsgIntersectorResult& intersection );
338 
340  bool processLineSegmentIntersection( const osg::Vec3d& testPoint,
341  osgUtil::LineSegmentIntersector::Intersections& hitList,
342  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
343  DtOsgIntersectorResult& intersection );
344 
346  bool processLineSegmentIntersection( const osg::Vec3d& testPoint,
347  osgUtil::LineSegmentIntersector::Intersections& hitList,
348  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
349  DtOsgIntersector::DtOsgIntersections& intersections, bool sort );
350 
352  bool processPickIntersection(
353  osgUtil::LineSegmentIntersector::Intersections& hitList,
354  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
355  DtOsgIntersectorResult& intersection );
356 
358  bool processPickIntersection(
359  osgUtil::LineSegmentIntersector::Intersections& hitList,
360  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
361  DtOsgIntersector::DtOsgIntersections& intersections );
362 
365  void setupCollisionVisitor( bool useHighLod, DtOsgIntersectionVisitor& visitor );
366 
369  bool shouldInstanceIntersect(osg::Node::NodeMask nodeMask);
370 
371  protected:
373  };
374 
379  {
380  public:
381  DtOsgIntersectorSorter( const osg::Vec3d& reference )
382  : myReference( reference ) {}
383 
384  inline bool operator() ( const DtOsgIntersectorResult& a,
385  const DtOsgIntersectorResult& b )
386  {
387  osg::Vec3d diffA = osg::Vec3d(a.x, a.y, a.z) - myReference;
388  osg::Vec3d diffB = osg::Vec3d(b.x, b.y, b.z) - myReference;
389  return diffA.length2() < diffB.length2();
390  }
391  protected:
392  osg::Vec3d myReference;
393  };
394 
398  {
399  public:
401  virtual DtIntersector* create(DtDe& de, int modelSet );
402  };
403 }
IntersectProperties
The IntersectProperties enum is a flag set that indicates the.
Definition: DtIntersector.h:135
DtOsgIntersectorSorter(const osg::Vec3d &reference)
Definition: DtOsgIntersector.h:381
std::vector< DtSceneRoot > DtSceneRootList
A list of DtOsgRenderer::SceneRoots.
Definition: DtSceneRoot.h:117
int myModelSet
Definition: DtOsgIntersector.h:372
DtOsgIntersectVisitor checks to see if it is visiting a a DtTerrainPatchGroup and if so...
Definition: DtOsgIntersectionVisitor.h:27
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
bool operator()(const DtOsgIntersectorResult &a, const DtOsgIntersectorResult &b)
Definition: DtOsgIntersector.h:384
Contains makVrv:DtOsgIntersector class.
DtIntersector is an abstract class that provides the interface for requesting intersections with the ...
Definition: DtIntersector.h:129
Contains makVrv:DtOsgNodeTraversalFlags class.
DtOsgIntersector is the OSG-specific implementation of the DtIntersector class.
Definition: DtOsgIntersector.h:82
DtOsgIntersectorResult is the OSG-specific implementation of DtIntersectorResult; it is a container c...
Definition: DtOsgIntersector.h:62
osg::Vec3d myReference
Definition: DtOsgIntersector.h:392
Descriptor for a single intersection result.
Definition: DtIntersector.h:33
std::vector< DtOsgIntersectorResult > DtOsgIntersections
Note that even with intersection debug drawing enabled, these OSG-specific functions do not result in...
Definition: DtOsgIntersector.h:189
std::vector< DtIntersectorResult > DtIntersections
A vector of DtIntersectionRecords.
Definition: DtIntersector.h:154
double y
y coordinate, in database coordinates of the intersection
Definition: DtIntersector.h:69
std::vector< osg::Vec3 > myHitTriangle
Definition: DtOsgIntersector.h:72
static const unsigned int FlagAllOn
Nodemask bitflag definitions.
Definition: DtOsgNodeTraversalFlags.h:19
osg::Matrixd myLocalToWorld
Definition: DtOsgIntersector.h:75
The abstract Channel Class.
Definition: DtChannel.h:29
Contains makVrv:DtIntersector, makVrv:DtIntersectorLineSegment, and makVrv:DtIntersectorResult classe...
double z
z coordinate, in database coordinates of the intersection
Definition: DtIntersector.h:72
DtOsgItersectorExclusions is a list of osg nodes from the scene graph and a list of element IDs to ex...
Definition: DtOsgIntersector.h:50
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
std::list< DtUniqueID > myExcludeIds
Definition: DtOsgIntersector.h:53
DT_DLL_vrfutil bool intersection(const DtRailSegment *currentSegment, const DtRailSegment *nextSegment)
Given two segments, determine if where they meet is an intersection or just a bend in the road...
Abstract creator base class.
Definition: DtOsgIntersector.h:397
double x
x coordinate, in database coordinates of the intersection
Definition: DtIntersector.h:66
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
Abstract creator base class.
Definition: DtIntersector.h:387
Contains makVrv::DtOsgRenderer class.
std::list< osg::Node * > myExcludeNodes
Definition: DtOsgIntersector.h:54
DtOsgIntersectorSorter provides an operator for comparing the the distances between 2 osg::vectors an...
Definition: DtOsgIntersector.h:378

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)