gwnavruntime/basesystem/coordsystem.h Source File

coordsystem.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 
8 // primary contact: GUAL - secondary contact: LASI
9 #ifndef Navigation_CoordSystem_H
10 #define Navigation_CoordSystem_H
11 
20 
21 
22 namespace Kaim
23 {
24 
25 class BlobFieldsMapping;
26 class BlobAggregate;
27 
28 
33 {
34  CLIENT_X = 0,
36  CLIENT_Y = 2,
38  CLIENT_Z = 4,
40 };
41 
42 
46 {
47  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
48 public:
50  {
55  }
56 
59  void Init_Zup(KyFloat32 oneMeterInClientUnits)
60  {
61  Init(oneMeterInClientUnits, CLIENT_X, CLIENT_Y, CLIENT_Z);
62  }
63 
69  void Init(
70  KyFloat32 oneMeterInClientUnits,
71  CoordSystemClientAxis clientAxisForNavigationX,
72  CoordSystemClientAxis clientAxisForNavigationY,
73  CoordSystemClientAxis clientAxisForNavigationZ)
74  {
75  m_oneMeterInClientUnits = oneMeterInClientUnits;
76  m_clientAxisForNavigationX = (KyUInt32)clientAxisForNavigationX;
77  m_clientAxisForNavigationY = (KyUInt32)clientAxisForNavigationY;
78  m_clientAxisForNavigationZ = (KyUInt32)clientAxisForNavigationZ;
79  }
80 
82  void AddMapping(BlobFieldsMapping& mapping);
83 
85  bool operator==(const CoordSystemConfig& other) const
86  {
91  }
92 
95  bool operator!=(const CoordSystemConfig& other) const { return !operator==(other); }
96 
97 public:
106 };
108 
111 inline void SwapEndianness(Endianness::Target e, CoordSystemConfig& self)
112 {
113  SwapEndianness(e, self.m_oneMeterInClientUnits);
114  SwapEndianness(e, self.m_clientAxisForNavigationX);
115  SwapEndianness(e, self.m_clientAxisForNavigationY);
116  SwapEndianness(e, self.m_clientAxisForNavigationZ);
117 }
118 
119 
136 class CoordSystem
137 {
138  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
139 public:
145  static const ClientAxis CLIENT_X = Kaim::CLIENT_X;
146  static const ClientAxis CLIENT_MINUS_X = Kaim::CLIENT_MINUS_X;
147  static const ClientAxis CLIENT_Y = Kaim::CLIENT_Y;
148  static const ClientAxis CLIENT_MINUS_Y = Kaim::CLIENT_MINUS_Y;
149  static const ClientAxis CLIENT_Z = Kaim::CLIENT_Z;
150  static const ClientAxis CLIENT_MINUS_Z = Kaim::CLIENT_MINUS_Z;
151 
153 public:
155  CoordSystem() { Setup(1.0f, CLIENT_X, CLIENT_Y, CLIENT_Z); }
162  void Setup(KyFloat32 oneMeterInClientUnits, ClientAxis clientAxisForNavigationX, ClientAxis clientAxisForNavigationY, ClientAxis clientAxisForNavigationZ);
163 
166  void Setup(const CoordSystemConfig& config);
167 
169  void SetOneMeterInClientUnits(KyFloat32 oneMeter);
170 
172  void SetClientAxisForNavigationX(ClientAxis clientAxisForNavigationX);
173 
175  void SetClientAxisForNavigationY(ClientAxis clientAxisForNavigationY);
176 
178  void SetClientAxisForNavigationZ(ClientAxis clientAxisForNavigationZ);
179 
182 
185 
188 
189 public:
190  // ------------------ Client <-> Gameware Navigation: Distances ------------------
191 
195  KyFloat32 ClientToNavigation_Dist(KyFloat32 clientDist) const; // Dist
196 
200  KyFloat32 NavigationToClient_Dist(KyFloat32 navigationDist) const; // Dist
201 
202 
203  // ------------------ Client <-> Gameware Navigation: Square Distances ------------------
204 
208  KyFloat32 ClientToNavigation_SquareDist(KyFloat32 clientSquareDist) const; // SquareDist
209 
213  KyFloat32 NavigationToClient_SquareDist(KyFloat32 navigationSquareDist) const; // SquareDist
214 
215 
216  // ------------------ Client <-> Gameware Navigation: Position Vectors ------------------
218 
222  void ClientToNavigation_Pos(const Vec3f& clientPos, Vec3f& navigationPos) const;
223 
227  void NavigationToClient_Pos(const Vec3f& navigationPos, Vec3f& clientPos) const;
228 
232  Vec3f ClientToNavigation_Pos(const Vec3f& clientPos) const;
233 
237  Vec3f NavigationToClient_Pos(const Vec3f& navigationPos) const;
238 
239  // ------------------ Client <-> Gameware Navigation: Normal Vectors ------------------
241 
245  void ClientToNavigation_Normal(const Vec3f& clientNormal, Vec3f& navigationNormal) const;
246 
250  void NavigationToClient_Normal(const Vec3f& navigationNormal, Vec3f& clientNormal) const;
251 
255  Vec3f ClientToNavigation_Normal(const Vec3f& clientNormal) const;
256 
260  Vec3f NavigationToClient_Normal(const Vec3f& navigationNormal) const;
261 
262  // ------------------ Client <-> Gameware Navigation: Angular Velocity Vectors ------------------
264 
268  void ClientToNavigation_AngularVelocity(const Vec3f& clientAngularVelocity, Vec3f& navigationAngularVelocity) const;
269 
273  void NavigationToClient_AngularVelocity(const Vec3f& navigationAngularVelocity, Vec3f& clientAngularVelocity) const;
274 
278  Vec3f ClientToNavigation_AngularVelocity(const Vec3f& clientAngularVelocity) const;
279 
283  Vec3f NavigationToClient_AngularVelocity(const Vec3f& navigationAngularVelocity) const;
284 
285 
286  // ------------------ Client <-> Gameware Navigation: Extents Vectors ------------------
288 
293  void ClientToNavigation_Extents(const Vec3f& clientExtents, Vec3f& navigationExtents) const;
294 
299  void NavigationToClient_Extents(const Vec3f& navigationExtents, Vec3f& clientExtents) const;
300 
305  Vec3f ClientToNavigation_Extents(const Vec3f& clientExtents) const;
306 
311  Vec3f NavigationToClient_Extents(const Vec3f& navigationExtents) const;
312 
313 
314  // ------------------ Client <-> Gameware Navigation: Triangle ------------------
315 
319  void ClientToNavigation_Triangle(const Triangle3f& clientTriangle, Triangle3f& navigationTriangle) const;
320 
324  void NavigationToClient_Triangle(const Triangle3f& navigationTriangle, Triangle3f& clientTriangle) const;
325 
326 
327  // ------------------ Client <-> Gameware Navigation: Boxes ------------------
328 
333  void ClientToNavigation_Box(const Vec3f& clientMin, const Vec3f& clientMax, Box3f& navigationBox) const;
334 
338  void ClientToNavigation_Box(const Box3f& clientBox, Box3f& navigationBox) const;
339 
344  void NavigationToClient_Box(const Box3f& navigationBox, Vec3f& clientMin, Vec3f& clientMax) const;
345 
349  void NavigationToClient_Box(const Box3f& navigationBox, Box3f& clientBox) const;
350 
351 
352  // ------------------ Client <-> Gameware Navigation: Matrixes & Transforms ------------------
353 
357  void ClientToNavigation_Matrix(const Matrix3x3f& clientMatrix, Matrix3x3f& navigationMatrix) const;
358 
362  void NavigationToClient_Matrix(const Matrix3x3f& navigationMatrix, Matrix3x3f& clientMatrix) const;
363 
364 
368  void ClientToNavigation_Transform(const Transform& clientTransform, Transform& navigationTransform) const;
369 
373  void NavigationToClient_Transform(const Transform& navigationTransform, Transform& clientTransform) const;
374 
376  bool operator==(const CoordSystem& other) const;
377 
379  bool operator!=(const CoordSystem& other) const;
380 
382  bool IsRightHanded() const;
383 
384 public:
385  // Client axis <=> Gameware Navigation axis
386  // navigation_x = m_navigationX_sign * clientPos[m_navigationX_idx];
387  // clientPos[m_navigationX_idx] = m_navigationX_sign * navigation_x;
390 
393 
396 
397  // client dist <=> navigation dist
400 
401 };
402 
405 inline void SwapEndianness(Endianness::Target e, CoordSystem& self)
406 {
407  SwapEndianness(e, self.m_navigationX_idx);
408  SwapEndianness(e, self.m_navigationX_sign);
409 
410  SwapEndianness(e, self.m_navigationY_idx);
411  SwapEndianness(e, self.m_navigationY_sign);
412 
413  SwapEndianness(e, self.m_navigationZ_idx);
414  SwapEndianness(e, self.m_navigationZ_sign);
415 
416  SwapEndianness(e, self.m_oneMeter);
417  SwapEndianness(e, self.m_inv_oneMeter);
418 }
419 
420 
421 }
422 
424 
425 
426 
427 #endif
428 
KyFloat32 m_oneMeter
The number of world units in the game engine that add up to one meter in length.
Definition: coordsystem.h:446
void NavigationToClient_Normal(const Vec3f &navigationNormal, Vec3f &clientNormal) const
Converts a normalized vector from the Gameware Navigation coordinate system to the game engine coordi...
Definition: coordsystem.inl:114
KyInt32 m_navigationY_idx
Identifies the index within each Vec3f that contains game engine coordinates that is mapped to the Y ...
Definition: coordsystem.h:439
void Setup(KyFloat32 oneMeterInClientUnits, ClientAxis clientAxisForNavigationX, ClientAxis clientAxisForNavigationY, ClientAxis clientAxisForNavigationZ)
Sets the mapping between the coordinate system used in the Gameware Navigation Engine and the game en...
Definition: coordsystem.inl:32
bool operator==(const CoordSystem &other) const
Indicates whether or not the two CoordSystem instances contain the same data members.
Definition: coordsystem.inl:305
void ClientToNavigation_Normal(const Vec3f &clientNormal, Vec3f &navigationNormal) const
Converts a normalized vector from the game engine coordinate system to the Gameware Navigation coordi...
Definition: coordsystem.inl:108
bool operator!=(const CoordSystem &other) const
Indicates whether or not the two CoordSystem instances contain at least one different data member...
Definition: coordsystem.inl:313
void Init(KyFloat32 oneMeterInClientUnits, CoordSystemClientAxis clientAxisForNavigationX, CoordSystemClientAxis clientAxisForNavigationY, CoordSystemClientAxis clientAxisForNavigationZ)
Sets up an instance of this class with any required components and configuration parameters.
Definition: coordsystem.h:70
static const ClientAxis CLIENT_Y
Represents the positive direction of the Y axis in the game engine.
Definition: coordsystem.h:156
KyFloat32 m_navigationZ_sign
Indicates whether coordinates on the Gameware Navigation Z axis need to be negated when converting be...
Definition: coordsystem.h:443
void NavigationToClient_Pos(const Vec3f &navigationPos, Vec3f &clientPos) const
Converts a position from the Gameware Navigation engine coordinate system to the game coordinate syst...
Definition: coordsystem.inl:88
Represents the positive direction of the X axis.
Definition: coordsystem.h:34
bool IsRightHanded() const
Indicates whether or not CoordSystem instance is right-handed.
Definition: coordsystem.inl:318
bool operator==(const CoordSystemConfig &other) const
Returns true if all data members in the specified CoordSystemConfig match all data members in this ob...
Definition: coordsystem.h:86
void ClientToNavigation_AngularVelocity(const Vec3f &clientAngularVelocity, Vec3f &navigationAngularVelocity) const
Converts an angular velocity vector from the game engine coordinate system to the Gameware Navigation...
Definition: coordsystem.inl:133
This class represents a triangle in three-dimensional space, whose dimensions are stored using float ...
Definition: triangle3f.h:22
KyUInt32 m_clientAxisForNavigationZ
The axis in the game engine coordinate system that should be mapped to the Z axis within the Gameware...
Definition: coordsystem.h:107
This class maintains the mapping between the system of coordinate axes used internally within the gam...
Definition: coordsystem.h:144
Represents the positive direction of the Y axis.
Definition: coordsystem.h:36
void ClientToNavigation_Transform(const Transform &clientTransform, Transform &navigationTransform) const
Converts a Transform from the game engine coordinate system to the Gameware Navigation coordinate sys...
Definition: coordsystem.inl:290
bool operator!=(const CoordSystemConfig &other) const
Returns true if at least one data member in the specified CoordSystemConfig does not match the corres...
Definition: coordsystem.h:96
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
void Init_Zup(KyFloat32 oneMeterInClientUnits)
Initialize the CoordSystemConfig to use a standard Z-up coordinate system in Gameware Navigation...
Definition: coordsystem.h:60
void SetOneMeterInClientUnits(KyFloat32 oneMeter)
Sets the number of world units in the game engine that add up to one meter in length.
Definition: coordsystem.inl:56
KyInt32 m_navigationZ_idx
Identifies the index within each Vec3f that contains game engine coordinates that is mapped to the Z ...
Definition: coordsystem.h:442
3x3 matrix.
Definition: matrix3x3f.h:21
KyFloat32 ClientToNavigation_Dist(KyFloat32 clientDist) const
Converts a distance measurement from the game engine coordinate system to the Gameware Navigation coo...
Definition: coordsystem.inl:73
A structure that sets up the mapping between the coordinate system used in the Gameware Navigation En...
Definition: coordsystem.h:45
void NavigationToClient_Extents(const Vec3f &navigationExtents, Vec3f &clientExtents) const
Converts an extents vector from the Gameware Navigation engine coordinate system to the game coordina...
Definition: coordsystem.inl:163
KyUInt32 m_clientAxisForNavigationY
The axis in the game engine coordinate system that should be mapped to the Y axis within the Gameware...
Definition: coordsystem.h:105
void SetClientAxisForNavigationZ(ClientAxis clientAxisForNavigationZ)
Sets the axis in the game engine coordinate system that should be mapped to the Z axis within the Gam...
Definition: coordsystem.inl:64
void SetClientAxisForNavigationX(ClientAxis clientAxisForNavigationX)
Sets the axis in the game engine coordinate system that should be mapped to the X axis within the Gam...
Definition: coordsystem.inl:62
CoordSystemClientAxis
Enumerates the possible axis orientations that can be assigned to each of the Right, Front, and Up axes used within Gameware Navigation.
Definition: coordsystem.h:32
static const ClientAxis CLIENT_MINUS_X
Represents the negative direction of the X axis in the game engine.
Definition: coordsystem.h:155
static const ClientAxis CLIENT_Z
Represents the positive direction of the Z axis in the game engine.
Definition: coordsystem.h:158
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
This class represents a three-dimensional axis-aligned bounding box whose dimensions are stored using...
Definition: box3f.h:25
Represents the positive direction of the Z axis.
Definition: coordsystem.h:38
KyFloat32 m_navigationX_sign
Indicates whether coordinates on the Gameware Navigation X axis need to be negated when converting be...
Definition: coordsystem.h:437
ClientAxis GetClientAxisForNavigationY()
Retrieves the axis in the game engine coordinate system that is mapped to the Y axis within the Gamew...
Definition: coordsystem.inl:67
void ClientToNavigation_Matrix(const Matrix3x3f &clientMatrix, Matrix3x3f &navigationMatrix) const
Converts a matrix from the game engine coordinate system to the Gameware Navigation coordinate system...
Definition: coordsystem.inl:252
KyFloat32 NavigationToClient_SquareDist(KyFloat32 navigationSquareDist) const
Converts a squared distance measurement from the Gameware Navigation coordinate system to the game en...
Definition: coordsystem.inl:77
void ClientToNavigation_Triangle(const Triangle3f &clientTriangle, Triangle3f &navigationTriangle) const
Converts a triangle from the game engine coordinate system to the Gameware Navigation coordinate syst...
Definition: coordsystem.inl:188
void SetClientAxisForNavigationY(ClientAxis clientAxisForNavigationY)
Sets the axis in the game engine coordinate system that should be mapped to the Y axis within the Gam...
Definition: coordsystem.inl:63
KyFloat32 m_oneMeterInClientUnits
The number of world units in the game engine that add up to one meter in length.
Definition: coordsystem.h:101
CoordSystemClientAxis ClientAxis
A type that represents the possible axis orientations that can be assigned to each of the Right...
Definition: coordsystem.h:152
ClientAxis GetClientAxisForNavigationZ()
Retrieves the axis in the game engine coordinate system that is mapped to the Z axis within the Gamew...
Definition: coordsystem.inl:68
Represents the negative direction of the Z axis.
Definition: coordsystem.h:39
static const ClientAxis CLIENT_X
Represents the positive direction of the X axis in the game engine.
Definition: coordsystem.h:154
void AddMapping(BlobFieldsMapping &mapping)
For internal use.
static const ClientAxis CLIENT_MINUS_Y
Represents the negative direction of the Y axis in the game engine.
Definition: coordsystem.h:157
Definition: gamekitcrowddispersion.h:20
static const ClientAxis CLIENT_MINUS_Z
Represents the negative direction of the Z axis in the game engine.
Definition: coordsystem.h:159
void NavigationToClient_Triangle(const Triangle3f &navigationTriangle, Triangle3f &clientTriangle) const
Converts a triangle from the Gameware Navigation coordinate system to the game engine coordinate syst...
Definition: coordsystem.inl:205
void NavigationToClient_Transform(const Transform &navigationTransform, Transform &clientTransform) const
Converts a Transform from the Gameware Navigation coordinate system to the game engine coordinate sys...
Definition: coordsystem.inl:295
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
Represents the negative direction of the Y axis.
Definition: coordsystem.h:37
void NavigationToClient_AngularVelocity(const Vec3f &navigationAngularVelocity, Vec3f &clientAngularVelocity) const
Converts an angular velocity vector from the Gameware Navigation coordinate system to the game engine...
Definition: coordsystem.inl:137
void NavigationToClient_Matrix(const Matrix3x3f &navigationMatrix, Matrix3x3f &clientMatrix) const
Converts a matrix from the Gameware Navigation coordinate system to the game engine coordinate system...
Definition: coordsystem.inl:271
KyUInt32 m_clientAxisForNavigationX
The axis in the game engine coordinate system that should be mapped to the X axis within the Gameware...
Definition: coordsystem.h:103
KyInt32 m_navigationX_idx
Identifies the index within each Vec3f that contains game engine coordinates that is mapped to the X ...
Definition: coordsystem.h:436
KyFloat32 m_inv_oneMeter
One divided by the m_oneMeter value.
Definition: coordsystem.h:447
Represents the negative direction of the X axis.
Definition: coordsystem.h:35
void NavigationToClient_Box(const Box3f &navigationBox, Vec3f &clientMin, Vec3f &clientMax) const
Converts a bounding box from the Gameware Navigation coordinate system to the game engine coordinate ...
Definition: coordsystem.inl:234
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
void ClientToNavigation_Pos(const Vec3f &clientPos, Vec3f &navigationPos) const
Converts a position from the game engine coordinate system to the Gameware Navigation coordinate syst...
Definition: coordsystem.inl:82
ClientAxis GetClientAxisForNavigationX()
Retrieves the axis in the game engine coordinate system that is mapped to the X axis within the Gamew...
Definition: coordsystem.inl:66
This class represents a three-dimensional 6 freedom degrees unit transform.
Definition: transform.h:20
KyFloat32 m_navigationY_sign
Indicates whether coordinates on the Gameware Navigation Y axis need to be negated when converting be...
Definition: coordsystem.h:440
KyFloat32 ClientToNavigation_SquareDist(KyFloat32 clientSquareDist) const
Converts a squared distance measurement from the game engine coordinate system to the Gameware Naviga...
Definition: coordsystem.inl:76
void ClientToNavigation_Extents(const Vec3f &clientExtents, Vec3f &navigationExtents) const
Converts an extents vector from the game engine coordinate system to the Gameware Navigation coordina...
Definition: coordsystem.inl:154
KyFloat32 NavigationToClient_Dist(KyFloat32 navigationDist) const
Converts a distance measurement from the Gameware Navigation coordinate system to the game engine coo...
Definition: coordsystem.inl:74
void ClientToNavigation_Box(const Vec3f &clientMin, const Vec3f &clientMax, Box3f &navigationBox) const
Converts a bounding box from the game engine coordinate system to the Gameware Navigation coordinate ...
Definition: coordsystem.inl:224
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