diff options
author | Stijn Buys <ingar@osirion.org> | 2009-08-09 16:34:38 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-08-09 16:34:38 +0000 |
commit | 324f5431245f2a550acddea70ea72770430a19d1 (patch) | |
tree | aa05d127c20f5bb5995a3fdceb915b5280887e4b /src/model/asefile.h | |
parent | b808c0e24cc4a59bd801059147bc9805944bee9a (diff) |
initial .ase support
Diffstat (limited to 'src/model/asefile.h')
-rw-r--r-- | src/model/asefile.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/model/asefile.h b/src/model/asefile.h new file mode 100644 index 0000000..bb731b7 --- /dev/null +++ b/src/model/asefile.h @@ -0,0 +1,90 @@ +/* + model/asefile.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + + +#ifndef __INCLUDED_MODEL_ASEFILE_H__ +#define __INCLUDED_MODEL_ASEFILE_H__ + +#include "math/vector3f.h" +#include "model/model.h" +#include "filesystem/filestream.h" + +#include <string> +#include <map> + +namespace model +{ + +/// class to parse the .ase file structure and load geometry data into a model +class ASEFile +{ +public: + /** + * @brief load a .ase file into a Model + * @param name name of the model to be loaded, without .ase extension or models/ prefix + * If the file can not be read, load() returns the NULL-pointer + */ + static Model *load(std::string const &name); + +private: + + typedef std::map<size_t, math::Vector3f> VertexList; + + ASEFile(std::string const &name); + ~ASEFile(); + + /** + * @brief read *MESH_FACE_LIST + */ + bool read_mesh_face_list(std::istream &is); + + /** + * @brief read *MESH_VERTEX_LIST + */ + bool read_mesh_vertex_list(std::istream &is); + + /** + * @brief read *MESH + */ + bool read_mesh(std::istream &is); + + /** + * @brief read *GEOMOBJECT + */ + bool read_geom(std::istream &is); + + /** + * @brief read the .ase header + */ + bool read_header(std::istream &is); + + /** + * @brief read the .ase file + */ + bool read(); + + inline const std::string &name() const { return asefile_name; } + + inline const bool is_open() const { return asefile_ifs.is_open(); } + + std::string asefile_name; + + filesystem::IFileStream asefile_ifs; + + VertexList ase_vertexlist; + + math::Vector3f ase_maxbbox; + + math::Vector3f ase_minbbox; + + math::Vector3f ase_center; + + Model *model; +}; + +} // namespace model + +#endif // __INCLUDED_MODEL_ASEFILE_H__ |