tools/navgenproj/ProjCoordSystem.h Source File

ProjCoordSystem.h
Go to the documentation of this file.
1 /*
2 * Copyright 2017 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 #pragma once
8 
9 #include "navgenproj/ProjTypes.h"
11 
12 namespace Kaim
13 {
14 
15 inline const char* GetClientAxisName(const CoordSystem::ClientAxis& clientAxis)
16 {
17  switch (clientAxis)
18  {
19  case CoordSystem::CLIENT_X: return "CLIENT_X";
20  case CoordSystem::CLIENT_MINUS_X: return "CLIENT_MINUS_X";
21  case CoordSystem::CLIENT_Y: return "CLIENT_Y";
22  case CoordSystem::CLIENT_MINUS_Y: return "CLIENT_MINUS_Y";
23  case CoordSystem::CLIENT_Z: return "CLIENT_Z";
24  case CoordSystem::CLIENT_MINUS_Z: return "CLIENT_MINUS_Z";
25  default: return "INVALID_CLIENT_AXIS";
26  }
27 }
28 
29 inline bool ReadCoordSystemAxis(XmlNode node, const char* name, CoordSystem::ClientAxis& axis)
30 {
31  CoordSystem::ClientAxis clientAxisEnums[6] = {CLIENT_X, CLIENT_MINUS_X, CLIENT_Y, CLIENT_MINUS_Y, CLIENT_Z, CLIENT_MINUS_Z};
32  const char* clientAxischar[6] = {"CLIENT_X", "CLIENT_MINUS_X", "CLIENT_Y", "CLIENT_MINUS_Y", "CLIENT_Z", "CLIENT_MINUS_Z"};
33 
34  std::string str = "";
35  if (node.ReadChild(name, str) == false)
36  return false;
37 
38  for (KyUInt32 i = 0; i < 6; ++i)
39  {
40  if (TiXml::SameValue(str.c_str(), clientAxischar[i]))
41  {
42  axis = clientAxisEnums[i];
43  return true;
44  }
45  }
46 
47  return false;
48 }
49 
50 //<CoordSystem>
51 // <oneMeter>1.000000</oneMeter>
52 // <X>CLIENT_X</X>
53 // <Y>CLIENT_Y</Y>
54 // <Z>CLIENT_Z</Z>
55 //</CoordSystem>
56 inline bool Read(XmlNode node, CoordSystem& value)
57 {
58  float one_meter = 1.0f;
59  if (node.ReadChild("oneMeter", one_meter) == false)
60  return false;
61 
62  CoordSystem::ClientAxis axis_x, axis_y, axis_z;
63  if (ReadCoordSystemAxis(node, "X", axis_x) == false) { return false; }
64  if (ReadCoordSystemAxis(node, "Y", axis_y) == false) { return false; }
65  if (ReadCoordSystemAxis(node, "Z", axis_z) == false) { return false; }
66 
67  value.Setup(one_meter, axis_x, axis_y, axis_z);
68  return true;
69 }
70 
71 inline void Write(XmlNode node, const CoordSystem& value)
72 {
73  node.WriteChild("oneMeter", value.m_oneMeter);
74  node.WriteChild("X", GetClientAxisName(value.GetClientAxisForNavigationX()));
75  node.WriteChild("Y", GetClientAxisName(value.GetClientAxisForNavigationY()));
76  node.WriteChild("Z", GetClientAxisName(value.GetClientAxisForNavigationZ()));
77 }
78 
79 }
static const ClientAxis CLIENT_Y
Represents the positive direction of the Y axis in the game engine.
Definition: coordsystem.h:127
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Represents the positive direction of the client game engine X axis.
Definition: coordsystem.h:32
Represents the positive direction of the client game engine Y axis.
Definition: coordsystem.h:34
static const ClientAxis CLIENT_MINUS_X
Represents the negative direction of the X axis in the game engine.
Definition: coordsystem.h:126
static const ClientAxis CLIENT_Z
Represents the positive direction of the Z axis in the game engine.
Definition: coordsystem.h:129
Represents the positive direction of the client game engine Z axis.
Definition: coordsystem.h:36
Represents the negative direction of the client game engine Z axis.
Definition: coordsystem.h:37
static const ClientAxis CLIENT_X
Represents the positive direction of the X axis in the game engine.
Definition: coordsystem.h:125
static const ClientAxis CLIENT_MINUS_Y
Represents the negative direction of the Y axis in the game engine.
Definition: coordsystem.h:128
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
static const ClientAxis CLIENT_MINUS_Z
Represents the negative direction of the Z axis in the game engine.
Definition: coordsystem.h:130
Represents the negative direction of the client game engine Y axis.
Definition: coordsystem.h:35
Represents the negative direction of the client game engine X axis.
Definition: coordsystem.h:33