# 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-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __MeshSerializerImpl_H__
    00031 #define __MeshSerializerImpl_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreString.h"
    00035 #include "OgreSerializer.h"
    00036 #include "OgreMaterial.h"
    00037 #include "OgreMesh.h"
    00038 #include "OgreEdgeListBuilder.h"
    00039
    00040 namespace Ogre {
    00041
    00042     class MeshSerializerListener;
    00043
    00051     class _OgrePrivate MeshSerializerImpl : public Serializer
    00052     {
    00053     public:
    00054         MeshSerializerImpl();
    00055         virtual ~MeshSerializerImpl();
    00064         void exportMesh(const Mesh* pMesh, const String& filename,
    00065             Endian endianMode = ENDIAN_NATIVE);
    00066
    00074         void importMesh(DataStreamPtr& stream, Mesh* pDest, MeshSerializerListener *listener);
    00075
    00076     protected:
    00077
    00078         // Internal methods
    00079         virtual void writeSubMeshNameTable(const Mesh* pMesh);
    00080         virtual void writeMesh(const Mesh* pMesh);
    00081         virtual void writeSubMesh(const SubMesh* s);
    00082         virtual void writeSubMeshOperation(const SubMesh* s);
    00083         virtual void writeSubMeshTextureAliases(const SubMesh* s);
    00084         virtual void writeGeometry(const VertexData* pGeom);
    00085         virtual void writeSkeletonLink(const String& skelName);
    00086         virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign);
    00087         virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign);
    00088         virtual void writeLodInfo(const Mesh* pMesh);
    00089         virtual void writeLodSummary(unsigned short numLevels, bool manual);
    00090         virtual void writeLodUsageManual(const MeshLodUsage& usage);
    00091         virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum);
    00092         virtual void writeBoundsInfo(const Mesh* pMesh);
    00093         virtual void writeEdgeList(const Mesh* pMesh);
    00094         virtual void writeAnimations(const Mesh* pMesh);
    00095         virtual void writeAnimation(const Animation* anim);
    00096         virtual void writePoses(const Mesh* pMesh);
    00097         virtual void writePose(const Pose* pose);
    00098         virtual void writeAnimationTrack(const VertexAnimationTrack* track);
    00099         virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00100         virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf);
    00101         virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef);
    00102         virtual void writeExtremes(const Mesh *pMesh);
    00103         virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh* s);
    00104
    00105         virtual size_t calcMeshSize(const Mesh* pMesh);
    00106         virtual size_t calcSubMeshSize(const SubMesh* pSub);
    00107         virtual size_t calcGeometrySize(const VertexData* pGeom);
    00108         virtual size_t calcSkeletonLinkSize(const String& skelName);
    00109         virtual size_t calcBoneAssignmentSize(void);
    00110         virtual size_t calcSubMeshOperationSize(const SubMesh* pSub);
    00111         virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh);
    00112         virtual size_t calcEdgeListSize(const Mesh* pMesh);
    00113         virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual);
    00114         virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group);
    00115         virtual size_t calcPosesSize(const Mesh* pMesh);
    00116         virtual size_t calcPoseSize(const Pose* pose);
    00117         virtual size_t calcAnimationsSize(const Mesh* pMesh);
    00118         virtual size_t calcAnimationSize(const Animation* anim);
    00119         virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track);
    00120         virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount);
    00121         virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf);
    00122         virtual size_t calcPoseKeyframePoseRefSize(void);
    00123         virtual size_t calcPoseVertexSize(void);
    00124         virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub);
    00125
    00126
    00127         virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat);
    00128         virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh);
    00129         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00130         virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00131         virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00132         virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub);
    00133         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00134         virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00135         virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00136         virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00137
    00138         virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00139         virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh);
    00140         virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh,
    00141             SubMesh* sub);
    00142         virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh);
    00143         virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh,
    00144             unsigned short lodNum, MeshLodUsage& usage);
    00145         virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh,
    00146             unsigned short lodNum, MeshLodUsage& usage);
    00147         virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh);
    00148         virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh);
    00149         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00150         virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh);
    00151         virtual void readPose(DataStreamPtr& stream, Mesh* pMesh);
    00152         virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh);
    00153         virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh);
    00154         virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim,
    00155             Mesh* pMesh);
    00156         virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00157         virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
    00158         virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh);
    00159
    00160
    00162         virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00164         virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00167         virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
    00168
    00169
    00170
    00171     };
    00172
    00174     class _OgrePrivate MeshSerializerImpl_v1_3 : public MeshSerializerImpl
    00175     {
    00176     public:
    00177         MeshSerializerImpl_v1_3();
    00178         ~MeshSerializerImpl_v1_3();
    00179     protected:
    00180         virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
    00181
    00183         virtual void reorganiseTriangles(EdgeData* edgeData);
    00184     };
    00185
    00187     class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl_v1_3
    00188     {
    00189     public:
    00190         MeshSerializerImpl_v1_2();
    00191         ~MeshSerializerImpl_v1_2();
    00192     protected:
    00193         virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh, MeshSerializerListener *listener);
    00194         virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest);
    00195         virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream,
    00196             Mesh* pMesh, VertexData* dest);
    00197         virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream,
    00198             Mesh* pMesh, VertexData* dest);
    00199         virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream,
    00200             Mesh* pMesh, VertexData* dest);
    00201         virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00202             Mesh* pMesh, VertexData* dest, unsigned short set);
    00203     };
    00204
    00206     class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2
    00207     {
    00208     public:
    00209         MeshSerializerImpl_v1_1();
    00210         ~MeshSerializerImpl_v1_1();
    00211     protected:
    00212         void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
    00213             Mesh* pMesh, VertexData* dest, unsigned short set);
    00214     };
    00215
    00216
    00217 }
    00218
    00219 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:32:18 2009