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 void* internalQuery() = 0;
67 };
68 
69 //Query that can be used when there is no valid navData.
71 {
72 public:
74  virtual ~DtNavAreaNullQuery() { };
75 
76  virtual bool complete() { return true; };
77  virtual bool tick() { return true; };
78  virtual bool success() { return true; };
79  virtual bool navDataChanged() { return false; };
80  virtual bool outOfWorkingMemory() { return false; };
81  virtual bool hadComputationError() { return false; };
82  virtual std::vector<DtVector> results() { return std::vector<DtVector>(); };
83  virtual void *internalQuery(void) { return 0; };
84 };
85 
88 {
89  DtNavAreaConfig() : workingMemorySize(16) {};
90 
93  int workingMemorySize;
94 
95 };
101 {
102 public:
104  {
106  int port;
107  std::vector<DtRwString> profiles;
109  };
110 
111  typedef DtNavArea* (*DtNavAreaCreatorFcn)();
112  typedef DtOnGraphVertexVisitedResult (*DtPointOfInterestEvaluatorFcn)(const DtVector& localPoint, void* userData);
113  typedef void (*DtSearchAreaPointCostModifierEvaluatorFcn)(const DtVector& localPoint, float* currentCost, void* userData);
114  typedef DtOnPathToGraphVertexComputedResult (*DtPathCalculatedEvaluatorFcn)(const DtVector& localPoint, double pathCost, void* userData);
115 
116  static DtNavArea* create();
117  static void setNavAreaCreatorFcn(DtNavAreaCreatorFcn fcn);
118 
119  static bool navAreaDebuggingEnabled();
120  static void setNavAreaDebuggingEnabled(bool enable);
121 
122  virtual ~DtNavArea() {};
123  virtual bool initialize(Coordinate_System* coordSys, DtNavAreaConfig config,
124  std::vector<DtString> profiles = std::vector<DtString>()) = 0;
125  virtual void update(float deltaTimeInSeconds) = 0;
127  virtual bool loadNavData(const DtString& path, const DtVariableBindingsList& variableBindings =
128  DtReaderWriter::nullVariableReference(), bool objectNavData = false) = 0;
129  virtual bool inNavArea(const DtVector& localPos) = 0;
130  virtual bool validPosition(const DtString& profile, const DtVector& localPos) = 0;
131 
132  //Returns true if this area is valid for the given navigation profile.
133  virtual bool validForProfile(const DtString& profile) const = 0;
134 
135  virtual DtNavDataDebugInfo* debugInfo() = 0;
136 
137  virtual void setExtent(DtExtent* e) = 0;
138  virtual DtExtent localExtent() = 0;
139 
141  virtual void cancelQuery(DtNavAreaQuery::Ptr) = 0;
142 
145  virtual DtNavAreaQuery::Ptr findNearbyPointOfInterest(const DtString& profile, const DtVector& startLocalPos,
146  int tag = DtNavDataTagAny, double propagationRadius = 200.,
147  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
148 
151  virtual DtNavAreaQuery::Ptr findBestExitPoint(const DtString& profile, DtNavBot* searcher,
152  const DtVector& startLocalPos, const DtVector& destination,
153  int tag = DtNavDataTagAny, double propagationRadius = 200.,
154  DtPointOfInterestEvaluatorFcn evalFcn = 0, DtPathCalculatedEvaluatorFcn pathFcn = 0, void* evalFcnUserData = 0) = 0;
155 
157  virtual bool findInsidePositionFromOutsidePosition(const DtString& profile,
158  double searchRadius, const DtVector& fromFromHere, DtVector& result, int& halfEdgeType) = 0;
159 
161  virtual DtNavAreaQuery::Ptr findBestPathTo(const DtString& profile, const DtVector& start,
162  const std::vector<DtVector>& localDestinationPositions, DtNavBot* searcher, int tag = -1,
163  DtSearchAreaPointCostModifierEvaluatorFcn = 0, DtPointOfInterestEvaluatorFcn = 0, DtPathCalculatedEvaluatorFcn = 0,
164  void* usrData = 0, bool startMovingWhenFound = false) = 0;
165 
166  //User callback to check randomly generated points. The callback function
167  //should return true if the point is acceptable.
168  typedef bool (*DtLocalPointUserEvalCallback)(const DtVector& localVector, DtNavAreaQuery* query, void* userData);
169  static bool emptyCallback(const DtVector&, DtNavAreaQuery*, void*);
170 
171  //Generate some number of random points.
172  //If localAccessibilityPoint is set, all points must be navigable
173  //from the access point.
174  //If boundingArea is set, all points must be inside the area,
175  //ignoring elevation. Note that this will not cause points to be
176  //generated outside the navArea.
177  //If boundingArea is not set, and radius is set, points will be generated
178  //using radius as a maximum distance from accessibilityPoint.
179  //If minDistanceBetweenPoints is set, generated points will be tested
180  //against the rest of the set of random points to make sure none are within
181  //the given distance of each other.
182  //If callbackFcn is set, this user function is called on each generated
183  //point, to test if each point is acceptable.
184  virtual DtNavAreaQuery::Ptr generateRandomPoints(const DtString& profile,
185  const DtVector& localAccessibilityPoint = DtVector::zero(),
186  double radius = -1,
187  const DtLocalVertexList& boundingArea = DtLocalVertexList(),
188  unsigned numberOfPoints = 1,
189  double minDistanceBetweenPoints = 0.0,
190  DtLocalPointUserEvalCallback callbackFcn = emptyCallback,
191  void* userData = 0) = 0;
192 
193  DtVrfObject* attachedObject() { return myAttachedObject; }
194  void setAttachedObject(DtVrfObject* object) { myAttachedObject = object; }
195 
200  virtual std::vector<DtVector> searchInArea(const DtString& profile,
201  const DtVector& startLocalPos, double radius, double postSpacing, DtNavBot* searcher,
202  DtPointOfInterestEvaluatorFcn evalFcn = 0, void* evalFcnUserData = 0, int tag = -1) = 0;
203 
204 protected:
205  static DtNavAreaCreatorFcn theNavAreaCreatorFcn;
206 
208 
212 };

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)