VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
navArea.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 
10 #pragma once
11 
13 #include <string>
15 #include <matrix/vlVector.h>
17 #include "boost/shared_ptr.hpp"
18 #include "vrfutil/rwString.h"
19 
20 class Coordinate_System;
21 class DtExtent;
22 class DtVrfObject;
23 class DtNavBot;
24 
26 {
32 };
33 
35 {
40 };
41 
42 //Base class for asynchronous Nav Area queries.
43 //In this context asynchronous means non-blocking, but performed
44 //in a single-thread. These queries are time-sliced by
45 //gameware's infrastructure.
46 //Will be ticked by the navArea's update function.
47 
49 {
50 public:
51  typedef boost::shared_ptr<DtNavAreaQuery> Ptr;
52 
54  virtual ~DtNavAreaQuery() { };
55 
56  virtual bool complete() = 0;
57  virtual bool tick() = 0;
58  virtual bool success() = 0;
59 
61  virtual bool navDataChanged() = 0;
62  virtual bool outOfWorkingMemory() = 0;
63  virtual bool hadComputationError() = 0;
64 
65  virtual std::vector<DtVector> results() = 0;
66  virtual std::vector<DtVector> debugPoints() { return std::vector<DtVector>(); };
67  virtual void* internalQuery() = 0;
68 };
69 
70 //Query that can be used when there is no valid navData.
72 {
73 public:
75  virtual ~DtNavAreaNullQuery() { };
76 
77  virtual bool complete() { return true; };
78  virtual bool tick() { return true; };
79  virtual bool success() { return true; };
80  virtual void cancel() {};
81  virtual bool navDataChanged() { return false; };
82  virtual bool outOfWorkingMemory() { return false; };
83  virtual bool hadComputationError() { return false; };
84  virtual std::vector<DtVector> results() { return std::vector<DtVector>(); };
85  virtual void *internalQuery(void) { return 0; };
86 };
87 
90 {
91  DtNavAreaConfig() : workingMemorySize(16) {};
92 
95  int workingMemorySize;
96 
97 };
103 {
104 public:
106  {
108  int port;
109  std::vector<DtRwString> profiles;
111  };
112 
113  typedef DtNavArea* (*DtNavAreaCreatorFcn)();
114  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestEvaluatorFcn)(const DtVector& localPoint, void* userData);
115  typedef void (*DtSearchAreaPointCostModifierEvaluatorFcn)(const DtVector& localPoint, float* currentCost, void* userData);
116  typedef DtOnPathToGraphVertexComputedResult (*DtPathCalculatedEvaluatorFcn)(const DtVector& localPoint, double pathCost, void* userData);
117 
118  static DtNavArea* create();
119  static void setNavAreaCreatorFcn(DtNavAreaCreatorFcn fcn);
120 
121  static bool navAreaDebuggingEnabled();
122  static void setNavAreaDebuggingEnabled(bool enable);
123 
124  virtual ~DtNavArea() {};
125  virtual bool initialize(Coordinate_System* coordSys, DtNavAreaConfig config,
126  std::vector<DtString> profiles = std::vector<DtString>()) = 0;
127  virtual void update(float deltaTimeInSeconds) = 0;
129  virtual bool loadNavData(const DtString& path, const DtVariableBindingsList& variableBindings =
130  DtReaderWriter::nullVariableReference(), bool objectNavData = false) = 0;
131  virtual bool inNavArea(const DtVector& localPos) = 0;
132  virtual bool validPosition(const DtString& profile, const DtVector& localPos) = 0;
133 
134  //Returns true if this area is valid for the given navigation profile.
135  virtual bool validForProfile(const DtString& profile) const = 0;
136 
137  virtual DtNavDataDebugInfo* debugInfo() = 0;
138 
139  virtual void setExtent(DtExtent* e) = 0;
140  virtual DtExtent localExtent() = 0;
141 
143  virtual void cancelQuery(DtNavAreaQuery::Ptr) = 0;
144 
147  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterest(const DtString& profile, const DtVector& startLocalPos,
148  int tag = DtNavDataTagAny, double propagationRadius = 200.,
149  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
150 
153  virtual DtNavAreaQuery::Ptr findBestExitPoint(const DtString& profile, DtNavBot* searcher,
154  const DtVector& startLocalPos, const DtVector& destination,
155  int tag = DtNavDataTagAny, double propagationRadius = 200.,
156  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
157 
159  virtual bool findInsidePositionFromOutsidePosition(const DtString& profile,
160  double searchRadius, const DtVector& fromFromHere, DtVector& result, int& halfEdgeType) = 0;
161 
163  virtual DtNavAreaQuery::Ptr findBestPathTo(const DtString& profile, const DtVector& start,
164  const std::vector<DtVector>& localDestinationPositions, DtNavBot* searcher, int tag = -1,
165  DtSearchAreaPointCostModifierEvaluatorFcn = 0, DtPointOfInterestEvaluatorFcn = 0, DtPathCalculatedEvaluatorFcn = 0,
166  void* usrData = 0, bool startMovingWhenFound = false) = 0;
167 
170  virtual bool findFarthestPositionAlongHeading(const DtString& profile, const DtVector& start,
171  double heading, double maxDistance, DtVector& result, bool& reachedMaxDist) = 0;
172 
173  //User callback to check randomly generated points. The callback function
174  //should return true if the point is acceptable.
175  typedef bool (*DtLocalPointUserEvalCallback)(const DtVector& localVector, DtNavAreaQuery* query, void* userData);
176  static bool emptyCallback(const DtVector&, DtNavAreaQuery*, void*);
177 
178  //Generate some number of random points.
179  //If localAccessibilityPoint is set, all points must be navigable
180  //from the access point.
181  //If boundingArea is set, all points must be inside the area,
182  //ignoring elevation. Note that this will not cause points to be
183  //generated outside the navArea.
184  //If boundingArea is not set, and radius is set, points will be generated
185  //using radius as a maximum distance from accessibilityPoint.
186  //If minDistanceBetweenPoints is set, generated points will be tested
187  //against the rest of the set of random points to make sure none are within
188  //the given distance of each other.
189  //If placementRestriction is set to one of the MovementMode strings (e.g.
190  //DtMovementModePreferRoads), points will be chosen that match that criteria.
191  //If isStrict is true, only points matching the placementRestriction will be
192  //generated, even if we can't create enough to match the desired number.
193  //If tightlyPack is true, points closer to access point or bounding area center
194  //will be favored.
195  //If needLos is true, will try to choose points that should have LOS to the
196  //specified access point.
197  //If leftOfLine, the points specified will be considered a line, and only points
198  //to the left of that line will be generated.
199  //If callbackFcn is set, this user function is called on each generated
200  //point, to test if each point is acceptable.
201  virtual DtNavAreaQuery::Ptr generateRandomPoints(const DtString& profile,
202  const DtVector& localAccessibilityPoint = DtVector::zero(),
203  double minRadius = -1,
204  double maxRadius = -1,
205  const DtLocalVertexList& boundingArea = DtLocalVertexList(),
206  unsigned numberOfPoints = 1,
207  double minDistanceBetweenPoints = 0.0,
208  const DtString& placementRestriction = DtString::nullString(),
209  bool isStrict = true,
210  bool tightlyPack = false,
211  bool needLos = false,
212  const DtLocalVertexList& leftOfLine = DtLocalVertexList(),
213  DtLocalPointUserEvalCallback callbackFcn = emptyCallback,
214  void* userData = 0) = 0;
215 
216  DtVrfObject* attachedObject() { return myAttachedObject; }
217  void setAttachedObject(DtVrfObject* object) { myAttachedObject = object; }
218 
223  virtual std::vector<DtVector> searchInArea(const DtString& profile,
224  const DtVector& startLocalPos, double radius, double postSpacing, DtNavBot* searcher,
225  DtPointOfInterestEvaluatorFcn evalFcn = 0, void* evalFcnUserData = 0, int tag = -1) = 0;
226 
227 protected:
228  static DtNavAreaCreatorFcn theNavAreaCreatorFcn;
229 
231 
235 };

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)