Check diffuse field in sdf.

This commit is contained in:
yunfeibai 2016-06-17 15:47:11 -07:00
parent 7d5dea1bac
commit d51320be2c

View File

@ -496,15 +496,17 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
{ {
UrdfMaterial* matPtr = new UrdfMaterial; UrdfMaterial* matPtr = new UrdfMaterial;
matPtr->m_name = "mat"; matPtr->m_name = "mat";
std::string diffuseText = mat->FirstChildElement("diffuse")->GetText(); TiXmlElement *diffuse = mat->FirstChildElement("diffuse");
if (diffuse) {
std::string diffuseText = diffuse->GetText();
btVector4 rgba(1,0,0,1); btVector4 rgba(1,0,0,1);
parseVector4(rgba,diffuseText); parseVector4(rgba,diffuseText);
matPtr->m_rgbaColor = rgba; matPtr->m_rgbaColor = rgba;
matPtr->m_textureFilename = "textureTest.png";
model.m_materials.insert(matPtr->m_name.c_str(),matPtr); model.m_materials.insert(matPtr->m_name.c_str(),matPtr);
visual.m_materialName = "mat"; visual.m_materialName = "mat";
visual.m_hasLocalMaterial = true; visual.m_hasLocalMaterial = true;
} }
}
else else
{ {
// get material name // get material name