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 "OSGColladaMayaExtraHandler.h"
44 #include "OSGColladaLog.h"
45 #include "OSGColladaGeometry.h"
46 #include "OSGColladaTexture.h"
48 #ifdef OSG_WITH_COLLADA
53 ColladaExtraHandlerRegHelper
ColladaMayaExtraHandler::_regHelper(
54 &ColladaMayaExtraHandler::create
);
56 ColladaExtraHandlerTransitPtr
ColladaMayaExtraHandler::create(void)
58 ColladaExtraHandlerTransitPtr
returnValue(new ColladaMayaExtraHandler
);
63 void ColladaMayaExtraHandler::readTextureExtraElements(
64 ColladaTexture
*texture
,
65 const domExtra
*extra
)
67 OSG_COLLADA_LOG(("ColladaMayaExtraHandler::readTextureParams %p %p\n",
71 const domTechnique_Array
&extraTechniques
= extra
->getTechnique_array();
73 for(UInt32 j
= 0; j
< extraTechniques
.getCount(); ++j
)
75 xsNMTOKEN extraProfile
= extraTechniques
[j
]->getProfile();
77 OSG_COLLADA_LOG(("Found extra profile %s\n",
80 if(osgStringNCmp(extraProfile
, "OpenCOLLADAMaya", 15) == 0)
82 OSG_COLLADA_LOG(("processing OpenCOLLADAMaya\n"));
84 const daeElementRefArray
&profileElements
=
85 extraTechniques
[j
]->getContents();
87 Vec3f
t(0.f
, 0.f
, 0.f
);
88 Vec3f
s(1.f
, 1.f
, 1.f
);
89 Quaternion
r(0.f
, 0.f
, 0.f
, 1.f
);
91 bool bMatrixModified
= false;
93 for(UInt32 k
= 0; k
< profileElements
.getCount(); ++k
)
95 OSG_COLLADA_LOG(("prElemName : %s | %s\n",
96 profileElements
[k
]->getElementName(),
97 profileElements
[k
]->getCharData().c_str()));
99 if(osgStringNCmp(profileElements
[k
]->getElementName(),
104 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
109 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
114 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
119 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
123 UInt32 mirrorU
= TypeTraits
<UInt32
>::getFromCString(
124 profileElements
[k
]->getCharData().c_str());
131 bMatrixModified
= true;
133 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
137 UInt32 mirrorV
= TypeTraits
<UInt32
>::getFromCString(
138 profileElements
[k
]->getCharData().c_str());
145 bMatrixModified
= true;
147 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
152 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
157 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
161 t
[0] = TypeTraits
<Real32
>::getFromCString(
162 profileElements
[k
]->getCharData().c_str());
164 bMatrixModified
= true;
166 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
170 t
[1] = TypeTraits
<Real32
>::getFromCString(
171 profileElements
[k
]->getCharData().c_str());
173 bMatrixModified
= true;
175 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
179 s
[0] *= TypeTraits
<Real32
>::getFromCString(
180 profileElements
[k
]->getCharData().c_str());
182 bMatrixModified
= true;
184 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
188 s
[1] *= TypeTraits
<Real32
>::getFromCString(
189 profileElements
[k
]->getCharData().c_str());
191 bMatrixModified
= true;
193 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
198 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
204 TypeTraits
<Real32
>::getFromCString(
205 profileElements
[k
]->getCharData().c_str()));
207 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
212 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
217 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
222 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
226 UInt32 wrapU
= TypeTraits
<UInt32
>::getFromCString(
227 profileElements
[k
]->getCharData().c_str());
229 TextureObjChunk
*pTex
= texture
->getTexture();
233 pTex
->setWrapS(GL_REPEAT
);
237 pTex
->setWrapS(GL_CLAMP_TO_BORDER
);
240 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
244 UInt32 wrapV
= TypeTraits
<UInt32
>::getFromCString(
245 profileElements
[k
]->getCharData().c_str());
247 TextureObjChunk
*pTex
= texture
->getTexture();
251 pTex
->setWrapT(GL_REPEAT
);
255 pTex
->setWrapT(GL_CLAMP_TO_BORDER
);
260 OSG_COLLADA_LOG(("ColladaMayaExtraHandler::readTexParam: "
261 "unknown OpenColladaMaya parameter %s\n",
262 profileElements
[k
]->getElementName()));
266 if(bMatrixModified
== true)
268 TextureTransformChunk
*pTexTr
= texture
->editTexTransform();
270 pTexTr
->editMatrix().setTransform(t
, r
, s
);
273 else if(osgStringNCmp(extraProfile
, "MAYA", 4) == 0)
275 OSG_COLLADA_LOG(("processing MAYA\n"));
277 const daeElementRefArray
&profileElements
=
278 extraTechniques
[j
]->getContents();
280 for(UInt32 k
= 0; k
< profileElements
.getCount(); ++k
)
282 OSG_COLLADA_LOG(("prElemName : %s | %s\n",
283 profileElements
[k
]->getElementName(),
284 profileElements
[k
]->getCharData().c_str()));
286 if(osgStringNCmp(profileElements
[k
]->getElementName(),
290 bool wrapU
= TypeTraits
<bool>::getFromCString(
291 profileElements
[k
]->getCharData().c_str());
293 TextureObjChunk
*pTex
= texture
->getTexture();
297 pTex
->setWrapS(GL_REPEAT
);
301 pTex
->setWrapS(GL_CLAMP_TO_BORDER
);
304 else if(osgStringNCmp(profileElements
[k
]->getElementName(),
308 bool wrapV
= TypeTraits
<bool>::getFromCString(
309 profileElements
[k
]->getCharData().c_str());
311 TextureObjChunk
*pTex
= texture
->getTexture();
315 pTex
->setWrapT(GL_REPEAT
);
319 pTex
->setWrapT(GL_CLAMP_TO_BORDER
);
324 OSG_COLLADA_LOG(("ColladaMayaExtraHandler::readTexParam:"
325 "MAYA : unknown parameter %s\n",
326 profileElements
[k
]->getElementName()));
333 void ColladaMayaExtraHandler::readTechniqueExtraElements(
334 ColladaEffect
*effect
,
335 const domExtra
*extra
)
339 void ColladaMayaExtraHandler::readProfileExtraElements(
340 ColladaEffect
*effect
,
341 const domExtra
*extra
)
345 void ColladaMayaExtraHandler::readGeometryExtraElements(
346 ColladaGeometry
*geometry
,
347 const domExtra
*extra
)
349 OSG_COLLADA_LOG(("ColladaMayaExtraHandler::readGeoExtraElems %p %p\n",
353 const domTechnique_Array
&extraTechniques
= extra
->getTechnique_array();
355 for(UInt32 j
= 0; j
< extraTechniques
.getCount(); ++j
)
357 xsNMTOKEN extraProfile
= extraTechniques
[j
]->getProfile();
359 OSG_COLLADA_LOG(("Found extra profile %s\n",
362 if(osgStringNCmp(extraProfile
, "OpenCOLLADAMaya", 15) == 0)
364 OSG_COLLADA_LOG(("processing\n"));
366 const daeElementRefArray
&profileElements
=
367 extraTechniques
[j
]->getContents();
369 for(UInt32 k
= 0; k
< profileElements
.getCount(); ++k
)
371 OSG_COLLADA_LOG(("prElemName : %s | %s\n",
372 profileElements
[k
]->getElementName(),
373 profileElements
[k
]->getCharData().c_str()));
376 if(osgStringNCmp(profileElements
[k
]->getElementName(),
381 TypeTraits
<UInt32
>::getFromCString(
382 profileElements
[k
]->getCharData().c_str()) != 0;
384 geometry
->setDoubleSided(doubleSided
);
391 void ColladaMayaExtraHandler::instProfileExtraElements(ColladaEffect
*effect
,
397 ColladaMayaExtraHandler::ColladaMayaExtraHandler(void) :
402 ColladaMayaExtraHandler::~ColladaMayaExtraHandler(void)
408 #endif // OSG_WITH_COLLADA