Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreMeshSerializer.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 7.7 KB
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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28
29#ifndef __MeshSerializer_H__
30#define __MeshSerializer_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreSerializer.h"
34#include "OgreMeshSerializerImpl.h"
35#include "OgreHeaderPrefix.h"
36
37namespace Ogre {
38       
39        class MeshSerializerListener;
40       
41        /// Mesh compatibility versions
42        enum MeshVersion
43        {
44                /// Latest version available
45                MESH_VERSION_LATEST,
46               
47                /// OGRE version v1.8+
48                MESH_VERSION_1_8,
49                /// OGRE version v1.7+
50                MESH_VERSION_1_7,
51                /// OGRE version v1.4+
52                MESH_VERSION_1_4,
53                /// OGRE version v1.0+
54                MESH_VERSION_1_0,
55               
56                /// Legacy versions, DO NOT USE for writing
57                MESH_VERSION_LEGACY
58        };
59
60        /** \addtogroup Core
61        *  @{
62        */
63        /** \addtogroup Resources
64        *  @{
65        */
66        /** Class for serialising mesh data to/from an OGRE .mesh file.
67    @remarks
68        This class allows exporters to write OGRE .mesh files easily, and allows the
69        OGRE engine to import .mesh files into instantiated OGRE Meshes.
70        Note that a .mesh file can include not only the Mesh, but also definitions of
71        any Materials it uses (although this is optional, the .mesh can rely on the
72        Material being loaded from another source, especially useful if you want to
73        take advantage of OGRE's advanced Material properties which may not be available
74        in your modeller).
75    @par
76        To export a Mesh:<OL>
77        <LI>Use the MaterialManager methods to create any dependent Material objects, if you want
78            to export them with the Mesh.</LI>
79        <LI>Create a Mesh object and populate it using it's methods.</LI>
80        <LI>Call the exportMesh method</LI>
81        </OL>
82    @par
83        It's important to realise that this exporter uses OGRE terminology. In this context,
84        'Mesh' means a top-level mesh structure which can actually contain many SubMeshes, each
85        of which has only one Material. Modelling packages may refer to these differently, for
86        example in Milkshape, it says 'Model' instead of 'Mesh' and 'Mesh' instead of 'SubMesh',
87        but the theory is the same.
88    */
89    class _OgreExport MeshSerializer : public Serializer
90    {
91    public:
92        MeshSerializer();
93        virtual ~MeshSerializer();
94
95
96        /** Exports a mesh to the file specified, in the latest format
97        @remarks
98            This method takes an externally created Mesh object, and exports it
99            to a .mesh file in the latest format version available.
100        @param pMesh Pointer to the Mesh to export
101        @param filename The destination filename
102                @param endianMode The endian mode of the written file
103        */
104        void exportMesh(const Mesh* pMesh, const String& filename,
105                        Endian endianMode = ENDIAN_NATIVE);
106
107        /** Exports a mesh to the file specified, in a specific version format.
108                 @remarks
109                 This method takes an externally created Mesh object, and exports it
110                 to a .mesh file in the specified format version. Note that picking a
111                 format version other that the latest will cause some information to be
112                 lost.
113                 @param pMesh Pointer to the Mesh to export
114                 @param filename The destination filename
115                 @param version Mesh version to write
116                 @param endianMode The endian mode of the written file
117                 */
118        void exportMesh(const Mesh* pMesh, const String& filename,
119                                                MeshVersion version,
120                                                Endian endianMode = ENDIAN_NATIVE);
121
122        /** Exports a mesh to the stream specified, in the latest format.
123        @remarks
124                 This method takes an externally created Mesh object, and exports it
125                 to a .mesh file in the latest format version.
126        @param pMesh Pointer to the Mesh to export
127        @param stream Writeable stream
128                @param endianMode The endian mode of the written file
129        */
130        void exportMesh(const Mesh* pMesh, DataStreamPtr stream,
131                        Endian endianMode = ENDIAN_NATIVE);
132
133        /** Exports a mesh to the stream specified, in a specific version format.
134                 @remarks
135                 This method takes an externally created Mesh object, and exports it
136                 to a .mesh file in the specified format version. Note that picking a
137                 format version other that the latest will cause some information to be
138                 lost.
139                 @param pMesh Pointer to the Mesh to export
140                 @param stream Writeable stream
141                 @param version Mesh version to write
142                 @param endianMode The endian mode of the written file
143                 */
144        void exportMesh(const Mesh* pMesh, DataStreamPtr stream,
145                                                MeshVersion version,
146                                                Endian endianMode = ENDIAN_NATIVE);
147       
148                /** Imports Mesh and (optionally) Material data from a .mesh file DataStream.
149        @remarks
150            This method imports data from a DataStream opened from a .mesh file and places it's
151            contents into the Mesh object which is passed in.
152        @param stream The DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer).
153        @param pDest Pointer to the Mesh object which will receive the data. Should be blank already.
154        */
155        void importMesh(DataStreamPtr& stream, Mesh* pDest);
156
157                /// Sets the listener for this serializer
158                void setListener(MeshSerializerListener *listener);
159                /// Returns the current listener
160                MeshSerializerListener *getListener();
161               
162    protected:
163               
164                class MeshVersionData : public SerializerAlloc
165                {
166                public:
167                        MeshVersion version;
168                        String versionString;
169                        MeshSerializerImpl* impl;
170                       
171                        MeshVersionData(MeshVersion _ver, const String& _string, MeshSerializerImpl* _impl)
172                        : version(_ver), versionString(_string), impl(_impl) {}
173                       
174                        ~MeshVersionData() { OGRE_DELETE impl; }
175                       
176                };
177
178        typedef vector<MeshVersionData*>::type MeshVersionDataList;
179        MeshVersionDataList mVersionData;
180
181                MeshSerializerListener *mListener;
182
183    };
184
185        /**
186         @remarks
187                This class allows users to hook into the mesh loading process and
188                modify references within the mesh as they are loading. Material and
189                skeletal references can be processed using this interface which allows
190                finer control over resources.
191        */
192        class MeshSerializerListener
193        {
194        public:
195                virtual ~MeshSerializerListener() {}
196                /// Called to override the loading of the given named material
197                virtual void processMaterialName(Mesh *mesh, String *name) = 0;
198                /// Called to override the reference to a skeleton
199                virtual void processSkeletonName(Mesh *mesh, String *name) = 0;
200                /// Allows to do changes on mesh after it's completely loaded. For example you can generate LOD levels here.
201                virtual void processMeshCompleted(Mesh *mesh) = 0;
202        };
203        /** @} */
204        /** @} */
205}
206
207#include "OgreHeaderSuffix.h"
208
209#endif
Note: See TracBrowser for help on using the repository browser.