VR-Forces 4.3 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>
15 #include <boost/unordered_map.hpp>
16 #include <vector>
17 
18 namespace makVrv
19 {
20  class DtDe;
21  class DtChannel;
22 
26  {
27  public:
28  // For this purpose, a triangle is described as 9 doubles; x0, y0, z0,
29  // x1, x2, etc...
30  typedef std::vector<double> DtIntersectTriangle;
31 
32  public:
35 
37  DtIntersectorResult( double x, double y, double z,
38  double normalX, double normalY, double normalZ, const DtUniqueID& id);
39 
42 
44  DtIntersectorResult& operator=( const DtIntersectorResult& orig );
45 
47  bool operator==(const DtIntersectorResult&) const;
48 
50  bool operator!=(const DtIntersectorResult& rhs) const
51  {
52  return !(*this == rhs);
53  }
54 
55  public:
56 
58  double x;
59 
61  double y;
62 
64  double z;
65 
68  double normalX;
69 
72  double normalY;
73 
76  double normalZ;
77 
80 
83 
86  };
87 
92  {
93  public:
94 
98  {
99  AllNodes = 0,
100  PickableNodes = 1,
101  SupportNodes = 2,
102  NodesThatReceivesShadows = 4,
103  NodesThatCastsShadows = 8
104  };
105 
107  {
108  DynamicOceanPropertyMsl = 0,
109  DynamicOceanPropertyWaves = 1,
110  DynamicOceanPropertyIgnore = 2
111  };
112 
114  typedef std::vector<DtIntersectorResult> DtIntersections;
115 
117  DtIntersector( DtDe& de );
118 
120  virtual ~DtIntersector();
121 
124  virtual void setDynamicOceanProperties( DynamicOceanProperties properties );
125 
127  DynamicOceanProperties dynamicOceanProperties() const;
128 
143  virtual bool findNearestIntersectionToPoint(double x, double y, double z,
144  double vx, double vy, double vz, DtIntersectorResult& intersection,
145  IntersectProperties properties = AllNodes,
146  std::vector<DtElementID>* ignoreList = 0, bool returnTriangle = false,
147  double maxIsectorLength = -1., bool useHighLod = false ) = 0;
148 
156  virtual bool findAllIntersectionsThroughPoint( double x, double y, double z,
157  double vx, double vy, double vz, DtIntersections& intersections,
158  IntersectProperties properties = AllNodes,
159  std::vector<DtElementID>* ignoreList = 0, bool sort = true,
160  bool useHighLod = false ) = 0;
161 
168  virtual bool findFirstIntersectWithLineSegment(
169  double x, double y, double z, double end_x, double end_y, double end_z,
171  IntersectProperties properties=AllNodes,
172  std::vector<DtElementID>* ignoreList=0,
173  bool useHighLod = false) = 0;
174 
181  virtual bool findAllIntersectWithLineSegment(
182  double x, double y, double z, double end_x, double end_y, double end_z,
183  DtIntersections& intersections,
184  IntersectProperties properties=AllNodes,
185  std::vector<DtElementID>* ignoreList=0, bool sort=true,
186  bool useHighLod = false ) = 0;
187 
193  virtual bool pick( DtChannel& channel, double mx, double my,
195  IntersectProperties properties=AllNodes,
196  std::vector<DtElementID>* ignoreList=0) = 0;
197 
202  virtual bool pickAll( DtChannel* channel, double mx, double my,
203  DtIntersections& intersections,
204  IntersectProperties properties=AllNodes,
205  std::vector<DtElementID>* ignoreList=0) = 0;
206 
207  protected:
210 
213  struct CachedPick
214  {
216  : simTime(0.0)
217  , channel(0)
218  , mx(0)
219  , my(0)
220  , properties(DtIntersector::AllNodes)
221  , ignoreList(0)
222  {
223  }
224 
225  bool operator==(const CachedPick& b)
226  {
227  return simTime == b.simTime &&
228  channel == b.channel &&
229  mx == b.mx &&
230  my == b.my &&
231  properties == b.properties &&
232  ignoreList == b.ignoreList;
233  }
234 
235  double simTime;
237  double mx;
238  double my;
240  std::vector<DtElementID>* ignoreList;
241  };
242 
246 
247  };
248 
252  {
253  public:
255  virtual ~DtIntersectorManager();
256 
259  static DtIntersectorManager& instance(DtDe& de);
260 
262  static void registerInstance(DtDe& de, DtIntersectorManager* anInstance);
263 
265  virtual DtIntersector& modelSetIntersector(int modelSet);
266 
268  virtual DtIntersector& characterIntersector();
269 
271  virtual void registerCharacterIntersector(DtIntersector* intersector);
272 
273  protected:
275 
276  protected:
277  typedef boost::unordered_map<int, DtIntersector*> IntersectorMap;
281  };
282 
286  {
287  public:
288 
291  static DtIntersectorCreator& instance(DtDe& de);
292 
294  static void registerInstance(DtDe& de, DtIntersectorCreator* anInstance);
295 
297  virtual DtIntersector* create( DtDe& de, int modelSet ) = 0;
298  };
299 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)