VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
terrainImplementation.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
17 #include <geometry/chord.h>
24 #include "features/feature.h"
25 #include "features/featureSet.h"
28 #include <vlpi/appearance.h>
29 
30 #include <string>
31 #include <boost/noncopyable.hpp>
32 #include <boost/signals2.hpp>
33 
36 class DtScenarioExplorer;
37 class DtString;
38 class Coordinate_System;
41 class DtTaitBryan;
44 class DtEntityType;
45 
46 
51 {
53  {
54  mySpatExtent = DtExtent::nullExtent();
55  myChangeType = DtString::nullString();
56  myIsInDefaultState = false;
57  myLastStateWasDefaultState = true;
58  }
59 
64 };
65 
69 {
70  std::size_t operator()(const DtTerrainChangeNotificationInfo &val) const noexcept
71  {
72  std::size_t hExtentMinX = std::hash<double>{}(val.mySpatExtent.minX());
73  std::size_t hExtentMinY = std::hash<double>{}(val.mySpatExtent.minY());
74  std::size_t hExtentMinZ = std::hash<double>{}(val.mySpatExtent.minZ());
75  std::size_t hExtentMaxX = std::hash<double>{}(val.mySpatExtent.maxX());
76  std::size_t hExtentMaxY = std::hash<double>{}(val.mySpatExtent.maxY());
77  std::size_t hExtentMaxZ = std::hash<double>{}(val.mySpatExtent.maxZ());
78  std::size_t hChangeType = std::hash<std::string>{}(std::string(val.myChangeType.c_str()));
79  std::size_t hIsInDefaultState = std::hash<bool>{}(val.myIsInDefaultState);
80  std::size_t hLastStateWasDefaultState = std::hash<bool>{}(val.myLastStateWasDefaultState);
81 
82  std::size_t seed = 0;
83  boost::hash_combine(seed, hExtentMinX);
84  boost::hash_combine(seed, hExtentMinY);
85  boost::hash_combine(seed, hExtentMinZ);
86  boost::hash_combine(seed, hExtentMaxX);
87  boost::hash_combine(seed, hExtentMaxY);
88  boost::hash_combine(seed, hExtentMaxZ);
89  boost::hash_combine(seed, hChangeType);
90  boost::hash_combine(seed, hIsInDefaultState);
91  boost::hash_combine(seed, hLastStateWasDefaultState);
92 
93  return seed;
94  }
95 };
96 
100 {
102  {
103  if (lhs.mySpatExtent == rhs.mySpatExtent &&
104  lhs.myChangeType == rhs.myChangeType &&
105  lhs.myIsInDefaultState == rhs.myIsInDefaultState &&
106  lhs.myLastStateWasDefaultState == rhs.myLastStateWasDefaultState)
107  {
108  return true;
109  }
110 
111  return false;
112  }
113 };
114 
115 
117 typedef void (*DtCacheProgressCallbackFunction)(int requestId, int current, bool completed, double elapsedTime, void* usr);
118 
121 typedef void(*DtTerrainChangeNotificationCallbackFcn)(const DtTerrainChangeNotificationInfo& terrainChangeInfo, void* userData);
122 
123 namespace makArchives
124 {
125  class DtGenericTerrainRecord;
126 }
127 
128 namespace MAKVRinTerra
129 {
130  class DtProj;
131  class DtAerodromeLoader;
132 }
133 
134 namespace makVrv
135 {
136  class DtDynamicTerrainGeometry;
137  class DtDynamicTerrainChange;
138  class DtDynamicTerrainFeature;
139  class DtDynamicTerrainChanges;
140 }
141 
146 {
147 public:
148 
150  {
151  public:
153  virtual void removeTerrainChange() = 0;
154  virtual void releaseOwnership() = 0;
155  };
156 
159 
161  DtDynamicTerrainRequestHandle(const std::shared_ptr<RequestHandleImpl>&);
162 
166  void removeTerrainChange();
167 
170  void releaseOwnership();
171 
172 private:
173 
174  std::shared_ptr<RequestHandleImpl> myImpl;
175 };
176 
181 {
182 public:
183 
185  {
186  public:
188  virtual void removeQuery() = 0;
189  virtual void releaseOwnership() = 0;
190  };
191 
194 
196  DtDynamicTerrainQueryHandle(const std::shared_ptr<QueryHandleImpl>&);
197 
199  void removeQuery();
200 
203  void releaseOwnership();
204 
205 private:
206 
207  std::shared_ptr<QueryHandleImpl> myImpl;
208 };
209 
210 typedef boost::function<void (const makVrv::DtDynamicTerrainFeature&)>
212 
216 {
217 public:
219  virtual ~DtTerrainGeometryHandle();
220 
222  virtual bool isDisabled() const = 0;
223 
226  virtual void disable() = 0;
227 
229  virtual void setAppearance(DtAppearance app) = 0;
230 
232  virtual void setPosition(const DtPoint& location, const DtDcm& orientation) = 0;
233 
234  virtual DtVector position() const = 0;
235  virtual DtDcm orientation() const = 0;
236 };
237 
245  : boost::noncopyable
246 {
247 public:
249  virtual ~DtTerrainImplementation();
250 
252  virtual MAKVRinTerra::DtFeatureDatabase& featureDatabase();
253  virtual const MAKVRinTerra::DtFeatureDatabase& featureDatabase() const;
254 
256  virtual MAKVRinTerra::DtFeatureContext& featureContext();
257  virtual const MAKVRinTerra::DtFeatureContext& featureContext() const;
258 
259  virtual MAKVRinTerra::DtAerodromeLoader& aerodromeLoader();
260  virtual const MAKVRinTerra::DtAerodromeLoader& aerodromeLoader() const;
261  virtual void cacheAerodromes();
262 
264  virtual void init();
265 
268  virtual void finishedLoading(const MAKVRinTerra::DtProj& proj);
269 
271  virtual bool loadTerrain(const makArchives::DtGenericTerrainRecord& rec) = 0;
272 
274  virtual void clearCache();
275 
277  virtual void shutdown(bool block=true);
278 
279  virtual const Coordinate_System* coordinateSystem() const = 0;
280 
283  virtual double modelHeightDifferencesFromAppearances(int oldApp, int newApp) const;
284 
286  virtual bool createFromExtent(const Dt3dBoundingVolume&);
287 
290  virtual bool loadModel(const DtFilename&, const DtEntityType& t = DtEntityType());
291 
292  virtual DtTerrainInterfaceConfig& configurationOptions();
293  virtual const DtTerrainInterfaceConfig& configurationOptions() const;
294 
302  virtual bool chordIntersect(
303  DtTerrainIntersectStatus& status,
304  const DtChord& chord,
306  const DtTerrainIntersectOptions& options) const = 0;
307 
315  virtual bool allIntersectsAlongChord(DtTerrainIntersectStatus& status,
316  const DtChord& chord,
318  const DtTerrainIntersectOptions& options) const = 0;
319 
334  virtual void preloadTerrainAreas(
335  const DtTerrainPagingGeometryList& preloadGeometry) {};
336 
338  virtual bool dataAvailable(
339  const DtTerrainPagingGeometryList& geometry,
341 
344  virtual const DtTerrainCapabilities* terrainCapabilities() const = 0;
345 
356  virtual void setAssertOnBlockingTerrainCalls(bool assertBlock);
357  virtual bool assertOnBlockingTerrainCalls() const;
359 
362  virtual void setWarnOnBlockingTerrainCalls(bool warnBlock);
363  virtual bool warnOnBlockingTerrainCalls() const;
365 
371  virtual void setIntersectDataLoadExpireTime(const double& expireTime) {};
372 
377  virtual void expireDataLoadRequestsBeforeTime(const double& currentTime) {};
378 
379  virtual void processTrianglesInArea(DtTriangleOutputInterface&, const DtTerrainProcessPolygonsBox&, DtTerrainCategoryMask terrainCategoryMask) const = 0;
380 
382 
385  virtual DtTerrainInformation* terrainInformation() { return NULL; };
386 
387  virtual void breakUpChords(const MAKVRinTerra::DtProj&, const DtChord& chord,
388  std::vector<DtChord>& chords);
389 
391  virtual bool hasFeatureContext() const;
392 
394  virtual DtTerrainGeometryHandle* createEntityGeometry(const DtFilename& file) { return 0; }
395 
397  virtual DtTerrainGeometryHandle* createEntityGeometry(const DtEntityType& file) { return 0; }
398 
400  virtual void loadVisuals(const DtScenarioExplorer&) {};
401 
408  double time,
410 
411  typedef boost::function<void (const makVrv::DtDynamicTerrainFeature&)>
413 
414  /*
415  virtual DtDynamicTerrainRequestHandle addDynamicTerrainCraterRequest(
416  double time,
417  makVrv::DtDynamicTerrainChange* command,
418  const std::map<DtString, DtString>& keyValueChanges,
419  const DtVector& centerLocation,
420  double radius) {
421  return DtDynamicTerrainRequestHandle(); }
422  */
423 
428  const DtDynamicTerrainQueryCallback& callback,
429  makVrv::DtDynamicTerrainGeometry* geometry = 0,
430  bool useOriginalGeometry = false) {
432  };
433 
435  const DtDynamicTerrainQueryCallback& callback,
436  makVrv::DtDynamicTerrainGeometry* geometry = 0,
437  bool useOriginalGeometry = false) { };
438 
441  virtual void cacheTerrainArea(int requestId,
442  unsigned minLOD, unsigned maxLOD, const DtExtent& cacheArea,
443  DtCacheProgressCallbackFunction fcn = 0, void* usr = 0);
444 
446  virtual void cancelCacheTerrainArea(int requestId);
447 
449  virtual void writeTerrainIndex(const DtString& name);
450 
452  virtual void addTerrainChangeNotificationCallback(DtTerrainChangeNotificationCallbackFcn fcn,
453  void* user);
454 
456  virtual void removeTerrainChangeNotificationCallback(DtTerrainChangeNotificationCallbackFcn fcn,
457  void* user);
458 
460  virtual void invokeTerrainChangeNotificationCallBacks();
461 
462  virtual void blockOnPendingOperations() {};
463 
465  boost::signals2::signal<void(bool)> signal_terrainPaging;
466 
467 protected:
469 
475 
476  std::unique_ptr<MAKVRinTerra::DtFeatureDatabase> myFeatureDatabase;
477  std::unique_ptr<MAKVRinTerra::DtFeatureContext> myFeatureContext;
478  std::shared_ptr<MAKVRinTerra::DtAerodromeLoader> myAerodromeLoader;
479 };
480 
void(* DtTerrainChangeNotificationCallbackFcn)(const DtTerrainChangeNotificationInfo &terrainChangeInfo, void *userData)
Callback function for terrain change notifications.
Definition: terrainImplementation.h:121
boost::function< void(const makVrv::DtDynamicTerrainFeature &)> DtDynamicTerrainQueryCallback
Definition: terrainImplementation.h:211
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Definition: stringKeyFactory.h:80
Class DtTerrainInterfaceConfig is a readable-writable class holding terrain interface configuration o...
Definition: terrainInterfaceConfig.h:33
This is the abstract base class for all terrain implementations. A terrain implementation is used by ...
Definition: terrainImplementation.h:244
std::shared_ptr< RequestHandleImpl > myImpl
Definition: terrainImplementation.h:174
boost::function< void(const makVrv::DtDynamicTerrainFeature &)> DtDynamicTerrainQueryCallback
Definition: terrainImplementation.h:412
Definition: terrainIntersectOptions.h:104
DtVrfChordIntersectionRecord represents a list of DtChordIntersectRecords. This is useful for followi...
Definition: vrfChordIntersectRecordList.h:31
std::unique_ptr< MAKVRinTerra::DtFeatureDatabase > myFeatureDatabase
Definition: terrainImplementation.h:476
virtual DtTerrainGeometryHandle * createEntityGeometry(const DtFilename &file)
Create geometry in the terrain which represents the entity.
Definition: terrainImplementation.h:394
bool myIsInDefaultState
Definition: terrainImplementation.h:62
Define a Hash operator for the DtTerrainChangeNotificationInfo. It&#39;s required for the DtTerrainChange...
Definition: terrainImplementation.h:68
virtual void queryCurrentDynamicTerrainFeatures(const DtDynamicTerrainQueryCallback &callback, makVrv::DtDynamicTerrainGeometry *geometry=0, bool useOriginalGeometry=false)
Definition: terrainImplementation.h:434
DtGenericTerrainRecords allow the VR-Forces terrainInterface library to instantiate and configure the...
Definition: DtGenericTerrainRecord.h:34
DtTerrainImplementation *(* DtCreatorFcn)(DtConsoleCommandManager *)
Definition: stringKeyFactory.h:84
std::list< std::pair< DtPagingMetaDataPtr, DtTerrainPagingGeometryPtr > > DtTerrainPagingGeometryList
Definition: terrainPagingGeometry.h:111
static DtExtent & nullExtent()
Return an invalid or empty extent, using the default constructor.
Represents (possibly infinite) area of space.
Definition: DtDynamicTerrainGeometry.h:20
class DtScenarioExplorer:
Definition: scenarioExplorer.h:26
Allows manipulating a terrain object. Returned by functions which create terrain objects.
Definition: terrainImplementation.h:215
bool operator()(const DtTerrainChangeNotificationInfo &lhs, const DtTerrainChangeNotificationInfo &rhs) const noexcept
Definition: terrainImplementation.h:101
bool myAssertOnBlockingTerrainCalls
Determines if an exception should be thrown if a blocking terrain call is made. This can help to trac...
Definition: terrainImplementation.h:473
DtTerrainInterfaceConfig myConfig
Definition: terrainImplementation.h:468
Definition: terrainImplementation.h:149
This is a class which maintains a list of string command names and the callback functions that are to...
Definition: consoleCommandManager.h:56
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
unsigned int DtTerrainGeometryId
Unique ID numbers that reference a specific geometry (or set of triangles) in the terrain...
Definition: terrainProcessPolygonsBox.h:38
bool myWarnOnBlockingTerrainCalls
Definition: terrainImplementation.h:474
virtual void processTrianglesForGeometry(DtTriangleOutputInterface &, DtTerrainGeometryId) const
Definition: terrainImplementation.h:381
DtTerrainIntersectOptions Passed to terrain intersect functions to modify how intersect acts...
Definition: terrainIntersectOptions.h:22
virtual bool dataAvailable(const DtTerrainPagingGeometryList &geometry, DtTerrainIntersectOptions::Fidelity=DtTerrainIntersectOptions::MAX_FIDELITY)
Returns true if all of the terrain which intersects the geometry list is paged in.
Definition: terrainImplementation.h:338
Definition: aerodromeLoader.h:28
Definition: coordSystem.h:54
Represents some coordinate system. The terms &quot;coordinate system&quot;, &quot;projection&quot;, &quot;spatial reference&quot;...
Definition: proj.h:52
#define DT_DLL_terrainInterface
This file is used to determine how to build.
Definition: terrainInterfaceDefines.h:25
Factory templates DtStringKeyFactory and DtStringKeyFactoryWithParam.
virtual DtTerrainGeometryHandle * createEntityGeometry(const DtEntityType &file)
Create geometry in the terrain which represents the entity by the given type, looking up visuals...
Definition: terrainImplementation.h:397
This class holds parameters which define the capabilities of the current terrain. The terrain impleme...
Definition: terrainCapabilities.h:28
std::shared_ptr< QueryHandleImpl > myImpl
Definition: terrainImplementation.h:207
DtExtent mySpatExtent
Definition: terrainImplementation.h:60
virtual void preloadTerrainAreas(const DtTerrainPagingGeometryList &preloadGeometry)
Specifies a list of terrain areas that should be preloaded by the terrain implementation, in the case of a paging or streaming terrain source. The typical use of this is to specify parts of the terrain that are expected to be needed in the near future.
Definition: terrainImplementation.h:334
std::unique_ptr< MAKVRinTerra::DtFeatureContext > myFeatureContext
Definition: terrainImplementation.h:477
RequestHandleImpl()
Definition: terrainImplementation.h:152
Definition: featureContext.h:50
DtTerrainImplementationFactory::DtCreatorFcn DtTerrainImplementationCreatorFcn
Definition: terrainImplementation.h:484
virtual DtTerrainInformation * terrainInformation()
Return the terrain information pointer of the terrain implementation (null if none exist) this is a d...
Definition: terrainImplementation.h:385
virtual DtDynamicTerrainRequestHandle addDynamicTerrainChangeRequest(double time, makVrv::DtDynamicTerrainChange *command)
Add a dynamic terrain change request to the system.
Definition: terrainImplementation.h:407
DtTerrainChangeNotificationInfo()
Definition: terrainImplementation.h:52
Definition: terrainImplementation.h:184
Definition: vrfChordIntersectionRecord.h:19
virtual void loadVisuals(const DtScenarioExplorer &)
Tells the terrain implementation (if it cares) to load visuals to support terrain/model usage...
Definition: terrainImplementation.h:400
A DtChord is a finite line segment in 3-space, represented by two points. Data derived from the two e...
Fidelity
Allows the system to use differently fidelity data for intersecting against. Currently only implement...
Definition: terrainIntersectOptions.h:102
unsigned int DtTerrainCategoryMask
This bitmask is made using DtTerrainCategory values.
Definition: rwTerrainCategoryMask.h:27
virtual void setIntersectDataLoadExpireTime(const double &expireTime)
No-op. Override to set the default expiration time for data load requests generated by intersect call...
Definition: terrainImplementation.h:371
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Define a KeyEqual operator for the DtTerrainChangeNotificationInfo. It&#39;s required for the DtTerrainCh...
Definition: terrainImplementation.h:99
DtStringKeyFactoryWithParam< DtTerrainImplementation, DtConsoleCommandManager * > DtTerrainImplementationFactory
Definition: terrainImplementation.h:482
std::size_t operator()(const DtTerrainChangeNotificationInfo &val) const noexcept
Definition: terrainImplementation.h:70
bool myLastStateWasDefaultState
Definition: terrainImplementation.h:63
Command which can be given to the dynamic terrain system to perform some change. This class is a simp...
Definition: DtDynamicTerrainChange.h:42
void(* DtCacheProgressCallbackFunction)(int requestId, int current, bool completed, double elapsedTime, void *usr)
Callback for terrain caching.
Definition: terrainImplementation.h:117
Resource handle for a query which has been added to the system. Returned from DtTerrainImplementation...
Definition: terrainImplementation.h:180
DtString myChangeType
Definition: terrainImplementation.h:61
Interface for getting terrain triangle data out of DtTerrainInterface::trianglesInArea. This object should always be created on the stack.
Definition: terrainProcessPolygonsBox.h:134
Definition: featureContext.h:228
Resource handle for a dynamic terrain change request which has been added to the system. Returned from DtTerrainImplementation::addDynamicTerrainChangeRequest(). Allows caller to manage request.
Definition: terrainImplementation.h:145
virtual DtDynamicTerrainQueryHandle queryDynamicTerrainFeatures(const DtDynamicTerrainQueryCallback &callback, makVrv::DtDynamicTerrainGeometry *geometry=0, bool useOriginalGeometry=false)
Install a query which will call the supplied callback on matching dynamic terrain features as they ar...
Definition: terrainImplementation.h:427
virtual void expireDataLoadRequestsBeforeTime(const double &currentTime)
No-op. Override to expire data load requests generated before the given time. See comment for #setInt...
Definition: terrainImplementation.h:377
std::shared_ptr< MAKVRinTerra::DtAerodromeLoader > myAerodromeLoader
Definition: terrainImplementation.h:478
Provides information about the terrain changes: mySpatExtent defines the terrain change type - e...
Definition: terrainImplementation.h:50
TODO Put this in the makTerrainLib.
Definition: terrainInformation.h:17
Definition: point.h:34
DtTerrainIntersectStatus Contains information about status of &quot;data available&quot; when an intersection c...
Definition: terrainIntersectStatus.h:23
QueryHandleImpl()
Definition: terrainImplementation.h:187
Represents an area query which can be used to extract triangles from DtTerrainInterface. The box points are in local but the box is always projected against the local topo at the center point of the box.
Definition: terrainProcessPolygonsBox.h:60

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)