tools/NavGenProj/include/NavGenProj.h Source File

NavGenProj.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: MAMU - secondary contact: GUAL
9 #ifndef GwNavGen_NavGenProj_H
10 #define GwNavGen_NavGenProj_H
11 
12 #include "NavGenProjConfig.h"
13 #include "NavGenProjSeedPoint.h"
14 
17 #include "LabEngine/base/filesystem.h"
18 
19 #include "tinyxml.h"
20 
21 #include <string>
22 #include <vector>
23 
24 
25 namespace Kaim
26 {
27 class OBJProducer;
28 }
29 
30 namespace LabEngine
31 {
32 class MirroredOBJProducer;
33 }
34 
35 namespace Kaim
36 {
37 
38 class NavGenProjGeometry;
39 class NavGenProjPdgInput;
40 class NavGenProjTagVolume;
41 class NavGenProjClientInput;
42 class NavGenProjSector;
43 class NavGenProjMirrorOptions;
44 class NavGenProjExclusiveSectors;
45 
46 
50 {
51 public:
52  NavGenProj();
53  ~NavGenProj();
54 
56  void Clear();
57 
61  KyResult Load(const char* fileName);
62 
65  KyResult Save(const char* fileName);
66 
70  KyResult Generate(const char* forcedOutputBaseDir = KY_NULL, const char* forcedRelativeOutputDir = KY_NULL);
71 
72  void AddSector(NavGenProjSector* sector) { m_sectors.push_back(sector); }
73 
83  KyResult AddTagVolume(const Vec3f* polylinePoints, int pointArraySize, const DynamicNavTag& navTag, float minAltitude, float maxAltitude);
84 
86  void AddSeedPoint(float x, float y, float z);
87 
88  //KyResult AddTerrainTypeMaterial(const char* materialName, unsigned int terrainTypeMask, const char* objFileName);
89 
90  void AddExclusiveGuids(const Kaim::KyGuid* guids, KyUInt32 guidsCount);
91 
94  void AddSpecificCellToGenerate(int posx, int posy);
95 
98  void SetOutputDir(const char* outputBaseDir, const char* relativeOutputDir);
99  std::string GetRelativeOutputDir() { return m_relativeOutputDir; }
100  std::string GetOutputBaseDir() { return m_outputBaseDir; }
101 
103  void SetDatabaseIndex(KyUInt32 dabaseIndex);
104  KyUInt32 GetDatabaseIndex() const;
105 
110  void SetConfig(const GeneratorParameters& params, const GeneratorRunOptions& runOptions, const CoordSystem& coordSystem);
111 
113  void SetAbstractGraphConfig(const GeneratorAbstractGraphParameters& abstractGraphParams);
114 
115  // MirrorOptions is not an SDK feature, this is an option of the NavGenProj to ease demoing/testing of large scale terrains.
116  // It emulates large scale terrain by mirroring either one sector and its geometry or only the geometry into this sector.
117  // SeedPoint and TagVolume are mirrored as well.
118  void AddMirrorOptions(const NavGenProjMirrorOptions& mirrorOptions);
119  NavGenProjMirrorOptions* GetMirrorOptions() { return m_mirrorOptions; }
120 
121  std::string GetGeometryFileName (NavGenProjSector* sector, int index);
122  std::string GetClientInputFileName(NavGenProjSector* sector, int index);
123 
124  int GetSectorCount() const;
125  NavGenProjSector* GetSector(int index);
126 
127  int GetSeedPointCount() const;
128  const NavGenProjSeedPoint& GetSeedPoint(int index) const;
129 
134  void SetNavGenProjAbsoluteFileName(const char* navGenProjAbsoluteFileName);
135 
136  // if path is relative then returns m_navGenProjDirectory/path or return path
137  std::string GetAbsolutePath(const char* path);
138 
139  std::string GetGeneratorInputOutputFilename()
140  {
141  if (m_navGenProjConfig.m_genIOFilename.IsEmpty())
142  {
143  std::string genIOFileName = m_navGenProjFileNameWithoutDirOrExtension;
144  genIOFileName += ".GenIO";
145  return genIOFileName;
146  }
147 
148  return m_navGenProjConfig.m_genIOFilename.ToCStr();
149  }
150 
151 public: // internal
152 
155 
156  // Indicates if the NavGenProj is ready for mirroring the geometry which has to be a .obj file,
157  // the NavGenProj must contain one and only one sector which contains a NavGenProjMirrorOptions
158  bool CanUseMirrorOptions();
159  void RemoveMirrorOptions();
160 
161  void ParseNavGenProjDoc(TiXmlNode* root);
162  void ParseNavGenProjChildNode(TiXmlNode* pChild);
163 
164  //KyResult CheckProjectVersion(TiXmlNode* pParent);
165 
166  static TiXmlNode* GetOrCreateFolderNode(TiXmlNode* node, const char* folderName);
167 
168  static bool GetParam(TiXmlNode* node, const char *elementName, float& value);
169  static bool GetParam(TiXmlNode* node, const char *elementName, int& value);
170  static bool GetParam(TiXmlNode* node, const char *elementName, unsigned int& value);
171  static bool GetParam(TiXmlNode* node, const char *elementName, unsigned int& value, const KyArray<String>& enumNames);
172  static bool GetParam(TiXmlNode* node, const char *elementName, bool& value);
173  static bool GetParam(TiXmlNode* node, const char *paramName, std::string& param);
174  static bool GetParam(TiXmlNode* node, const char *paramName, Kaim::CellPos& pos);
175  static bool GetParam(TiXmlNode* node, const char *paramName, Kaim::Vec3f& pos);
176 
177  static void SetParam(TiXmlNode* folder, const char* paramName, float param);
178  static void SetParam(TiXmlNode* folder, const char* paramName, int param);
179  static void SetParam(TiXmlNode* folder, const char* paramName, unsigned int param);
180  static void SetParam(TiXmlNode* folder, const char* paramName, unsigned int param, const KyArray<String>& enumNames);
181  static void SetParam(TiXmlNode* folder, const char* paramName, bool param);
182  static void SetParam(TiXmlNode* folder, const char *paramName, const std::string& param);
183  static void SetParam(TiXmlNode* folder, const char *paramName, const Kaim::CellPos& pos);
184  static void SetParam(TiXmlNode* folder, const char *paramName, const Kaim::Vec3f& pos);
185 
186  static void ReadNavTag(TiXmlNode* node, DynamicNavTag& navTag);
187  static void ReadBlindData(TiXmlNode* node, Kaim::KyArrayPOD<KyUInt32>& blindDataArray);
188  static void ReadColor(TiXmlNode* node, VisualColor& color);
189  static void ReadPoints(TiXmlNode* node, Kaim::KyArrayPOD<Vec3f>& points);
190 
191  static void WriteNavTag(TiXmlNode* node, const DynamicNavTag& navTag, bool writeOnlyBlindData = false);
192  static void WriteBlindData(TiXmlNode* node, const Kaim::KyArrayPOD<KyUInt32>& blindDataArray);
193  static void WriteColor(TiXmlNode* node, const KyUInt32* color);
194  static void WritePoints(TiXmlNode* node, const Kaim::KyArrayPOD<Vec3f>& points);
195 
196 private:
197  void ParseOutputDir(TiXmlNode* node);
198  void ParseSectors(TiXmlNode* sectorsNode);
199  void CreateSector(TiXmlNode* sectorNode);
200  void ParseTagVolumes(TiXmlNode* tagVolumesNode);
201  void CreateTagVolume(TiXmlNode* tagVolumeNode);
202  void ParseSeedPoints(TiXmlNode* seedpointsNode);
203  void CreateSeedPoint(TiXmlNode* seedpointNode);
204  void CreateMirrorOptions(TiXmlNode* node);
205 
206  KyResult GenerateMirroredObj(const char* absoluteOutputBaseDir, const char* relativeOutputDir);
207  KyResult GenerateObj(const char* absoluteOutputBaseDir, const char* relativeOutputDir);
208  KyResult DoGenerate(Kaim::GeneratorInputProducer* producer, const char* absoluteOutputBaseDir, const char* relativeOutputDir);
209  Kaim::Ptr<Kaim::Generator> CreateGenerator(Kaim::Ptr<Kaim::GeneratorInputProducer> producer);
210  void InitInputGeometry(Kaim::Ptr<Kaim::GeneratorSector> sector, NavGenProjSector* navGenProjSector);
211  void InitSeedAndTag(Kaim::Ptr<Kaim::GeneratorSector> sector, NavGenProjSector* navGenProjSector);
212  void InitSeedAndTagForMirroredOBJ(NavGenProjSector* navGenProjSector, LabEngine::MirroredOBJProducer* producer);
213  void GetValidGuid(Kaim::KyGuid& sectorGuid);
214  void ConfigGeneratorSector(Kaim::Ptr<Kaim::GeneratorSector> sector, NavGenProjSector* navGenProjSector);
215  void InitGeneratorInputOutput(Kaim::GeneratorInputOutput& generatorInputOutput, const char* absoluteOutputBaseDir, const char* relativeOutputDir);
216  KyResult RunGenerator(Kaim::Ptr<Kaim::Generator> generator, Kaim::GeneratorInputOutput& generatorInputOutput, const char* absoluteOutputBaseDir, const char* relativeOutputDir);
217 
218 public:
219  // sectors, tagVolumes, arrayOfExclusiveSectors, seedPoints
220  // are maintained in these vectors instead of the m_navGenProjConfig.m_generatorInputOutput
221  std::vector<NavGenProjSector*> m_sectors;
222  std::vector<NavGenProjTagVolume*> m_tagVolumes;
223  std::vector<NavGenProjExclusiveSectors*> m_arrayOfExclusiveSectors;
224  std::vector<NavGenProjSeedPoint> m_seedPoints;
225 
226  NavGenProjConfig m_navGenProjConfig; //< Content of <config>...</config>
227  NavGenProjMirrorOptions* m_mirrorOptions;
228 
229  KyUInt32 m_databaseIndex;
230 
233  char m_outputBaseDir[LabEngine::Paths::PathMax];
235  char m_relativeOutputDir[LabEngine::Paths::PathMax];
236 
239  char m_navGenProjDirectory[LabEngine::Paths::PathMax];
241  // FileName of the .NavGenProj file without the directory and without the extension
242  char m_navGenProjFileNameWithoutDirOrExtension[LabEngine::Paths::PathMax];
243 };
244 
245 }
247 
248 #endif
void ClearAllSpecificCellsToGenerate()
For internal use.
void SetAbstractGraphConfig(const GeneratorAbstractGraphParameters &abstractGraphParams)
Sets up the NavGenProjConfig that will be used when generating AbstractGraphs from this NavGenProj...
KyResult Save(const char *fileName)
Saves the data in this NavGenProj object to a file on disk with the specfied path and file name...
char m_navGenProjDirectory[LabEngine::Paths::PathMax]
absolute directory of the NavGenProj file all files in the navGenProj file are relative to this m_nav...
Definition: NavGenProj.h:246
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
The NavGenProj class is a representation of the input data required for the standalone NavData genera...
Definition: NavGenProj.h:49
char m_relativeOutputDir[LabEngine::Paths::PathMax]
content of
Definition: NavGenProj.h:242
This class is used to store parameters if a sector must be mirrored cf.
Definition: NavGenProjMirrorOptions.h:24
This class is used by the NavGenProj to store configuration parameters required by the NavData genera...
Definition: NavGenProjConfig.h:24
An instance of this class is used to represent each seedpoint in a NavGenProj.
Definition: NavGenProjSeedPoint.h:23
This class maintains the mapping between the system of coordinate axes used internally within the gam...
Definition: coordsystem.h:144
char m_outputBaseDir[LabEngine::Paths::PathMax]
content of
Definition: NavGenProj.h:240
The MirroredOBJProducer class is a concrete implementation of GeneratorInputProducer that can read th...
Definition: mirroredobjproducer.h:48
#define KY_NULL
Null value.
Definition: types.h:247
Represents a single RGBA color.
Definition: visualcolor.h:19
void SetNavGenProjAbsoluteFileName(const char *navGenProjAbsoluteFileName)
Sets the navGenProj absolute fileName this is only used to implement GetAbsolutePath() set generatorI...
void SetDatabaseIndex(KyUInt32 dabaseIndex)
Set and get the database name and index for current generation.
String m_genIOFilename
.GenIO file to use based on the specified outputDir, m_generatorParams and m_generatorRunOptions will...
Definition: NavGenProjConfig.h:53
KyResult AddTagVolume(const Vec3f *polylinePoints, int pointArraySize, const DynamicNavTag &navTag, float minAltitude, float maxAltitude)
Adds a new tag volume to the NavGenProj.
An instance of this class is used to represent each input geometry file in a NavGenProj.
Definition: NavGenProjSector.h:27
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
The KyGuid class represents a globally unique ID.
Definition: kyguid.h:22
KyResult Load(const char *fileName)
Loads the data contained in the .NavGenProj with the specfied path and file name into this NavGenProj...
The GeneratorInputOutput class is a central element of the generation.
Definition: generatorinputoutput.h:41
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:75
void AddSpecificCellToGenerate(int posx, int posy)
If at least one specific cell is added, the generation will only generate these cells.
KyResult Generate(const char *forcedOutputBaseDir=0, const char *forcedRelativeOutputDir=0)
Generates NavData NavGenProj.
The GeneratorRunOptions class contains configuration parameters that control the way in which the Gen...
Definition: generatorrunoptions.h:49
void SetConfig(const GeneratorParameters &params, const GeneratorRunOptions &runOptions, const CoordSystem &coordSystem)
Sets up the NavGenProjConfig that will be used when generating NavData from this NavGenProj.
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:36
void AddSeedPoint(float x, float y, float z)
Add a seed point to the navGenProj.
void SetOutputDir(const char *outputBaseDir, const char *relativeOutputDir)
Sets the outputDir, with a base path and a relative path, i.e where the Kaim::Generator outputs are w...
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
void Clear()
Clears all information maintained by this object.
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
Definition: mirroredobjproducer.h:24