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-2012 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
    00061     class _OgrePrivate MeshSerializerImpl : public Serializer
    00062     {
    00063     public:
    00064         MeshSerializerImpl();
    00065         virtual ~MeshSerializerImpl();
    00074         void exportMesh(const Mesh* pMesh, DataStreamPtr stream,
    00075             Endian endianMode = ENDIAN_NATIVE);
    00076
    00084         void importMesh(DataStreamPtr& stream, Mesh* pDest, MeshSerializerListener *listener);
    00085
    00086     protected:
    00087
    00088         // Internal methods
    00089         virtual void writeSubMeshNameTable(const Mesh* pMesh);
    00090         virtual void writeMesh(const Mesh* pMesh);
    00091         virtual void writeSubMesh(const SubMesh* s);
    00092         virtual void writeSubMeshOperation(const SubMesh* s);
    00093         virtual void writeSubMeshTextureAliases(const SubMesh* s);
    00094         virtual void writeGeometry(const VertexData* pGeom);
    00095         virtual void writeSkeletonLink(const String& skelName);
    00096         virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign);
    00097         virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
    00098         virtual void writeLodInfo(const Mesh* pMesh);
    00099         virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
    00100         virtual void writeLodUsageManual(const MeshLodUsage& usage);
    00101         virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum);
    00102         virtual void writeBoundsInfo(const Mesh* pMesh);
    00103         virtual void writeEdgeList(const Mesh* pMesh);
    00104         virtual void writeAnimations(const Mesh* pMesh);
    00105         virtual void writeAnimation(const Animation* anim);
    00106         virtual void writePoses(const Mesh* pMesh);
    00107         virtual void writePose(const Pose* pose);
    00108         virtual void writeAnimationTrack(const VertexAnimationTrack* track);
    00109         virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00110         virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf);
    00111         virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef);
    00112         virtual void writeExtremes(const Mesh *pMesh);
    00113         virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh* s);
    00114
    00115         virtual size_t calcMeshSize(const Mesh* pMesh);
    00116         virtual size_t calcSubMeshSize(const SubMesh* pSub);
    00117         virtual size_t calcGeometrySize(const VertexData* pGeom);
    00118         virtual size_t calcSkeletonLinkSize(const String& skelName);
    00119         virtual size_t calcBoneAssignmentSize(void);
    00120         virtual size_t calcSubMeshOperationSize(const SubMesh* pSub);
    00121         virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh);
    00122         virtual size_t calcEdgeListSize(const Mesh* pMesh);
    00123         virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual);
    00124         virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group);
    00125         virtual size_t calcPosesSize(const Mesh* pMesh);
    00126         virtual size_t calcPoseSize(const Pose* pose);
    00127         virtual size_t calcAnimationsSize(const Mesh* pMesh);
    00128         virtual size_t calcAnimationSize(const Animation* anim);
    00129         virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track);
    00130         virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00131         virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf);
    00132         virtual size_t calcPoseKeyframePoseRefSize(void);
    00133         virtual size_t calcPoseVertexSize(const Pose* pose);
    00134         virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub);
    00135
    00136
    00137         virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat);
    00138         virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh);
    00139         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00140         virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00141         virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00142         virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00143         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00144         virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00145         virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00146         virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00147
    00148         virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00149         virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh);
    00150         virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh,
    00151             SubMesh* sub);
    00152         virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
    00153         virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh,
    00154             unsigned short lodNum, MeshLodUsage& usage);
    00155         virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh,
    00156             unsigned short lodNum, MeshLodUsage& usage);
    00157         virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh);
    00158         virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh);
    00159         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00160         virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh);
    00161         virtual void readPose(DataStreamPtr& stream, Mesh* pMesh);
    00162         virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh);
    00163         virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh);
    00164         virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim,
    00165             Mesh* pMesh);
    00166         virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00167         virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00168         virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh);
    00169
    00170
    00172         virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00174         virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00177         virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00178
    00179
    00180
    00181     };
    00182
    00186     class _OgrePrivate MeshSerializerImpl_v1_41 : public MeshSerializerImpl
    00187     {
    00188     public:
    00189         MeshSerializerImpl_v1_41();
    00190         ~MeshSerializerImpl_v1_41();
    00191     protected:
    00192         void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00193         void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00194         void writePose(const Pose* pose);
    00195         void readPose(DataStreamPtr& stream, Mesh* pMesh);
    00196         size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00197         size_t calcPoseSize(const Pose* pose);
    00198         size_t calcPoseVertexSize(void);
    00199     };
    00200
    00204     class _OgrePrivate MeshSerializerImpl_v1_4 : public MeshSerializerImpl_v1_41
    00205     {
    00206     public:
    00207         MeshSerializerImpl_v1_4();
    00208         ~MeshSerializerImpl_v1_4();
    00209     protected:
    00210         virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy);
    00211         virtual void writeLodUsageManual(const MeshLodUsage& usage);
    00212         virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage,
    00213                                     unsigned short lodNum);
    00214
    00215         virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
    00216     };
    00217
    00221     class _OgrePrivate MeshSerializerImpl_v1_3 : public MeshSerializerImpl_v1_4
    00222     {
    00223     public:
    00224         MeshSerializerImpl_v1_3();
    00225         ~MeshSerializerImpl_v1_3();
    00226     protected:
    00227         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00228
    00230         virtual void reorganiseTriangles(EdgeData* edgeData);
    00231
    00232         virtual void writeEdgeList(const Mesh* pMesh);
    00233     };
    00234
    00238     class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl_v1_3
    00239     {
    00240     public:
    00241         MeshSerializerImpl_v1_2();
    00242         ~MeshSerializerImpl_v1_2();
    00243     protected:
    00244         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00245         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00246         virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream,
    00247             Mesh* pMesh, VertexData* dest);
    00248         virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream,
    00249             Mesh* pMesh, VertexData* dest);
    00250         virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream,
    00251             Mesh* pMesh, VertexData* dest);
    00252         virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00253             Mesh* pMesh, VertexData* dest, unsigned short set);
    00254     };
    00255
    00259     class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2
    00260     {
    00261     public:
    00262         MeshSerializerImpl_v1_1();
    00263         ~MeshSerializerImpl_v1_1();
    00264     protected:
    00265         void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00266             Mesh* pMesh, VertexData* dest, unsigned short set);
    00267     };
    00268
    00272 }
    00273
    00274 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:22