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 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
40 #pragma GCC diagnostic ignored "-Wold-style-cast"
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>
56 ColladaElementRegistrationHelper
ColladaCOLLADA::_regHelper(
57 &ColladaCOLLADA::create
, "COLLADA");
60 ColladaElementTransitPtr
61 ColladaCOLLADA::create(daeElement
*elem
, ColladaGlobal
*global
)
63 return ColladaElementTransitPtr(new ColladaCOLLADA(elem
, global
));
67 ColladaCOLLADA::read(ColladaElement
*colElemParent
)
69 OSG_COLLADA_LOG(("ColladaCOLLADA::read\n"));
71 domCOLLADARef collada
= getDOMElementAs
<domCOLLADA
>();
72 domAssetRef docAsset
= collada
->getAsset();
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(),
88 SINFO
<< "ColladaCOLLADA::read: Detected Google SketchUp file "
89 << "enabling transparency workaround." << std::endl
;
91 getGlobal()->getOptions()->setInvertTransparency(true);
97 domCOLLADA::domSceneRef scene
= collada
->getScene();
98 ColladaSceneRefPtr colScene
= getUserDataAs
<ColladaScene
>(scene
);
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
)
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)
141 #endif // OSG_WITH_COLLADA