# OgreMeshSerializerImpl.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __MeshSerializerImpl_H__
    00030 #define __MeshSerializerImpl_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreString.h"
    00034 #include "OgreSerializer.h"
    00035 #include "OgreMaterial.h"
    00036 #include "OgreMesh.h"
    00037 #include "OgreEdgeListBuilder.h"
    00038
    00039 namespace Ogre {
    00040
    00041     class MeshSerializerListener;
    00042     class LodStrategy;
    00043
    00057     class _OgrePrivate MeshSerializerImpl : public Serializer
    00058     {
    00059     public:
    00060         MeshSerializerImpl();
    00061         virtual ~MeshSerializerImpl();
    00070         void exportMesh(const Mesh* pMesh, const String& filename,
    00071             Endian endianMode = ENDIAN_NATIVE);
    00072
    00080         void importMesh(DataStreamPtr& stream, Mesh* pDest, MeshSerializerListener *listener);
    00081
    00082     protected:
    00083
    00084         // Internal methods
    00085         virtual void writeSubMeshNameTable(const Mesh* pMesh);
    00086         virtual void writeMesh(const Mesh* pMesh);
    00087         virtual void writeSubMesh(const SubMesh* s);
    00088         virtual void writeSubMeshOperation(const SubMesh* s);
    00089         virtual void writeSubMeshTextureAliases(const SubMesh* s);
    00090         virtual void writeGeometry(const VertexData* pGeom);
    00091         virtual void writeSkeletonLink(const String& skelName);
    00092         virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign);
    00093         virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
    00094         virtual void writeLodInfo(const Mesh* pMesh);
    00095         virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
    00096         virtual void writeLodUsageManual(const MeshLodUsage& usage);
    00097         virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum);
    00098         virtual void writeBoundsInfo(const Mesh* pMesh);
    00099         virtual void writeEdgeList(const Mesh* pMesh);
    00100         virtual void writeAnimations(const Mesh* pMesh);
    00101         virtual void writeAnimation(const Animation* anim);
    00102         virtual void writePoses(const Mesh* pMesh);
    00103         virtual void writePose(const Pose* pose);
    00104         virtual void writeAnimationTrack(const VertexAnimationTrack* track);
    00105         virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00106         virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf);
    00107         virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef);
    00108         virtual void writeExtremes(const Mesh *pMesh);
    00109         virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh* s);
    00110
    00111         virtual size_t calcMeshSize(const Mesh* pMesh);
    00112         virtual size_t calcSubMeshSize(const SubMesh* pSub);
    00113         virtual size_t calcGeometrySize(const VertexData* pGeom);
    00114         virtual size_t calcSkeletonLinkSize(const String& skelName);
    00115         virtual size_t calcBoneAssignmentSize(void);
    00116         virtual size_t calcSubMeshOperationSize(const SubMesh* pSub);
    00117         virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh);
    00118         virtual size_t calcEdgeListSize(const Mesh* pMesh);
    00119         virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual);
    00120         virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group);
    00121         virtual size_t calcPosesSize(const Mesh* pMesh);
    00122         virtual size_t calcPoseSize(const Pose* pose);
    00123         virtual size_t calcAnimationsSize(const Mesh* pMesh);
    00124         virtual size_t calcAnimationSize(const Animation* anim);
    00125         virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track);
    00126         virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00127         virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf);
    00128         virtual size_t calcPoseKeyframePoseRefSize(void);
    00129         virtual size_t calcPoseVertexSize(void);
    00130         virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub);
    00131
    00132
    00133         virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat);
    00134         virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh);
    00135         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00136         virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00137         virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00138         virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00139         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00140         virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00141         virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00142         virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00143
    00144         virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00145         virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh);
    00146         virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh,
    00147             SubMesh* sub);
    00148         virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
    00149         virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh,
    00150             unsigned short lodNum, MeshLodUsage& usage);
    00151         virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh,
    00152             unsigned short lodNum, MeshLodUsage& usage);
    00153         virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh);
    00154         virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh);
    00155         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00156         virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh);
    00157         virtual void readPose(DataStreamPtr& stream, Mesh* pMesh);
    00158         virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh);
    00159         virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh);
    00160         virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim,
    00161             Mesh* pMesh);
    00162         virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00163         virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00164         virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh);
    00165
    00166
    00168         virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00170         virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00173         virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00174
    00175
    00176
    00177     };
    00178
    00180     class _OgrePrivate MeshSerializerImpl_v1_4 : public MeshSerializerImpl
    00181     {
    00182     public:
    00183         MeshSerializerImpl_v1_4();
    00184         ~MeshSerializerImpl_v1_4();
    00185     protected:
    00186         virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
    00187         virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
    00188     };
    00189
    00191     class _OgrePrivate MeshSerializerImpl_v1_3 : public MeshSerializerImpl_v1_4
    00192     {
    00193     public:
    00194         MeshSerializerImpl_v1_3();
    00195         ~MeshSerializerImpl_v1_3();
    00196     protected:
    00197         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00198
    00200         virtual void reorganiseTriangles(EdgeData* edgeData);
    00201     };
    00202
    00204     class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl_v1_3
    00205     {
    00206     public:
    00207         MeshSerializerImpl_v1_2();
    00208         ~MeshSerializerImpl_v1_2();
    00209     protected:
    00210         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00211         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00212         virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream,
    00213             Mesh* pMesh, VertexData* dest);
    00214         virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream,
    00215             Mesh* pMesh, VertexData* dest);
    00216         virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream,
    00217             Mesh* pMesh, VertexData* dest);
    00218         virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00219             Mesh* pMesh, VertexData* dest, unsigned short set);
    00220     };
    00221
    00223     class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2
    00224     {
    00225     public:
    00226         MeshSerializerImpl_v1_1();
    00227         ~MeshSerializerImpl_v1_1();
    00228     protected:
    00229         void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00230             Mesh* pMesh, VertexData* dest, unsigned short set);
    00231     };
    00232
    00236 }
    00237
    00238 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun May 8 2011 20:28:08