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-2005 The OGRE Team 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 */ 00025 00026 #ifndef __MeshSerializerImpl_H__ 00027 #define __MeshSerializerImpl_H__ 00028 00029 #include "OgrePrerequisites.h" 00030 #include "OgreString.h" 00031 #include "OgreSerializer.h" 00032 #include "OgreMaterial.h" 00033 #include "OgreMesh.h" 00034 #include "OgreEdgeListBuilder.h" 00035 00036 namespace Ogre { 00037 00038 00046 class _OgrePrivate MeshSerializerImpl : public Serializer 00047 { 00048 public: 00049 MeshSerializerImpl(); 00050 virtual ~MeshSerializerImpl(); 00059 void exportMesh(const Mesh* pMesh, const String& filename, 00060 Endian endianMode = ENDIAN_NATIVE); 00061 00069 void importMesh(DataStreamPtr& stream, Mesh* pDest); 00070 00071 protected: 00072 00073 bool mIsSkeletallyAnimated; 00074 00075 // Internal methods 00076 virtual void writeSubMeshNameTable(const Mesh* pMesh); 00077 virtual void writeMesh(const Mesh* pMesh); 00078 virtual void writeSubMesh(const SubMesh* s); 00079 virtual void writeSubMeshOperation(const SubMesh* s); 00080 virtual void writeSubMeshTextureAliases(const SubMesh* s); 00081 virtual void writeGeometry(const VertexData* pGeom); 00082 virtual void writeSkeletonLink(const String& skelName); 00083 virtual void writeMeshBoneAssignment(const VertexBoneAssignment& assign); 00084 virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment& assign); 00085 virtual void writeLodInfo(const Mesh* pMesh); 00086 virtual void writeLodSummary(unsigned short numLevels, bool manual); 00087 virtual void writeLodUsageManual(const MeshLodUsage& usage); 00088 virtual void writeLodUsageGenerated(const Mesh* pMesh, const MeshLodUsage& usage, unsigned short lodNum); 00089 virtual void writeBoundsInfo(const Mesh* pMesh); 00090 virtual void writeEdgeList(const Mesh* pMesh); 00091 virtual void writeAnimations(const Mesh* pMesh); 00092 virtual void writeAnimation(const Animation* anim); 00093 virtual void writePoses(const Mesh* pMesh); 00094 virtual void writePose(const Pose* pose); 00095 virtual void writeAnimationTrack(const VertexAnimationTrack* track); 00096 virtual void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount); 00097 virtual void writePoseKeyframe(const VertexPoseKeyFrame* kf); 00098 virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef); 00099 00100 virtual size_t calcMeshSize(const Mesh* pMesh); 00101 virtual size_t calcSubMeshSize(const SubMesh* pSub); 00102 virtual size_t calcGeometrySize(const VertexData* pGeom); 00103 virtual size_t calcSkeletonLinkSize(const String& skelName); 00104 virtual size_t calcBoneAssignmentSize(void); 00105 virtual size_t calcSubMeshOperationSize(const SubMesh* pSub); 00106 virtual size_t calcSubMeshNameTableSize(const Mesh* pMesh); 00107 virtual size_t calcEdgeListSize(const Mesh* pMesh); 00108 virtual size_t calcEdgeListLodSize(const EdgeData* data, bool isManual); 00109 virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup& group); 00110 virtual size_t calcPosesSize(const Mesh* pMesh); 00111 virtual size_t calcPoseSize(const Pose* pose); 00112 virtual size_t calcAnimationsSize(const Mesh* pMesh); 00113 virtual size_t calcAnimationSize(const Animation* anim); 00114 virtual size_t calcAnimationTrackSize(const VertexAnimationTrack* track); 00115 virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame* kf, size_t vertexCount); 00116 virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame* kf); 00117 virtual size_t calcPoseKeyframePoseRefSize(void); 00118 virtual size_t calcPoseVertexSize(void); 00119 virtual size_t calcSubMeshTextureAliasesSize(const SubMesh* pSub); 00120 00121 00122 virtual void readTextureLayer(DataStreamPtr& stream, Mesh* pMesh, MaterialPtr& pMat); 00123 virtual void readSubMeshNameTable(DataStreamPtr& stream, Mesh* pMesh); 00124 virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh); 00125 virtual void readSubMesh(DataStreamPtr& stream, Mesh* pMesh); 00126 virtual void readSubMeshOperation(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub); 00127 virtual void readSubMeshTextureAlias(DataStreamPtr& stream, Mesh* pMesh, SubMesh* sub); 00128 virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); 00129 virtual void readGeometryVertexDeclaration(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); 00130 virtual void readGeometryVertexElement(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); 00131 virtual void readGeometryVertexBuffer(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); 00132 00133 virtual void readSkeletonLink(DataStreamPtr& stream, Mesh* pMesh); 00134 virtual void readMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh); 00135 virtual void readSubMeshBoneAssignment(DataStreamPtr& stream, Mesh* pMesh, 00136 SubMesh* sub); 00137 virtual void readMeshLodInfo(DataStreamPtr& stream, Mesh* pMesh); 00138 virtual void readMeshLodUsageManual(DataStreamPtr& stream, Mesh* pMesh, 00139 unsigned short lodNum, MeshLodUsage& usage); 00140 virtual void readMeshLodUsageGenerated(DataStreamPtr& stream, Mesh* pMesh, 00141 unsigned short lodNum, MeshLodUsage& usage); 00142 virtual void readBoundsInfo(DataStreamPtr& stream, Mesh* pMesh); 00143 virtual void readEdgeList(DataStreamPtr& stream, Mesh* pMesh); 00144 virtual void readPoses(DataStreamPtr& stream, Mesh* pMesh); 00145 virtual void readPose(DataStreamPtr& stream, Mesh* pMesh); 00146 virtual void readAnimations(DataStreamPtr& stream, Mesh* pMesh); 00147 virtual void readAnimation(DataStreamPtr& stream, Mesh* pMesh); 00148 virtual void readAnimationTrack(DataStreamPtr& stream, Animation* anim, 00149 Mesh* pMesh); 00150 virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track); 00151 virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track); 00152 00153 00155 virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); 00157 virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); 00160 virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems); 00161 00162 00163 00164 }; 00165 00167 class _OgrePrivate MeshSerializerImpl_v1_2 : public MeshSerializerImpl 00168 { 00169 public: 00170 MeshSerializerImpl_v1_2(); 00171 ~MeshSerializerImpl_v1_2(); 00172 protected: 00173 virtual void readMesh(DataStreamPtr& stream, Mesh* pMesh); 00174 virtual void readGeometry(DataStreamPtr& stream, Mesh* pMesh, VertexData* dest); 00175 virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr& stream, 00176 Mesh* pMesh, VertexData* dest); 00177 virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr& stream, 00178 Mesh* pMesh, VertexData* dest); 00179 virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr& stream, 00180 Mesh* pMesh, VertexData* dest); 00181 virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, 00182 Mesh* pMesh, VertexData* dest, unsigned short set); 00183 }; 00184 00186 class _OgrePrivate MeshSerializerImpl_v1_1 : public MeshSerializerImpl_v1_2 00187 { 00188 public: 00189 MeshSerializerImpl_v1_1(); 00190 ~MeshSerializerImpl_v1_1(); 00191 protected: 00192 void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream, 00193 Mesh* pMesh, VertexData* dest, unsigned short set); 00194 }; 00195 00196 00197 } 00198 00199 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:44 2006