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

Revision 1092, 4.7 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

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        */
61        void exportSkeleton(const Skeleton* pSkeleton, const String& filename);
62
63        /** Imports Skeleton and animation data from a .skeleton file DataStream.
64        @remarks
65            This method imports data from a DataStream opened from a .skeleton file and places it's
66            contents into the Skeleton object which is passed in.
67        @param stream The DataStream holding the .skeleton data. Must be initialised (pos at the start of the buffer).
68        @param pDest Weak reference to the Skeleton object which will receive the data. Should be blank already.
69        */
70        void importSkeleton(DataStreamPtr& stream, Skeleton* pDest);
71
72        // TODO: provide Cal3D importer?
73
74    private:
75        // Internal export methods
76        void writeSkeleton(const Skeleton* pSkel);
77        void writeBone(const Skeleton* pSkel, const Bone* pBone);
78        void writeBoneParent(const Skeleton* pSkel, unsigned short boneId, unsigned short parentId);
79        void writeAnimation(const Skeleton* pSkel, const Animation* anim);
80        void writeAnimationTrack(const Skeleton* pSkel, const AnimationTrack* track);
81        void writeKeyFrame(const Skeleton* pSkel, const KeyFrame* key);
82                void writeSkeletonAnimationLink(const Skeleton* pSkel,
83                        const LinkedSkeletonAnimationSource& link);
84
85        // Internal import methods
86        void readBone(DataStreamPtr& stream, Skeleton* pSkel);
87        void readBoneParent(DataStreamPtr& stream, Skeleton* pSkel);
88        void readAnimation(DataStreamPtr& stream, Skeleton* pSkel);
89        void readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel);
90        void readKeyFrame(DataStreamPtr& stream, AnimationTrack* track, Skeleton* pSkel);
91                void readSkeletonAnimationLink(DataStreamPtr& stream, Skeleton* pSkel);
92
93        size_t calcBoneSize(const Skeleton* pSkel, const Bone* pBone);
94        size_t calcBoneParentSize(const Skeleton* pSkel);
95        size_t calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim);
96        size_t calcAnimationTrackSize(const Skeleton* pSkel, const AnimationTrack* pTrack);
97        size_t calcKeyFrameSize(const Skeleton* pSkel, const KeyFrame* pKey);
98                size_t calcSkeletonAnimationLinkSize(const Skeleton* pSkel,
99                        const LinkedSkeletonAnimationSource& link);
100
101
102
103
104    };
105
106}
107
108
109#endif
Note: See TracBrowser for help on using the repository browser.