fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Collada / OSGColladaAnimation.h
blob6e6f12a98be7f284ffa51729573d2bac3839275d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2009 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 _OSGCOLLADAANIMATION_H_
40 #define _OSGCOLLADAANIMATION_H_
42 #include "OSGConfig.h"
44 #ifdef OSG_WITH_COLLADA
46 #include "OSGColladaInstantiableElement.h"
47 #include "OSGColladaElementFactoryHelper.h"
48 #include "OSGColladaInstInfo.h"
49 #include "OSGColladaSource.h"
51 #include "OSGAnimKeyFrameTemplate.h"
53 #ifdef OSG_WITH_COLLADA_NAMESPACE
54 namespace ColladaDOM141 {
55 #endif
56 // forward decl
57 class domAnimation;
58 class domInputLocal;
59 class domChannel;
60 class domSampler;
61 #ifdef OSG_WITH_COLLADA_NAMESPACE
63 #endif
65 #ifdef OSG_WITH_COLLADA_NAMESPACE
66 using namespace ColladaDOM141;
67 #endif
69 OSG_BEGIN_NAMESPACE
71 // forward decl
72 class ColladaAnimation;
73 OSG_GEN_MEMOBJPTR(ColladaAnimation);
74 class ColladaAnimationClip;
75 class ColladaInstanceAnimation;
78 class OSG_FILEIO_DLLMAPPING ColladaAnimation
79 : public ColladaInstantiableElement
81 /*========================== PUBLIC =================================*/
82 public:
83 /*---------------------------------------------------------------------*/
84 /*! \name Types */
85 /*! \{ */
87 typedef ColladaInstantiableElement Inherited;
88 typedef ColladaAnimation Self;
90 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaAnimation);
92 class ColladaAnimationInstInfo : public ColladaInstInfo
94 /*========================== PUBLIC =============================*/
95 public:
96 typedef ColladaInstInfo Inherited;
97 typedef ColladaAnimationInstInfo Self;
99 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaAnimationInstInfo);
101 static ColladaInstInfoTransitPtr
102 create(ColladaAnimationClip *colInstParent,
103 ColladaInstanceAnimation *colInst,
104 ColladaAnimation *colInstTarget,
105 AnimKeyFrameTemplate *animTmpl );
107 /*! \} */
108 /*-----------------------------------------------------------------*/
109 /*! \name Access */
110 /*! \{ */
112 ColladaAnimation *getAnim (void) const;
113 AnimKeyFrameTemplate *getTemplate(void) const;
115 /*! \} */
116 /*-----------------------------------------------------------------*/
117 /*! \name Process */
118 /*! \{ */
120 virtual void process(void);
122 /*! \} */
123 /*========================= PROTECTED ===========================*/
124 protected:
125 /*-----------------------------------------------------------------*/
126 /*! \name Constructors/Destructor */
127 /*! \{ */
129 ColladaAnimationInstInfo(
130 ColladaAnimationClip *colInstParent,
131 ColladaInstanceAnimation *colInst,
132 ColladaAnimation *colInstTarget,
133 AnimKeyFrameTemplate *animTmpl );
134 virtual ~ColladaAnimationInstInfo(void );
136 /*! \} */
137 /*-----------------------------------------------------------------*/
139 ColladaAnimationRefPtr _colInstTarget;
140 AnimKeyFrameTemplateUnrecPtr _animTmpl;
143 OSG_GEN_MEMOBJPTR(ColladaAnimationInstInfo);
145 /*! \} */
146 /*---------------------------------------------------------------------*/
147 /*! \name Create */
148 /*! \{ */
150 static ColladaElementTransitPtr
151 create(daeElement *elem, ColladaGlobal *global);
153 /*! \} */
154 /*---------------------------------------------------------------------*/
155 /*! \name Reading */
156 /*! \{ */
158 virtual void read (ColladaElement *colElemParent);
159 virtual AnimKeyFrameTemplate *createInstance(ColladaInstInfo *colInstInfo );
161 /*! \} */
162 /*========================= PROTECTED ===============================*/
163 protected:
164 /*---------------------------------------------------------------------*/
165 /*! \name Constructors/Destructor */
166 /*! \{ */
168 ColladaAnimation(daeElement *elem, ColladaGlobal *global);
169 virtual ~ColladaAnimation(void );
171 /*! \} */
172 /*---------------------------------------------------------------------*/
174 typedef std::map<std::string, ColladaSourceRefPtr> SourceMap;
175 typedef SourceMap::iterator SourceMapIt;
176 typedef SourceMap::const_iterator SourceMapConstIt;
178 struct DataSourceInfo
180 AnimKeyFrameDataSourceUnrecPtr _dataSource;
181 std::string _target;
182 UInt32 _firstKey;
183 UInt32 _lastKey;
185 DataSourceInfo(void) :
186 _dataSource(NULL),
187 _target ( ),
188 _firstKey (0 ),
189 _lastKey (0 ) {}
192 void readAnim (domAnimation *anim );
193 void createInstanceAnim (domAnimation *anim,
194 ColladaElement *colInstParent,
195 ColladaInstanceElement *colInst,
196 AnimKeyFrameTemplate *animTmpl );
198 void createDataSource (domChannel *channel,
199 domSampler *sampler,
200 DataSourceInfo &dsInfo );
201 void handleInput (domChannel *channel,
202 domSampler *sampler,
203 ColladaAnimationClip *colAnimClip,
204 AnimKeyFrameTemplate *animTmpl,
205 DataSourceInfo &dsInfo );
206 void handleOutput (domChannel *channel,
207 domSampler *sampler,
208 AnimKeyFrameTemplate *animTmpl,
209 DataSourceInfo &dsInfo );
210 void handleInterpolation(domChannel *channel,
211 domSampler *sampler,
212 AnimKeyFrameTemplate *animTmpl,
213 DataSourceInfo &dsInfo );
215 domInputLocal *findInput(domSampler *sampler, const std::string &semantic);
217 static ColladaElementRegistrationHelper _regHelper;
219 SourceMap _sourceMap;
222 OSG_END_NAMESPACE
224 // #include "OSGColladaAnimation.inl"
226 #endif // OSG_WITH_COLLADA
228 #endif // _OSGCOLLADAANIMATION_H_