Add intensity and range parameters to lights.
PiperOrigin-RevId: 758603199 Change-Id: I74e88bdfeedd9224e84d953f237d68eca79e6cb7
This commit is contained in:
committed by
Copybara-Service
parent
a6c3a287d6
commit
fa95fe0c59
@@ -2172,6 +2172,8 @@ void mjv_makeLights(const mjModel* m, const mjData* d, mjvScene* scn) {
|
||||
thislight->directional = m->light_directional[i];
|
||||
thislight->castshadow = m->light_castshadow[i];
|
||||
thislight->bulbradius = m->light_bulbradius[i];
|
||||
thislight->intensity = m->light_intensity[i];
|
||||
thislight->range = m->light_range[i];
|
||||
if (!thislight->directional) {
|
||||
f2f(thislight->attenuation, m->light_attenuation+3*i, 3);
|
||||
thislight->exponent = m->light_exponent[i];
|
||||
|
||||
@@ -203,6 +203,8 @@ void mjs_defaultLight(mjsLight* light) {
|
||||
// intrinsics
|
||||
light->castshadow = 1;
|
||||
light->bulbradius = 0.02;
|
||||
light->intensity = 1000.0;
|
||||
light->range = 10.0;
|
||||
light->active = 1;
|
||||
light->attenuation[0] = 1;
|
||||
light->cutoff = 45;
|
||||
@@ -404,4 +406,3 @@ void mjs_defaultKey(mjsKey* key) {
|
||||
void mjs_defaultPlugin(mjsPlugin* plugin) {
|
||||
memset(plugin, 0, sizeof(mjsPlugin));
|
||||
}
|
||||
|
||||
|
||||
@@ -2675,6 +2675,8 @@ void mjCModel::CopyTree(mjModel* m) {
|
||||
mjuu_copyvec(m->light_pos+3*lid, pl->pos, 3);
|
||||
mjuu_copyvec(m->light_dir+3*lid, pl->dir, 3);
|
||||
m->light_bulbradius[lid] = pl->bulbradius;
|
||||
m->light_intensity[lid] = pl->intensity;
|
||||
m->light_range[lid] = pl->range;
|
||||
mjuu_copyvec(m->light_attenuation+3*lid, pl->attenuation, 3);
|
||||
m->light_cutoff[lid] = pl->cutoff;
|
||||
m->light_exponent[lid] = pl->exponent;
|
||||
|
||||
@@ -167,8 +167,9 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
{"camera", "?", "17", "orthographic", "fovy", "ipd", "resolution", "pos", "quat",
|
||||
"axisangle", "xyaxes", "zaxis", "euler", "mode", "focal", "focalpixel",
|
||||
"principal", "principalpixel", "sensorsize", "user"},
|
||||
{"light", "?", "13", "pos", "dir", "bulbradius", "directional", "castshadow", "active",
|
||||
"attenuation", "cutoff", "exponent", "ambient", "diffuse", "specular", "mode"},
|
||||
{"light", "?", "15", "pos", "dir", "bulbradius", "intensity", "range",
|
||||
"directional", "castshadow", "active", "attenuation", "cutoff", "exponent",
|
||||
"ambient", "diffuse", "specular", "mode"},
|
||||
{"pair", "?", "7", "condim", "friction", "solref", "solreffriction", "solimp",
|
||||
"gap", "margin"},
|
||||
{"equality", "?", "3", "active", "solref", "solimp"},
|
||||
@@ -280,9 +281,9 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
{"camera", "*", "20", "name", "class", "orthographic", "fovy", "ipd", "resolution", "pos",
|
||||
"quat", "axisangle", "xyaxes", "zaxis", "euler", "mode", "target",
|
||||
"focal", "focalpixel", "principal", "principalpixel", "sensorsize", "user"},
|
||||
{"light", "*", "16", "name", "class", "directional", "castshadow", "active",
|
||||
"pos", "dir", "bulbradius", "attenuation", "cutoff", "exponent", "ambient", "diffuse",
|
||||
"specular", "mode", "target"},
|
||||
{"light", "*", "18", "name", "class", "directional", "castshadow", "active",
|
||||
"pos", "dir", "bulbradius", "intensity", "range", "attenuation", "cutoff",
|
||||
"exponent", "ambient", "diffuse", "specular", "mode", "target"},
|
||||
{"plugin", "*", "2", "plugin", "instance"},
|
||||
{"<"},
|
||||
{"config", "*", "2", "key", "value"},
|
||||
@@ -1856,6 +1857,8 @@ void mjXReader::OneLight(XMLElement* elem, mjsLight* light) {
|
||||
ReadAttr(elem, "pos", 3, light->pos, text);
|
||||
ReadAttr(elem, "dir", 3, light->dir, text);
|
||||
ReadAttr(elem, "bulbradius", 1, &light->bulbradius, text);
|
||||
ReadAttr(elem, "intensity", 1, &light->intensity, text);
|
||||
ReadAttr(elem, "range", 1, &light->range, text);
|
||||
ReadAttr(elem, "attenuation", 3, light->attenuation, text);
|
||||
ReadAttr(elem, "cutoff", 1, &light->cutoff, text);
|
||||
ReadAttr(elem, "exponent", 1, &light->exponent, text);
|
||||
|
||||
@@ -604,6 +604,8 @@ void mjXWriter::OneLight(XMLElement* elem, const mjCLight* light, mjCDef* def,
|
||||
|
||||
// defaults and regular
|
||||
WriteAttr(elem, "bulbradius", 1, &light->bulbradius, &def->Light().bulbradius);
|
||||
WriteAttr(elem, "intensity", 1, &light->intensity, &def->Light().intensity);
|
||||
WriteAttr(elem, "range", 1, &light->range, &def->Light().range);
|
||||
WriteAttrKey(elem, "directional", bool_map, 2, light->directional, def->Light().directional);
|
||||
WriteAttrKey(elem, "castshadow", bool_map, 2, light->castshadow, def->Light().castshadow);
|
||||
WriteAttrKey(elem, "active", bool_map, 2, light->active, def->Light().active);
|
||||
|
||||
Reference in New Issue
Block a user