OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreSkeletonSerializer.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 __SkeletonSerializer_H__
30 #define __SkeletonSerializer_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreSerializer.h"
34 
35 namespace Ogre {
36 
37  struct LinkedSkeletonAnimationSource;
38 
41  {
46 
49  };
50 
70  {
71 
72  public:
74  virtual ~SkeletonSerializer();
75 
76 
85  void exportSkeleton(const Skeleton* pSkeleton, const String& filename,
86  SkeletonVersion ver = SKELETON_VERSION_LATEST, Endian endianMode = ENDIAN_NATIVE);
87 
96  void exportSkeleton(const Skeleton* pSkeleton, DataStreamPtr stream,
97  SkeletonVersion ver = SKELETON_VERSION_LATEST, Endian endianMode = ENDIAN_NATIVE);
105  void importSkeleton(DataStreamPtr& stream, Skeleton* pDest);
106 
107  // TODO: provide Cal3D importer?
108 
109  protected:
110 
111  void setWorkingVersion(SkeletonVersion ver);
112 
113  // Internal export methods
114  void writeSkeleton(const Skeleton* pSkel, SkeletonVersion ver);
115  void writeBone(const Skeleton* pSkel, const OldBone* pBone);
116  void writeBoneParent(const Skeleton* pSkel, unsigned short boneId, unsigned short parentId);
117  void writeAnimation(const Skeleton* pSkel, const Animation* anim, SkeletonVersion ver);
118  void writeAnimationTrack(const Skeleton* pSkel, const OldNodeAnimationTrack* track);
119  void writeKeyFrame(const Skeleton* pSkel, const TransformKeyFrame* key);
120  void writeSkeletonAnimationLink(const Skeleton* pSkel,
121  const LinkedSkeletonAnimationSource& link);
122 
123  // Internal import methods
124  void readFileHeader(DataStreamPtr& stream);
125  void readBone(DataStreamPtr& stream, Skeleton* pSkel);
126  void readBoneParent(DataStreamPtr& stream, Skeleton* pSkel);
127  void readAnimation(DataStreamPtr& stream, Skeleton* pSkel);
128  void readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel);
129  void readKeyFrame(DataStreamPtr& stream, OldNodeAnimationTrack* track, Skeleton* pSkel);
130  void readSkeletonAnimationLink(DataStreamPtr& stream, Skeleton* pSkel);
131 
132  size_t calcBoneSize(const Skeleton* pSkel, const OldBone* pBone);
133  size_t calcBoneSizeWithoutScale(const Skeleton* pSkel, const OldBone* pBone);
134  size_t calcBoneParentSize(const Skeleton* pSkel);
135  size_t calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim, SkeletonVersion ver);
136  size_t calcAnimationTrackSize(const Skeleton* pSkel, const OldNodeAnimationTrack* pTrack);
137  size_t calcKeyFrameSize(const Skeleton* pSkel, const TransformKeyFrame* pKey);
138  size_t calcKeyFrameSizeWithoutScale(const Skeleton* pSkel, const TransformKeyFrame* pKey);
139  size_t calcSkeletonAnimationLinkSize(const Skeleton* pSkel,
140  const LinkedSkeletonAnimationSource& link);
141 
142 
143 
144 
145  };
149 }
150 
151 
152 #endif
Latest version available.
Specialised KeyFrame which stores a full transform.
Definition: OgreKeyFrame.h:102
#define _OgreExport
Definition: OgrePlatform.h:255
Generic class for serialising data to / from binary stream-based files.
Class for serialising skeleton data to/from an OGRE .skeleton file.
Endian
The endianness of written files.
Link to another skeleton to share animations.
Definition: OgreSkeleton.h:464
A bone in a skeleton.
Definition: OgreOldBone.h:51
SkeletonVersion
Skeleton compatibility versions.
Specialised AnimationTrack for dealing with node transforms.
_StringBase String
Definition: OgreCommon.h:53
An animation sequence.
Definition: OgreAnimation.h:90
A collection of OldBone objects used to animate a skinned mesh.
Definition: OgreSkeleton.h:84