VR-Forces 4.10 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) 2021 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/LineSegmentIntersector>
20 #include <osgUtil/IntersectVisitor>
21 
22 #include <osg/Node>
23 
24 #include <matrix/vlVector.h>
25 
26 #include <vector>
27 
28 namespace osgUtil
29 {
30  class Hit;
31 }
32 
33 namespace osgViewer
34 {
35  class View;
36 }
37 
38 namespace makVrv
39 {
40  class DtOsgRenderer;
41  class DtOsgIntersectionVisitor;
42 
53  {
54  public:
55  std::list<DtUniqueID> myExcludeIds;
56  std::list<osg::Node*> myExcludeNodes;
57  };
58 
59 
65  {
66  public:
69 
70  DtOsgIntersectorResult& operator=( const DtOsgIntersectorResult &orig );
71 
72  public:
73  // 3 points of the intersected triangle
74  std::vector<osg::Vec3> myHitTriangle;
75 
76  // matrix transform from world to triangle local coordinates
77  osg::Matrixd myLocalToWorld;
78  };
79 
85  {
86  public:
87 
88  // Abstract DtIntersector Implementation for OSG
89 
91  DtOsgIntersector( DtDe& de, int modelSet );
92 
94  virtual ~DtOsgIntersector();
95 
110  virtual bool findNearestIntersectionToPoint(double x, double y, double z,
111  double vx, double vy, double vz,
113  IntersectProperties properties=AllNodes,
114  std::vector<DtElementID>* ignoreList=0,
115  bool returnTriangle=false,
116  double maxIsectorLength=-1., bool useHighLod=false );
117 
125  virtual bool findAllIntersectionsThroughPoint( double x, double y, double z,
126  double vx, double vy, double vz, DtIntersections& intersections,
127  IntersectProperties properties=AllNodes,
128  std::vector<DtElementID>* ignoreList=0, bool sort=true, bool useHighLod=false );
129 
136  virtual bool findFirstIntersectWithLineSegment(
137  double x, double y, double z, double end_x, double end_y, double end_z,
138  DtIntersectorResult& intersection,
139  IntersectProperties properties=AllNodes,
140  std::vector<DtElementID>* ignoreList=0, bool useHighLod=false);
141 
148  virtual bool findAllIntersectWithLineSegment(
149  double x, double y, double z, double end_x, double end_y, double end_z,
150  DtIntersections& intersections,
151  IntersectProperties properties=AllNodes,
152  std::vector<DtElementID>* ignoreList=0, bool sort=true, bool useHighLod=false );
153 
159  virtual bool pick( DtChannel& channel, double mx, double my,
160  DtIntersectorResult& intersection,
161  IntersectProperties properties=AllNodes,
162  std::vector<DtElementID>* ignoreList=0);
163 
168  virtual bool pickAll( DtChannel* channel, double mx, double my,
169  DtIntersections& intersections, IntersectProperties properties=AllNodes,
170  std::vector<DtElementID>* ignoreList=0);
171 
172  public:
173 
174  // OSG-specific Interface
175 
189 
190 
191  typedef std::vector<DtOsgIntersectorResult> DtOsgIntersections;
192 
193 
213 
214  virtual bool findNearestIntersection(double x, double y, double z,
215  double vx, double vy, double vz, DtOsgIntersectorResult& intersection,
216  const DtSceneRootList& intersectionRoots,
217  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
218  DtOsgItersectorExclusions* excludeNodeList=0, bool returnHitTriangle=false,
219  double maxIsectorLength=-1.0, bool useHighLod=false );
220 
234  virtual bool findIntersectionsThroughPoint(double x, double y, double z,
235  double vx, double vy, double vz,
237  const DtSceneRootList& intersectionRoots,
238  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
239  DtOsgItersectorExclusions* exclusions=0, bool returnHitTriangle=false,
240  double maxIsectorLength=-1.0, bool sort=true, bool useHighLod=false );
241 
247  virtual bool intersectLineSegmentWithScene( double x, double y, double z,
248  double end_x, double end_y, double end_z,
249  DtOsgIntersectorResult& intersection,
250  const DtSceneRootList& intersectionRoots,
251  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
252  DtOsgItersectorExclusions* excludeNodeList=0,
253  bool returnHitTriangle=false, bool useHighLod=false );
254 
260  virtual bool intersectLineSegmentWithScene( double x, double y, double z,
261  double end_x, double end_y, double end_z,
262  DtOsgIntersector::DtOsgIntersections& intersections,
263  const DtSceneRootList& intersectionRoots,
264  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
265  DtOsgItersectorExclusions* excludeNodeList=0,
266  bool returnHitTriangle=false, bool sort=true, bool useHighLod=false );
267 
270  virtual bool pick( osgViewer::View& view, double mx, double my,
271  DtOsgIntersectorResult& intersection,
272  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
273  DtOsgItersectorExclusions* excludeNodeList=0,
274  bool returnHitTriangle=false );
275 
278  virtual bool pick( osgViewer::View& view, double mx, double my,
280  osg::Node::NodeMask mask=DtOsgNodeFlags::FlagAllOn,
281  DtOsgItersectorExclusions* excludeNodeList=0,
282  bool returnHitTriangle=false );
283 
284  public:
285 
286  static osg::Node::NodeMask nodeMaskFromIntersectProperties(
287  IntersectProperties properties );
288 
289  static bool anyNodeInNodePath(std::list<osg::Node*>* n,
290  osg::NodePath const& path);
291 
292  protected:
293 
295  virtual float distanceToResult2(double x, double y, double z, DtOsgIntersectorResult& result);
296 
297  virtual bool calcEndpointsFromDirectionAndLength( double x, double y,
298  double z, double vx, double vy, double vz, double length,
299  const DtSceneRootList& intersectionRoots, DtVector& startPoint,
300  DtVector& endPoint ) const;
301 
302  void getExcludeNodesFromIgnoreList( std::vector<DtUniqueID>* ignoreList,
303  DtOsgItersectorExclusions& exclusions );
304 
307  osg::Vec3d worldIntersectPoint( const osgUtil::Hit& hit );
308 
309  osg::Vec3d worldIntersectPoint(
310  const osgUtil::LineSegmentIntersector::Intersection& hit );
311 
312  osg::Vec3d localToWorld( const osg::Vec3& local, const osg::Matrix& localToWorld );
313 
314  bool findIdFromNodePath( const osg::NodePath& nodePath, DtUniqueID& id );
315 
318  osg::Camera * getActiveCamera(osgViewer::View& view);
319 
322  void updateInstanceIntersectElementId(DtOsgIntersectorResult &result);
323 
325  bool fillResultFromHit(DtOsgIntersectorResult& result,
326  const osgUtil::LineSegmentIntersector::Intersection& hit,
327  bool returnHitTriangle ) ;
328 
331  void doLineSegmentIntersections(
332  osgUtil::IntersectionVisitor& collisionVisitor,
333  const DtSceneRootList& intersectionRoots, osg::Node::NodeMask mask);
334 
336  bool processLineSegmentIntersection(
337  osgUtil::LineSegmentIntersector::Intersections& hitList,
338  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
339  DtOsgIntersectorResult& intersection );
340 
342  bool processLineSegmentIntersection( const osg::Vec3d& testPoint,
343  osgUtil::LineSegmentIntersector::Intersections& hitList,
344  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
345  DtOsgIntersectorResult& intersection );
346 
348  bool processLineSegmentIntersection( const osg::Vec3d& testPoint,
349  osgUtil::LineSegmentIntersector::Intersections& hitList,
350  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
351  DtOsgIntersector::DtOsgIntersections& intersections, bool sort );
352 
354  bool processPickIntersection(
355  osgUtil::LineSegmentIntersector::Intersections& hitList,
356  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
357  DtOsgIntersectorResult& intersection );
358 
360  bool processPickIntersection(
361  osgUtil::LineSegmentIntersector::Intersections& hitList,
362  DtOsgItersectorExclusions* excludeNodeList, bool returnHitTriangle,
363  DtOsgIntersector::DtOsgIntersections& intersections );
364 
367  void setupCollisionVisitor( bool useHighLod, DtOsgIntersectionVisitor& visitor );
368 
371  bool shouldInstanceIntersect(osg::Node::NodeMask nodeMask);
372 
373  protected:
375  };
376 
381  {
382  public:
383  DtOsgIntersectorSorter( const osg::Vec3d& reference )
384  : myReference( reference ) {}
385 
386  inline bool operator() ( const DtOsgIntersectorResult& a,
387  const DtOsgIntersectorResult& b )
388  {
389  osg::Vec3d diffA = osg::Vec3d(a.x, a.y, a.z) - myReference;
390  osg::Vec3d diffB = osg::Vec3d(b.x, b.y, b.z) - myReference;
391  return diffA.length2() < diffB.length2();
392  }
393  protected:
394  osg::Vec3d myReference;
395  };
396 
400  {
401  public:
403  virtual DtIntersector* create(DtDe& de, int modelSet );
404  };
405 }
IntersectProperties
The IntersectProperties enum is a flag set that indicates the.
Definition: DtIntersector.h:135
DtOsgIntersectorSorter(const osg::Vec3d &reference)
Definition: DtOsgIntersector.h:383
std::vector< DtSceneRoot > DtSceneRootList
A list of DtOsgRenderer::SceneRoots.
Definition: DtSceneRoot.h:133
int myModelSet
Definition: DtOsgIntersector.h:374
DtOsgIntersectVisitor checks to see if it is visiting a a DtTerrainPatchGroup and if so...
Definition: DtOsgIntersectionVisitor.h:24
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
bool operator()(const DtOsgIntersectorResult &a, const DtOsgIntersectorResult &b)
Definition: DtOsgIntersector.h:386
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:84
DtOsgIntersectorResult is the OSG-specific implementation of DtIntersectorResult; it is a container c...
Definition: DtOsgIntersector.h:64
osg::Vec3d myReference
Definition: DtOsgIntersector.h:394
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:191
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:74
static const unsigned int FlagAllOn
Nodemask bitflag definitions.
Definition: DtOsgNodeTraversalFlags.h:19
osg::Matrixd myLocalToWorld
Definition: DtOsgIntersector.h:77
The abstract Channel Class.
Definition: DtChannel.h:30
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:52
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
std::list< DtUniqueID > myExcludeIds
Definition: DtOsgIntersector.h:55
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:399
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:56
DtOsgIntersectorSorter provides an operator for comparing the the distances between 2 osg::vectors an...
Definition: DtOsgIntersector.h:380

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)