[3] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
| 8 | Also see acknowledgements in Readme.html |
---|
| 9 | |
---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
| 13 | version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
| 18 | |
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
| 23 | |
---|
| 24 | You may alternatively use this source under the terms of a specific version of |
---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
| 26 | Torus Knot Software Ltd. |
---|
| 27 | ----------------------------------------------------------------------------- |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef __MeshSerializer_H__ |
---|
| 31 | #define __MeshSerializer_H__ |
---|
| 32 | |
---|
| 33 | #include "OgrePrerequisites.h" |
---|
| 34 | #include "OgreMeshSerializerImpl.h" |
---|
| 35 | #include "OgreSerializer.h" |
---|
| 36 | |
---|
| 37 | namespace Ogre { |
---|
| 38 | |
---|
| 39 | /** Class for serialising mesh data to/from an OGRE .mesh file. |
---|
| 40 | @remarks |
---|
| 41 | This class allows exporters to write OGRE .mesh files easily, and allows the |
---|
| 42 | OGRE engine to import .mesh files into instatiated OGRE Meshes. |
---|
| 43 | Note that a .mesh file can include not only the Mesh, but also definitions of |
---|
| 44 | any Materials it uses (although this is optional, the .mesh can rely on the |
---|
| 45 | Material being loaded from another source, especially useful if you want to |
---|
| 46 | take advantage of OGRE's advanced Material properties which may not be available |
---|
| 47 | in your modeller). |
---|
| 48 | @par |
---|
| 49 | To export a Mesh:<OL> |
---|
| 50 | <LI>Use the MaterialManager methods to create any dependent Material objects, if you want |
---|
| 51 | to export them with the Mesh.</LI> |
---|
| 52 | <LI>Create a Mesh object and populate it using it's methods.</LI> |
---|
| 53 | <LI>Call the exportMesh method</LI> |
---|
| 54 | </OL> |
---|
| 55 | @par |
---|
| 56 | It's important to realise that this exporter uses OGRE terminology. In this context, |
---|
| 57 | 'Mesh' means a top-level mesh structure which can actually contain many SubMeshes, each |
---|
| 58 | of which has only one Material. Modelling packages may refer to these differently, for |
---|
| 59 | example in Milkshape, it says 'Model' instead of 'Mesh' and 'Mesh' instead of 'SubMesh', |
---|
| 60 | but the theory is the same. |
---|
| 61 | */ |
---|
| 62 | class _OgreExport MeshSerializer : public Serializer |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | MeshSerializer(); |
---|
| 66 | virtual ~MeshSerializer(); |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /** Exports a mesh to the file specified. |
---|
| 70 | @remarks |
---|
| 71 | This method takes an externally created Mesh object, and exports both it |
---|
| 72 | and optionally the Materials it uses to a .mesh file. |
---|
| 73 | @param pMesh Pointer to the Mesh to export |
---|
| 74 | @param filename The destination filename |
---|
| 75 | @param endianMode The endian mode of the written file |
---|
| 76 | */ |
---|
| 77 | void exportMesh(const Mesh* pMesh, const String& filename, |
---|
| 78 | Endian endianMode = ENDIAN_NATIVE); |
---|
| 79 | |
---|
| 80 | /** Imports Mesh and (optionally) Material data from a .mesh file DataStream. |
---|
| 81 | @remarks |
---|
| 82 | This method imports data from a DataStream opened from a .mesh file and places it's |
---|
| 83 | contents into the Mesh object which is passed in. |
---|
| 84 | @param stream The DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer). |
---|
| 85 | @param pDest Pointer to the Mesh object which will receive the data. Should be blank already. |
---|
| 86 | */ |
---|
| 87 | void importMesh(DataStreamPtr& stream, Mesh* pDest); |
---|
| 88 | protected: |
---|
| 89 | static String msCurrentVersion; |
---|
| 90 | |
---|
| 91 | typedef std::map<String, MeshSerializerImpl* > MeshSerializerImplMap; |
---|
| 92 | MeshSerializerImplMap mImplementations; |
---|
| 93 | |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | #endif |
---|