1 // Copyright (C) 2009-2012 Gaz Davidson
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_PLY_MESH_FILE_LOADER_H_INCLUDED__
\r
6 #define __C_PLY_MESH_FILE_LOADER_H_INCLUDED__
\r
8 #include "IMeshLoader.h"
\r
9 #include "ISceneManager.h"
\r
10 #include "CDynamicMeshBuffer.h"
\r
17 enum E_PLY_PROPERTY_TYPE
\r
28 //! Meshloader capable of loading obj meshes.
\r
29 class CPLYMeshFileLoader : public IMeshLoader
\r
34 CPLYMeshFileLoader(scene::ISceneManager* smgr);
\r
37 virtual ~CPLYMeshFileLoader();
\r
39 //! returns true if the file maybe is able to be loaded by this class
\r
40 //! based on the file extension (e.g. ".ply")
\r
41 virtual bool isALoadableFileExtension(const io::path& filename) const _IRR_OVERRIDE_;
\r
43 //! creates/loads an animated mesh from the file.
\r
44 virtual IAnimatedMesh* createMesh(io::IReadFile* file) _IRR_OVERRIDE_;
\r
51 E_PLY_PROPERTY_TYPE Type;
\r
59 struct SPLYListProperty
\r
61 E_PLY_PROPERTY_TYPE CountType;
\r
62 E_PLY_PROPERTY_TYPE ItemType;
\r
67 inline u32 size() const
\r
76 case EPLYPT_FLOAT32:
\r
78 case EPLYPT_FLOAT64:
\r
81 case EPLYPT_UNKNOWN:
\r
87 inline bool isFloat() const
\r
91 case EPLYPT_FLOAT32:
\r
92 case EPLYPT_FLOAT64:
\r
98 case EPLYPT_UNKNOWN:
\r
107 // name of the element. We only want "vertex" and "face" elements
\r
108 // but we have to parse the others anyway.
\r
109 core::stringc Name;
\r
110 // The number of elements in the file
\r
112 // Properties of this element
\r
113 core::array<SPLYProperty> Properties;
\r
114 // in binary files, true if this is a fixed size
\r
116 // known size in bytes, 0 if unknown
\r
120 bool allocateBuffer();
\r
124 E_PLY_PROPERTY_TYPE getPropertyType(const c8* typeString) const;
\r
126 bool readVertex(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb);
\r
127 bool readFace(const SPLYElement &Element, scene::CDynamicMeshBuffer* mb);
\r
128 void skipElement(const SPLYElement &Element);
\r
129 void skipProperty(const SPLYProperty &Property);
\r
130 f32 getFloat(E_PLY_PROPERTY_TYPE t);
\r
131 u32 getInt(E_PLY_PROPERTY_TYPE t);
\r
132 void moveForward(u32 bytes);
\r
134 core::array<SPLYElement*> ElementList;
\r
136 scene::ISceneManager* SceneManager;
\r
137 io::IReadFile *File;
\r
139 bool IsBinaryFile, IsWrongEndian, EndOfFile;
\r
141 c8 *StartPointer, *EndPointer, *LineEndPointer;
\r
144 } // end namespace scene
\r
145 } // end namespace irr
\r