Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreMeshSerializerImpl.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: 12.9 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 __MeshSerializerImpl_H__
30#define __MeshSerializerImpl_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreString.h"
34#include "OgreSerializer.h"
35#include "OgreMaterial.h"
36#include "OgreMesh.h"
37#include "OgreEdgeListBuilder.h"
38
39namespace Ogre {
40       
41        class MeshSerializerListener;
42    class LodStrategy;
43
44        /** \addtogroup Core
45        *  @{
46        */
47        /** \addtogroup Resources
48        *  @{
49        */
50        /** Internal implementation of Mesh reading / writing for the latest version of the
51    .mesh format.
52    @remarks
53    In order to maintain compatibility with older versions of the .mesh format, there
54    will be alternative subclasses of this class to load older versions, whilst this class
55    will remain to load the latest version.
56
57         @note
58                This mesh format was used from Ogre v1.8.
59
60    */
61    class _OgrePrivate MeshSerializerImpl : public Serializer
62    {
63    public:
64        MeshSerializerImpl();
65        virtual ~MeshSerializerImpl();
66        /** Exports a mesh to the file specified.
67        @remarks
68        This method takes an externally created Mesh object, and exports both it
69        and optionally the Materials it uses to a .mesh file.
70        @param pMesh Pointer to the Mesh to export
71        @param stream The destination stream
72                @param endianMode The endian mode for the written file
73        */
74        void exportMesh(const Mesh* pMesh, DataStreamPtr stream,
75                        Endian endianMode = ENDIAN_NATIVE);
76
77        /** Imports Mesh and (optionally) Material data from a .mesh file DataStream.
78        @remarks
79        This method imports data from a DataStream opened from a .mesh file and places it's
80        contents into the Mesh object which is passed in.
81        @param stream The DataStream holding the .mesh data. Must be initialised (pos at the start of the buffer).
82        @param pDest Pointer to the Mesh object which will receive the data. Should be blank already.
83        */
84        void importMesh(DataStreamPtr& stream, Mesh* pDest, MeshSerializerListener *listener);
85
86    protected:
87
88        // Internal methods
89        virtual void writeSubMeshNameTable(const Mesh* pMesh);
90        virtual void writeMesh(const Mesh* pMesh);
91        virtual void writeSubMesh(const SubMesh* s);
92        virtual void writeSubMeshOperation(const SubMesh* s);
93        virtual void writeSubMeshTextureAliases(const SubMesh* s);
94        virtual void writeGeometry(const VertexData* pGeom);
95        virtual void writeSkeletonLink(const String& skelName);
96        virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign);
97        virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
98        virtual void writeLodInfo(const Mesh* pMesh);
99        virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
100        virtual void writeLodUsageManual(const MeshLodUsage& usage);
101        virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum);
102        virtual void writeBoundsInfo(const Mesh* pMesh);
103        virtual void writeEdgeList(const Mesh* pMesh);
104                virtual void writeAnimations(const Mesh* pMesh);
105                virtual void writeAnimation(const Animation* anim);
106                virtual void writePoses(const Mesh* pMesh);
107                virtual void writePose(const Pose* pose);
108                virtual void writeAnimationTrack(const VertexAnimationTrack* track);
109                virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
110                virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf);
111                virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef);
112        virtual void writeExtremes(const Mesh *pMesh);
113        virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh* s);
114
115        virtual size_t calcMeshSize(const Mesh* pMesh);
116        virtual size_t calcSubMeshSize(const SubMesh* pSub);
117        virtual size_t calcGeometrySize(const VertexData* pGeom);
118        virtual size_t calcSkeletonLinkSize(const String& skelName);
119        virtual size_t calcBoneAssignmentSize(void);
120        virtual size_t calcSubMeshOperationSize(const SubMesh* pSub);
121        virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh);
122        virtual size_t calcEdgeListSize(const Mesh* pMesh);
123        virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual);
124        virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group);
125                virtual size_t calcPosesSize(const Mesh* pMesh);
126                virtual size_t calcPoseSize(const Pose* pose);
127                virtual size_t calcAnimationsSize(const Mesh* pMesh);
128                virtual size_t calcAnimationSize(const Animation* anim);
129                virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track);
130                virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
131                virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf);
132                virtual size_t calcPoseKeyframePoseRefSize(void);
133                virtual size_t calcPoseVertexSize(const Pose* pose);
134        virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub);
135
136
137        virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat);
138        virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh);
139        virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
140        virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
141        virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
142        virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
143        virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
144        virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
145        virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
146        virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
147
148        virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
149        virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh);
150        virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh, 
151            SubMesh* sub);
152        virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
153        virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh, 
154            unsigned short lodNum, MeshLodUsage& usage);
155        virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh, 
156            unsigned short lodNum, MeshLodUsage& usage);
157        virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh);
158        virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh);
159        virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
160                virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh);
161                virtual void readPose(DataStreamPtr& stream, Mesh* pMesh);
162                virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh);
163                virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh);
164                virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim, 
165                        Mesh* pMesh);
166                virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
167                virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
168                virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh);
169
170
171        /// Flip an entire vertex buffer from little endian
172        virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
173        /// Flip an entire vertex buffer to little endian
174        virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
175        /// Flip the endianness of an entire vertex buffer, passed in as a
176        /// pointer to locked or temporary memory
177        virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
178
179
180
181    };
182
183    /** Class for providing backwards-compatibility for loading version 1.41 of the .mesh format.
184         This mesh format was used from Ogre v1.7.
185         */
186    class _OgrePrivate MeshSerializerImpl_v1_41 : public MeshSerializerImpl
187    {
188    public:
189        MeshSerializerImpl_v1_41();
190        ~MeshSerializerImpl_v1_41();
191    protected:
192                void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
193                void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
194                void writePose(const Pose* pose);
195                void readPose(DataStreamPtr& stream, Mesh* pMesh);
196                size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
197                size_t calcPoseSize(const Pose* pose);
198                size_t calcPoseVertexSize(void);
199    };
200
201    /** Class for providing backwards-compatibility for loading version 1.4 of the .mesh format.
202         This mesh format was used from Ogre v1.4.
203         */
204    class _OgrePrivate MeshSerializerImpl_v1_4 : public MeshSerializerImpl_v1_41
205    {
206    public:
207        MeshSerializerImpl_v1_4();
208        ~MeshSerializerImpl_v1_4();
209    protected:
210        virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
211                virtual void writeLodUsageManual(const MeshLodUsage& usage);
212                virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage,
213                                                                        unsigned short lodNum);
214
215        virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
216    };
217
218    /** Class for providing backwards-compatibility for loading version 1.3 of the .mesh format.
219         This mesh format was used from Ogre v1.0 (and some pre-releases)
220         */
221    class _OgrePrivate MeshSerializerImpl_v1_3 : public MeshSerializerImpl_v1_4
222    {
223    public:
224        MeshSerializerImpl_v1_3();
225        ~MeshSerializerImpl_v1_3();
226    protected:
227        virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
228
229        /// Reorganise triangles of the edge list to group by vertex set
230        virtual void reorganiseTriangles(EdgeData* edgeData);
231               
232                virtual void writeEdgeList(const Mesh* pMesh);
233    };
234
235    /** Class for providing backwards-compatibility for loading version 1.2 of the .mesh format.
236         This is a LEGACY FORMAT that pre-dates version Ogre 1.0
237         */
238    class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl_v1_3
239    {
240    public:
241        MeshSerializerImpl_v1_2();
242        ~MeshSerializerImpl_v1_2();
243    protected:
244        virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
245        virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
246        virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream, 
247            Mesh* pMesh, VertexData* dest);
248        virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream, 
249            Mesh* pMesh, VertexData* dest);
250        virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream, 
251            Mesh* pMesh, VertexData* dest);
252        virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, 
253            Mesh* pMesh, VertexData* dest, unsigned short set);
254    };
255
256    /** Class for providing backwards-compatibility for loading version 1.1 of the .mesh format.
257         This is a LEGACY FORMAT that pre-dates version Ogre 1.0
258         */
259    class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2
260    {
261    public:
262        MeshSerializerImpl_v1_1();
263        ~MeshSerializerImpl_v1_1();
264    protected:
265        void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, 
266            Mesh* pMesh, VertexData* dest, unsigned short set);
267    };
268
269        /** @} */
270        /** @} */
271
272}
273
274#endif
Note: See TracBrowser for help on using the repository browser.