Add option to mjspec for creating a texture directly from a buffer.
PiperOrigin-RevId: 662186527 Change-Id: I469c876681d52964ac971c0bb2ec3517224d3a3d
This commit is contained in:
committed by
Copybara-Service
parent
20cae556ee
commit
851bb6eef4
+7
-1
@@ -406,5 +406,11 @@ std::string WriteXML(const mjSpec* spec, char* error, int nerror) {
|
||||
|
||||
mjXWriter writer;
|
||||
writer.SetModel(spec);
|
||||
return writer.Write(error, nerror);
|
||||
|
||||
try {
|
||||
return writer.Write(error, nerror);
|
||||
} catch (mjXError err) {
|
||||
mjCopyError(error, err.message, nerror);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ void mjXWriter::OneMaterial(XMLElement* elem, const mjCMaterial* pmat, mjCDef* d
|
||||
}
|
||||
if (has_non_rgb) {
|
||||
// // TODO elem = InsertEnd(section, "role");
|
||||
mju_error("mjXWriter: no support for non-RGB textures.");
|
||||
throw mjXError(0, "no support for non-RGB textures.");
|
||||
}
|
||||
WriteAttrKey(elem, "texuniform", bool_map, 2, pmat->texuniform, def->Material().texuniform);
|
||||
WriteAttr(elem, "texrepeat", 2, pmat->texrepeat, def->Material().texrepeat);
|
||||
@@ -1452,6 +1452,14 @@ void mjXWriter::Asset(XMLElement* root) {
|
||||
WriteAttrInt(elem, "height", ptex->height);
|
||||
}
|
||||
|
||||
// write buffer
|
||||
else if (ptex->get_cubefiles()[0].empty() && ptex->get_cubefiles()[1].empty() &&
|
||||
ptex->get_cubefiles()[2].empty() && ptex->get_cubefiles()[3].empty() &&
|
||||
ptex->get_cubefiles()[4].empty() && ptex->get_cubefiles()[5].empty() &&
|
||||
ptex->get_file().empty() && ptex->gridsize[0] == 1 && ptex->gridsize[1] == 1) {
|
||||
throw mjXError(0, "no support for buffer textures.");
|
||||
}
|
||||
|
||||
// write textures loaded from files
|
||||
else {
|
||||
// write single file
|
||||
|
||||
Reference in New Issue
Block a user