Modifies an entity for use as a 'visual hint'. Contacts will be disabled for all geoms within the entity, and its bodies will be converted to "mocap" bodies (which are viewed as fixed from the perspective of the dynamics). The geom alpha values may also be overridden to render the geoms as
(entity, alpha=None)
| 530 | |
| 531 | |
| 532 | def _hintify(entity, alpha=None): |
| 533 | """Modifies an entity for use as a 'visual hint'. |
| 534 | |
| 535 | Contacts will be disabled for all geoms within the entity, and its bodies will |
| 536 | be converted to "mocap" bodies (which are viewed as fixed from the perspective |
| 537 | of the dynamics). The geom alpha values may also be overridden to render the |
| 538 | geoms as translucent. |
| 539 | |
| 540 | Args: |
| 541 | entity: A `composer.Entity`, modified in place. |
| 542 | alpha: Optional float between 0 and 1, used to override the alpha values for |
| 543 | all of the geoms in this entity. |
| 544 | """ |
| 545 | for subentity in entity.iter_entities(): |
| 546 | # TODO(b/112084359): This assumes that all geoms either define explicit RGBA |
| 547 | # values, or inherit from the top-level default. It will |
| 548 | # not correctly handle more complicated hierarchies of |
| 549 | # default classes. |
| 550 | if (alpha is not None |
| 551 | and subentity.mjcf_model.default.geom is not None |
| 552 | and subentity.mjcf_model.default.geom.rgba is not None): |
| 553 | subentity.mjcf_model.default.geom.rgba = _replace_alpha( |
| 554 | subentity.mjcf_model.default.geom.rgba, alpha=alpha) |
| 555 | for body in subentity.mjcf_model.find_all('body'): |
| 556 | body.mocap = 'true' |
| 557 | for geom in subentity.mjcf_model.find_all('geom'): |
| 558 | if alpha is not None and geom.rgba is not None: |
| 559 | geom.rgba = _replace_alpha(geom.rgba, alpha=alpha) |
| 560 | geom.contype = 0 |
| 561 | geom.conaffinity = 0 |
| 562 | |
| 563 | |
| 564 | def _stack(obs_settings, num_bricks, moveable_base, randomize_order, |
no test coverage detected
searching dependent graphs…