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 _OSGCOLLADACONTROLLER_H_
40 #define _OSGCOLLADACONTROLLER_H_
42 #include "OSGConfig.h"
44 #ifdef OSG_WITH_COLLADA
46 #include "OSGColladaGeometry.h"
47 #include "OSGColladaElementFactoryHelper.h"
49 #include "OSGSkeleton.h"
51 #ifdef OSG_WITH_COLLADA_NAMESPACE
52 namespace ColladaDOM141
{
59 #ifdef OSG_WITH_COLLADA_NAMESPACE
66 class ColladaInstanceController
;
70 class OSG_FILEIO_DLLMAPPING ColladaController
: public ColladaGeometry
72 /*========================== PUBLIC =================================*/
74 /*---------------------------------------------------------------------*/
78 typedef ColladaGeometry Inherited
;
79 typedef ColladaController Self
;
81 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaController
);
83 class ColladaControllerInstInfo
: public ColladaInstInfo
85 /*========================== PUBLIC =============================*/
87 /*-----------------------------------------------------------------*/
91 typedef ColladaInstInfo Inherited
;
92 typedef ColladaControllerInstInfo Self
;
94 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaControllerInstInfo
);
97 /*-----------------------------------------------------------------*/
101 static ColladaInstInfoTransitPtr
102 create(ColladaNode
*colInstParent
,
103 ColladaInstanceController
*colInst
,
107 /*-----------------------------------------------------------------*/
111 inline Node
*getParentNode(void) const;
114 /*-----------------------------------------------------------------*/
118 virtual void process(void);
121 /*========================= PROTECTED ===========================*/
123 /*-----------------------------------------------------------------*/
124 /*! \name Constructors/Destructor */
127 ColladaControllerInstInfo(
128 ColladaNode
*colInstParent
,
129 ColladaInstanceController
*colInst
,
131 virtual ~ColladaControllerInstInfo(void );
134 /*-----------------------------------------------------------------*/
136 NodeUnrecPtr _parentN
;
139 OSG_GEN_MEMOBJPTR(ColladaControllerInstInfo
);
142 /*---------------------------------------------------------------------*/
146 static ColladaElementTransitPtr
147 create(daeElement
*elem
, ColladaGlobal
*global
);
150 /*---------------------------------------------------------------------*/
154 virtual void read (ColladaElement
*colElemParent
);
155 virtual Node
*createInstance(ColladaInstInfo
*colInstInfo
);
158 /*========================= PROTECTED ===============================*/
160 /*---------------------------------------------------------------------*/
161 /*! \name Constructors/Destructor */
164 ColladaController(daeElement
*elem
, ColladaGlobal
*global
);
165 virtual ~ColladaController(void );
168 /*---------------------------------------------------------------------*/
169 /*! \name Internal Types */
175 ColladaNode
*colJointNode
;
178 Matrix invBindMatrix
;
186 JointInfo(const JointInfo
&other
) :
187 jointNode (other
.jointNode
),
188 colJointNode (other
.colJointNode
),
189 jointId (other
.jointId
),
190 invBindMatrix(other
.invBindMatrix
) {}
192 JointInfo
& operator =(const JointInfo
&other
)
194 jointNode
= other
.jointNode
;
195 colJointNode
= other
.colJointNode
;
196 jointId
= other
.jointId
;
197 invBindMatrix
= other
.invBindMatrix
;
203 typedef std::vector
<JointInfo
> JointInfoStore
;
204 typedef JointInfoStore::iterator JointInfoStoreIt
;
205 typedef JointInfoStore::const_iterator JointInfoStoreConstIt
;
207 typedef std::vector
<Int16
> JointIdMap
;
208 typedef JointIdMap::iterator JointIdMapIt
;
209 typedef JointIdMap::const_iterator JointIdMapConstIt
;
212 /*---------------------------------------------------------------------*/
213 /*! \name Helper functions */
216 void readSkin (domSkin
*skin
);
217 void readBindShapeMatrix(domSkin
*skin
);
218 void resolveJoints (domSkin
*skin
,
219 ColladaInstanceController
*colInstCtrl
,
220 JointInfoStore
&jointStore
,
221 JointIdMap
&jointIdMap
);
222 void remapJointIds (domSkin
*skin
,
223 ColladaInstanceController
*colInstCtrl
,
224 const JointInfoStore
&jointStore
,
225 const JointIdMap
&jointIdMap
);
226 Int32
findJoint (const JointInfoStore
&jointStore
,
230 /*---------------------------------------------------------------------*/
232 static ColladaElementRegistrationHelper _regHelper
;
234 Matrix _matBindShape
;
235 SkeletonUnrecPtr _skeleton
;
238 OSG_GEN_MEMOBJPTR(ColladaController
);
242 #include "OSGColladaController.inl"
244 #endif // OSG_WITH_COLLADA
246 #endif // _OSGCOLLADACONTROLLER_H_