From d51320be2ce7632ea0b006088c252387d53e37ae Mon Sep 17 00:00:00 2001 From: yunfeibai Date: Fri, 17 Jun 2016 15:47:11 -0700 Subject: [PATCH] Check diffuse field in sdf. --- .../Importers/ImportURDFDemo/UrdfParser.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp index 17f6ef93f..0e720a7c2 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp +++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp @@ -496,14 +496,16 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement* { UrdfMaterial* matPtr = new UrdfMaterial; matPtr->m_name = "mat"; - std::string diffuseText = mat->FirstChildElement("diffuse")->GetText(); - btVector4 rgba(1,0,0,1); - parseVector4(rgba,diffuseText); - matPtr->m_rgbaColor = rgba; - matPtr->m_textureFilename = "textureTest.png"; - model.m_materials.insert(matPtr->m_name.c_str(),matPtr); - visual.m_materialName = "mat"; - visual.m_hasLocalMaterial = true; + TiXmlElement *diffuse = mat->FirstChildElement("diffuse"); + if (diffuse) { + std::string diffuseText = diffuse->GetText(); + btVector4 rgba(1,0,0,1); + parseVector4(rgba,diffuseText); + matPtr->m_rgbaColor = rgba; + model.m_materials.insert(matPtr->m_name.c_str(),matPtr); + visual.m_materialName = "mat"; + visual.m_hasLocalMaterial = true; + } } else {