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 _OSGCOLLADAGLOBAL_H_
40 #define _OSGCOLLADAGLOBAL_H_
45 /*! \file OSGColladaGlobal.h
48 #include "OSGConfig.h"
50 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
52 #include "OSGFileIODef.h"
53 #include "OSGMemoryObject.h"
54 #include "OSGPathHandler.h"
56 #include "OSGColladaElement.h"
57 #include "OSGColladaLoaderState.h"
58 #include "OSGColladaOptions.h"
59 #include "OSGStatElemTypes.h"
60 #include "OSGStatCollector.h"
61 #include "OSGGlobalsAttachment.h"
63 // collada dom includes
65 #include <dom/domCOLLADA.h>
75 class ColladaInstInfo
;
76 OSG_GEN_MEMOBJPTR(ColladaInstInfo
);
81 class ColladaInstInfo
;
82 OSG_GEN_MEMOBJPTR(ColladaInstInfo
);
84 /*! \ingroup GrpFileIOCollada
88 class OSG_FILEIO_DLLMAPPING ColladaGlobal
: public MemoryObject
90 /*========================== PUBLIC =================================*/
92 /*---------------------------------------------------------------------*/
96 typedef MemoryObject Inherited
;
97 typedef ColladaGlobal Self
;
99 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaGlobal
);
101 typedef std::deque
<ColladaInstInfoRefPtr
> InstanceQueue
;
102 typedef InstanceQueue::iterator InstanceQueueIt
;
103 typedef InstanceQueue::const_iterator InstanceQueueConstIt
;
105 typedef std::map
<std::string
,
106 ColladaLoaderStateRefPtr
> LoaderStateMap
;
107 typedef LoaderStateMap::iterator LoaderStateMapIt
;
108 typedef LoaderStateMap::const_iterator LoaderStateMapConstIt
;
110 typedef std::vector
<ColladaElementRefPtr
> ElementStore
;
111 typedef ElementStore::iterator ElementStoreIt
;
112 typedef ElementStore::const_iterator ElementStoreConstIt
;
115 /*---------------------------------------------------------------------*/
116 /*! \name Statistics */
119 static StatElemDesc
<StatIntElem
> statNGeometryCreated
;
120 static StatElemDesc
<StatIntElem
> statNGeometryUsed
;
121 static StatElemDesc
<StatIntElem
> statNMaterialCreated
;
122 static StatElemDesc
<StatIntElem
> statNMaterialUsed
;
123 static StatElemDesc
<StatIntElem
> statNLightCreated
;
124 static StatElemDesc
<StatIntElem
> statNLightUsed
;
125 static StatElemDesc
<StatIntElem
> statNTextureCreated
;
126 static StatElemDesc
<StatIntElem
> statNTextureUsed
;
128 StatCollector
*getStatCollector(void );
129 void setStatCollector(StatCollector
*statColl
);
132 /*---------------------------------------------------------------------*/
136 static ObjTransitPtr
create(void);
139 /*---------------------------------------------------------------------*/
143 NodeTransitPtr
read( std::istream
&is
,
144 const std::string
&fileName
);
146 NodeTransitPtr
read( DAE
*dae
,
147 const std::string
&fileName
);
150 /*---------------------------------------------------------------------*/
154 inline const DAE
*getDAE (void ) const;
155 inline DAE
*editDAE (void );
156 inline domCOLLADA
*getDocRoot (void ) const;
158 inline const std::string
&getDocPath (void ) const;
159 inline void setDocPath (const std::string
&docPath
);
161 inline ColladaOptions
*getOptions (void ) const;
162 inline void setOptions (ColladaOptions
*options
);
164 inline Node
*getRoot (void ) const;
165 inline void setRoot (Node
*rootN
);
167 inline GlobalsAttachment
*getGlobalsAtt(void ) const;
170 /*---------------------------------------------------------------------*/
171 /*! \name LoaderState */
174 inline void addLoaderState(const std::string
&name
,
175 ColladaLoaderState
*state
);
176 inline void subLoaderState(const std::string
&name
);
178 inline ColladaLoaderState
*getLoaderState (const std::string
&name
) const;
179 template <class StateTypeT
>
180 inline StateTypeT
*getLoaderStateAs(const std::string
&name
) const;
183 /*---------------------------------------------------------------------*/
184 /*! \name ElementStore */
187 inline const InstanceQueue
&getInstQueue (void ) const;
188 inline InstanceQueue
&editInstQueue(void );
190 inline const ElementStore
&getElemStore (void ) const;
191 inline ElementStore
&editElemStore(void );
193 void addElement (ColladaElement
*elem
);
195 ColladaElement
*getElement (const daeURI
&elemURI
) const;
196 ColladaElement
*getElement (const std::string
&elemId
) const;
199 /*---------------------------------------------------------------------*/
200 /*! \name ElementStore */
203 static std::string
fixFilepath ( std::string szFilepath
);
204 static std::string
fixImageFilepath( std::string szImgPath
);
205 static std::string
uriToNativePath (const std::string
&uriRef
,
206 cdom::systemType type
=
207 cdom::getSystemType());
210 /*========================= PROTECTED ===============================*/
212 /*---------------------------------------------------------------------*/
213 /*! \name Constructors/Destructor */
217 virtual ~ColladaGlobal(void);
220 /*---------------------------------------------------------------------*/
224 NodeTransitPtr
doRead(void);
227 /*---------------------------------------------------------------------*/
229 InstanceQueue _instQueue
;
230 LoaderStateMap _loaderState
;
231 ElementStore _elemStore
;
233 ColladaOptionsRefPtr _options
;
234 StatCollectorRefPtr _statColl
;
236 PathHandler _pathHandler
;
237 std::string _docPath
;
239 domCOLLADARef _docRoot
;
243 GlobalsAttachmentUnrecPtr _globalsAtt
;
247 ColladaGlobal(const ColladaGlobal
&other
);
248 void operator=(const ColladaGlobal
&rhs
);
252 OSG_GEN_MEMOBJPTR(ColladaGlobal
);
256 #include "OSGColladaGlobal.inl"
258 #endif // OSG_WITH_COLLADA
260 #endif // _OSGCOLLADAGLOBAL_H_