1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2010 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOGRESKELETONREADER_H_
40 #define _OSGOGRESKELETONREADER_H_
45 /*! \file OSGOgreSkeletonReader.h
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"
60 #include "OSGSkeleton.h"
64 class OSG_FILEIO_DLLMAPPING OgreSkeletonReader
: public OgreChunkReader
66 /*========================== PUBLIC =================================*/
68 /*---------------------------------------------------------------------*/
72 typedef OgreChunkReader Inherited
;
75 /*---------------------------------------------------------------------*/
76 /*! \name Constructors/Destructor */
79 explicit OgreSkeletonReader( std::istream
&is
,
80 const OgreOptions
&options
);
81 virtual ~OgreSkeletonReader(void );
84 /*---------------------------------------------------------------------*/
90 Skeleton
* getSkeleton(void);
91 GlobalsAttachment
* getGlobals (void);
94 /*========================= PROTECTED ===============================*/
98 CHUNK_HEADER
= 0x1000,
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
,
130 Quaternion parentRotate
);
132 const OgreOptions
&_options
;
134 SkeletonUnrecPtr _skel
;
135 GlobalsAttachmentUnrecPtr _globals
;
140 #endif // _OSGOGRESKELETONREADER_H_