gwnavgeneration/utils/mirroredobjproducer.h Source File

mirroredobjproducer.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 
8 #pragma once
9 
13 
19 
20 
21 namespace LabEngine
22 {
23 
24 class MirroredObjSectorUserData : public Kaim::GeneratorSectorRefCountedUserData
25 {
26 public:
27  static const char* GetStaticType() { return "FROM_MIRRORED_OBJ"; }
28  virtual const char* GetType() const { return GetStaticType(); }
29 
30  MirroredObjSectorUserData() {}
31  MirroredObjSectorUserData(KyInt32 x, KyInt32 y) : m_sectorPosInGrid(x, y) {}
32 
33 public:
34  Kaim::Vec2i m_sectorPosInGrid;
35 };
36 
37 
42 {
43 public:
44  class Config
45  {
46  public:
47  Config() : m_desiredWorldSizeInMeters(0.0f), m_useMultipleSector(false) {}
48 
49  public:
50  Kaim::String m_objFileName;
51  KyFloat32 m_desiredWorldSizeInMeters;
53  Kaim::GeneratorParameters m_generatorParams;
54  bool m_useMultipleSector;
55  };
56 
58 
59 public:
60  KyResult Initialize(const Config& config);
61  void SetDefaultNavTag(const Kaim::DynamicNavTag& defaultNavTag) { m_defaultNavTag = defaultNavTag; }
62 
63  // ------------------------ query the grid ------------------------
64  Kaim::CellBox GetSectorCellBox(KyUInt32 x, KyUInt32 y);
65  KyUInt32 GetNbSectorAlongX() { return (m_useMultipleSector ? m_nbInstanceAlongX : 1); }
66  KyUInt32 GetNbSectorAlongY() { return (m_useMultipleSector ? m_nbInstanceAlongY : 1); }
67  KyUInt32 GetSectorCount() { return (m_useMultipleSector ? m_nbInstanceAlongX * m_nbInstanceAlongY : 1); }
68 
69  // ------------------------ seeds and tagVolume setup ------------------------
70  void AddSeedPoint(const Kaim::Vec3f& seedpoint) { m_seedPoints.PushBack(seedpoint); }
71 
72  void AddSeedPointInClientCoordinates(const Kaim::Vec3f& client_seedpoint) { m_seedPoints.PushBack(m_objCoordSystem.ClientToNavigation_Pos(client_seedpoint)); }
73 
74  void AddClientInputTagVolume(const Kaim::ClientInputTagVolume& tagVolume) { m_tagVolumes.PushBack(tagVolume); }
75 
76  // ------------------------ Produce inputs ------------------------
77  virtual KyResult Produce(const Kaim::GeneratorSector& sector, Kaim::ClientInputConsumer& inputConsumer);
78 
79 private:
80  Kaim::Vec3f GetTranslationVector(const Kaim::Vec2i& instancePos);
81  void MirrorPosX(Kaim::Vec3f& pos) { pos.x = 2.0f * m_mirrorAxisX - pos.x; }
82  void MirrorPosY(Kaim::Vec3f& pos) { pos.y = 2.0f * m_mirrorAxisY - pos.y; }
83  KyResult ProduceMirroredInstance(Kaim::ClientInputConsumer& inputConsumer, KyUInt32 xIndex, KyUInt32 yIndex);
84 
85 private:
86  Kaim::DynamicNavTag m_defaultNavTag;
88 
89  Kaim::String m_objFileName;
90  Kaim::ObjFileTriangleSoup m_objFileReader;
91 
92  Kaim::Box3f m_objBBox;
93  KyFloat32 m_mirrorAxisX;
94  KyFloat32 m_mirrorAxisY;
95  KyUInt32 m_nbInstanceAlongX;
96  KyUInt32 m_nbInstanceAlongY;
97  KyFloat32 m_cellSize;
98 
99  bool m_useMultipleSector;
100 
102  Kaim::KyArray<Kaim::Vec3f> m_seedPoints;
103 };
104 
105 }
106 
The ClientInputConsumer class is one of the primary components of the NavData generation system...
Definition: clientinputconsumer.h:62
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
This class maintains the mapping between the system of coordinate axes used by the client game engine...
Definition: coordsystem.h:119
The MirroredOBJProducer class is a concrete implementation of GeneratorInputProducer that can read th...
Definition: mirroredobjproducer.h:41
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.cpp:86
3d axis aligned box of 32bits floating points
Definition: box3f.h:16
A basic parser of .obj files in text format able to read triangles.
Definition: objfiletrianglesoup.h:22
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
2d vector using KyInt32
Definition: vec2i.h:18
Base class for the optional m_refCountedUserData that allows to refCount your user data...
Definition: generatorsector.h:25
The GeneratorParameters class contains configuration parameters that control the characteristics of t...
Definition: generatorparameters.h:67
std::int32_t KyInt32
int32_t
Definition: types.h:24
The GeneratorInputProducer is an abstract base class for an object invoked by the NavData generation ...
Definition: generatorinputproducer.h:28
Kaim::DynamicNavTag m_defaultNavTag
The default NavTag that will be applied to all triangles.
Definition: mirroredobjproducer.h:86
void ClientToNavigation_Pos(const Vec3f &clientPos, Vec3f &navigationPos) const
Convert positions or any other vectors which length have to be scaled when converted.
Definition: coordsystem.inl:78
Represents a volume using a two-dimensional polyline extruded vertically along the "up" axis associat...
Definition: clientinputtagvolume.h:25
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
Definition: mirroredobjproducer.cpp:12
Kaim::CoordSystem m_objCoordSystem
defines the CoordSystem of the obj files
Definition: mirroredobjproducer.h:87