gwnavgeneration/input/clientinputtagvolume.h Source File

clientinputtagvolume.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 // primary contact: LASI - secondary contact: LASI
8 #ifndef GwNavGen_ClientInputTagVolume_H
9 #define GwNavGen_ClientInputTagVolume_H
10 
15 
16 namespace Kaim
17 {
18 
19 class ClientInputTagVolumeBlob;
20 class TagVolume;
21 class TagVolumeInitConfig;
22 
27 class ClientInputTagVolume
28 {
29  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
30 
31 public:
34 
44  KyResult Init(
45  const Vec3f* points, KyUInt32 pointsCount,
46  KyFloat32 altitudeMin, KyFloat32 altitudeMax,
47  const KyUInt32* blindDataBuffer=NULL, KyUInt32 blindDataCount=0);
48 
49  KyResult InitInClientCoordinates(
50  const Vec3f* client_points, KyUInt32 pointsCount,
51  KyFloat32 client_altitudeMin, KyFloat32 client_altitudeMax,
52  const CoordSystem& coordSystem,
53  const KyUInt32* blindDataBuffer=NULL, KyUInt32 blindDataCount=0, VisualColor color = DynamicNavTag::GetDefaultColor());
54 
55  KyResult Init(
56  const Vec3f* points, KyUInt32 pointsCount,
57  KyFloat32 altitudeMin, KyFloat32 altitudeMax,
58  const DynamicNavTag& navTag);
59 
60  KyResult InitInClientCoordinates(
61  const Vec3f* client_points, KyUInt32 pointsCount,
62  KyFloat32 client_altitudeMin, KyFloat32 client_altitudeMax,
63  const DynamicNavTag& navTag,
64  const CoordSystem& coordSystem);
65 
66  void InitFromBlob(const ClientInputTagVolumeBlob& tagVolumeBlob);
67 
68  KyUInt32 GetPointsCount() const { return m_polyline.GetCount(); }
69  KyFloat32 GetAltitudeMin() const { return m_altMin; }
70  KyFloat32 GetAltitudeMax() const { return m_altMax; }
71 
72  const Vec3f& GetPoint(KyUInt32 i) const;
73 
74  void CreateNavigationTagVolume(TagVolume& volume) const;
75  void CreateNavigationTagVolumeConfig(TagVolumeInitConfig& volumeConfig) const;
76 public:
78  DynamicNavTag m_navTag; //< Stores the NavTag set for this volume.
79  KyFloat32 m_altMin; //< The lower altitude limit of the volume.
80  KyFloat32 m_altMax; //< The upper altitude limit of the volume.
81 };
82 
83 
84 class ClientInputTagVolumeBlob
85 {
86  KY_CLASS_WITHOUT_COPY(ClientInputTagVolumeBlob)
87  KY_ROOT_BLOB_CLASS(Generator, ClientInputTagVolumeBlob, 0)
88 public:
89  ClientInputTagVolumeBlob() : m_index(0), m_navTagIdx(KyUInt32MAXVAL) {}
90 
91  bool operator==(const ClientInputTagVolumeBlob& other) const
92  {
93  if (m_polyline.GetCount() != other.m_polyline.GetCount())
94  {
95  return false;
96  }
97 
98  const Vec3f* thisPoints = m_polyline.GetValues();
99  const Vec3f* otherPoints = other.m_polyline.GetValues();
100  for (UPInt i = 0; i < m_polyline.GetCount(); ++i)
101  {
102  if (thisPoints[i] != otherPoints[i])
103  {
104  return false;
105  }
106  }
107  return m_navTag == other.m_navTag && m_altMax == other.m_altMax && m_altMin == other.m_altMin;
108  }
109  bool operator!=(const ClientInputTagVolumeBlob& other) const { return !operator==(other); }
110 
111 public:
112  BlobArray<Vec3f> m_polyline;
113  KyFloat32 m_altMin;
114  KyFloat32 m_altMax;
115  NavTag m_navTag;
116  KyUInt32 m_index;
117  mutable KyUInt32 m_navTagIdx;
118 };
119 inline void SwapEndianness(Endianness::Target e, ClientInputTagVolumeBlob& self)
120 {
121  SwapEndianness(e, self.m_polyline);
122  SwapEndianness(e, self.m_altMin);
123  SwapEndianness(e, self.m_altMax);
124  SwapEndianness(e, self.m_navTag);
125  SwapEndianness(e, self.m_index);
126  SwapEndianness(e, self.m_navTagIdx);
127 }
128 
129 class ClientInputTagVolumeBlobBuilder : public BaseBlobBuilder<ClientInputTagVolumeBlob>
130 {
131 public:
132  ClientInputTagVolumeBlobBuilder(const ClientInputTagVolume& tagVolume) : m_tagVolume(&tagVolume) {}
133 private:
134  void DoBuild()
135  {
136  if (IsWriteMode())
137  {
138  m_blob->m_index = 0;
139  m_blob->m_altMin = m_tagVolume->m_altMin;
140  m_blob->m_altMax = m_tagVolume->m_altMax;
141  }
142 
143  BLOB_ARRAY_COPY_2(m_blob->m_polyline, m_tagVolume->m_polyline);
144  BLOB_BUILD(m_blob->m_navTag, NavTagBlobBuilder(m_tagVolume->m_navTag));
145  }
146 private:
147  const ClientInputTagVolume* m_tagVolume;
148 };
149 
150 }
151 
152 
153 #endif
154 
Class used to provide TagVolume initialization parameters.
Definition: tagvolume.h:36
void CreateNavigationTagVolume(TagVolume &volume) const
Build a Runtime Tag Volume.
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Kaim::KyArray< Vec3f > m_polyline
Stores the polyline set for this volume. Do not modify directly. Access using GetPoint() ...
Definition: clientinputtagvolume.h:82
KyFloat32 GetAltitudeMin() const
Retrieves the max altitude of the extruded polyline.
Definition: clientinputtagvolume.h:73
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:189
This class maintains the mapping between the system of coordinate axes used internally within the gam...
Definition: coordsystem.h:144
The Generator is the principal class in the NavData generation system.
Definition: generator.h:61
KyUInt32 GetPointsCount() const
Retrieves the number of unique points in the polyline that outlines this volume.
Definition: clientinputtagvolume.h:72
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
Represents a single RGBA color.
Definition: visualcolor.h:19
KyResult Init(const Vec3f *points, KyUInt32 pointsCount, KyFloat32 altitudeMin, KyFloat32 altitudeMax, const KyUInt32 *blindDataBuffer=NULL, KyUInt32 blindDataCount=0)
Sets up an instance of this class with any required components and configuration parameters.
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
This class represents runtime-defined volumes with customized NavTag.
Definition: tagvolume.h:108
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
A BlobArray an array that is compatible with the blob serialization framework.
Definition: blobarray.h:28
ClientInputTagVolumeBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:47
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define BLOB_ARRAY_COPY_2(blobArray, ky_array)
same as BLOB_ARRAY_COPY but uses Kaim::Array as input
Definition: baseblobbuilder.h:165
KyFloat32 GetAltitudeMax() const
Retrieves the min altitude of the extruded polyline.
Definition: clientinputtagvolume.h:74
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Represents a volume using a two-dimensional polyline extruded vertically along the "up" axis associat...
Definition: clientinputtagvolume.h:30
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
const Vec3f & GetPoint(KyUInt32 i) const
Retrieves the point at the specified index within the polyline that outlines this volume...
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23