source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreSkeletonSerializer.h @ 1812

Revision 1812, 5.0 KB checked in by gumbau, 18 years ago (diff)
Line 
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-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26#ifndef __SkeletonSerializer_H__
27#define __SkeletonSerializer_H__
28
29#include "OgrePrerequisites.h"
30#include "OgreSkeleton.h"
31#include "OgreSerializer.h"
32
33namespace Ogre {
34
35    /** Class for serialising skeleton data to/from an OGRE .skeleton file.
36    @remarks
37        This class allows exporters to write OGRE .skeleton files easily, and allows the
38        OGRE engine to import .skeleton files into instatiated OGRE Skeleton objects.
39        Note that a .skeleton file includes not only the Skeleton, but also definitions of
40        any Animations it uses.
41    @par
42        To export a Skeleton:<OL>
43        <LI>Create a Skeleton object and populate it using it's methods.</LI>
44        <LI>Call the exportSkeleton method</LI>
45        </OL>
46    */
47    class _OgreExport SkeletonSerializer : public Serializer
48    {
49    public:
50        SkeletonSerializer();
51        virtual ~SkeletonSerializer();
52
53
54        /** Exports a skeleton to the file specified.
55        @remarks
56            This method takes an externally created Skeleton object, and exports both it
57            and animations it uses to a .skeleton file.
58        @param pSkeleton Weak reference to the Skeleton to export
59        @param filename The destination filename
60                @param endianMode The endian mode to write in
61        */
62        void exportSkeleton(const Skeleton* pSkeleton, const String& filename,
63                        Endian endianMode = ENDIAN_NATIVE);
64
65        /** Imports Skeleton and animation data from a .skeleton file DataStream.
66        @remarks
67            This method imports data from a DataStream opened from a .skeleton file and places it's
68            contents into the Skeleton object which is passed in.
69        @param stream The DataStream holding the .skeleton data. Must be initialised (pos at the start of the buffer).
70        @param pDest Weak reference to the Skeleton object which will receive the data. Should be blank already.
71        */
72        void importSkeleton(DataStreamPtr& stream, Skeleton* pDest);
73
74        // TODO: provide Cal3D importer?
75
76    private:
77        // Internal export methods
78        void writeSkeleton(const Skeleton* pSkel);
79        void writeBone(const Skeleton* pSkel, const Bone* pBone);
80        void writeBoneParent(const Skeleton* pSkel, unsigned short boneId, unsigned short parentId);
81        void writeAnimation(const Skeleton* pSkel, const Animation* anim);
82        void writeAnimationTrack(const Skeleton* pSkel, const NodeAnimationTrack* track);
83        void writeKeyFrame(const Skeleton* pSkel, const TransformKeyFrame* key);
84                void writeSkeletonAnimationLink(const Skeleton* pSkel,
85                        const LinkedSkeletonAnimationSource& link);
86
87        // Internal import methods
88        void readBone(DataStreamPtr& stream, Skeleton* pSkel);
89        void readBoneParent(DataStreamPtr& stream, Skeleton* pSkel);
90        void readAnimation(DataStreamPtr& stream, Skeleton* pSkel);
91        void readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel);
92        void readKeyFrame(DataStreamPtr& stream, NodeAnimationTrack* track, Skeleton* pSkel);
93                void readSkeletonAnimationLink(DataStreamPtr& stream, Skeleton* pSkel);
94
95        size_t calcBoneSize(const Skeleton* pSkel, const Bone* pBone);
96        size_t calcBoneSizeWithoutScale(const Skeleton* pSkel, const Bone* pBone);
97        size_t calcBoneParentSize(const Skeleton* pSkel);
98        size_t calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim);
99        size_t calcAnimationTrackSize(const Skeleton* pSkel, const NodeAnimationTrack* pTrack);
100        size_t calcKeyFrameSize(const Skeleton* pSkel, const TransformKeyFrame* pKey);
101        size_t calcKeyFrameSizeWithoutScale(const Skeleton* pSkel, const TransformKeyFrame* pKey);
102                size_t calcSkeletonAnimationLinkSize(const Skeleton* pSkel,
103                        const LinkedSkeletonAnimationSource& link);
104
105
106
107
108    };
109
110}
111
112
113#endif
Note: See TracBrowser for help on using the repository browser.