VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIntersector.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
10 
11 #pragma once
12 #include <vrvCore/vrvCore.h>
13 #include <vrvCore/DtUniqueID.h>
14 #include <vrvCore/DtTickable.h>
15 
18 #include <boost/unordered_map.hpp>
19 #include <vector>
20 #include <map>
21 
22 
23 namespace makVrv
24 {
25  class DtDe;
26  class DtChannel;
27 
28  class DtSceneObjectAgent;
29  class Dt3DSegmentedLineModelAgent;
30 
34  {
35  public:
36  // For this purpose, a triangle is described as 9 doubles; x0, y0, z0,
37  // x1, x2, etc...
38  typedef std::vector<double> DtIntersectTriangle;
39 
40  public:
43 
46 
48  DtIntersectorResult& operator=( const DtIntersectorResult& orig );
49 
51  bool operator==(const DtIntersectorResult&) const;
52 
54  bool operator!=(const DtIntersectorResult& rhs) const
55  {
56  return !(*this == rhs);
57  }
58 
59  public:
60 
64 
66  double x;
67 
69  double y;
70 
72  double z;
73 
76  double normalX;
77 
80  double normalY;
81 
84  double normalZ;
85 
88 
92 
95 
98 
101  double startX;
102 
105  double startY;
106 
109  double startZ;
110 
113  double endX;
114 
117  double endY;
118 
121  double endZ;
122  };
123 
124  class DtDrawnIntersector;
125 
130  {
131  public:
132 
136  {
137  AllNodes = 0,
138  PickableNodes = 1,
139  SupportNodes = 2,
140  NodesThatReceivesShadows = 4,
141  NodesThatCastsShadows = 8
142  };
143 
145  {
146  DynamicOceanPropertyMsl = 0,
147  DynamicOceanPropertyWaves = 1,
148  DynamicOceanPropertyIgnore = 2
149  };
150 
152  typedef std::vector<DtIntersectorResult> DtIntersections;
153 
155  DtIntersector( DtDe& de );
156 
158  virtual ~DtIntersector();
159 
162  virtual void setDynamicOceanProperties( DynamicOceanProperties properties );
163 
165  DynamicOceanProperties dynamicOceanProperties() const;
166 
181  virtual bool findNearestIntersectionToPoint(double x, double y, double z,
182  double vx, double vy, double vz, DtIntersectorResult& intersection,
183  IntersectProperties properties = AllNodes,
184  std::vector<DtElementID>* ignoreList = 0, bool returnTriangle = false,
185  double maxIsectorLength = -1., bool useHighLod = false ) = 0;
186 
194  virtual bool findAllIntersectionsThroughPoint( double x, double y, double z,
195  double vx, double vy, double vz, DtIntersections& intersections,
196  IntersectProperties properties = AllNodes,
197  std::vector<DtElementID>* ignoreList = 0, bool sort = true,
198  bool useHighLod = false ) = 0;
199 
206  virtual bool findFirstIntersectWithLineSegment(
207  double x, double y, double z, double end_x, double end_y, double end_z,
209  IntersectProperties properties=AllNodes,
210  std::vector<DtElementID>* ignoreList=0,
211  bool useHighLod = false) = 0;
212 
219  virtual bool findAllIntersectWithLineSegment(
220  double x, double y, double z, double end_x, double end_y, double end_z,
221  DtIntersections& intersections,
222  IntersectProperties properties=AllNodes,
223  std::vector<DtElementID>* ignoreList=0, bool sort=true,
224  bool useHighLod = false ) = 0;
225 
231  virtual bool pick( DtChannel& channel, double mx, double my,
233  IntersectProperties properties=AllNodes,
234  std::vector<DtElementID>* ignoreList=0) = 0;
235 
240  virtual bool pickAll( DtChannel* channel, double mx, double my,
241  DtIntersections& intersections,
242  IntersectProperties properties=AllNodes,
243  std::vector<DtElementID>* ignoreList=0) = 0;
244 
246 
247 
248 
249 
250 
251 
252 
253  virtual void setDefaultMaxClamp(double maximumIsectorLength);
254  virtual double defaultMaxClamp() const;
256 
257  protected:
260 
263  struct CachedPick
264  {
266  : simTime(0.0)
267  , channel(0)
268  , mx(0)
269  , my(0)
270  , properties(DtIntersector::AllNodes)
271  , ignoreList(0)
272  {
273  }
274 
275  bool operator==(const CachedPick& b)
276  {
277  return simTime == b.simTime &&
278  channel == b.channel &&
279  mx == b.mx &&
280  my == b.my &&
281  properties == b.properties &&
282  ignoreList == b.ignoreList;
283  }
284 
285  double simTime;
287  double mx;
288  double my;
290  std::vector<DtElementID>* ignoreList;
291  };
292 
297 
298  };
299 
301  {
302  public:
303  DtDrawnIntersector( DtDe& de );
304  virtual ~DtDrawnIntersector();
305 
306  virtual void draw( const DtIntersector::DtIntersections& results );
307 
308  virtual void setColors( const DtColorValue& failedColor,
309  const DtColorValue& oddColor, const DtColorValue& evenColor );
310 
311  protected:
313  typedef std::vector<Dt3DSegmentedLineModelAgent*> LineModelList;
315  typedef std::vector<DtSceneObjectAgent*> SceneObjectList;
320  };
321 
323  {
324  public:
326  virtual ~DtDrawnIntersectorManager();
327 
328  virtual void update( DtTime tNow );
329 
330  virtual void drawIntersection(
331  const DtIntersector::DtIntersections& results, double duration );
332 
333  protected:
335 
336  typedef std::multimap<double, DtDrawnIntersector* > DtDrawnIntersectorMap;
338  };
339 
340 
344  {
345  public:
347  virtual ~DtIntersectorManager();
348 
351  static DtIntersectorManager& instance(DtDe& de);
352 
354  static void registerInstance(DtDe& de, DtIntersectorManager* anInstance);
355 
357  virtual DtIntersector& modelSetIntersector(int modelSet);
358 
360  virtual DtIntersector& characterIntersector();
361 
363  virtual void registerCharacterIntersector(DtIntersector* intersector);
364 
366  virtual void drawIntersection( const DtIntersectorResult& result,
367  double duration );
368 
369  virtual void drawIntersection(
370  const DtIntersector::DtIntersections& results, double duration );
371 
372  protected:
374 
375  protected:
376  typedef boost::unordered_map<int, DtIntersector*> IntersectorMap;
381  };
382 
386  {
387  public:
388 
391  static DtIntersectorCreator& instance(DtDe& de);
392 
394  static void registerInstance(DtDe& de, DtIntersectorCreator* anInstance);
395 
397  virtual DtIntersector* create( DtDe& de, int modelSet ) = 0;
398  };
399 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)