Example #1
0
    def __init__(self, model=None, max_geom=None):
        """Initializes a new `MjvScene` instance.

    Args:
      model: (optional) An `MjModel` instance.
      max_geom: (optional) An integer specifying the maximum number of geoms
        that can be represented in the scene. If None, this will be chosen
        automatically based on `model`.
    """
        model_ptr = model.ptr if model is not None else None
        scene_ptr = ctypes.pointer(types.MJVSCENE())

        if max_geom is None:
            if model is None:
                max_renderable_geoms = 0
            else:
                max_renderable_geoms = _estimate_max_renderable_geoms(model)
            max_geom = max(1000, max_renderable_geoms)

        # Allocate and initialize resources for the abstract scene.
        mjlib.mjv_makeScene(model_ptr, scene_ptr, max_geom)

        # Free resources when the ctypes pointer is garbage collected.
        _create_finalizer(scene_ptr, mjlib.mjv_freeScene)

        super().__init__(scene_ptr)
Example #2
0
  def __init__(self, max_geom=1000):
    """Initializes a new `MjvScene` instance.

    Args:
      max_geom: (optional) An integer specifying the maximum number of geoms
        that can be represented in the scene.
    """
    scene_ptr = ctypes.pointer(types.MJVSCENE())

    # Allocate and initialize resources for the abstract scene.
    mjlib.mjv_makeScene(scene_ptr, max_geom)

    # Free resources when the ctypes pointer is garbage collected.
    _create_finalizer(scene_ptr, mjlib.mjv_freeScene)

    super(MjvScene, self).__init__(scene_ptr)