Add ability to specify a material assignment to a mesh asset.
This extends both the spec and the XML definition to allow specification of a material name on a mesh. This material acts as a fallback in the case that the referencing geom element does not specify a material of it's own. PiperOrigin-RevId: 798232378 Change-Id: Iaf300c727732744ea1b613e64334ee505ac6e209
This commit is contained in:
committed by
Copybara-Service
parent
42d8454555
commit
1fb1810b07
@@ -230,9 +230,9 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
|
||||
{"asset", "*", "0"},
|
||||
{"<"},
|
||||
{"mesh", "*", "16", "name", "class", "content_type", "file", "vertex", "normal",
|
||||
{"mesh", "*", "17", "name", "class", "content_type", "file", "vertex", "normal",
|
||||
"texcoord", "face", "refpos", "refquat", "scale", "smoothnormal",
|
||||
"maxhullvert", "inertia", "builtin", "params"},
|
||||
"maxhullvert", "inertia", "builtin", "params", "material"},
|
||||
{"<"},
|
||||
{"plugin", "*", "2", "plugin", "instance"},
|
||||
{"<"},
|
||||
@@ -1569,6 +1569,11 @@ void mjXReader::OneMesh(XMLElement* elem, mjsMesh* mesh, const mjVFS* vfs) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string material;
|
||||
if (ReadAttrTxt(elem, "material", material)) {
|
||||
mjs_setString(mesh->material, material.c_str());
|
||||
}
|
||||
|
||||
// write error info
|
||||
mjs_setString(mesh->info, ("line " + std::to_string(elem->GetLineNum())).c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user