1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2009 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 _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
{
61 #ifdef OSG_WITH_COLLADA_NAMESPACE
65 #ifdef OSG_WITH_COLLADA_NAMESPACE
66 using namespace ColladaDOM141
;
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 =================================*/
83 /*---------------------------------------------------------------------*/
87 typedef ColladaInstantiableElement Inherited
;
88 typedef ColladaAnimation Self
;
90 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaAnimation
);
92 class ColladaAnimationInstInfo
: public ColladaInstInfo
94 /*========================== 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
);
108 /*-----------------------------------------------------------------*/
112 ColladaAnimation
*getAnim (void) const;
113 AnimKeyFrameTemplate
*getTemplate(void) const;
116 /*-----------------------------------------------------------------*/
120 virtual void process(void);
123 /*========================= PROTECTED ===========================*/
125 /*-----------------------------------------------------------------*/
126 /*! \name Constructors/Destructor */
129 ColladaAnimationInstInfo(
130 ColladaAnimationClip
*colInstParent
,
131 ColladaInstanceAnimation
*colInst
,
132 ColladaAnimation
*colInstTarget
,
133 AnimKeyFrameTemplate
*animTmpl
);
134 virtual ~ColladaAnimationInstInfo(void );
137 /*-----------------------------------------------------------------*/
139 ColladaAnimationRefPtr _colInstTarget
;
140 AnimKeyFrameTemplateUnrecPtr _animTmpl
;
143 OSG_GEN_MEMOBJPTR(ColladaAnimationInstInfo
);
146 /*---------------------------------------------------------------------*/
150 static ColladaElementTransitPtr
151 create(daeElement
*elem
, ColladaGlobal
*global
);
154 /*---------------------------------------------------------------------*/
158 virtual void read (ColladaElement
*colElemParent
);
159 virtual AnimKeyFrameTemplate
*createInstance(ColladaInstInfo
*colInstInfo
);
162 /*========================= PROTECTED ===============================*/
164 /*---------------------------------------------------------------------*/
165 /*! \name Constructors/Destructor */
168 ColladaAnimation(daeElement
*elem
, ColladaGlobal
*global
);
169 virtual ~ColladaAnimation(void );
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
;
185 DataSourceInfo(void) :
192 void readAnim (domAnimation
*anim
);
193 void createInstanceAnim (domAnimation
*anim
,
194 ColladaElement
*colInstParent
,
195 ColladaInstanceElement
*colInst
,
196 AnimKeyFrameTemplate
*animTmpl
);
198 void createDataSource (domChannel
*channel
,
200 DataSourceInfo
&dsInfo
);
201 void handleInput (domChannel
*channel
,
203 ColladaAnimationClip
*colAnimClip
,
204 AnimKeyFrameTemplate
*animTmpl
,
205 DataSourceInfo
&dsInfo
);
206 void handleOutput (domChannel
*channel
,
208 AnimKeyFrameTemplate
*animTmpl
,
209 DataSourceInfo
&dsInfo
);
210 void handleInterpolation(domChannel
*channel
,
212 AnimKeyFrameTemplate
*animTmpl
,
213 DataSourceInfo
&dsInfo
);
215 domInputLocal
*findInput(domSampler
*sampler
, const std::string
&semantic
);
217 static ColladaElementRegistrationHelper _regHelper
;
219 SourceMap _sourceMap
;
224 // #include "OSGColladaAnimation.inl"
226 #endif // OSG_WITH_COLLADA
228 #endif // _OSGCOLLADAANIMATION_H_