AGXDynamics  2.35.0.2
MeshReader.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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
agxPhysics_export.h
agxIO::FileExtension::LWS
@ LWS
LightWave Scene.
Definition: MeshReader.h:51
agxIO::FileExtension::MDL
@ MDL
Quake I.
Definition: MeshReader.h:61
agxIO::FileExtension::SCN
@ SCN
TrueSpace.
Definition: MeshReader.h:57
Referenced.h
agxIO::FileExtension::ASE
@ ASE
3ds Max ASE
Definition: MeshReader.h:43
agxIO::MeshReader::m_texCoordinates
agx::Vec2Vector m_texCoordinates
Definition: MeshReader.h:175
FileSystem.h
agxIO::FileExtension::MD3
@ MD3
Quake III Mesh.
Definition: MeshReader.h:63
agxIO::MeshReader::m_indices
agx::UInt32Vector m_indices
Definition: MeshReader.h:174
agxIO::MeshReader::m_vertices
agx::Vec3Vector m_vertices
Definition: MeshReader.h:172
Vector.h
agxIO::FileExtension::UNREAL3D
@ UNREAL3D
Unreal.
Definition: MeshReader.h:68
agx::Vector< AgXString< std::string > >
agxIO::FileExtension::M3
@ M3
Starcraft II M3.
Definition: MeshReader.h:67
agx::Container::size
size_t size() const
Definition: Container.h:134
agxIO::FileExtension::FileType
FileType
Definition: MeshReader.h:34
agxIO::MeshReader::getNormals
const agx::Vec3Vector & getNormals() const
Get normals from previously read mesh file.
Definition: MeshReader.h:190
agxIO::FileExtension::Q3D
@ Q3D
Quick3D.
Definition: MeshReader.h:69
agxIO::FileExtension::PLY
@ PLY
Stanford Polygon Library.
Definition: MeshReader.h:48
agxIO::FileExtension::IRRMESH
@ IRRMESH
Irrlicht Mesh.
Definition: MeshReader.h:59
agxIO::FileExtension
Support mesh file formats.
Definition: MeshReader.h:32
agxIO::FileExtension::ASSIMP
@ ASSIMP
AssImp reader/writer.
Definition: MeshReader.h:39
agxIO::FileExtension::X
@ X
DirectX X.
Definition: MeshReader.h:54
agxIO::FileExtension::GLTF
@ GLTF
Ascii GL Transmission format.
Definition: MeshReader.h:45
agxIO::FileExtension::UNDEFINED
@ UNDEFINED
Definition: MeshReader.h:35
agx::VectorPOD< Vec3 >
agxIO::FileExtension::DAE
@ DAE
Collada.
Definition: MeshReader.h:40
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agxIO::readFile
void AGXCORE_EXPORT readFile(agx::String &result, const agx::String &filePath)
agxIO::FileExtension::OFF
@ OFF
Object File Format.
Definition: MeshReader.h:70
agxIO::FileExtension::MD5
@ MD5
Doom 3.
Definition: MeshReader.h:65
agxIO::FileExtension::IRR
@ IRR
Irrlicht Scene.
Definition: MeshReader.h:60
Vec3.h
agxIO::FileExtension::GLTFB
@ GLTFB
Binary GL Transmission format.
Definition: MeshReader.h:44
agxIO::MeshReader::getNumTriangles
size_t getNumTriangles() const
Get number of triangles from previously read mesh file.
Definition: MeshReader.h:201
agxIO::FileExtension::TER
@ TER
Terragen Terrain.
Definition: MeshReader.h:71
agxIO::FileExtension::PK3
@ PK3
Quake III Map/BSP.
Definition: MeshReader.h:64
agxIO::FileExtension::STL
@ STL
Stereolithography.
Definition: MeshReader.h:53
agxIO::MeshReader::~MeshReader
virtual ~MeshReader()
Definition: MeshReader.h:170
agxIO::FileExtension::SMD
@ SMD
Valve Model.
Definition: MeshReader.h:66
agxIO::FileExtension::MAX3DS
@ MAX3DS
3ds Max 3DS
Definition: MeshReader.h:42
agxIO::MeshReader::getIndices
const agx::UInt32Vector & getIndices() const
Get indices from previously read mesh file.
Definition: MeshReader.h:185
agxIO::FileExtension::BLEND
@ BLEND
Blender 3D.
Definition: MeshReader.h:41
agxIO::MeshReader::getTextureCoordinates
const agx::Vec2Vector & getTextureCoordinates() const
Get texture coordinates from previously read mesh file.
Definition: MeshReader.h:195
agxIO::FileExtension::MS3D
@ MS3D
Milkshape 3D.
Definition: MeshReader.h:56
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
agxIO::FileExtension::SHL
@ SHL
Shell data file.
Definition: MeshReader.h:37
agxIO::FileExtension::AC
@ AC
AC3D.
Definition: MeshReader.h:55
agxIO::FileExtension::DXF
@ DXF
AutoCAD DXF.
Definition: MeshReader.h:49
agxIO::FileExtension::XML
@ XML
Ogre XML.
Definition: MeshReader.h:58
agxIO::FileExtension::IFC
@ IFC
Industry Foundation Classes (IFC/Step)
Definition: MeshReader.h:72
agxIO::FileExtension::LXO
@ LXO
Modo.
Definition: MeshReader.h:52
agx::AgXString< std::string >
agxIO::FileExtension::OGEX
@ OGEX
Open Game Engine Exchange(.ogex)
Definition: MeshReader.h:73
agxIO::FileExtension::OBJ
@ OBJ
Wavefront OBJ.
Definition: MeshReader.h:36
agxIO::FileExtension::XGL
@ XGL
XGL.
Definition: MeshReader.h:46
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
agxIO::MeshReader::getVertices
const agx::Vec3Vector & getVertices() const
Get vertices from previously read mesh file.
Definition: MeshReader.h:180
agxIO::FileExtension::ZGL
@ ZGL
ZGL.
Definition: MeshReader.h:47
agxIO::MeshReader
Class for reading a mesh object from file and extracting vertices, normals and indices for collision ...
Definition: MeshReader.h:82
agxIO
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:41
agxIO::FileExtension::MD2
@ MD2
Quake II.
Definition: MeshReader.h:62
agx_vector_types.h
agxIO::FileExtension::FBX
@ FBX
Filmbox AutoDesk.
Definition: MeshReader.h:38
agxIO::FileExtension::LWO
@ LWO
LightWave.
Definition: MeshReader.h:50
agxIO::MeshReader::m_extensions
static agx::StringVector m_extensions
Definition: MeshReader.h:177
agxIO::MeshReader::m_normals
agx::Vec3Vector m_normals
Definition: MeshReader.h:173