changed: gcc8 base update
[opensg.git] / Source / System / FileIO / Collada / OSGColladaInstanceEffect.cpp
blob26b3c1bcdb89d80e594da3511c88e5f40651f70d
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 "OSGColladaInstanceEffect.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
49 #include <dom/domInstance_effect.h>
51 OSG_BEGIN_NAMESPACE
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));
62 void
63 ColladaInstanceEffect::read(ColladaElement *colElemParent)
65 OSG_COLLADA_LOG(("ColladaInstanceEffect::read\n"));
67 ColladaEffectRefPtr colEffect = getTargetElem();
69 if(colEffect == NULL)
71 colEffect = dynamic_pointer_cast<ColladaEffect>(
72 ColladaElementFactory::the()->create(
73 getTargetDOMElem(), getGlobal()));
75 colEffect->read(this);
78 #if 0
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."
89 << std::endl;
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."
99 << std::endl;
101 #endif
104 ColladaEffect *
105 ColladaInstanceEffect::getTargetElem(void) const
107 ColladaEffect *retVal = NULL;
108 domEffectRef targetElem = getTargetDOMElem();
110 if(targetElem != NULL)
112 retVal = getUserDataAs<ColladaEffect>(targetElem);
115 return retVal;
118 domEffect *
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());
128 else
130 SWARNING << "ColladaInstanceEffet::getTargetDOMElem: "
131 << "can not resolve URL [" << instEffect->getUrl().str()
132 << "]." << std::endl;
135 return retVal;
138 const ColladaInstanceEffect::TCSymbolToSlotMap &
139 ColladaInstanceEffect::getTCMap(void) const
141 return _tcMap;
144 ColladaInstanceEffect::TCSymbolToSlotMap &
145 ColladaInstanceEffect::editTCMap(void)
147 return _tcMap;
150 bool
151 ColladaInstanceEffect::findTC(
152 const std::string &tcSymbol, UInt32 &texSlot) const
154 bool retVal = false;
155 TCSymbolToSlotMapConstIt tcIt = _tcMap.find(tcSymbol);
157 if(tcIt != _tcMap.end())
159 texSlot = tcIt->second;
160 retVal = true;
163 return retVal;
166 ColladaInstanceEffect::ColladaInstanceEffect(
167 daeElement *elem, ColladaGlobal *global) :
169 Inherited(elem, global),
170 _tcMap ( )
174 ColladaInstanceEffect::~ColladaInstanceEffect(void)
178 OSG_END_NAMESPACE
180 #endif // OSG_WITH_COLLADA