@@ -32,6 +32,12 @@
|
|||||||
<uri>meshes/link_0.stl</uri>
|
<uri>meshes/link_0.stl</uri>
|
||||||
</mesh>
|
</mesh>
|
||||||
</geometry>
|
</geometry>
|
||||||
|
<material>
|
||||||
|
<ambient>1 0 0 1</ambient>
|
||||||
|
<diffuse>0 0 1 1</diffuse>
|
||||||
|
<specular>0.1 0.1 0.1 1</specular>
|
||||||
|
<emissive>0 0 0 0</emissive>
|
||||||
|
</material>
|
||||||
</visual>
|
</visual>
|
||||||
</link>
|
</link>
|
||||||
<link name='lbr_iiwa_link_1'>
|
<link name='lbr_iiwa_link_1'>
|
||||||
@@ -407,4 +413,4 @@
|
|||||||
</joint>
|
</joint>
|
||||||
</model>
|
</model>
|
||||||
</world>
|
</world>
|
||||||
</sdf>
|
</sdf>
|
||||||
|
|||||||
@@ -490,29 +490,45 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
|
|||||||
// Material
|
// Material
|
||||||
TiXmlElement *mat = config->FirstChildElement("material");
|
TiXmlElement *mat = config->FirstChildElement("material");
|
||||||
//todo(erwincoumans) skip materials in SDF for now (due to complexity)
|
//todo(erwincoumans) skip materials in SDF for now (due to complexity)
|
||||||
if (mat && !m_parseSDF)
|
if (mat)
|
||||||
{
|
{
|
||||||
// get material name
|
if (m_parseSDF)
|
||||||
if (!mat->Attribute("name"))
|
{
|
||||||
{
|
UrdfMaterial* matPtr = new UrdfMaterial;
|
||||||
logger->reportError("Visual material must contain a name attribute");
|
matPtr->m_name = "mat";
|
||||||
return false;
|
std::string diffuseText = mat->FirstChildElement("diffuse")->GetText();
|
||||||
}
|
btVector4 rgba(1,0,0,1);
|
||||||
visual.m_materialName = mat->Attribute("name");
|
parseVector4(rgba,diffuseText);
|
||||||
|
matPtr->m_rgbaColor = rgba;
|
||||||
// try to parse material element in place
|
matPtr->m_textureFilename = "textureTest.png";
|
||||||
|
model.m_materials.insert(matPtr->m_name.c_str(),matPtr);
|
||||||
TiXmlElement *t = mat->FirstChildElement("texture");
|
visual.m_materialName = "mat";
|
||||||
TiXmlElement *c = mat->FirstChildElement("color");
|
visual.m_hasLocalMaterial = true;
|
||||||
if (t||c)
|
}
|
||||||
{
|
else
|
||||||
if (parseMaterial(visual.m_localMaterial, mat,logger))
|
{
|
||||||
{
|
// get material name
|
||||||
UrdfMaterial* matPtr = new UrdfMaterial(visual.m_localMaterial);
|
if (!mat->Attribute("name"))
|
||||||
model.m_materials.insert(matPtr->m_name.c_str(),matPtr);
|
{
|
||||||
visual.m_hasLocalMaterial = true;
|
logger->reportError("Visual material must contain a name attribute");
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
visual.m_materialName = mat->Attribute("name");
|
||||||
|
|
||||||
|
// try to parse material element in place
|
||||||
|
|
||||||
|
TiXmlElement *t = mat->FirstChildElement("texture");
|
||||||
|
TiXmlElement *c = mat->FirstChildElement("color");
|
||||||
|
if (t||c)
|
||||||
|
{
|
||||||
|
if (parseMaterial(visual.m_localMaterial, mat,logger))
|
||||||
|
{
|
||||||
|
UrdfMaterial* matPtr = new UrdfMaterial(visual.m_localMaterial);
|
||||||
|
model.m_materials.insert(matPtr->m_name.c_str(),matPtr);
|
||||||
|
visual.m_hasLocalMaterial = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user