fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Ogre / OSGOgreSkeletonReader.h
blob7e3afc28c74fcc31a4c2f9dcf61bad9f5422c9de
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2010 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOGRESKELETONREADER_H_
40 #define _OSGOGRESKELETONREADER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 /*! \file OSGOgreSkeletonReader.h
46 \ingroup GrpLoader
49 #include "OSGConfig.h"
50 #include "OSGFileIODef.h"
51 #include "OSGOgreChunkReader.h"
52 #include "OSGOgreOptions.h"
54 #include "OSGAnimMatrixDataSource.h"
55 #include "OSGAnimQuaternionDataSource.h"
56 #include "OSGAnimVec3fDataSource.h"
57 #include "OSGAnimTemplate.h"
58 #include "OSGGlobalsAttachment.h"
59 #include "OSGNode.h"
60 #include "OSGSkeleton.h"
62 OSG_BEGIN_NAMESPACE
64 class OSG_FILEIO_DLLMAPPING OgreSkeletonReader : public OgreChunkReader
66 /*========================== PUBLIC =================================*/
67 public:
68 /*---------------------------------------------------------------------*/
69 /*! \name Types */
70 /*! \{ */
72 typedef OgreChunkReader Inherited;
74 /*! \} */
75 /*---------------------------------------------------------------------*/
76 /*! \name Constructors/Destructor */
77 /*! \{ */
79 explicit OgreSkeletonReader( std::istream &is,
80 const OgreOptions &options);
81 virtual ~OgreSkeletonReader(void );
83 /*! \} */
84 /*---------------------------------------------------------------------*/
85 /*! \name Read */
86 /*! \{ */
88 void read(void);
90 Skeleton* getSkeleton(void);
91 GlobalsAttachment* getGlobals (void);
93 /*! \} */
94 /*========================= PROTECTED ===============================*/
95 protected:
96 enum ChunkIds
98 CHUNK_HEADER = 0x1000,
99 CHUNK_BONE = 0x2000,
100 CHUNK_BONE_PARENT = 0x3000,
102 CHUNK_ANIMATION = 0x4000,
103 CHUNK_ANIMATION_TRACK = 0x4100,
104 CHUNK_ANIMATION_TRACK_KEYFRAME = 0x4110,
105 CHUNK_ANIMATION_LINK = 0x5000
108 typedef std::vector<NodeUnrecPtr> JointNodeStore;
110 static const std::string _versionString;
111 static const std::size_t _boneLengthNoScale;
112 static const std::size_t _keyFrameLengthNoScale;
114 void readContent (void);
115 void readBone (JointNodeStore &joints );
116 void readBoneParent (JointNodeStore &joints );
117 void readAnimation (JointNodeStore &joints );
118 void readAnimationTrack (JointNodeStore &joints,
119 AnimTemplate *animTmpl);
120 // void readAnimationTrackKeyFrame(AnimMatrixDataSource *dataSrc );
121 void readAnimationTrackKeyFrame(AnimVec3fDataSource *translateSrc,
122 AnimVec3fDataSource *scaleSrc,
123 AnimQuaternionDataSource *rotateSrc );
124 void readAnimationLink (void);
126 void calcInvBindMatrices(JointNodeStore &joints );
127 void calcInvBindMatrix (Node *node,
128 Vec3f parentTranslate,
129 Vec3f parentScale,
130 Quaternion parentRotate );
132 const OgreOptions &_options;
134 SkeletonUnrecPtr _skel;
135 GlobalsAttachmentUnrecPtr _globals;
138 OSG_END_NAMESPACE
140 #endif // _OSGOGRESKELETONREADER_H_