AGX Dynamics  2.37.2.0
MeshReader.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/Referenced.h>
20 #include <agx/Vector.h>
21 #include <agx/agxPhysics_export.h>
22 #include <string>
23 #include <agx/Vec3.h>
24 #include <agx/agx_vector_types.h>
25 #include <agxIO/FileSystem.h>
26 
27 namespace agxIO
28 {
33  {
34  enum FileType {
35  UNDEFINED = 0,
36  OBJ,
37  SHL,
38  FBX,
40  DAE,
43  ASE,
45  GLTF,
46  XGL,
47  ZGL,
48  PLY,
49  DXF,
50  LWO,
51  LWS,
52  LXO,
53  STL,
54  X,
55  AC,
56  MS3D,
57  SCN,
58  XML,
60  IRR,
61  MDL,
62  MD2,
63  MD3,
64  PK3,
65  MD5,
66  SMD,
67  M3,
69  Q3D,
70  OFF,
71  TER,
72  IFC,
74  };
75  };
76 
83  {
84  public:
85 
86  MeshReader();
87 
92  virtual size_t readFile( const agx::String& filename );
93 
98  virtual size_t readString( const agx::String& mesh, FileExtension::FileType fet );
99 
104  virtual size_t readStream( std::istream& stream, FileExtension::FileType fet );
105 
111  const agx::Vec3Vector& getVertices() const;
112 
118  const agx::UInt32Vector& getIndices() const;
119 
125  const agx::Vec3Vector& getNormals() const;
126 
132  const agx::Vec2Vector& getTextureCoordinates() const;
133 
139  size_t getNumTriangles() const;
140 
141 
147  static FileExtension::FileType getFileExtensionType( const agx::String& fileName);
148 
154  static agx::String getFileExtension( FileExtension::FileType type );
155 
156  protected:
157 
158 
163  size_t readShlStream( std::istream& stream );
164 
168  void clear();
169 
170  virtual ~MeshReader() {}
171 
176 
178  };
179 
181  {
182  return m_vertices;
183  }
184 
186  {
187  return m_indices;
188  }
189 
191  {
192  return m_normals;
193  }
194 
196  {
197  return m_texCoordinates;
198  }
199 
200 
201  inline size_t MeshReader::getNumTriangles() const
202  {
203  return m_indices.size() / 3;
204  }
205 
206 
207 } // namespace agxIO
AGXTERRAIN_EXPORT void clear()
Wavefront OBJ.
Definition: MeshReader.h:36
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:41
Industry Foundation Classes (IFC/Step)
Definition: MeshReader.h:72
Support mesh file formats.
Definition: MeshReader.h:32
Shell data file.
Definition: MeshReader.h:37
#define AGXPHYSICS_EXPORT
agx::Vec3Vector m_vertices
Definition: MeshReader.h:172
virtual ~MeshReader()
Definition: MeshReader.h:170
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Irrlicht Scene.
Definition: MeshReader.h:60
agx::Vec2Vector m_texCoordinates
Definition: MeshReader.h:175
void AGXCORE_EXPORT readFile(agx::String &result, const agx::String &filePath)
LightWave Scene.
Definition: MeshReader.h:51
Open Game Engine Exchange(.ogex)
Definition: MeshReader.h:73
const agx::Vec3Vector & getNormals() const
Get normals from previously read mesh file.
Definition: MeshReader.h:190
const agx::Vec2Vector & getTextureCoordinates() const
Get texture coordinates from previously read mesh file.
Definition: MeshReader.h:195
Filmbox AutoDesk.
Definition: MeshReader.h:38
Base class providing referencing counted objects.
Definition: Referenced.h:119
Quake III Map/BSP.
Definition: MeshReader.h:64
Starcraft II M3.
Definition: MeshReader.h:67
Stanford Polygon Library.
Definition: MeshReader.h:48
const agx::Vec3Vector & getVertices() const
Get vertices from previously read mesh file.
Definition: MeshReader.h:180
agx::Vec3Vector m_normals
Definition: MeshReader.h:173
const agx::UInt32Vector & getIndices() const
Get indices from previously read mesh file.
Definition: MeshReader.h:185
Quake III Mesh.
Definition: MeshReader.h:63
static agx::StringVector m_extensions
Definition: MeshReader.h:177
Object File Format.
Definition: MeshReader.h:70
Binary GL Transmission format.
Definition: MeshReader.h:44
Class for reading a mesh object from file and extracting vertices, normals and indices for collision ...
Definition: MeshReader.h:82
agx::UInt32Vector m_indices
Definition: MeshReader.h:174
Stereolithography.
Definition: MeshReader.h:53
Terragen Terrain.
Definition: MeshReader.h:71
size_t getNumTriangles() const
Get number of triangles from previously read mesh file.
Definition: MeshReader.h:201
Ascii GL Transmission format.
Definition: MeshReader.h:45
AssImp reader/writer.
Definition: MeshReader.h:39