source: OGRE/trunk/ogrenew/OgreMain/include/OgreMeshSerializer.h @ 692

Revision 692, 4.0 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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