Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WIP changed: loader rewrite make pieces customizable through factory

git-svn-id: https://opensg.vrsource.org/svn/trunk@2243 4683daeb-ad0f-0410-a623-93161e962ae5
  • Loading branch information...
commit cba999d4369be3198c8c68019ec189e6f31f5e0a 1 parent f9befdd
cneumann authored
Showing with 2,720 additions and 6,875 deletions.
  1. +0 −734 Source/System/FileIO/Collada/OSGColladaEffect.cpp
  2. +0 −153 Source/System/FileIO/Collada/OSGColladaEffect.h
  3. +0 −96 Source/System/FileIO/Collada/OSGColladaEffect.inl
  4. +17 −24 Source/System/FileIO/Collada/OSGColladaElement.cpp
  5. +31 −33 Source/System/FileIO/Collada/OSGColladaElement.h
  6. +14 −14 Source/System/FileIO/Collada/OSGColladaElement.inl
  7. +286 −0 Source/System/FileIO/Collada/OSGColladaElementFactory.cpp
  8. +163 −0 Source/System/FileIO/Collada/OSGColladaElementFactory.h
  9. +11 −4 Source/System/FileIO/Collada/{OSGColladaInstanceLight.inl → OSGColladaElementFactoryHelper.cpp}
  10. +23 −37 Source/System/FileIO/Collada/{OSGColladaImage.h → OSGColladaElementFactoryHelper.h}
  11. +36 −134 Source/System/FileIO/Collada/OSGColladaFileType.cpp
  12. +35 −165 Source/System/FileIO/Collada/OSGColladaFileType.h
  13. +0 −114 Source/System/FileIO/Collada/OSGColladaGeoInputAttachment.cpp
  14. +0 −59 Source/System/FileIO/Collada/OSGColladaGeoInputAttachment.fcd
  15. +0 −43 Source/System/FileIO/Collada/OSGColladaGeoInputAttachment.inl
  16. +0 −947 Source/System/FileIO/Collada/OSGColladaGeoInputAttachmentBase.cpp
  17. +0 −356 Source/System/FileIO/Collada/OSGColladaGeoInputAttachmentBase.h
  18. +0 −169 Source/System/FileIO/Collada/OSGColladaGeoInputAttachmentBase.inl
  19. +0 −223 Source/System/FileIO/Collada/OSGColladaGeoInputAttachmentFields.h
  20. +404 −418 Source/System/FileIO/Collada/OSGColladaGeometry.cpp
  21. +119 −101 Source/System/FileIO/Collada/OSGColladaGeometry.h
  22. +0 −57 Source/System/FileIO/Collada/OSGColladaGeometry.inl
  23. +121 −126 Source/System/FileIO/Collada/OSGColladaGlobal.cpp
  24. +103 −45 Source/System/FileIO/Collada/OSGColladaGlobal.h
  25. +39 −22 Source/System/FileIO/Collada/OSGColladaGlobal.inl
  26. +0 −113 Source/System/FileIO/Collada/OSGColladaImage.cpp
  27. +0 −52 Source/System/FileIO/Collada/OSGColladaImage.inl
  28. +16 −13 Source/System/FileIO/Collada/OSGColladaInstanceElement.cpp
  29. +29 −29 Source/System/FileIO/Collada/OSGColladaInstanceElement.h
  30. +0 −57 Source/System/FileIO/Collada/OSGColladaInstanceElement.inl
  31. +50 −287 Source/System/FileIO/Collada/OSGColladaInstanceGeometry.cpp
  32. +51 −50 Source/System/FileIO/Collada/OSGColladaInstanceGeometry.h
  33. +0 −48 Source/System/FileIO/Collada/OSGColladaInstanceGeometry.inl
  34. +0 −129 Source/System/FileIO/Collada/OSGColladaInstanceLight.cpp
  35. +51 −49 Source/System/FileIO/Collada/OSGColladaInstanceNode.cpp
  36. +56 −26 Source/System/FileIO/Collada/OSGColladaInstanceNode.h
  37. +0 −48 Source/System/FileIO/Collada/OSGColladaInstanceNode.inl
  38. +58 −45 Source/System/FileIO/Collada/OSGColladaInstanceVisualScene.cpp
  39. +51 −24 Source/System/FileIO/Collada/OSGColladaInstanceVisualScene.h
  40. +0 −48 Source/System/FileIO/Collada/OSGColladaInstanceVisualScene.inl
  41. +13 −13 Source/System/FileIO/Collada/OSGColladaInstantiableElement.cpp
  42. +34 −17 Source/System/FileIO/Collada/OSGColladaInstantiableElement.h
  43. +7 −6 Source/System/FileIO/Collada/{OSGColladaLight.inl → OSGColladaInstantiableElement.inl}
  44. +0 −206 Source/System/FileIO/Collada/OSGColladaLight.cpp
  45. +0 −150 Source/System/FileIO/Collada/OSGColladaLoader.cpp
  46. +0 −207 Source/System/FileIO/Collada/OSGColladaLoader.h
  47. +1 −3 Source/System/FileIO/Collada/OSGColladaLog.h
  48. +268 −154 Source/System/FileIO/Collada/OSGColladaNode.cpp
  49. +70 −48 Source/System/FileIO/Collada/OSGColladaNode.h
  50. +19 −6 Source/System/FileIO/Collada/{OSGColladaNode.inl → OSGColladaOptions.cpp}
  51. +43 −50 Source/System/FileIO/Collada/{OSGColladaLight.h → OSGColladaOptions.h}
  52. +4 −4 Source/System/FileIO/Collada/{OSGColladaSource.inl → OSGColladaOptions.inl}
  53. +0 −121 Source/System/FileIO/Collada/OSGColladaSampler2D.cpp
  54. +0 −103 Source/System/FileIO/Collada/OSGColladaSampler2D.h
  55. +0 −57 Source/System/FileIO/Collada/OSGColladaSampler2D.inl
  56. +58 −45 Source/System/FileIO/Collada/{OSGColladaInstanceLight.h → OSGColladaScene.cpp}
  57. +40 −53 Source/System/FileIO/Collada/{OSGColladaGeoInputAttachment.h → OSGColladaScene.h}
  58. +212 −100 Source/System/FileIO/Collada/OSGColladaSource.cpp
  59. +69 −36 Source/System/FileIO/Collada/OSGColladaSource.h
  60. +0 −126 Source/System/FileIO/Collada/OSGColladaSurface.cpp
  61. +0 −97 Source/System/FileIO/Collada/OSGColladaSurface.h
  62. +0 −52 Source/System/FileIO/Collada/OSGColladaSurface.inl
  63. +73 −34 Source/System/FileIO/Collada/OSGColladaVisualScene.cpp
  64. +45 −42 Source/System/FileIO/Collada/OSGColladaVisualScene.h
  65. +0 −53 Source/System/FileIO/Collada/OSGColladaVisualScene.inl
View
734 Source/System/FileIO/Collada/OSGColladaEffect.cpp
@@ -1,734 +0,0 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2008 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
-
-#if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
-//#pragma GCC diagnostic warning "-Wold-style-cast"
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif
-
-#include "OSGColladaEffect.h"
-#include "OSGColladaLog.h"
-
-#ifdef OSG_WITH_COLLADA
-
-#include "OSGColladaGlobal.h"
-#include "OSGColladaImage.h"
-#include "OSGColladaSampler2D.h"
-
-#include "OSGImage.h"
-#include "OSGBlendChunk.h"
-#include "OSGMaterialChunk.h"
-#include "OSGTextureEnvChunk.h"
-#include "OSGTextureObjChunk.h"
-
-#include <dom/domEffect.h>
-#include <dom/domProfile_COMMON.h>
-#include <dom/domProfile_GLSL.h>
-#include <dom/domProfile_CG.h>
-
-OSG_BEGIN_NAMESPACE
-
-void ColladaEffect::read(void)
-{
- OSG_COLLADA_LOG(("ColladaEffect::read:\n"));
-
- domEffectRef effect = getDOMElementAs<domEffect>();
-
- if(effect == NULL)
- return;
-
- OSG_COLLADA_LOG(("ColladaEffect::read: <effect> [%s] [%s]\n",
- effect->getId(), effect->getDocumentURI()->getURI()));
-
- UInt32 numProfiles =
- effect->getFx_profile_abstract_array().getCount();
-
- OSG_COLLADA_LOG(("ColladaEffect::read: profiles [%u]\n", numProfiles));
-
- for(UInt32 i = 0; i < numProfiles; ++i)
- {
- OSG_COLLADA_LOG(("ColladaEffect::read: profile [%u] [%s]\n",
- i, effect->getFx_profile_abstract_array()[i]->getTypeName()));
-
- domProfile_COMMONRef profCommon =
- daeSafeCast<domProfile_COMMON>(
- effect->getFx_profile_abstract_array()[i]);
-
- domProfile_GLSLRef profGLSL =
- daeSafeCast<domProfile_GLSL>(
- effect->getFx_profile_abstract_array()[i]);
-
- domProfile_CGRef profCG =
- daeSafeCast<domProfile_CG>(
- effect->getFx_profile_abstract_array()[i]);
-
- if(profCommon != NULL)
- {
- handleCommonProfile(profCommon);
- }
- else if(profGLSL != NULL)
- {
- handleGLSLProfile(profGLSL);
- }
- else if(profCG != NULL)
- {
- handleCGProfile(profCG);
- }
- else
- {
- FWARNING(("ColladaEffect::read: Unknown profile.\n"));
- }
- }
-}
-
-domFx_surface_common *ColladaEffect::getSurface(const std::string &ref)
-{
- domFx_surface_common *returnValue = NULL;
-
- SurfaceMap::iterator surfIt = _surfaceMap.find(ref);
-
- if(surfIt != _surfaceMap.end())
- {
- returnValue = surfIt->second;
- }
-
- return returnValue;
-}
-
-UInt32 ColladaEffect::getTexBinding(const std::string &ref)
-{
- UInt32 returnValue = 0xFFFF;
-
- for(UInt32 i = 0; i < _texCoordMapping.size(); ++i)
- {
- if(_texCoordMapping[i] == ref)
- {
- returnValue = i;
- break;
- }
- }
-
- return returnValue;
-}
-
-
-ColladaEffect::ColladaEffect(domEffect *effect, ColladaGlobal *global)
-
- : Inherited(effect, global)
-{
- // nothing to do
-}
-
-ColladaEffect::~ColladaEffect(void)
-{
- // nothing to do
-}
-
-void ColladaEffect::handleCommonProfile(domProfile_COMMON *profCommon)
-{
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile:\n"));
-
- domProfile_COMMON::domTechniqueRef technique = profCommon->getTechnique();
-
- if(technique == NULL)
- return;
-
- if(_material == NULL)
- _material = ChunkMaterial::create();
-
- const domCommon_newparam_type_Array &params =
- profCommon->getNewparam_array();
-
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: num params [%u]\n",
- params.getCount()));
-
- for(UInt32 i = 0; i < params.getCount(); ++i)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: param [%d] sid [%s]\n",
- i, params[i]->getSid()));
-
- if(params[i]->getSurface() != NULL)
- {
- _surfaceMap[params[i]->getSid()] = params[i]->getSurface();
- }
-
- if(params[i]->getSampler2D() != NULL)
- {
- _samplerMap[params[i]->getSid()] = params[i]->getSampler2D();
- }
- }
-
- if(technique->getConstant() != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: technique constant\n"));
-
- FWARNING(("ColladaEffect::handleCommonProfile: technique constant NIY\n"));
- }
- else if(technique->getLambert() != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: technique lambert\n"));
-
- setupSimpleColorAndTex(technique->getLambert());
- }
- else if(technique->getPhong())
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: technique phong\n"));
-
- setupSimpleSpecColorAndTex(technique->getPhong());
- }
- else if(technique->getBlinn())
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleCommonProfile: technique blinn\n"));
-
- setupSimpleSpecColorAndTex(technique->getBlinn());
- }
- else
- {
- FWARNING(("ColladaEffect::handleCommonProfile: Unknown technique.\n"));
- }
-}
-
-void ColladaEffect::handleGLSLProfile(domProfile_GLSL *profGLSL)
-{
- FWARNING(("ColladaEffect::handleGLSLProfile: NIY\n"));
-}
-
-void ColladaEffect::handleCGProfile(domProfile_CG *profCG)
-{
- FWARNING(("ColladaEffect::handleCGProfile: NIY\n"));
-}
-
-template <class TechTypeT>
-void ColladaEffect::setupSimpleColorAndTex(
- TechTypeT tech,
- DomFloat *shininess,
- DomColor *specularCol,
- DomTexture *specularTex )
-{
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex:\n"));
-
- if(tech == NULL)
- return;
-
- domCommon_color_or_texture_type::domColorRef diffuseCol = NULL;
- domCommon_color_or_texture_type::domTextureRef diffuseTex = NULL;
-
- domCommon_color_or_texture_type::domColorRef ambientCol = NULL;
- domCommon_color_or_texture_type::domTextureRef ambientTex = NULL;
-
- domCommon_color_or_texture_type::domColorRef emissionCol = NULL;
- domCommon_color_or_texture_type::domTextureRef emissionTex = NULL;
-
- domCommon_color_or_texture_type::domColorRef transCol = NULL;
- domCommon_color_or_texture_type::domTextureRef transTex = NULL;
-
- fillElements(tech->getDiffuse (), diffuseCol, diffuseTex );
- fillElements(tech->getAmbient (), ambientCol, ambientTex );
- fillElements(tech->getEmission (), emissionCol, emissionTex);
- fillElements(tech->getTransparent(), transCol, transTex );
-
- domCommon_float_or_param_typeRef transparency =
- tech->getTransparency();
-
- Real32 shininessVal = 10.f;
- Real32 transparencyVal = 1.f;
-
- if(shininess != NULL && shininess->getFloat() != NULL)
- shininessVal = shininess->getFloat()->getValue();
-
- if(transparency != NULL && transparency->getFloat() != NULL)
- {
- if(_global != NULL && _global->invertTransparency() == true)
- {
- transparencyVal = 1.f - transparency->getFloat()->getValue();
- }
- else
- {
- transparencyVal = transparency->getFloat()->getValue();
- }
- }
-
- MaterialChunkTransitPtr matChunk = handleSimpleColor(
- diffuseCol,
- ambientCol,
- specularCol,
- emissionCol,
- transCol,
- tech->getTransparent()->getOpaque(),
- shininessVal,
- transparencyVal);
-
- UInt32 currTex = 0;
-
- if(ambientTex != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: Got ambient texture [%s]\n",
- ambientTex->getTexture()));
-
- SamplerMap::iterator samplerIt;
-
- samplerIt = _samplerMap.find(ambientTex->getTexture());
-
- if(samplerIt != _samplerMap.end())
- {
- domFx_sampler2D_commonRef sampler = samplerIt->second;
-
- ColladaSampler2DRefPtr colSampler =
- getUserDataAs<ColladaSampler2D>(sampler);
-
- if(colSampler == NULL)
- {
- colSampler = ColladaSampler2D::create(sampler, getGlobal());
- addElement(colSampler);
-
- colSampler->setEffect(this);
- colSampler->read ( );
- }
-
- TextureObjChunkUnrecPtr texObj = colSampler->getTexObj();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: got texObj [%p]\n", texObj.get()));
-
- if(texObj != NULL)
- {
- TextureEnvChunkUnrecPtr texEnv = TextureEnvChunk::create();
-
- _material->addChunk(texObj);
- _material->addChunk(texEnv);
-
- texEnv->setEnvMode(GL_REPLACE);
-
- setTexCoordMapping(currTex++, ambientTex->getTexcoord());
-
- if(texObj->getImage() != NULL &&
- texObj->getImage()->hasAlphaChannel() == true )
- {
- StateChunk *stateChunk =
- _material->find(BlendChunk::getClassType());
-
- if(stateChunk == NULL)
- {
- BlendChunkUnrecPtr blendChunk = BlendChunk::create();
-
- blendChunk->setSrcFactor (GL_SRC_ALPHA );
- blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
-
- _material->addChunk(blendChunk);
- }
- }
- }
- }
- else
- {
- domEffectRef effect = getDOMElementAs<domEffect>();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: got <effect> [%s] [%s]\n",
- effect->getId(),
- effect->getDocumentURI()->getURI()));
-
- std::string imageUriStr = effect->getDocumentURI()->getURI();
-
- imageUriStr += "#";
- imageUriStr += ambientTex->getTexture();
-
- daeURI imageUri(getGlobal()->getDAE(), imageUriStr);
-
- imageUri.resolveElement();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: textureUri [%s] [%d]\n",
- imageUri.getURI(), imageUri.getState()));
-
- daeElementRef imageElem = imageUri.getElement();
- domImageRef image = daeSafeCast<domImage>(imageElem);
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: imageElem [%s] [%s]\n",
- imageElem->getTypeName(),
- imageElem->getElementName()));
-
- ColladaImageRefPtr colImage = getUserDataAs<ColladaImage>(image);
-
- if(colImage == NULL)
- {
- colImage = ColladaImage::create(image, getGlobal());
- addElement(colImage);
-
- colImage->read();
- }
-
- ImageUnrecPtr texImage = colImage->getImage();
-
- if(texImage != NULL)
- {
- TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
- TextureEnvChunkUnrecPtr texEnv = TextureEnvChunk::create();
-
- texObj->setImage(texImage);
-
- _material->addChunk(texObj);
- _material->addChunk(texEnv);
-
- texEnv->setEnvMode(GL_REPLACE);
-
- setTexCoordMapping(currTex++, ambientTex->getTexcoord());
-
- if(texObj->getImage() != NULL &&
- texObj->getImage()->hasAlphaChannel() == true )
- {
- StateChunk *stateChunk =
- _material->find(BlendChunk::getClassType());
-
- if(stateChunk == NULL)
- {
- BlendChunkUnrecPtr blendChunk = BlendChunk::create();
-
- blendChunk->setSrcFactor (GL_SRC_ALPHA );
- blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
-
- _material->addChunk(blendChunk);
- }
- }
- }
- }
- }
-
- if(diffuseTex != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: Got diffuse texture [%s]\n",
- diffuseTex->getTexture()));
-
- Color4f colVal;
-
- colVal[0] = 0.8f;
- colVal[1] = 0.8f;
- colVal[2] = 0.8f;
- colVal[3] = 1.0f;
-
- matChunk->setDiffuse(colVal);
-
- SamplerMap::iterator samplerIt;
-
- samplerIt = _samplerMap.find(diffuseTex->getTexture());
-
- if(samplerIt != _samplerMap.end())
- {
- domFx_sampler2D_commonRef sampler = samplerIt->second;
-
- ColladaSampler2DRefPtr colSampler =
- getUserDataAs<ColladaSampler2D>(sampler);
-
- if(colSampler == NULL)
- {
- colSampler = ColladaSampler2D::create(sampler, getGlobal());
- addElement(colSampler);
-
- colSampler->setEffect(this);
- colSampler->read ( );
- }
-
- TextureObjChunkUnrecPtr texObj = colSampler->getTexObj();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: got texObj [%p]\n", texObj.get()));
-
- if(texObj != NULL)
- {
- TextureEnvChunkUnrecPtr texEnv = TextureEnvChunk::create();
-
- _material->addChunk(texObj);
- _material->addChunk(texEnv);
-
- texEnv->setEnvMode(GL_MODULATE);
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: texCoordMapping [%u] [%s]\n",
- currTex, diffuseTex->getTexcoord()));
-
- setTexCoordMapping(currTex++, diffuseTex->getTexcoord());
-
- if(texObj->getImage() != NULL &&
- texObj->getImage()->hasAlphaChannel() == true )
- {
- StateChunk *stateChunk =
- _material->find(BlendChunk::getClassType());
-
- if(stateChunk == NULL)
- {
- BlendChunkUnrecPtr blendChunk = BlendChunk::create();
-
- blendChunk->setSrcFactor (GL_SRC_ALPHA );
- blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
-
- _material->addChunk(blendChunk);
- }
- }
- }
- }
- else
- {
- domEffectRef effect = getDOMElementAs<domEffect>();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: got <effect> [%s] [%s]\n",
- effect->getId(),
- effect->getDocumentURI()->getURI()));
-
- std::string imageUriStr = effect->getDocumentURI()->getURI();
-
- imageUriStr += "#";
- imageUriStr += diffuseTex->getTexture();
-
- daeURI imageUri(getGlobal()->getDAE(), imageUriStr);
-
- imageUri.resolveElement();
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: textureUri [%s] [%d]\n",
- imageUri.getURI(), imageUri.getState()));
-
- daeElementRef imageElem = imageUri.getElement();
- domImageRef image = daeSafeCast<domImage>(imageElem);
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: imageElem [%s] [%s]\n",
- imageElem->getTypeName(),
- imageElem->getElementName()));
-
- ColladaImageRefPtr colImage = getUserDataAs<ColladaImage>(image);
-
- if(colImage == NULL)
- {
- colImage = ColladaImage::create(image, getGlobal());
- addElement(colImage);
-
- colImage->read();
- }
-
- ImageUnrecPtr texImage = colImage->getImage();
-
- if(texImage != NULL)
- {
- TextureObjChunkUnrecPtr texObj = TextureObjChunk::create();
- TextureEnvChunkUnrecPtr texEnv = TextureEnvChunk::create();
-
- texObj->setImage(texImage);
-
- _material->addChunk(texObj);
- _material->addChunk(texEnv);
-
- texEnv->setEnvMode(GL_MODULATE);
-
- OSG_COLLADA_LOG(("ColladaEffect::setupSimpleColorAndTex: texCoordMapping [%u] [%s]\n",
- currTex, diffuseTex->getTexcoord()));
-
- setTexCoordMapping(currTex++, diffuseTex->getTexcoord());
-
- if(texObj->getImage() != NULL &&
- texObj->getImage()->hasAlphaChannel() == true )
- {
- StateChunk *stateChunk =
- _material->find(BlendChunk::getClassType());
-
- if(stateChunk == NULL)
- {
- BlendChunkUnrecPtr blendChunk = BlendChunk::create();
-
- blendChunk->setSrcFactor (GL_SRC_ALPHA );
- blendChunk->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
-
- _material->addChunk(blendChunk);
- }
- }
- }
- }
- }
-}
-
-template <class TechTypeT>
-void ColladaEffect::setupSimpleSpecColorAndTex(TechTypeT tech)
-{
- domCommon_color_or_texture_type::domColorRef specularCol = NULL;
- domCommon_color_or_texture_type::domTextureRef specularTex = NULL;
-
- fillElements(tech->getSpecular(), specularCol, specularTex);
-
- domCommon_float_or_param_typeRef shininess = tech->getShininess();
-
- setupSimpleColorAndTex(tech,
- shininess,
- specularCol,
- specularTex );
-}
-
-MaterialChunkTransitPtr ColladaEffect::handleSimpleColor(
- DomColor *diffuse,
- DomColor *ambient,
- DomColor *specular,
- DomColor *emission,
- DomColor *transparent,
- domFx_opaque_enum opaqueMode,
- Real32 shininess,
- Real32 transparency)
-{
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor:\n"));
-
- MaterialChunkUnrecPtr matChunk = MaterialChunk::create();
- bool useBlendChunk = false;
- Color4f colVal;
-
- if(transparent != NULL || transparency < (1.0 - Eps))
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: setting transparent color\n"));
-
- Color4r blendColor(1.0, 1.0, 1.0, 1.0);
- BlendChunkRefPtr blendChunk;
-
- if(opaqueMode == FX_OPAQUE_ENUM_A_ONE)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: FX_OPAQUE_ENUM_A_ONE mode\n"));
-
- if(transparent->getValue()[3] * transparency < (1.0 - Eps))
- {
- blendColor[0] = 0.0;
- blendColor[1] = 0.0;
- blendColor[2] = 0.0;
- blendColor[3] = transparent->getValue()[3] * transparency;
-
- blendChunk = BlendChunk::create();
- blendChunk->setSrcFactor (GL_CONSTANT_ALPHA_EXT );
- blendChunk->setDestFactor(GL_ONE_MINUS_CONSTANT_ALPHA_EXT);
- blendChunk->setColor (blendColor );
-
- useBlendChunk = true;
- }
- }
- else if(opaqueMode == FX_OPAQUE_ENUM_RGB_ZERO)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: FX_OPAQUE_ENUM_RGB_ZERO mode\n"));
-
- if(transparent->getValue()[0] * transparency > Eps ||
- transparent->getValue()[1] * transparency > Eps ||
- transparent->getValue()[2] * transparency > Eps )
- {
- blendColor[0] = transparent->getValue()[0] * transparency;
- blendColor[1] = transparent->getValue()[1] * transparency;
- blendColor[2] = transparent->getValue()[2] * transparency;
- blendColor[3] = computeLuminance(blendColor[0],
- blendColor[1],
- blendColor[2] );
-
- blendChunk = BlendChunk::create();
- blendChunk->setSrcFactor (GL_ONE_MINUS_CONSTANT_COLOR_EXT);
- blendChunk->setDestFactor(GL_CONSTANT_COLOR_EXT );
- blendChunk->setColor (blendColor );
-
- useBlendChunk = true;
- }
- }
- else
- {
- FWARNING(("ColladaEffect::handleSimpleColor: Unknown opaque value [%d]\n",
- opaqueMode));
- }
-
- if(blendChunk != NULL)
- _material->addChunk(blendChunk);
- }
-
- if(diffuse != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: setting diffuse color\n"));
-
- const domFx_color_common &color = diffuse->getValue();
-
- colVal[0] = color[0];
- colVal[1] = color[1];
- colVal[2] = color[2];
- colVal[3] = useBlendChunk ? color[3] : 1.0;
-
- matChunk->setDiffuse(colVal);
- }
-
- if(ambient != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: setting ambient color\n"));
-
- const domFx_color_common &color = ambient->getValue();
-
- colVal[0] = color[0];
- colVal[1] = color[1];
- colVal[2] = color[2];
- colVal[3] = useBlendChunk ? color[3] : 1.0;
-
- matChunk->setAmbient(colVal);
- }
-
- if(specular != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: setting specular color\n"));
-
- const domFx_color_common &color = specular->getValue();
-
- colVal[0] = color[0];
- colVal[1] = color[1];
- colVal[2] = color[2];
- colVal[3] = useBlendChunk ? color[3] : 1.0;
-
- matChunk->setSpecular(colVal);
- }
-
- if(emission != NULL)
- {
- OSG_COLLADA_LOG(("ColladaEffect::handleSimpleColor: setting emissive color\n"));
-
- const domFx_color_common &color = emission->getValue();
-
- colVal[0] = color[0];
- colVal[1] = color[1];
- colVal[2] = color[2];
- colVal[3] = useBlendChunk ? color[3] : 1.0;
-
- matChunk->setEmission(colVal);
- }
-
- shininess = osgClamp(0.f, shininess, 128.f);
-
- matChunk->setShininess(shininess);
-
- _material->addChunk(matChunk);
-
- return MaterialChunkTransitPtr(matChunk);
-}
-
-OSG_END_NAMESPACE
-
-#endif // OSG_WITH_COLLADA
View
153 Source/System/FileIO/Collada/OSGColladaEffect.h
@@ -1,153 +0,0 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2008 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
-
-#ifndef _OSGCOLLADAEFFECT_H_
-#define _OSGCOLLADAEFFECT_H_
-#ifdef __sgi
-#pragma once
-#endif
-
-/*! \file OSGColladaGeometry.h
- \ingroup GrpLoader
- */
-
-#include "OSGConfig.h"
-
-#ifdef OSG_WITH_COLLADA
-
-#include "OSGFileIODef.h"
-#include "OSGColladaElement.h"
-
-#include "OSGChunkMaterial.h"
-#include "OSGMaterialChunk.h"
-
-#include <dom/domCommon_color_or_texture_type.h>
-#include <dom/domCommon_float_or_param_type.h>
-#include <dom/domCommon_transparent_type.h>
-
-// forward declarations
-class domEffect;
-class domFx_surface_common;
-class domFx_sampler2D_common;
-class domProfile_COMMON;
-class domProfile_GLSL;
-class domProfile_CG;
-
-
-OSG_BEGIN_NAMESPACE
-
-class OSG_FILEIO_DLLMAPPING ColladaEffect : public ColladaElement
-{
- public:
- typedef ColladaElement Inherited;
- typedef ColladaEffect Self;
-
- typedef RefCountPtr<Self, MemObjRefCountPolicy> ObjRefPtr;
- typedef TransitPtr <Self > ObjTransitPtr;
-
- typedef domCommon_color_or_texture_type::domColor DomColor;
- typedef domCommon_color_or_texture_type::domTexture DomTexture;
- typedef domCommon_float_or_param_type DomFloat;
-
- static inline ObjTransitPtr create(domEffect *effect,
- ColladaGlobal *global );
-
- virtual void read(void);
-
- inline ChunkMaterial *getMaterial (void );
- domFx_surface_common *getSurface (const std::string &ref);
- UInt32 getTexBinding(const std::string &ref);
-
- protected:
- ColladaEffect(domEffect *effect, ColladaGlobal *global);
- virtual ~ColladaEffect(void );
-
- typedef std::map<std::string,
- domFx_surface_common * > SurfaceMap;
- typedef std::map<std::string,
- domFx_sampler2D_common *> SamplerMap;
-
- void handleCommonProfile(domProfile_COMMON *profCommon);
- void handleGLSLProfile (domProfile_GLSL *profGLSL );
- void handleCGProfile (domProfile_CG *profCG );
-
- inline void setTexCoordMapping( UInt32 texCoord,
- const std::string &mappedTC );
- inline Real32 computeLuminance (Real32 colR, Real32 colG, Real32 colB);
-
- template <class TechTypeT>
- void setupSimpleColorAndTex (TechTypeT tech,
- DomFloat *shininess = NULL,
- DomColor *specularCol = NULL,
- DomTexture *specularTex = NULL );
-
- template <class TechTypeT>
- void setupSimpleSpecColorAndTex(TechTypeT tech );
-
- MaterialChunkTransitPtr handleSimpleColor(DomColor *diffuse,
- DomColor *ambient,
- DomColor *specular,
- DomColor *emission,
- DomColor *transparent,
- domFx_opaque_enum opaqueMode,
- Real32 shininess,
- Real32 transparency);
- inline void fillElements(
- domCommon_color_or_texture_type *colTexIn,
- domCommon_color_or_texture_type::domColorRef &colOut,
- domCommon_color_or_texture_type::domTextureRef &texOut );
- inline void fillElements(
- domCommon_transparent_type *colTexIn,
- domCommon_color_or_texture_type::domColorRef &colOut,
- domCommon_color_or_texture_type::domTextureRef &texOut );
- ChunkMaterialUnrecPtr _material;
- std::vector<std::string> _texCoordMapping;
- SurfaceMap _surfaceMap;
- SamplerMap _samplerMap;
-};
-
-typedef ColladaEffect::ObjRefPtr ColladaEffectRefPtr;
-typedef ColladaEffect::ObjTransitPtr ColladaEffectTransitPtr;
-
-OSG_END_NAMESPACE
-
-#include "OSGColladaEffect.inl"
-
-#endif // OSG_WITH_COLLADA
-
-#endif // _OSGCOLLADAEFFECT_H_
View
96 Source/System/FileIO/Collada/OSGColladaEffect.inl
@@ -1,96 +0,0 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2008 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
-
-OSG_BEGIN_NAMESPACE
-
-inline ColladaEffectTransitPtr ColladaEffect::create(
- domEffect *effect, ColladaGlobal *global)
-{
- return ColladaEffectTransitPtr(new ColladaEffect(effect, global));
-}
-
-inline ChunkMaterial *ColladaEffect::getMaterial(void)
-{
- return _material;
-}
-
-inline void ColladaEffect::setTexCoordMapping(
- UInt32 texCoord, const std::string &mappedTC)
-{
- if(texCoord >= _texCoordMapping.size())
- {
- _texCoordMapping.resize(texCoord + 1);
- }
-
- _texCoordMapping[texCoord] = mappedTC;
-}
-
-/*! Computes a luminance value from the red, green and blue component of a
- color per the Collada Spec.
- */
-inline Real32 ColladaEffect::computeLuminance(
- Real32 colR, Real32 colG, Real32 colB)
-{
- return colR * 0.212671 + colG * 0.71516 + colB * 0.072169;
-}
-
-inline void ColladaEffect::fillElements(
- domCommon_color_or_texture_type *colTexIn,
- domCommon_color_or_texture_type::domColorRef &colOut,
- domCommon_color_or_texture_type::domTextureRef &texOut )
-{
- if(colTexIn != NULL)
- {
- colOut = colTexIn->getColor ();
- texOut = colTexIn->getTexture();
- }
-}
-
-inline void ColladaEffect::fillElements(
- domCommon_transparent_type *colTexIn,
- domCommon_color_or_texture_type::domColorRef &colOut,
- domCommon_color_or_texture_type::domTextureRef &texOut )
-{
- if(colTexIn != NULL)
- {
- colOut = colTexIn->getColor ();
- texOut = colTexIn->getTexture();
- }
-}
-
-OSG_END_NAMESPACE
View
41 Source/System/FileIO/Collada/OSGColladaElement.cpp
@@ -2,7 +2,7 @@
* OpenSG *
* *
* *
- * Copyright (C) 2008 by the OpenSG Forum *
+ * Copyright (C) 2009 by the OpenSG Forum *
* *
* www.opensg.org *
* *
@@ -36,23 +36,16 @@
* *
\*---------------------------------------------------------------------------*/
-#if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
-//#pragma GCC diagnostic warning "-Wold-style-cast"
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif
-
#include "OSGColladaElement.h"
-#include "OSGColladaLog.h"
+#include "OSGColladaGlobal.h"
#ifdef OSG_WITH_COLLADA
-#include "OSGColladaGlobal.h"
-
/*! \class OSG::ColladaElement
The base class for all objects responsible for converting a part of the
Collada DOM representation to OpenSG data structures.
Each has a pointer to the DOM element it converts (\c _elem ) and a pointer
- to the special \c ColladaGlobal element (\c _global ).
+ to a \c ColladaGlobal object (\c _global ).
Each DOM element that has a corresponding \c ColladaElement associated with
it, stores a pointer to it in its user data pointer. This pointer allows
@@ -60,30 +53,30 @@
DOM.
*/
+/*! \fn void ColladaElement::read(void)
+ Read the collada DOM elements and generate internal data structures.
+ This function will only be called once for every ColladaElement,
+ usually right after it is created.
+ */
+
+/*! \fn FieldContainer *ColladaElement::process(ColladaElement *parent)
+ Generates the OpenSG data structures that correspond to this
+ ColladaElement.
+ */
+
OSG_BEGIN_NAMESPACE
ColladaElement::ColladaElement(daeElement *elem, ColladaGlobal *global)
- : _global(global),
- _elem (elem )
+ : Inherited( )
+ , _elem (elem )
+ , _global (global)
{
- if(_elem != NULL)
- _elem->setUserData(this);
}
ColladaElement::~ColladaElement(void)
{
}
-void ColladaElement::addElement(ColladaElement *elem)
-{
- _global->addElement(elem);
-}
-
-void ColladaElement::subElement(ColladaElement *elem)
-{
- _global->subElement(elem);
-}
-
OSG_END_NAMESPACE
#endif // OSG_WITH_COLLADA
View
64 Source/System/FileIO/Collada/OSGColladaElement.h
@@ -2,7 +2,7 @@
* OpenSG *
* *
* *
- * Copyright (C) 2008 by the OpenSG Forum *
+ * Copyright (C) 2009 by the OpenSG Forum *
* *
* www.opensg.org *
* *
@@ -42,17 +42,13 @@
#pragma once
#endif
-/*! \file OSGColladaElement.h
- \ingroup GrpLoader
- */
-
#include "OSGConfig.h"
#ifdef OSG_WITH_COLLADA
#include "OSGFileIODef.h"
#include "OSGMemoryObject.h"
-#include "OSGFieldContainer.h"
+#include "OSGContainerForwards.h"
#include "OSGRefCountPtr.h"
#include "OSGTransitPtr.h"
@@ -64,6 +60,8 @@ OSG_BEGIN_NAMESPACE
// forward declarations
class ColladaGlobal;
+OSG_GEN_MEMOBJPTR(ColladaGlobal);
+
class OSG_FILEIO_DLLMAPPING ColladaElement : public MemoryObject
{
@@ -73,32 +71,36 @@ class OSG_FILEIO_DLLMAPPING ColladaElement : public MemoryObject
/*! \name Types */
/*! \{ */
- typedef MemoryObject Inherited;
- typedef ColladaElement Self;
-
- typedef RefCountPtr<Self, MemObjRefCountPolicy> ObjRefPtr;
- typedef TransitPtr <Self > ObjTransitPtr;
+ typedef MemoryObject Inherited;
+ typedef ColladaElement Self;
+
+ OSG_GEN_INTERNAL_MEMOBJPTR(ColladaElement);
/*! \} */
/*---------------------------------------------------------------------*/
/*! \name Reading */
/*! \{ */
-
- virtual void read(void) = 0;
-
-
- inline ColladaGlobal *getGlobal (void ) const;
- inline daeElement *getDOMElement (void ) const;
+
+ virtual void read (void ) = 0;
+ virtual FieldContainer *process(ColladaElement *parent) = 0;
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Access */
+ /*! \{ */
+
+ inline ColladaGlobal *getGlobal (void) const;
+
+ inline daeElement *getDOMElement (void) const;
template <class DomTypeT>
- inline DomTypeT *getDOMElementAs(void ) const;
-
-
+ inline DomTypeT *getDOMElementAs(void) const;
+
template <class UserDataTypeT>
- inline UserDataTypeT *getUserDataAs (void ) const;
-
+ inline UserDataTypeT *getUserDataAs(void ) const;
+
template <class UserDataTypeT>
static inline UserDataTypeT *getUserDataAs(daeElement *elem);
-
+
/*! \} */
/*========================= PROTECTED ===============================*/
protected:
@@ -108,20 +110,16 @@ class OSG_FILEIO_DLLMAPPING ColladaElement : public MemoryObject
ColladaElement(daeElement *elem, ColladaGlobal *global);
virtual ~ColladaElement(void );
-
+
/*! \} */
/*---------------------------------------------------------------------*/
-
- void addElement(ColladaElement *elem);
- void subElement(ColladaElement *elem);
-
-
- ColladaGlobal *_global;
- daeElementRef _elem;
+
+ daeElementRef _elem;
+ ColladaGlobalRefPtr _global;
};
-typedef ColladaElement::ObjRefPtr ColladaElementRefPtr;
-typedef ColladaElement::ObjTransitPtr ColladaElementTransitPtr;
+
+OSG_GEN_MEMOBJPTR(ColladaElement);
OSG_END_NAMESPACE
View
28 Source/System/FileIO/Collada/OSGColladaElement.inl
@@ -2,7 +2,7 @@
* OpenSG *
* *
* *
- * Copyright (C) 2008 by the OpenSG Forum *
+ * Copyright (C) 2009 by the OpenSG Forum *
* *
* www.opensg.org *
* *
@@ -38,36 +38,36 @@
OSG_BEGIN_NAMESPACE
-inline ColladaGlobal *ColladaElement::getGlobal(void) const
+ColladaGlobal *
+ColladaElement::getGlobal(void) const
{
return _global;
}
-inline daeElement *ColladaElement::getDOMElement(void) const
+inline daeElement *
+ColladaElement::getDOMElement(void) const
{
return _elem;
}
-template <class DomTypeT> inline
-DomTypeT *ColladaElement::getDOMElementAs(void) const
+template <class DomTypeT>
+inline DomTypeT *
+ColladaElement::getDOMElementAs(void) const
{
return daeSafeCast<DomTypeT>(_elem);
}
+/*! Return the user data associated with the DOM element of this object.
+ In all normal cases this is simply this object.
+ */
template <class UserDataTypeT> inline
UserDataTypeT *ColladaElement::getUserDataAs(void) const
{
- if(_elem->getUserData() != NULL)
- {
- return dynamic_cast<UserDataTypeT *>(
- static_cast<ColladaElement *>(_elem->getUserData()));
- }
- else
- {
- return NULL;
- }
+ return getUserDataAs<UserDataTypeT>(_elem);
}
+/*! Return the user data associated with the DOM element \a elem.
+ */
template <class UserDataTypeT> inline
UserDataTypeT *ColladaElement::getUserDataAs(daeElement *elem)
{
View
286 Source/System/FileIO/Collada/OSGColladaElementFactory.cpp
@@ -0,0 +1,286 @@
+/*---------------------------------------------------------------------------*\
+ * OpenSG *
+ * *
+ * *
+ * Copyright (C) 2009 by the OpenSG Forum *
+ * *
+ * www.opensg.org *
+ * *
+ * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
+ * *
+\*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*\
+ * License *
+ * *
+ * This library is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Library General Public License as published *
+ * by the Free Software Foundation, version 2. *
+ * *
+ * This library is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
+ * *
+\*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*\
+ * Changes *
+ * *
+ * *
+ * *
+ * *
+ * *
+ * *
+\*---------------------------------------------------------------------------*/
+
+#include "OSGColladaElementFactory.h"
+
+#ifdef OSG_WITH_COLLADA
+
+#include "OSGBaseInitFunctions.h"
+#include "OSGColladaLog.h"
+#include "OSGColladaGlobal.h"
+#include "OSGSingletonHolder.ins"
+
+
+OSG_BEGIN_NAMESPACE
+
+OSG_SINGLETON_INST(OSG::ColladaElementFactorySingleton, addPostFactoryExitFunction)
+
+template class SingletonHolder<OSG::ColladaElementFactorySingleton>;
+
+
+bool
+ColladaElementFactorySingleton::registerElement(
+ CreateFunctor createFunc,
+ const std::string &elemName, const std::string &profile)
+{
+ bool retVal = true;
+
+ if(profile.empty() == false)
+ {
+ retVal = doRegisterElement(createFunc, elemName,
+ _profileHandlerMap[profile]);
+ }
+ else
+ {
+ retVal = doRegisterElement(createFunc, elemName,
+ _defaultHandlerMap );
+ }
+
+ return retVal;
+}
+
+bool
+ColladaElementFactorySingleton::unregisterElement(
+ const std::string &elemName, const std::string &profile)
+{
+ bool retVal = true;
+
+ if(profile.empty() == false)
+ {
+ retVal = doUnregisterElement(elemName, _profileHandlerMap[profile]);
+ }
+ else
+ {
+ retVal = doUnregisterElement(elemName, _defaultHandlerMap );
+ }
+
+ return retVal;
+}
+
+const ColladaElementFactorySingleton::HandlerMap &
+ColladaElementFactorySingleton::getDefaultHandlerMap(void) const
+{
+ return _defaultHandlerMap;
+}
+
+ColladaElementFactorySingleton::HandlerMap &
+ColladaElementFactorySingleton::editDefaultHandlerMap(void)
+{
+ return _defaultHandlerMap;
+}
+
+const ColladaElementFactorySingleton::ProfileHandlerMap &
+ColladaElementFactorySingleton::getProfileHandlerMap(void) const
+{
+ return _profileHandlerMap;
+}
+
+ColladaElementFactorySingleton::ProfileHandlerMap &
+ColladaElementFactorySingleton::editProfileHandlerMap(void)
+{
+ return _profileHandlerMap;
+}
+
+const std::string &
+ColladaElementFactorySingleton::getDefaultProfile(void) const
+{
+ return _defaultProfile;
+}
+
+void
+ColladaElementFactorySingleton::setDefaultProfile(const std::string &profile)
+{
+ _defaultProfile = profile;
+}
+
+ColladaElementFactorySingleton::CreateFunctor
+ColladaElementFactorySingleton::getCreateFunc(const std::string &elemName,
+ const std::string &profile )
+{
+ if(profile.empty() == false)
+ {
+ return doGetCreateFunc(elemName, _profileHandlerMap[profile] );
+ }
+ else if(_defaultProfile.empty() == false)
+ {
+ return doGetCreateFunc(elemName, _profileHandlerMap[_defaultProfile]);
+ }
+ else
+ {
+ return doGetCreateFunc(elemName, _defaultHandlerMap );
+ }
+}
+
+ColladaElementTransitPtr
+ColladaElementFactorySingleton::create(daeElement *daeElem,
+ ColladaGlobal *global,
+ const std::string &elemName,
+ const std::string &profile )
+{
+ ColladaElementTransitPtr retVal;
+ std::string lookupName;
+
+ if(elemName.empty() == true)
+ {
+ if(daeElem->getElementName() != NULL)
+ {
+ lookupName = daeElem->getElementName();
+ }
+ else if(daeElem->getTypeName() != NULL)
+ {
+ lookupName = daeElem->getTypeName();
+ }
+ }
+ else
+ {
+ lookupName = elemName;
+ }
+
+ if(lookupName.empty() == false)
+ {
+ CreateFunctor createFunc = getCreateFunc(lookupName, profile);
+
+ if(createFunc.empty() == false)
+ {
+ retVal = createFunc(daeElem, global);
+ }
+
+ if(retVal != NULL)
+ {
+ retVal->getDOMElement()->setUserData(retVal.get());
+
+ global->addElement (retVal.get());
+ }
+ else
+ {
+ daeString elemName =
+ daeElem->getElementName() != NULL ?
+ daeElem->getElementName() : "??";
+ daeString typeName =
+ daeElem->getTypeName () != NULL ?
+ daeElem->getTypeName () : "??";
+
+ SWARNING << "ColladaElementFactory::create: No element registered "
+ << "for [" << lookupName
+ << "] - elemName [" << elemName
+ << "] typeName [" << typeName
+ << "] id [" << daeElem->typeID() << "]."
+ << std::endl;
+ }
+ }
+
+ return retVal;
+}
+
+
+bool
+ColladaElementFactorySingleton::doRegisterElement(
+ CreateFunctor createFunc,
+ const std::string &elemName, HandlerMap &handlerMap)
+{
+ bool retVal = true;
+ HandlerMapIt hIt = handlerMap.find(elemName);
+
+ if(hIt != handlerMap.end())
+ {
+ SWARNING << "ColladaElementFactorySingleton::doRegisterElement: "
+ << "elemName [" << elemName << "] already registered."
+ << std::endl;
+
+ retVal = false;
+ }
+ else
+ {
+ handlerMap.insert(hIt, HandlerMap::value_type(elemName, createFunc));
+ }
+
+ return retVal;
+}
+
+bool
+ColladaElementFactorySingleton::doUnregisterElement(
+ const std::string &elemName, HandlerMap &handlerMap)
+{
+ bool retVal = true;
+ HandlerMapIt hIt = handlerMap.find(elemName);
+
+ if(hIt != handlerMap.end())
+ {
+ handlerMap.erase(hIt);
+ }
+ else
+ {
+ SWARNING << "ColladaElemnetFactorySingleton::doUnregisterElement: "
+ << "elemName [" << elemName << "] not registered."
+ << std::endl;
+
+ retVal = false;
+ }
+
+ return false;
+}
+
+ColladaElementFactorySingleton::CreateFunctor
+ColladaElementFactorySingleton::doGetCreateFunc(
+ const std::string &elemName, HandlerMap &handlerMap)
+{
+ CreateFunctor retVal;
+ HandlerMapIt hIt = handlerMap.find(elemName);
+
+ if(hIt != handlerMap.end())
+ {
+ retVal = hIt->second;
+ }
+
+ return retVal;
+}
+
+ColladaElementFactorySingleton::ColladaElementFactorySingleton(void)
+ : _defaultProfile ()
+ , _defaultHandlerMap()
+ , _profileHandlerMap()
+{
+}
+
+ColladaElementFactorySingleton::~ColladaElementFactorySingleton(void)
+{
+}
+
+OSG_END_NAMESPACE
+
+#endif // OSG_WITH_COLLADA
View
163 Source/System/FileIO/Collada/OSGColladaElementFactory.h
@@ -0,0 +1,163 @@
+/*---------------------------------------------------------------------------*\
+ * OpenSG *
+ * *
+ * *
+ * Copyright (C) 2009 by the OpenSG Forum *
+ * *
+ * www.opensg.org *
+ * *
+ * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
+ * *
+\*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*\
+ * License *
+ * *
+ * This library is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Library General Public License as published *
+ * by the Free Software Foundation, version 2. *
+ * *
+ * This library is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
+ * *
+\*---------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------*\
+ * Changes *
+ * *
+ * *
+ * *
+ * *
+ * *
+ * *
+\*---------------------------------------------------------------------------*/
+
+#ifndef _OSGCOLLADAELEMENTFACTORY_H_
+#define _OSGCOLLADAELEMENTFACTORY_H_
+#ifdef __sgi
+#pragma once
+#endif
+
+#include "OSGConfig.h"
+
+#ifdef OSG_WITH_COLLADA
+
+#include "OSGFileIODef.h"
+#include "OSGSingletonHolder.h"
+#include "OSGColladaElement.h"
+
+#include <map>
+#include <string>
+
+#include <boost/function.hpp>
+
+OSG_BEGIN_NAMESPACE
+
+class OSG_FILEIO_DLLMAPPING ColladaElementFactorySingleton
+{
+ /*========================== PUBLIC =================================*/
+ public:
+ /*---------------------------------------------------------------------*/
+ /*! \name Types */
+ /*! \{ */
+
+ typedef boost::function<
+ ColladaElementTransitPtr (daeElement *,
+ ColladaGlobal *)> CreateFunctor;
+
+ typedef std::map<std::string, CreateFunctor> HandlerMap;
+ typedef HandlerMap::iterator HandlerMapIt;
+ typedef HandlerMap::const_iterator HandlerMapConstIt;
+
+ typedef std::map<std::string, HandlerMap > ProfileHandlerMap;
+ typedef ProfileHandlerMap::iterator ProfileHandlerMapIt;
+ typedef ProfileHandlerMap::const_iterator ProfileHandlerMapConstIt;
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Registration */
+ /*! \{ */
+
+ bool registerElement (CreateFunctor createFunc,
+ const std::string &elemName,
+ const std::string &profile = "");
+ bool unregisterElement(const std::string &elemName,
+ const std::string &profile = "");
+
+ const HandlerMap &getDefaultHandlerMap (void) const;
+ HandlerMap &editDefaultHandlerMap(void);
+
+ const ProfileHandlerMap &getProfileHandlerMap (void) const;
+ ProfileHandlerMap &editProfileHandlerMap(void);
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Default Profile */
+ /*! \{ */
+
+ const std::string &getDefaultProfile(void ) const;
+ void setDefaultProfile(const std::string &profile);
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Create */
+ /*! \{ */
+
+ CreateFunctor getCreateFunc(const std::string &elemName,
+ const std::string &profile = "" );
+
+ ColladaElementTransitPtr create (daeElement *daeElem,
+ ColladaGlobal *global,
+ const std::string &elemName = "",
+ const std::string &profile = "" );
+
+ /*! \} */
+ /*========================= PROTECTED ===============================*/
+ protected:
+ /*---------------------------------------------------------------------*/
+ /*! \name Helper */
+ /*! \{ */
+
+ bool doRegisterElement (CreateFunctor createFunc,
+ const std::string &elemName,
+ HandlerMap &handlerMap );
+ bool doUnregisterElement(const std::string &elemName,
+ HandlerMap &handlerMap );
+
+ CreateFunctor doGetCreateFunc (const std::string &elemName,
+ HandlerMap &handlerMap );
+
+ /*! \} */
+ /*========================== PRIVATE ================================*/
+ private:
+
+ /*---------------------------------------------------------------------*/
+ /*! \name Constructors/Destructor */
+ /*! \{ */
+
+ ColladaElementFactorySingleton(void);
+ ~ColladaElementFactorySingleton(void);
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+
+ template <class SingletonT>
+ friend class SingletonHolder;
+
+ std::string _defaultProfile;
+ HandlerMap _defaultHandlerMap;
+ ProfileHandlerMap _profileHandlerMap;
+};
+
+
+typedef SingletonHolder<ColladaElementFactorySingleton> ColladaElementFactory;
+
+OSG_END_NAMESPACE
+
+#endif // OSG_WITH_COLLADA
+
+#endif // _OSGCOLLADAELEMENTFACTORY_H_
View
15 ...System/FileIO/Collada/OSGColladaInstanceLight.inl → ...FileIO/Collada/OSGColladaElementFactoryHelper.cpp
@@ -36,13 +36,20 @@
* *
\*---------------------------------------------------------------------------*/
+#include "OSGColladaElementFactoryHelper.h"
+
+#ifdef OSG_WITH_COLLADA
+
OSG_BEGIN_NAMESPACE
-inline ColladaInstanceLightTransitPtr ColladaInstanceLight::create(
- domInstance_light *instLight, ColladaGlobal *global)
+ColladaElementRegistrationHelper::ColladaElementRegistrationHelper(
+ CreateFunctor createFunctor,
+ const std::string &elemName, const std::string &profile)
{
- return ColladaInstanceLightTransitPtr(
- new ColladaInstanceLight(instLight, global));
+ ColladaElementFactory::the()->registerElement(
+ createFunctor, elemName, profile);
}
OSG_END_NAMESPACE
+
+#endif // OSG_WITH_COLLADA
View
60 Source/System/FileIO/Collada/OSGColladaImage.h → ...m/FileIO/Collada/OSGColladaElementFactoryHelper.h
@@ -2,7 +2,7 @@
* OpenSG *
* *
* *
- * Copyright (C) 2008 by the OpenSG Forum *
+ * Copyright (C) 2009 by the OpenSG Forum *
* *
* www.opensg.org *
* *
@@ -36,60 +36,46 @@
* *
\*---------------------------------------------------------------------------*/
-#ifndef _OSGCOLLADAIMAGE_H_
-#define _OSGCOLLADAIMAGE_H_
+#ifndef _OSGCOLLADAELEMENTFACTORYHELPER_H_
+#define _OSGCOLLADAELEMENTFACTORYHELPER_H_
#ifdef __sgi
#pragma once
#endif
-/*! \file OSGColladaImage.h
- \ingroup GrpLoader
- */
-
#include "OSGConfig.h"
#ifdef OSG_WITH_COLLADA
#include "OSGFileIODef.h"
-#include "OSGColladaElement.h"
-
-#include "OSGImage.h"
-
-// forward declarations
-class domImage;
+#include "OSGColladaElementFactory.h"
OSG_BEGIN_NAMESPACE
-class OSG_FILEIO_DLLMAPPING ColladaImage : public ColladaElement
+class OSG_FILEIO_DLLMAPPING ColladaElementRegistrationHelper
{
+ /*========================== PUBLIC =================================*/
public:
- typedef ColladaElement Inherited;
- typedef ColladaImage Self;
-
- typedef RefCountPtr<Self, MemObjRefCountPolicy> ObjRefPtr;
- typedef TransitPtr <Self > ObjTransitPtr;
-
- static inline ObjTransitPtr create(domImage *image,
- ColladaGlobal *global);
-
- virtual void read(void);
+ /*---------------------------------------------------------------------*/
+ /*! \name Types */
+ /*! \{ */
- inline Image *getImage(void);
-
- protected:
- ColladaImage(domImage *image, ColladaGlobal *global);
- virtual ~ColladaImage(void );
-
- ImageUnrecPtr _image;
-};
+ typedef ColladaElementFactorySingleton::CreateFunctor CreateFunctor;
-typedef ColladaImage::ObjRefPtr ColladaImageRefPtr;
-typedef ColladaImage::ObjTransitPtr ColladaImageTransitPtr;
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Constructor */
+ /*! \{ */
-OSG_END_NAMESPACE
+ ColladaElementRegistrationHelper(CreateFunctor createFunc,
+ const std::string &elemName,
+ const std::string &profile = "");
+
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+};
-#include "OSGColladaImage.inl"
+OSG_END_NAMESPACE
#endif // OSG_WITH_COLLADA
-#endif // _OSGCOLLADAIMAGE_H_
+#endif // _OSGCOLLADAELEMENTFACTORYHELPER_H_
View
170 Source/System/FileIO/Collada/OSGColladaFileType.cpp
@@ -1,164 +1,66 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2000-2006 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
-
-/*! \file OSGColladaFileType.cpp
- \ingroup GrpLoader
- */
-
-//---------------------------------------------------------------------------
-// Includes
-//---------------------------------------------------------------------------
-
-#include <cstdlib>
-#include <cstdio>
-
-#include "OSGConfig.h"
-
-#include <iostream>
#include "OSGColladaFileType.h"
-#include "OSGColladaLoader.h"
-OSG_USING_NAMESPACE
+#ifdef OSG_WITH_COLLADA
-//---------------------------------------------------------------------------
-// Class
-//---------------------------------------------------------------------------
+#include "OSGColladaGlobal.h"
+#include "OSGColladaOptions.h"
-const Char8 *ColladaFileType::_suffixA[] = { "dae" };
-
- ColladaFileType ColladaFileType::_the(_suffixA,
- sizeof(_suffixA),
- false,
- 10,
- (OSG_READ_SUPPORTED |
- OSG_WRITE_SUPPORTED));
-
-/***************************************************************************\
- * Types *
-\***************************************************************************/
+OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Class variables *
\***************************************************************************/
-/***************************************************************************\
- * Class methods *
-\***************************************************************************/
-
-/*-------------------------------------------------------------------------*\
- - private -
-\*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*\
- - protected -
-\*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*\
- - public -
-\*-------------------------------------------------------------------------*/
-
-/***************************************************************************\
- * Instance methods *
-\***************************************************************************/
-
-/*-------------------------------------------------------------------------*\
- - private -
-\*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*\
- - protected -
-\*-------------------------------------------------------------------------*/
+const Char8 *ColladaFileType::_suffixA[] = { "dae" };
-/*------------- constructors & destructors --------------------------------*/
+ ColladaFileType ColladaFileType::_the(_suffixA,
+ sizeof(_suffixA),
+ false,
+ 10,
+ OSG_READ_SUPPORTED);
-ColladaFileType::ColladaFileType(const Char8 *suffixArray[],
- UInt16 suffixByteCount,
- bool override,
- UInt32 overridePriority,
- UInt32 flags) :
- Inherited(suffixArray,
- suffixByteCount,
- override,
- overridePriority,
- flags)
+const Char8 *
+ColladaFileType::getName(void) const
{
+ return "Collada SCENE";
}
-ColladaFileType::~ColladaFileType(void)
+NodeTransitPtr
+ColladaFileType::read(
+ std::istream &is, const Char8 *fileNameOrExtension, Resolver resolver) const
{
-}
-
-/*-------------------------------------------------------------------------*\
- - public -
-\*-------------------------------------------------------------------------*/
-
-/*------------------------------ access -----------------------------------*/
+ NodeTransitPtr rootN;
-const Char8 *ColladaFileType::getName(void) const
-{
- return "Collada SCENE";
-}
+ ColladaGlobalRefPtr colGlobal = ColladaGlobal ::create();
+ ColladaOptionsRefPtr colOpts = ColladaOptions::create();
+ colOpts->parseOptions(this->getOptions());
-NodeTransitPtr ColladaFileType::read(
- std::istream &is,
- const Char8 *fileNameOrExtension,
- Resolver ) const
-{
- NodeTransitPtr returnValue(NULL);
+ colGlobal->setOptions(colOpts);
- ColladaLoader *pLoader = new ColladaLoader;
+ rootN = colGlobal->read(is, fileNameOrExtension);
- returnValue = pLoader->read(is, fileNameOrExtension);
+ return rootN;
+}
+
- delete pLoader;
+ColladaFileType::ColladaFileType(
+ const Char8 *suffixArray[], UInt16 suffixByteCount,
+ bool override, UInt32 overridePriority,
+ UInt32 flags )
- return returnValue;
+ : Inherited(suffixArray, suffixByteCount,
+ override, overridePriority, flags)
+{
}
-
-bool ColladaFileType::write(Node * const node,
- std::ostream &os,
- Char8 const *fileNameOrExtension) const
+ColladaFileType::~ColladaFileType(void)
{
- return true;
}
+
+OSG_END_NAMESPACE
+#endif // OSG_WITH_COLLADA
View
200 Source/System/FileIO/Collada/OSGColladaFileType.h
@@ -1,40 +1,4 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2000-2006 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
+
#ifndef _OSGCOLLADAFILETYPE_H_
#define _OSGCOLLADAFILETYPE_H_
@@ -42,125 +6,49 @@
#pragma once
#endif
-/*! \file OSGColladaFileType.h
- \ingroup GrpLoader
- */
+#include "OSGConfig.h"
-//---------------------------------------------------------------------------
-// Includes
-//---------------------------------------------------------------------------
+#ifdef OSG_WITH_COLLADA
#include "OSGFileIODef.h"
#include "OSGSceneFileType.h"
OSG_BEGIN_NAMESPACE
-//---------------------------------------------------------------------------
-// Forward References
-//---------------------------------------------------------------------------
-
-//---------------------------------------------------------------------------
-// Types
-//---------------------------------------------------------------------------
-
-//---------------------------------------------------------------------------
-// Class
-//---------------------------------------------------------------------------
-
-/*! \ingroup GrpFoundationLoader
- */
-
class OSG_FILEIO_DLLMAPPING ColladaFileType : public SceneFileType
{
- private:
-
- //-----------------------------------------------------------------------
- // types
- //-----------------------------------------------------------------------
-
- typedef SceneFileType Inherited;
-
+ /*========================== PUBLIC =================================*/
public:
+ /*---------------------------------------------------------------------*/
+ /*! \name Types */
+ /*! \{ */
- //-----------------------------------------------------------------------
- // types
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // constants
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // enums
- //-----------------------------------------------------------------------
+ typedef SceneFileType Inherited;
+ typedef ColladaFileType Self;
- private:
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Name */
+ /*! \{ */
- //-----------------------------------------------------------------------
- // enums
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // types
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // friend classes
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // friend functions
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // class variables
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // class functions
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // instance variables
- //-----------------------------------------------------------------------
+ virtual const Char8 *getName(void) const;
- //-----------------------------------------------------------------------
- // instance functions
- //-----------------------------------------------------------------------
+ /*! \} */
+ /*---------------------------------------------------------------------*/
+ /*! \name Read */
+ /*! \{ */
- //! prohibit default function (move to 'public' if needed)
- ColladaFileType(const ColladaFileType &source);
- //! prohibit default function (move to 'public' if needed)
- void operator =(const ColladaFileType &source);
+ virtual NodeTransitPtr
+ read( std::istream &is,
+ const Char8 *fileNameOrExtension,
+ Resolver resolver = NULL) const;
+ /*! \} */
+ /*========================= PROTECTED ===============================*/
protected:
-
- //-----------------------------------------------------------------------
- // enums
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // types
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // class variables
- //-----------------------------------------------------------------------
-
- static const Char8 *_suffixA[];
- static ColladaFileType _the;
-
- //-----------------------------------------------------------------------
- // class functions
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // instance variables
- //-----------------------------------------------------------------------
-
- //-----------------------------------------------------------------------
- // instance functions
- //-----------------------------------------------------------------------
+ /*---------------------------------------------------------------------*/
+ /*! \name Constructors/Destructor */
+ /*! \{ */
ColladaFileType(const Char8 *suffixArray[],
UInt16 suffixByteCount,
@@ -168,35 +56,17 @@ class OSG_FILEIO_DLLMAPPING ColladaFileType : public SceneFileType
UInt32 overridePriority,
UInt32 flags);
- virtual ~ColladaFileType(void);
-
- public :
-
- //-----------------------------------------------------------------------
- // class functions
- //-----------------------------------------------------------------------
+ virtual ~ColladaFileType(void);
- //-----------------------------------------------------------------------
- // instance functions
- //-----------------------------------------------------------------------
+ /*! \} */
+ /*---------------------------------------------------------------------*/
- /*------------------------- your_category -------------------------------*/
-
- virtual NodeTransitPtr read( std::istream &is,
- const Char8 *fileNameOrExtension,
- Resolver resolver = NULL ) const;
-
- /*------------------------- your_category -------------------------------*/
-
- virtual bool write(Node * const node,
- std::ostream &os,
- Char8 const *fileNameOrExtension) const;
-
- /*------------------------- your_category -------------------------------*/
-
- virtual const Char8 *getName(void) const;
+ static const Char8 *_suffixA[];
+ static ColladaFileType _the;
};
OSG_END_NAMESPACE
-#endif /* _OSGCOLLADAFILETYPE_HPP_ */
+#endif // OSG_WITH_COLLADA
+
+#endif // _OSGCOLLADAFILETYPE_H_
View
114 Source/System/FileIO/Collada/OSGColladaGeoInputAttachment.cpp
@@ -1,114 +0,0 @@
-/*---------------------------------------------------------------------------*\
- * OpenSG *
- * *
- * *
- * Copyright (C) 2000-2006 by the OpenSG Forum *
- * *
- * www.opensg.org *
- * *
- * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * License *
- * *
- * This library is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Library General Public License as published *
- * by the Free Software Foundation, version 2. *
- * *
- * This library is distributed in the hope that it will be useful, but *
- * WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Library General Public License for more details. *
- * *
- * You should have received a copy of the GNU Library General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- * *
-\*---------------------------------------------------------------------------*/
-/*---------------------------------------------------------------------------*\
- * Changes *
- * *
- * *
- * *
- * *
- * *
- * *
-\*---------------------------------------------------------------------------*/
-
-//---------------------------------------------------------------------------
-// Includes
-//---------------------------------------------------------------------------
-
-#include <cstdlib>
-#include <cstdio>
-
-#include "OSGConfig.h"
-
-#include "OSGColladaGeoInputAttachment.h"
-
-OSG_BEGIN_NAMESPACE
-
-// Documentation for this class is emitted in the
-// OSGColladaGeoInputAttachmentBase.cpp file.
-// To modify it, please change the .fcd file (OSGColladaGeoInputAttachment.fcd) and
-// regenerate the base file.
-
-/***************************************************************************\
- * Class variables *
-\***************************************************************************/
-
-/***************************************************************************\
- * Class methods *
-\***************************************************************************/
-
-void ColladaGeoInputAttachment::initMethod(InitPhase ePhase)
-{
- Inherited::initMethod(ePhase);
-
- if(ePhase == TypeObject::SystemPost)
- {
- }
-}
-
-
-/***************************************************************************\
- * Instance methods *
-\***************************************************************************/
-
-/*-------------------------------------------------------------------------*\
- - private -
-\*-------------------------------------------------------------------------*/
-