fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Collada / OSGColladaController.h
blob057356e0bbc817bf4fc1bcfac158c4ce4f155513
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 _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 {
53 #endif
55 // forward decl
56 class domNode;
57 class domSkin;
59 #ifdef OSG_WITH_COLLADA_NAMESPACE
61 #endif
63 OSG_BEGIN_NAMESPACE
65 // forward decl
66 class ColladaInstanceController;
67 class ColladaNode;
70 class OSG_FILEIO_DLLMAPPING ColladaController : public ColladaGeometry
72 /*========================== PUBLIC =================================*/
73 public:
74 /*---------------------------------------------------------------------*/
75 /*! \name Types */
76 /*! \{ */
78 typedef ColladaGeometry Inherited;
79 typedef ColladaController Self;
81 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaController);
83 class ColladaControllerInstInfo : public ColladaInstInfo
85 /*========================== PUBLIC =============================*/
86 public:
87 /*-----------------------------------------------------------------*/
88 /*! \name Types */
89 /*! \{ */
91 typedef ColladaInstInfo Inherited;
92 typedef ColladaControllerInstInfo Self;
94 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaControllerInstInfo);
96 /*! \} */
97 /*-----------------------------------------------------------------*/
98 /*! \name Create */
99 /*! \{ */
101 static ColladaInstInfoTransitPtr
102 create(ColladaNode *colInstParent,
103 ColladaInstanceController *colInst,
104 Node *parentN );
106 /*! \} */
107 /*-----------------------------------------------------------------*/
108 /*! \name Access */
109 /*! \{ */
111 inline Node *getParentNode(void) const;
113 /*! \} */
114 /*-----------------------------------------------------------------*/
115 /*! \name Process */
116 /*! \{ */
118 virtual void process(void);
120 /*! \} */
121 /*========================= PROTECTED ===========================*/
122 protected:
123 /*-----------------------------------------------------------------*/
124 /*! \name Constructors/Destructor */
125 /*! \{ */
127 ColladaControllerInstInfo(
128 ColladaNode *colInstParent,
129 ColladaInstanceController *colInst,
130 Node *parentN );
131 virtual ~ColladaControllerInstInfo(void );
133 /*! \} */
134 /*-----------------------------------------------------------------*/
136 NodeUnrecPtr _parentN;
139 OSG_GEN_MEMOBJPTR(ColladaControllerInstInfo);
141 /*! \} */
142 /*---------------------------------------------------------------------*/
143 /*! \name Create */
144 /*! \{ */
146 static ColladaElementTransitPtr
147 create(daeElement *elem, ColladaGlobal *global);
149 /*! \} */
150 /*---------------------------------------------------------------------*/
151 /*! \name Reading */
152 /*! \{ */
154 virtual void read (ColladaElement *colElemParent);
155 virtual Node *createInstance(ColladaInstInfo *colInstInfo );
157 /*! \} */
158 /*========================= PROTECTED ===============================*/
159 protected:
160 /*---------------------------------------------------------------------*/
161 /*! \name Constructors/Destructor */
162 /*! \{ */
164 ColladaController(daeElement *elem, ColladaGlobal *global);
165 virtual ~ColladaController(void );
167 /*! \} */
168 /*---------------------------------------------------------------------*/
169 /*! \name Internal Types */
170 /*! \{ */
172 struct JointInfo
174 domNode *jointNode;
175 ColladaNode *colJointNode;
177 Int16 jointId;
178 Matrix invBindMatrix;
180 JointInfo(void):
181 jointNode (NULL),
182 colJointNode (NULL),
183 jointId (0 ),
184 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;
199 return *this;
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;
211 /*! \} */
212 /*---------------------------------------------------------------------*/
213 /*! \name Helper functions */
214 /*! \{ */
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,
227 domNode *joint );
229 /*! \} */
230 /*---------------------------------------------------------------------*/
232 static ColladaElementRegistrationHelper _regHelper;
234 Matrix _matBindShape;
235 SkeletonUnrecPtr _skeleton;
238 OSG_GEN_MEMOBJPTR(ColladaController);
240 OSG_END_NAMESPACE
242 #include "OSGColladaController.inl"
244 #endif // OSG_WITH_COLLADA
246 #endif // _OSGCOLLADACONTROLLER_H_