gwnavgeneration/utils/mirroredobjproducer.h Source File

mirroredobjproducer.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 #ifndef LabEngine_ProceduralGeometryClonerProducer_H
9 #define LabEngine_ProceduralGeometryClonerProducer_H
10 
11 
15 
21 
22 
23 
24 namespace LabEngine
25 {
26 
27 class MirroredObjSectorUserData : public Kaim::GeneratorSectorRefCountedUserData
28 {
29 public:
30  static const char* GetStaticType() { return "FROM_MIRRORED_OBJ"; }
31  virtual const char* GetType() const { return GetStaticType(); }
32 
33  MirroredObjSectorUserData() {}
34  MirroredObjSectorUserData(KyInt32 x, KyInt32 y) : m_sectorPosInGrid(x, y) {}
35 
36 public:
37  Kaim::Vec2i m_sectorPosInGrid;
38 };
39 
40 
44 class MirroredOBJProducer : public Kaim::GeneratorInputProducer
45 {
46 public:
47  class Config
48  {
49  public:
50  Config() : m_desiredWorldSizeInMeters(0.0f), m_useMultipleSector(false) {}
51 
52  public:
53  Kaim::String m_objFileName;
54  KyFloat32 m_desiredWorldSizeInMeters;
56  Kaim::GeneratorParameters m_generatorParams;
57  bool m_useMultipleSector;
58  };
59 
61 
62 public:
63  KyResult Initialize(const Config& config);
64  void SetDefaultNavTag(const Kaim::DynamicNavTag& defaultNavTag) { m_defaultNavTag = defaultNavTag; }
65 
66  // ------------------------ query the grid ------------------------
67  Kaim::CellBox GetSectorCellBox(KyUInt32 x, KyUInt32 y);
68  KyUInt32 GetNbSectorAlongX() { return (m_useMultipleSector ? m_nbInstanceAlongX : 1); }
69  KyUInt32 GetNbSectorAlongY() { return (m_useMultipleSector ? m_nbInstanceAlongY : 1); }
70  KyUInt32 GetSectorCount() { return (m_useMultipleSector ? m_nbInstanceAlongX * m_nbInstanceAlongY : 1); }
71 
72  // ------------------------ seeds and tagVolume setup ------------------------
73  void AddSeedPoint(const Kaim::Vec3f& seedpoint) { m_seedPoints.PushBack(seedpoint); }
74 
75  void AddSeedPointInClientCoordinates(const Kaim::Vec3f& client_seedpoint) { m_seedPoints.PushBack(m_objCoordSystem.ClientToNavigation_Pos(client_seedpoint)); }
76 
77  void AddClientInputTagVolume(const Kaim::ClientInputTagVolume& tagVolume) { m_tagVolumes.PushBack(tagVolume); }
78 
79  // ------------------------ Produce inputs ------------------------
80  virtual KyResult Produce(const Kaim::GeneratorSector& sector, Kaim::ClientInputConsumer& inputConsumer);
81 
82 private:
83  Kaim::Vec3f GetTranslationVector(const Kaim::Vec2i& instancePos);
84  void MirrorPosX(Kaim::Vec3f& pos) { pos.x = 2.0f * m_mirrorAxisX - pos.x; }
85  void MirrorPosY(Kaim::Vec3f& pos) { pos.y = 2.0f * m_mirrorAxisY - pos.y; }
86  KyResult ProduceMirroredInstance(Kaim::ClientInputConsumer& inputConsumer, KyUInt32 xIndex, KyUInt32 yIndex);
87 
88 private:
89  Kaim::DynamicNavTag m_defaultNavTag;
91 
92  Kaim::String m_objFileName;
93  Kaim::ObjFileReader m_objFileReader;
94 
95  Kaim::Box3f m_objBBox;
96  KyFloat32 m_mirrorAxisX;
97  KyFloat32 m_mirrorAxisY;
98  KyUInt32 m_nbInstanceAlongX;
99  KyUInt32 m_nbInstanceAlongY;
100  KyFloat32 m_cellSize;
101 
102  bool m_useMultipleSector;
103 
105  Kaim::KyArray<Kaim::Vec3f> m_seedPoints;
106 };
107 
108 }
110 #endif
The ClientInputConsumer class is one of the primary components of the NavData generation system...
Definition: clientinputconsumer.h:67
This class represents a two-dimensional axis-aligned bounding box whose dimensions are stored using 3...
Definition: box2i.h:119
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
This class maintains the mapping between the system of coordinate axes used internally within the gam...
Definition: coordsystem.h:144
The MirroredOBJProducer class is a concrete implementation of GeneratorInputProducer that can read th...
Definition: mirroredobjproducer.h:48
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
A basic parser of .obj files in text format able to read triangles.
Definition: objfilereader.h:25
KyFloat32 y
The size of the vector along the Y axis.
Definition: vec3f.h:228
This class represents a three-dimensional axis-aligned bounding box whose dimensions are stored using...
Definition: box3f.h:25
KyFloat32 x
The size of the vector along the X axis.
Definition: vec3f.h:227
The GeneratorSector class provides a definition for a single sector to be treated by the Generator...
Definition: generatorsector.h:46
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Base class for the optional m_refCountedUserData that allows to refCount your user data...
Definition: generatorsector.h:29
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:75
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:36
Kaim::DynamicNavTag m_defaultNavTag
The default NavTag that will be applied to all triangles.
Definition: mirroredobjproducer.h:109
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
Represents a volume using a two-dimensional polyline extruded vertically along the "up" axis associat...
Definition: clientinputtagvolume.h:30
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
virtual KyResult Produce(const Kaim::GeneratorSector &sector, Kaim::ClientInputConsumer &inputConsumer)
Called by the NavData generation system to retrieve the geometry associated to the sector...
Definition: mirroredobjproducer.h:24
Kaim::CoordSystem m_objCoordSystem
defines the CoordSystem of the obj files
Definition: mirroredobjproducer.h:110