From 796ccd14c8994a3d110bd53c1da9d6469879ba55 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 12 Sep 2011 11:28:14 +0000 Subject: [PATCH] From Cedric Pinson, from three submissions: "Here a patch that correct like the previous assign collada material name to stateset." and "I changed how the collada reader set object name in osg. Current implementation use collada ID to setup name. with this patch I use collada name to setup name in osg object and if collada provide no name I use as fallback ID. I am not sure we want this fallback. The motivation of this change is that when an artist set names to its objects and export to collada, I am not able to use those names in osg to retrieve the node." and "Here the update of the file that fix the light id stuff" --- src/osgPlugins/dae/daeRMaterials.cpp | 7 +++++-- src/osgPlugins/dae/daeRSceneObjects.cpp | 5 ++++- src/osgPlugins/dae/daeReader.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/osgPlugins/dae/daeRMaterials.cpp b/src/osgPlugins/dae/daeRMaterials.cpp index f8bb81276..b404645b8 100644 --- a/src/osgPlugins/dae/daeRMaterials.cpp +++ b/src/osgPlugins/dae/daeRMaterials.cpp @@ -201,6 +201,9 @@ void daeReader::processBindMaterial( domBind_material *bm, domGeometry *geom, os void daeReader::processMaterial(osg::StateSet *ss, domMaterial *mat ) { _currentInstance_effect = mat->getInstance_effect(); + if (mat && mat->getName()) { + ss->setName(mat->getName()); + } domEffect *effect = daeSafeCast< domEffect >( getElementFromURI( _currentInstance_effect->getUrl() ) ); if (effect) { @@ -1096,11 +1099,11 @@ osg::Texture2D* daeReader::processTexture( parameters.wrap_t = getWrapMode(sampler->getWrap_s()->getValue()); } - if (sampler->getMinfilter()) + if (sampler->getMinfilter() && sampler->getMinfilter()->getValue() != FX_SAMPLER_FILTER_COMMON_NONE) { parameters.filter_min = getFilterMode(sampler->getMinfilter()->getValue(), true); } - if (sampler->getMagfilter()) + if (sampler->getMagfilter() && sampler->getMagfilter()->getValue() != FX_SAMPLER_FILTER_COMMON_NONE) { parameters.filter_mag = getFilterMode(sampler->getMagfilter()->getValue(), false); } diff --git a/src/osgPlugins/dae/daeRSceneObjects.cpp b/src/osgPlugins/dae/daeRSceneObjects.cpp index 7c368268a..2a7cfe7db 100644 --- a/src/osgPlugins/dae/daeRSceneObjects.cpp +++ b/src/osgPlugins/dae/daeRSceneObjects.cpp @@ -358,7 +358,10 @@ osg::Node* daeReader::processLight( domLight *dlight ) osg::LightSource* lightsource = new osg::LightSource(); lightsource->setLight(light); - lightsource->setName(dlight->getId()); + std::string name = dlight->getId() ? dlight->getId() : ""; + if (dlight->getName()) + name = dlight->getName(); + lightsource->setName(name); daeElement *el = dlight->getTechnique_common()->getContents()[0]; ambient = daeSafeCast< domLight::domTechnique_common::domAmbient >( el ); diff --git a/src/osgPlugins/dae/daeReader.cpp b/src/osgPlugins/dae/daeReader.cpp index fc2440b49..00408e9ad 100644 --- a/src/osgPlugins/dae/daeReader.cpp +++ b/src/osgPlugins/dae/daeReader.cpp @@ -552,7 +552,12 @@ osg::Node* daeReader::processNode( domNode *node, bool skeleton) if (resultNode->getName().empty()) { - resultNode->setName( node->getId() ? node->getId() : "" ); + std::string name = ""; + if (node->getId()) + name = node->getId(); + if (node->getName()) + name = node->getName(); + resultNode->setName( name ); } osg::Group* attachTo = resultNode;