Adds color space to textures.
PiperOrigin-RevId: 761907261 Change-Id: Iec546d1d5907a15e57ef809ec31850640fc52915
This commit is contained in:
committed by
Copybara-Service
parent
62a9d5b98d
commit
3e9bc79b54
@@ -35,6 +35,7 @@ extern const int jac_sz;
|
||||
extern const int solver_sz;
|
||||
extern const int equality_sz;
|
||||
extern const int texture_sz;
|
||||
extern const int colorspace_sz;
|
||||
extern const int builtin_sz;
|
||||
extern const int mark_sz;
|
||||
extern const int dyn_sz;
|
||||
@@ -60,6 +61,7 @@ extern const mjMap jac_map[];
|
||||
extern const mjMap solver_map[];
|
||||
extern const mjMap equality_map[];
|
||||
extern const mjMap texture_map[];
|
||||
extern const mjMap colorspace_map[];
|
||||
extern const mjMap texrole_map[];
|
||||
extern const mjMap builtin_map[];
|
||||
extern const mjMap mark_map[];
|
||||
|
||||
@@ -241,8 +241,8 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
{"<"},
|
||||
{"bone", "*", "5", "body", "bindpos", "bindquat", "vertid", "vertweight"},
|
||||
{">"},
|
||||
{"texture", "*", "23", "name", "type", "content_type", "file", "gridsize", "gridlayout",
|
||||
"fileright", "fileleft", "fileup", "filedown", "filefront", "fileback",
|
||||
{"texture", "*", "24", "name", "type", "colorspace", "content_type", "file", "gridsize",
|
||||
"gridlayout", "fileright", "fileleft", "fileup", "filedown", "filefront", "fileback",
|
||||
"builtin", "rgb1", "rgb2", "mark", "markrgb", "random", "width", "height",
|
||||
"hflip", "vflip", "nchannel"},
|
||||
{"material", "*", "12", "name", "class", "texture", "texrepeat", "texuniform",
|
||||
@@ -650,6 +650,15 @@ const mjMap texture_map[texture_sz] = {
|
||||
};
|
||||
|
||||
|
||||
// colorspace for texture
|
||||
const int colorspace_sz = 3;
|
||||
const mjMap colorspace_map[colorspace_sz] = {
|
||||
{"auto", mjCOLORSPACE_AUTO},
|
||||
{"linear", mjCOLORSPACE_LINEAR},
|
||||
{"sRGB", mjCOLORSPACE_SRGB}
|
||||
};
|
||||
|
||||
|
||||
// builtin type for texture
|
||||
const int builtin_sz = 4;
|
||||
const mjMap builtin_map[builtin_sz] = {
|
||||
@@ -3194,6 +3203,9 @@ void mjXReader::Asset(XMLElement* section, const mjVFS* vfs) {
|
||||
if (MapValue(elem, "type", &n, texture_map, texture_sz)) {
|
||||
texture->type = (mjtTexture)n;
|
||||
}
|
||||
if (MapValue(elem, "colorspace", &n, colorspace_map, colorspace_sz)) {
|
||||
texture->colorspace = (mjtColorSpace)n;
|
||||
}
|
||||
if (ReadAttrTxt(elem, "name", texname)) {
|
||||
mjs_setString(texture->name, texname.c_str());
|
||||
}
|
||||
|
||||
@@ -1488,6 +1488,7 @@ void mjXWriter::Asset(XMLElement* root) {
|
||||
|
||||
// write common attributes
|
||||
WriteAttrKey(elem, "type", texture_map, texture_sz, texture->type);
|
||||
WriteAttrKey(elem, "colorspace", colorspace_map, colorspace_sz, texture->colorspace);
|
||||
WriteAttrTxt(elem, "name", texture->name);
|
||||
|
||||
// write builtin
|
||||
|
||||
Reference in New Issue
Block a user