OGRE  1.9.0
OgreMeshSerializerImpl.h
Go to the documentation of this file.
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-2014 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
42 class LodStrategy;
43
62 {
63 public:
74 void exportMesh(const Mesh* pMesh, DataStreamPtr stream,
75 Endian endianMode = ENDIAN_NATIVE);
76
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);
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);
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);
168 virtual void readExtremes(DataStreamPtr& stream, Mesh *pMesh);
169
170
172 virtual void flipFromLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
174 virtual void flipToLittleEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
177 virtual void flipEndian(void* pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList& elems);
178
179
180
181 };
182
187 {
188 public:
191 protected:
192 void writeMorphKeyframe(const VertexMorphKeyFrame* kf, size_t vertexCount);
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
205 {
206 public:
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
222 {
223 public:
226 protected:
227 virtual void readEdgeListLodInfo(DataStreamPtr& stream, EdgeData* edgeData);
228
230 virtual void reorganiseTriangles(EdgeData* edgeData);
231
232 virtual void writeEdgeList(const Mesh* pMesh);
233 };
234
239 {
240 public:
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
260 {
261 public:
264 protected:
265 void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr& stream,
266 Mesh* pMesh, VertexData* dest, unsigned short set);
267 };
268
271
272}
273
274#endif
#define _OgrePrivate
An animation sequence.
This class contains the information required to describe the edge connectivity of a given set of vert...
Strategy for determining level of detail.
void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr &stream, Mesh *pMesh, VertexData *dest, unsigned short set)
virtual void readGeometryNormals(unsigned short bindIdx, DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readGeometryColours(unsigned short bindIdx, DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readMesh(DataStreamPtr &stream, Mesh *pMesh, MeshSerializerListener *listener)
virtual void readGeometryPositions(unsigned short bindIdx, DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readGeometry(DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readGeometryTexCoords(unsigned short bindIdx, DataStreamPtr &stream, Mesh *pMesh, VertexData *dest, unsigned short set)
virtual void writeEdgeList(const Mesh *pMesh)
virtual void readEdgeListLodInfo(DataStreamPtr &stream, EdgeData *edgeData)
virtual void reorganiseTriangles(EdgeData *edgeData)
Reorganise triangles of the edge list to group by vertex set.
size_t calcPoseSize(const Pose *pose)
void readMorphKeyFrame(DataStreamPtr &stream, VertexAnimationTrack *track)
void writePose(const Pose *pose)
void writeMorphKeyframe(const VertexMorphKeyFrame *kf, size_t vertexCount)
size_t calcMorphKeyframeSize(const VertexMorphKeyFrame *kf, size_t vertexCount)
void readPose(DataStreamPtr &stream, Mesh *pMesh)
virtual void writeLodUsageGenerated(const Mesh *pMesh, const MeshLodUsage &usage, unsigned short lodNum)
virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy)
virtual void writeLodUsageManual(const MeshLodUsage &usage)
virtual void readMeshLodInfo(DataStreamPtr &stream, Mesh *pMesh)
virtual void flipEndian(void *pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList &elems)
Flip the endianness of an entire vertex buffer, passed in as a pointer to locked or temporary memory.
virtual void writePoses(const Mesh *pMesh)
virtual void writeBoundsInfo(const Mesh *pMesh)
virtual void writeAnimations(const Mesh *pMesh)
virtual size_t calcPoseVertexSize(const Pose *pose)
virtual void readPoseKeyFrame(DataStreamPtr &stream, VertexAnimationTrack *track)
virtual void readMesh(DataStreamPtr &stream, Mesh *pMesh, MeshSerializerListener *listener)
virtual void readEdgeListLodInfo(DataStreamPtr &stream, EdgeData *edgeData)
virtual void flipToLittleEndian(void *pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList &elems)
Flip an entire vertex buffer to little endian.
virtual void readMeshLodUsageManual(DataStreamPtr &stream, Mesh *pMesh, unsigned short lodNum, MeshLodUsage &usage)
virtual size_t calcMorphKeyframeSize(const VertexMorphKeyFrame *kf, size_t vertexCount)
virtual void writeAnimationTrack(const VertexAnimationTrack *track)
virtual void readEdgeList(DataStreamPtr &stream, Mesh *pMesh)
virtual void writeSubMesh(const SubMesh *s)
virtual void readPoses(DataStreamPtr &stream, Mesh *pMesh)
virtual void readAnimations(DataStreamPtr &stream, Mesh *pMesh)
virtual size_t calcSubMeshSize(const SubMesh *pSub)
virtual size_t calcMeshSize(const Mesh *pMesh)
virtual void writeMeshBoneAssignment(const VertexBoneAssignment &assign)
void importMesh(DataStreamPtr &stream, Mesh *pDest, MeshSerializerListener *listener)
Imports Mesh and (optionally) Material data from a .mesh file DataStream.
virtual void readAnimation(DataStreamPtr &stream, Mesh *pMesh)
virtual void writeMesh(const Mesh *pMesh)
virtual size_t calcEdgeGroupSize(const EdgeData::EdgeGroup &group)
virtual size_t calcAnimationSize(const Animation *anim)
virtual void writeLodInfo(const Mesh *pMesh)
virtual void writePoseKeyframe(const VertexPoseKeyFrame *kf)
virtual void writeSubMeshOperation(const SubMesh *s)
virtual size_t calcPosesSize(const Mesh *pMesh)
virtual void writeLodUsageManual(const MeshLodUsage &usage)
virtual void writeSubMeshTextureAliases(const SubMesh *s)
virtual void writeAnimation(const Animation *anim)
virtual size_t calcSubMeshTextureAliasesSize(const SubMesh *pSub)
virtual void readMeshLodUsageGenerated(DataStreamPtr &stream, Mesh *pMesh, unsigned short lodNum, MeshLodUsage &usage)
virtual void writeSubMeshNameTable(const Mesh *pMesh)
virtual void readMorphKeyFrame(DataStreamPtr &stream, VertexAnimationTrack *track)
virtual size_t calcEdgeListSize(const Mesh *pMesh)
virtual void readExtremes(DataStreamPtr &stream, Mesh *pMesh)
virtual size_t calcSubMeshNameTableSize(const Mesh *pMesh)
virtual void readSubMeshTextureAlias(DataStreamPtr &stream, Mesh *pMesh, SubMesh *sub)
virtual size_t calcBoneAssignmentSize(void)
virtual size_t calcAnimationTrackSize(const VertexAnimationTrack *track)
virtual void readSkeletonLink(DataStreamPtr &stream, Mesh *pMesh, MeshSerializerListener *listener)
virtual void writePose(const Pose *pose)
virtual void readSubMesh(DataStreamPtr &stream, Mesh *pMesh, MeshSerializerListener *listener)
virtual size_t calcPoseKeyframePoseRefSize(void)
virtual void readMeshLodInfo(DataStreamPtr &stream, Mesh *pMesh)
virtual void readMeshBoneAssignment(DataStreamPtr &stream, Mesh *pMesh)
virtual void readSubMeshOperation(DataStreamPtr &stream, Mesh *pMesh, SubMesh *sub)
virtual void readBoundsInfo(DataStreamPtr &stream, Mesh *pMesh)
virtual void readGeometryVertexElement(DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readTextureLayer(DataStreamPtr &stream, Mesh *pMesh, MaterialPtr &pMat)
virtual void readAnimationTrack(DataStreamPtr &stream, Animation *anim, Mesh *pMesh)
virtual void writeGeometry(const VertexData *pGeom)
virtual void readGeometryVertexBuffer(DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void writeLodSummary(unsigned short numLevels, bool manual, const LodStrategy *strategy)
virtual void writeMorphKeyframe(const VertexMorphKeyFrame *kf, size_t vertexCount)
void exportMesh(const Mesh *pMesh, DataStreamPtr stream, Endian endianMode=ENDIAN_NATIVE)
Exports a mesh to the file specified.
virtual void writeExtremes(const Mesh *pMesh)
virtual size_t calcAnimationsSize(const Mesh *pMesh)
virtual void writeSkeletonLink(const String &skelName)
virtual void writeSubMeshBoneAssignment(const VertexBoneAssignment &assign)
virtual size_t calcSkeletonLinkSize(const String &skelName)
virtual size_t calcPoseSize(const Pose *pose)
virtual size_t calcSubMeshOperationSize(const SubMesh *pSub)
virtual void readPose(DataStreamPtr &stream, Mesh *pMesh)
virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef &poseRef)
virtual void writeEdgeList(const Mesh *pMesh)
virtual size_t calcPoseKeyframeSize(const VertexPoseKeyFrame *kf)
virtual void readSubMeshNameTable(DataStreamPtr &stream, Mesh *pMesh)
virtual void flipFromLittleEndian(void *pData, size_t vertexCount, size_t vertexSize, const VertexDeclaration::VertexElementList &elems)
Flip an entire vertex buffer from little endian.
virtual size_t calcGeometrySize(const VertexData *pGeom)
virtual void readGeometryVertexDeclaration(DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readGeometry(DataStreamPtr &stream, Mesh *pMesh, VertexData *dest)
virtual void readSubMeshBoneAssignment(DataStreamPtr &stream, Mesh *pMesh, SubMesh *sub)
virtual void writeSubMeshExtremes(unsigned short idx, const SubMesh *s)
virtual void writeLodUsageGenerated(const Mesh *pMesh, const MeshLodUsage &usage, unsigned short lodNum)
virtual size_t calcEdgeListLodSize(const EdgeData *data, bool isManual)
Resource holding data about 3D mesh.
Definition OgreMesh.h:94
A pose is a linked set of vertex offsets applying to one set of vertex data.
Definition OgrePose.h:56
Endian
The endianness of written files.
@ ENDIAN_NATIVE
Use the platform native endian.
Defines a part of a complete mesh.
Definition OgreSubMesh.h:63
Specialised AnimationTrack for dealing with changing vertex position information.
Summary class collecting together vertex source information.
list< VertexElement >::type VertexElementList
Defines the list of vertex elements that makes up this declaration.
Specialised KeyFrame which stores absolute vertex positions for a complete buffer,...
Specialised KeyFrame which references a Mesh::Pose at a certain influence level, which stores offsets...
struct Ogre::VertexBoneAssignment_s VertexBoneAssignment
Records the assignment of a single vertex to a single bone with the corresponding weight.
SharedPtr< DataStream > DataStreamPtr
Shared pointer to allow data streams to be passed around without worrying about deallocation.
SharedPtr< Material > MaterialPtr
_StringBase String
A group of edges sharing the same vertex data.
A way of recording the way each LODs is recorded this Mesh.
Definition OgreMesh.h:947
Reference to a pose at a given influence level.