gwnavruntime/utils/objfiletrianglesoup.h Source File

objfiletrianglesoup.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 
14 
15 namespace Kaim
16 {
17 
18 class FileOpenerBase;
19 class CoordSystem;
20 
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
26 public:
28 
30 
31  KyResult ReadObjFile(Ptr<File> objFileToRead);
32 
33  // ---------------------------------- Parsed data ----------------------------------
34  KyUInt32 VerticesCount() const { return m_vertices.GetCount(); }
35  const Vec3f* Vertices() const { return m_vertices.GetDataPtr(); }
36 
37  KyUInt32 IndicesCount() const { return m_indices.GetCount(); }
38  const KyUInt32* Indices() const { return m_indices.GetDataPtr(); }
39 
40  KyUInt32 GetFacesCount() const { return m_facesCount; }
41  KyUInt32 GetFaceMinVertexCount() const { return m_faceMinVertexCount; }
42  KyUInt32 GetFaceMaxVertexCount() const { return m_faceMaxVertexCount; }
43 
44  // ---------------------------------- Misc ----------------------------------
45  void Clear();
46 
48  Box3f ComputeBoundingBox() const;
49  Box3f ComputeBoundingBox(const CoordSystem& coordSystem) const;
50 
51  const char* GetFileName() const { return m_file != nullptr ? m_file->GetFilePath() : nullptr; }
52 
53 private:
54  KyResult ReadPosition(const char* str, Vec3f& pos);
55  KyResult ReadFace(const char* str);
56  KyResult ReadFaceFast(const char* str);
57 
58  KyResult ReadContent();
59 
60  KyResult ReadNextChunk();
61  char* ReadLine();
62 
63 private:
64  char* m_line;
65  char* m_fileIOBuffer;
66  const char* m_endOfReadFileChunk;
67  char* m_currentPosInBuffer;
68  Ptr<File> m_file;
69 
70  const KyUInt32 m_maxLineSize;
71  const KyUInt32 m_maxBufferSize;
72 
73  KyUInt32 m_facesCount;
74  KyUInt32 m_faceMinVertexCount;
75  KyUInt32 m_faceMaxVertexCount;
76 
77  // current file data
78  KyArray<Vec3f> m_vertices;
79  KyArrayPOD<KyUInt32> m_indices;
80  KyArrayPOD<KyUInt32> m_faceIndices;
81 };
82 
83 
84 }
85 
86 
87 
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
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Box3f ComputeBoundingBox() const
Will browse all the vertices extracted from file and compute a bounding box from them.
Definition: objfiletrianglesoup.cpp:400
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
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 Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
3d vector using 32bits floating points.
Definition: vec3f.h:16