gwnavgeneration/input/generatorinputproducer.h Source File

generatorinputproducer.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 
12 
13 // a forward declare of ClientInputConsumer would be enough but #include is handy
14 // to avoid the derivation to #include manually <gwnavgeneration/input/clientinputconsumer.h>
15 // and <gwnavgeneration/generator/generatorsector.h>
16 
17 namespace Kaim
18 {
19 
20 class GeneratorSystem;
21 
28 class GeneratorInputProducer : public RefCountBaseNTS<GeneratorInputProducer, MemStat_NavDataGen>
29 {
30 public:
35 
38  KyResult ProduceSectorInputs(const GeneratorSector& sector, ClientInputConsumer& sectorInputConsumer)
39  {
40  for (UPInt i = 0; i < sector.m_additionalTagVolumes.GetSize(); ++i)
41  sectorInputConsumer.ConsumeTagVolume(sector.m_additionalTagVolumes[i]);
42 
43  for (UPInt i = 0; i < sector.m_additionalSeedPoints.GetSize(); ++i)
44  sectorInputConsumer.ConsumeSeedPoint(sector.m_additionalSeedPoints[i]);
45 
46  // HeightFields & IndexedMeshes
47  for (UPInt i = 0; i < sector.m_inputFileNames.GetSize(); ++i)
48  {
49  const String& inputFileName = sector.m_inputFileNames[i];
50  const String ext = inputFileName.GetExtension();
51 
52  if (ext.CompareNoCase(".HeightField") == 0)
53  {
54  if (sectorInputConsumer.ConsumeHeightFieldFile(inputFileName) == KY_ERROR)
55  return KY_ERROR;
56  }
57  else if (ext.CompareNoCase(".IndexedMesh") == 0)
58  {
59  if (sectorInputConsumer.ConsumeIndexedMeshFile(inputFileName) == KY_ERROR)
60  return KY_ERROR;
61  }
62 
63  // Note it may seem reasonable to support .obj file here: if (".obj") { sectorInputConsumer.ConsumeObjFile(inputFileName); }
64  // The problem is that .obj are not always 1unit=1m and zup. And we consider that handling a specific coordSystem should be part
65  // of the Produce() virtual function implementation. This is why one should use ObjFileInputProducer as producer and call its SetupCoordSystem() function.
66  }
67 
68  if (Produce(sector, sectorInputConsumer) == KY_ERROR)
69  return KY_ERROR;
70 
71  return KY_SUCCESS;
72  }
73 
74 private:
78  virtual KyResult Produce(const GeneratorSector& sector, ClientInputConsumer& sectorInputConsumer) = 0;
79 };
80 }
81 
82 
83 
The ClientInputConsumer class is one of the primary components of the NavData generation system...
Definition: clientinputconsumer.h:62
KyArray< ClientInputTagVolume > m_additionalTagVolumes
Optional. Will be fed automatically to the Sector. Sometimes easier than producing TagVolumes in Gene...
Definition: generatorsector.h:129
KyResult ConsumeTagVolume(const ClientInputTagVolume &inputTagVolume)
Provides a single tag volume to the ClientInputConsumer.
Definition: clientinputconsumer.cpp:221
KyArray< Vec3f > m_additionalSeedPoints
Optional. Will be fed automatically to the Sector. Sometimes easier than producing seedPoints in Gene...
Definition: generatorsector.h:128
GeneratorInputProducer()
Constructor for objects of this class.
Definition: generatorinputproducer.h:34
KyArray< String > m_inputFileNames
Optional. To be used in GeneratorInputProducer::ProduceSectorInputs().
Definition: generatorsector.h:127
KyResult ConsumeSeedPoint(const Vec3f &position)
Provides a seed point that identifies a walkable area of the terrain.
Definition: clientinputconsumer.cpp:246
Navigation return code class.
Definition: types.h:108
The GeneratorSector class provides a definition for a single sector to be treated by the Generator...
Definition: generatorsector.h:39
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KY_ERROR
use result == KY_ERROR to test for error
Definition: types.h:132
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:28
virtual KyResult Produce(const GeneratorSector &sector, ClientInputConsumer &sectorInputConsumer)=0
Called by the NavData generation system to retrieve the geometry associated to the sector...
KyResult ProduceSectorInputs(const GeneratorSector &sector, ClientInputConsumer &sectorInputConsumer)
Called by the NavData generation system to retrieve the geometry all the input associated with this s...
Definition: generatorinputproducer.h:38