fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Collada / OSGColladaCOLLADA.cpp
blob08582393a6a228edbe228e595cb717e54bb9297e
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 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
40 #pragma GCC diagnostic ignored "-Wold-style-cast"
41 #endif
43 #include "OSGColladaCOLLADA.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
48 #include "OSGColladaGlobal.h"
49 #include "OSGColladaScene.h"
50 #include "OSGColladaLibraryAnimationClips.h"
52 #include <dom/domCOLLADA.h>
54 OSG_BEGIN_NAMESPACE
56 ColladaElementRegistrationHelper ColladaCOLLADA::_regHelper(
57 &ColladaCOLLADA::create, "COLLADA");
60 ColladaElementTransitPtr
61 ColladaCOLLADA::create(daeElement *elem, ColladaGlobal *global)
63 return ColladaElementTransitPtr(new ColladaCOLLADA(elem, global));
66 void
67 ColladaCOLLADA::read(ColladaElement *colElemParent)
69 OSG_COLLADA_LOG(("ColladaCOLLADA::read\n"));
71 domCOLLADARef collada = getDOMElementAs<domCOLLADA>();
72 domAssetRef docAsset = collada->getAsset();
74 if(docAsset != NULL)
76 domAsset::domContributor_Array &domContrA =
77 docAsset->getContributor_array();
79 for(UInt32 i = 0; i < domContrA.getCount(); ++i)
81 domAsset::domContributor::domAuthoring_toolRef docAuthTool =
82 domContrA.get(i)->getAuthoring_tool();
84 if(osgStringNCaseCmp(docAuthTool->getValue(),
85 "Google SketchUp",
86 15 ) == 0)
88 SINFO << "ColladaCOLLADA::read: Detected Google SketchUp file "
89 << "enabling transparency workaround." << std::endl;
91 getGlobal()->getOptions()->setInvertTransparency(true);
92 break;
97 domCOLLADA::domSceneRef scene = collada->getScene();
98 ColladaSceneRefPtr colScene = getUserDataAs<ColladaScene>(scene);
100 if(colScene == NULL)
102 colScene = dynamic_pointer_cast<ColladaScene>(
103 ColladaElementFactory::the()->create(scene, getGlobal()));
105 colScene->read(this);
107 if(getGlobal()->getOptions()->getLoadAnimations() == true)
109 const domLibrary_animation_clips_Array &animClipLibs =
110 collada->getLibrary_animation_clips_array();
112 for(UInt32 i = 0; i < animClipLibs.getCount(); ++i)
114 ColladaLibraryAnimationClipsRefPtr colLibAnimClips =
115 getUserDataAs<ColladaLibraryAnimationClips>(animClipLibs[i]);
117 if(colLibAnimClips == NULL)
119 colLibAnimClips =
120 dynamic_pointer_cast<ColladaLibraryAnimationClips>(
121 ColladaElementFactory::the()->create(
122 animClipLibs[i], getGlobal()));
124 colLibAnimClips->read(this);
130 ColladaCOLLADA::ColladaCOLLADA(daeElement *elem, ColladaGlobal *global)
131 : Inherited(elem, global)
135 ColladaCOLLADA::~ColladaCOLLADA(void)
139 OSG_END_NAMESPACE
141 #endif // OSG_WITH_COLLADA