OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreMeshSerializerImpl.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE 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 
39 namespace Ogre {
40 
41  class MeshSerializerListener;
42  class LodStrategy;
43 
62  {
63  public:
65  virtual ~MeshSerializerImpl();
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);
97  virtual void writeSubMeshBoneAssignment(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);
111  virtual void writePoseKeyframePoseRef(const VertexPoseKeyFrame::PoseRef& poseRef);
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);
166  virtual void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
167  virtual void readPoseKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
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);
193  void readMorphKeyFrame(DataStreamPtr& stream, VertexAnimationTrack* track);
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 
272 }
273 
274 #endif
Specialised KeyFrame which stores absolute vertex positions for a complete buffer, designed to be interpolated with other keys in the same track.
Definition: OgreKeyFrame.h:154
Reference to a pose at a given influence level.
Definition: OgreKeyFrame.h:195
Generic class for serialising data to / from binary stream-based files.
A way of recording the way each LODs is recorded this Mesh.
Definition: OgreMesh.h:946
A pose is a linked set of vertex offsets applying to one set of vertex data.
Definition: OgrePose.h:55
Strategy for determining level of detail.
A group of edges sharing the same vertex data.
#define _OgrePrivate
Definition: OgrePlatform.h:261
Endian
The endianness of written files.
Internal implementation of Mesh reading / writing for the latest version of the .mesh format...
Specialised AnimationTrack for dealing with changing vertex position information. ...
Defines a part of a complete mesh.
Definition: OgreSubMesh.h:62
Summary class collecting together vertex source information.
list< VertexElement >::type VertexElementList
Defines the list of vertex elements that makes up this declaration.
Class for providing backwards-compatibility for loading version 1.2 of the .mesh format.
Class for providing backwards-compatibility for loading version 1.4 of the .mesh format.
This class contains the information required to describe the edge connectivity of a given set of vert...
Specialised KeyFrame which references a Mesh::Pose at a certain influence level, which stores offsets...
Definition: OgreKeyFrame.h:184
_StringBase String
Resource holding data about 3D mesh.
Definition: OgreMesh.h:93
Class for providing backwards-compatibility for loading version 1.41 of the .mesh format...
An animation sequence.
Definition: OgreAnimation.h:92
Records the assignment of a single vertex to a single bone with the corresponding weight...
Class for providing backwards-compatibility for loading version 1.1 of the .mesh format.
Class for providing backwards-compatibility for loading version 1.3 of the .mesh format.