collada_urdf: adding support for URDF material colors (thanks to Kei Okada) #4276

This commit is contained in:
tfield 2010-11-29 19:48:58 +00:00
parent 2940fdf3d6
commit bc143cd55c
1 changed files with 11 additions and 0 deletions

View File

@ -697,6 +697,17 @@ void ColladaWriter::addMaterials() {
if (j == geometry_ids_.end()) if (j == geometry_ids_.end())
continue; continue;
if (!urdf_link->visual->material->texture_filename.empty()) {
ambient.r = ambient.g = ambient.b = 1; ambient.a = 0;
diffuse.r = diffuse.g = diffuse.b = 1; diffuse.a = 0;
}
else {
ambient.r = diffuse.r = urdf_link->visual->material->color.r;
ambient.g = diffuse.g = urdf_link->visual->material->color.g;
ambient.b = diffuse.b = urdf_link->visual->material->color.b;
ambient.a = diffuse.a = urdf_link->visual->material->color.a;
}
string geometry_id = j->second; string geometry_id = j->second;
domEffectRef effect = addEffect(geometry_id, ambient, diffuse); domEffectRef effect = addEffect(geometry_id, ambient, diffuse);