Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreSkeletonSerializer.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 5.2 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30#ifndef __SkeletonSerializer_H__
31#define __SkeletonSerializer_H__
32
33#include "OgrePrerequisites.h"
34#include "OgreSkeleton.h"
35#include "OgreSerializer.h"
36
37namespace Ogre {
38
39    /** Class for serialising skeleton data to/from an OGRE .skeleton file.
40    @remarks
41        This class allows exporters to write OGRE .skeleton files easily, and allows the
42        OGRE engine to import .skeleton files into instatiated OGRE Skeleton objects.
43        Note that a .skeleton file includes not only the Skeleton, but also definitions of
44        any Animations it uses.
45    @par
46        To export a Skeleton:<OL>
47        <LI>Create a Skeleton object and populate it using it's methods.</LI>
48        <LI>Call the exportSkeleton method</LI>
49        </OL>
50    */
51    class _OgreExport SkeletonSerializer : public Serializer
52    {
53    public:
54        SkeletonSerializer();
55        virtual ~SkeletonSerializer();
56
57
58        /** Exports a skeleton to the file specified.
59        @remarks
60            This method takes an externally created Skeleton object, and exports both it
61            and animations it uses to a .skeleton file.
62        @param pSkeleton Weak reference to the Skeleton to export
63        @param filename The destination filename
64                @param endianMode The endian mode to write in
65        */
66        void exportSkeleton(const Skeleton* pSkeleton, const String& filename,
67                        Endian endianMode = ENDIAN_NATIVE);
68
69        /** Imports Skeleton and animation data from a .skeleton file DataStream.
70        @remarks
71            This method imports data from a DataStream opened from a .skeleton file and places it's
72            contents into the Skeleton object which is passed in.
73        @param stream The DataStream holding the .skeleton data. Must be initialised (pos at the start of the buffer).
74        @param pDest Weak reference to the Skeleton object which will receive the data. Should be blank already.
75        */
76        void importSkeleton(DataStreamPtr& stream, Skeleton* pDest);
77
78        // TODO: provide Cal3D importer?
79
80    protected:
81        // Internal export methods
82        void writeSkeleton(const Skeleton* pSkel);
83        void writeBone(const Skeleton* pSkel, const Bone* pBone);
84        void writeBoneParent(const Skeleton* pSkel, unsigned short boneId, unsigned short parentId);
85        void writeAnimation(const Skeleton* pSkel, const Animation* anim);
86        void writeAnimationTrack(const Skeleton* pSkel, const NodeAnimationTrack* track);
87        void writeKeyFrame(const Skeleton* pSkel, const TransformKeyFrame* key);
88                void writeSkeletonAnimationLink(const Skeleton* pSkel, 
89                        const LinkedSkeletonAnimationSource& link);
90
91        // Internal import methods
92        void readBone(DataStreamPtr& stream, Skeleton* pSkel);
93        void readBoneParent(DataStreamPtr& stream, Skeleton* pSkel);
94        void readAnimation(DataStreamPtr& stream, Skeleton* pSkel);
95        void readAnimationTrack(DataStreamPtr& stream, Animation* anim, Skeleton* pSkel);
96        void readKeyFrame(DataStreamPtr& stream, NodeAnimationTrack* track, Skeleton* pSkel);
97                void readSkeletonAnimationLink(DataStreamPtr& stream, Skeleton* pSkel);
98
99        size_t calcBoneSize(const Skeleton* pSkel, const Bone* pBone);
100        size_t calcBoneSizeWithoutScale(const Skeleton* pSkel, const Bone* pBone);
101        size_t calcBoneParentSize(const Skeleton* pSkel);
102        size_t calcAnimationSize(const Skeleton* pSkel, const Animation* pAnim);
103        size_t calcAnimationTrackSize(const Skeleton* pSkel, const NodeAnimationTrack* pTrack);
104        size_t calcKeyFrameSize(const Skeleton* pSkel, const TransformKeyFrame* pKey);
105        size_t calcKeyFrameSizeWithoutScale(const Skeleton* pSkel, const TransformKeyFrame* pKey);
106                size_t calcSkeletonAnimationLinkSize(const Skeleton* pSkel, 
107                        const LinkedSkeletonAnimationSource& link);
108
109
110
111
112    };
113
114}
115
116
117#endif
Note: See TracBrowser for help on using the repository browser.