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 "OSGColladaInstanceEffect.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
49 #include <dom/domInstance_effect.h>
53 ColladaElementRegistrationHelper
ColladaInstanceEffect::_regHelper(
54 &ColladaInstanceEffect::create
, "instance_effect");
56 ColladaElementTransitPtr
57 ColladaInstanceEffect::create(daeElement
*elem
, ColladaGlobal
*global
)
59 return ColladaElementTransitPtr(new ColladaInstanceEffect(elem
, global
));
63 ColladaInstanceEffect::read(ColladaElement
*colElemParent
)
65 OSG_COLLADA_LOG(("ColladaInstanceEffect::read\n"));
67 ColladaEffectRefPtr colEffect
= getTargetElem();
71 colEffect
= dynamic_pointer_cast
<ColladaEffect
>(
72 ColladaElementFactory::the()->create(
73 getTargetDOMElem(), getGlobal()));
75 colEffect
->read(this);
79 domInstance_effectRef instEffect
= getDOMElementAs
<domInstance_effect
>();
81 const domInstance_effect::domTechnique_hint_Array
&techHints
=
82 instEffect
->getTechnique_hint_array();
84 // what's the point of this?
85 if(techHints
.getCount() > 0)
87 SWARNING
<< "ColladaInstanceEffect::read: Ignoring ["
88 << techHints
.getCount() << "] <technique_hint> elements."
92 const domInstance_effect::domSetparam_Array
&setParams
=
93 instEffect
->getSetparam_array();
95 if(setParams
.getCount() > 0)
97 SWARNING
<< "ColladaInstanceEffect::read: Ignoring ["
98 << setParams
.getCount() << "] <setparam> elements."
105 ColladaInstanceEffect::getTargetElem(void) const
107 ColladaEffect
*retVal
= NULL
;
108 domEffectRef targetElem
= getTargetDOMElem();
110 if(targetElem
!= NULL
)
112 retVal
= getUserDataAs
<ColladaEffect
>(targetElem
);
119 ColladaInstanceEffect::getTargetDOMElem(void) const
121 domEffectRef retVal
= NULL
;
122 domInstance_effectRef instEffect
= getDOMElementAs
<domInstance_effect
>();
124 if(instEffect
->getUrl().getElement() != NULL
)
126 retVal
= daeSafeCast
<domEffect
>(instEffect
->getUrl().getElement());
130 SWARNING
<< "ColladaInstanceEffet::getTargetDOMElem: "
131 << "can not resolve URL [" << instEffect
->getUrl().str()
132 << "]." << std::endl
;
138 const ColladaInstanceEffect::TCSymbolToSlotMap
&
139 ColladaInstanceEffect::getTCMap(void) const
144 ColladaInstanceEffect::TCSymbolToSlotMap
&
145 ColladaInstanceEffect::editTCMap(void)
151 ColladaInstanceEffect::findTC(
152 const std::string
&tcSymbol
, UInt32
&texSlot
) const
155 TCSymbolToSlotMapConstIt tcIt
= _tcMap
.find(tcSymbol
);
157 if(tcIt
!= _tcMap
.end())
159 texSlot
= tcIt
->second
;
166 ColladaInstanceEffect::ColladaInstanceEffect(
167 daeElement
*elem
, ColladaGlobal
*global
) :
169 Inherited(elem
, global
),
174 ColladaInstanceEffect::~ColladaInstanceEffect(void)
180 #endif // OSG_WITH_COLLADA