Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

imeshloader.h

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef SHEEP_MESHIO_IMESHLOADER_H
00024 #define SHEEP_MESHIO_IMESHLOADER_H
00025 
00026 #include "common/misc/config.h"
00027 
00028 #include <cstdio>
00029 #include <string>
00030 
00031 namespace sheep {
00032 
00033     class IMeshBuilder;
00034     class ProgressMonitor;
00035 
00036     class IMeshLoader {
00037     public:
00038         struct LoadingException {};
00039 
00040         //! A resource file is missing
00041         struct FileNotFoundException : public LoadingException {
00042             FileNotFoundException(const std::string &filename) :
00043                 m_filename(filename) {}
00044 
00045             const std::string m_filename;   //!< The name of the file the loader failed to open.
00046         };
00047 
00048         enum OptionBits {
00049             //! [All] Use default configuration.
00050             DEFAULT_CONFIGURATION_BIT = 0,
00051 
00052             //! [All] Stop loading mesh file if a material or texture file is missing.
00053             //! Default behaviour: loading continues even if a material file or texture
00054             //! file is missing, or if an I/O error occurs when loading a texture file
00055             //! (parse errors in material files are not recoverable). Note that an
00056             //! exception is still thrown if the primary file is missing or broken.
00057             STOP_ON_MISSING_FILE_BIT = 1,
00058 
00059             //! [OBJ] Stop loading mesh file if a degenerate face is encountered.
00060             //! Default behaviour: invalid faces are ignored (they are not inserted
00061             //! into the mesh).
00062             STOP_ON_INVALID_FACE = 2,
00063 
00064             //! [OBJ] Disable polygons triangulation.
00065             //! Default behaviour: polygons are always triangulated.
00066             DISABLE_TRIANGULATION_BIT = 4,
00067 
00068             //! [OBJ] Stop loading mesh file if a triangulation error occurs.
00069             //! Default behaviour: triangulation errors are ignored (polygons which
00070             //! could not be triangulated are not inserted into the mesh).
00071             STOP_ON_TRIANGULATION_ERROR_BIT = 8
00072         };
00073 
00074         virtual ~IMeshLoader() {}
00075 
00076         virtual void Load(
00077             const std::string &filename,
00078             IMeshBuilder &builder,
00079             int option_mask = DEFAULT_CONFIGURATION_BIT,
00080             ProgressMonitor *progmon = 0
00081         ) throw(LoadingException) = 0;
00082     };
00083 
00084     // Common utility functions.
00085     bool LoadImage(const std::string &filename);
00086     bool TryLoadingImage(const std::string &path, const std::string &filename);
00087     FILE *TryOpeningFile(
00088         const std::string &path,
00089         const std::string &filename,
00090         const char *mode);
00091 
00092 #include "imeshloader.inl"
00093 
00094 }
00095 
00096 #endif  // !SHEEP_MESHIO_IMESHLOADER_H

Generated on Tue May 11 01:31:50 2004 for toxic by doxygen 1.3.6