Gazebo change material color successfully but doesn't show in the screen

asked 2023-07-13 16:01:27 -0500

Luisa gravatar image

I want to change the material color in Preupdate and following are my codes

void changeColor::Change(sim::EntityComponentManager &_ecm){
auto link = this->model.LinkByName(_ecm, "0000");
auto newLink = Link(link);
auto visual = newLink.VisualByName(_ecm, "visual");
auto color = _ecm.ComponentData<sim::components::Material>(visual).value();
color.SetAmbient(gz::math::Color(1, 0, 0, 1));
color.SetDiffuse(gz::math::Color(1, 0, 0, 1));
color.SetEmissive(gz::math::Color(1, 0, 0, 1));
cout << color.Ambient() << endl;
_ecm.SetComponentData<sim::components::Material>(visual, color);
_ecm.SetChanged(visual, sim::components::Material::typeId);

}

I the result looks weird, in right hand side we can see the color successfully change, but in left hand side it still black image description hope someone can help me, thanks

edit retag flag offensive close merge delete