Add textured materials to render context, and refactor mjvGeom to refer to those textures.

PiperOrigin-RevId: 648719103
Change-Id: Idb4425bdeea3cbc1133cda3e4366574ed3bb5ccc
This commit is contained in:
Tom Erez
2024-07-02 08:00:06 -07:00
committed by Copybara-Service
parent af3233f98d
commit 3b73dfe33b
14 changed files with 252 additions and 195 deletions
+3 -14
View File
@@ -302,21 +302,13 @@ static void setMaterial(const mjModel* m, mjvGeom* geom, int matid, const float*
const mjtByte* flags) {
// set material properties if given
if (matid >= 0) {
f2f(geom->texrepeat, m->mat_texrepeat + 2*matid, 2);
f2f(geom->rgba, m->mat_rgba + 4*matid, 4);
geom->texuniform = m->mat_texuniform[matid];
geom->emission = m->mat_emission[matid];
geom->specular = m->mat_specular[matid];
geom->shininess = m->mat_shininess[matid];
geom->reflectance = m->mat_reflectance[matid];
}
// otherwise clear texrepeat
else {
geom->texrepeat[0] = 0;
geom->texrepeat[1] = 0;
}
// use rgba if different from default, or no material given
if (rgba[0] != 0.5f || rgba[1] != 0.5f || rgba[2] != 0.5f || rgba[3] != 1.0f || matid < 0) {
f2f(geom->rgba, rgba, 4);
@@ -324,7 +316,7 @@ static void setMaterial(const mjModel* m, mjvGeom* geom, int matid, const float*
// set texture
if (flags[mjVIS_TEXTURE] && matid >= 0) {
geom->texid = m->mat_texid[matid];
geom->matid = matid;
}
// scale alpha for dynamic geoms only
@@ -458,11 +450,8 @@ void mjv_initGeom(mjvGeom* geom, int type, const mjtNum* size,
// set defaults that cannot be assigned via this function
geom->dataid = -1;
geom->texid = -1;
geom->texuniform = 0;
geom->matid = -1;
geom->texcoord = 0;
geom->texrepeat[0] = 1;
geom->texrepeat[1] = 1;
geom->emission = 0;
geom->specular = 0.5;
geom->shininess = 0.5;
@@ -571,7 +560,7 @@ void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* vopt,
thisgeom->texcoord = 1;
}
else {
thisgeom->texid = -1;
thisgeom->matid = -1;
}
// glow flex if selected