VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
245  protected:
248 
251  struct CachedPick
252  {
254  : simTime(0.0)
255  , channel(0)
256  , mx(0)
257  , my(0)
258  , properties(DtIntersector::AllNodes)
259  , ignoreList(0)
260  {
261  }
262 
263  bool operator==(const CachedPick& b)
264  {
265  return simTime == b.simTime &&
266  channel == b.channel &&
267  mx == b.mx &&
268  my == b.my &&
269  properties == b.properties &&
270  ignoreList == b.ignoreList;
271  }
272 
273  double simTime;
275  double mx;
276  double my;
278  std::vector<DtElementID>* ignoreList;
279  };
280 
284 
285  };
286 
288  {
289  public:
290  DtDrawnIntersector( DtDe& de );
291  virtual ~DtDrawnIntersector();
292 
293  virtual void draw( const DtIntersector::DtIntersections& results );
294 
295  virtual void setColors( const DtColorValue& failedColor,
296  const DtColorValue& oddColor, const DtColorValue& evenColor );
297 
298  protected:
300  typedef std::vector<Dt3DSegmentedLineModelAgent*> LineModelList;
302  typedef std::vector<DtSceneObjectAgent*> SceneObjectList;
307  };
308 
310  {
311  public:
313  virtual ~DtDrawnIntersectorManager();
314 
315  virtual void update( DtTime tNow );
316 
317  virtual void drawIntersection(
318  const DtIntersector::DtIntersections& results, double duration );
319 
320  protected:
322 
323  typedef std::multimap<double, DtDrawnIntersector* > DtDrawnIntersectorMap;
325  };
326 
327 
331  {
332  public:
334  virtual ~DtIntersectorManager();
335 
338  static DtIntersectorManager& instance(DtDe& de);
339 
341  static void registerInstance(DtDe& de, DtIntersectorManager* anInstance);
342 
344  virtual DtIntersector& modelSetIntersector(int modelSet);
345 
347  virtual DtIntersector& characterIntersector();
348 
350  virtual void registerCharacterIntersector(DtIntersector* intersector);
351 
353  virtual void drawIntersection( const DtIntersectorResult& result,
354  double duration );
355 
356  virtual void drawIntersection(
357  const DtIntersector::DtIntersections& results, double duration );
358 
359  protected:
361 
362  protected:
363  typedef boost::unordered_map<int, DtIntersector*> IntersectorMap;
368  };
369 
373  {
374  public:
375 
378  static DtIntersectorCreator& instance(DtDe& de);
379 
381  static void registerInstance(DtDe& de, DtIntersectorCreator* anInstance);
382 
384  virtual DtIntersector* create( DtDe& de, int modelSet ) = 0;
385  };
386 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)