def __init__(self, shutdown_delegate: callable, camera: opengl.Camera,
                 input_intent_queue: mp.Queue, viewer):

        self._logger = util.get_class_logger(__name__, self)
        self._input_intent_queue = input_intent_queue
        self._last_robot_control_intents = _RobotControlIntents()
        self._is_keyboard_control_enabled = False

        # Keyboard
        self._is_key_pressed = {}
        self._is_alt_down = False
        self._is_ctrl_down = False
        self._is_shift_down = False

        # Mouse
        self._is_mouse_down = {}
        self._mouse_pos = None  # type: util.Vector2

        self._shutdown_delegate = shutdown_delegate

        self._last_robot_position = None

        self._camera = camera

        self._opengl_viewer = viewer
    def __init__(self,
                 close_event: mp.Event,
                 input_intent_queue: mp.Queue,
                 nav_map_queue: mp.Queue,
                 world_frame_queue: mp.Queue,
                 extra_render_function_queue: mp.Queue,
                 user_data_queue: mp.Queue,
                 resolution: List[int] = None,
                 projector: opengl.Projector = None,
                 camera: opengl.Camera = None,
                 lights: List[opengl.Light] = None,
                 show_viewer_controls: bool = True):
        if resolution is None:
            resolution = default_resolution
        if projector is None:
            projector = default_projector
        if camera is None:
            camera = default_camera
        if lights is None:
            lights = default_lights

        self._close_event = close_event
        self._input_intent_queue = input_intent_queue
        self._nav_map_queue = nav_map_queue
        self._world_frame_queue = world_frame_queue
        self._extra_render_function_queue = extra_render_function_queue
        self._user_data_queue = user_data_queue

        self._logger = util.get_class_logger(__name__, self)
        self._extra_render_calls = []

        self._internal_function_finished = False

        # Controls
        self.show_controls = show_viewer_controls
        self._instructions = '\n'.join([
            'W, S: Move forward, backward', 'A, D: Turn left, right',
            'R, F: Lift up, down', 'T, G: Head up, down', '',
            'C: Connect to LightCube', '', 'LMB: Rotate camera',
            'RMB: Move camera', 'LMB + RMB: Move camera up/down',
            'LMB + Z: Zoom camera', 'X: same as RMB',
            'TAB: center view on robot', '', 'H: Toggle help'
        ])

        self._vector_view_manifest = opengl_vector.VectorViewManifest()
        self._main_window = opengl.OpenGLWindow(0, 0, resolution[0],
                                                resolution[1],
                                                b"Vector 3D Visualizer")

        # Create a 3d projector configuration class.
        self._projector = projector
        self._camera = camera
        self._lights = lights

        self._view_controller = _OpenGLViewController(self.close, self._camera,
                                                      self._input_intent_queue,
                                                      self)

        self._latest_world_frame: opengl_vector.WorldRenderFrame = None
예제 #3
0
    def __init__(self, resource_manager: ResourceManager, asset_key: str):

        # All worldspace vertex positions in this mesh (coordinates stored as list of 3 floats).
        self._vertices: List[List[float]] = []
        # All directional vertex normals in this mesh (coordinates stored as list of 3 floats).
        self._normals: List[List[float]] = []
        # All texture coordinates in this mesh (coordinates stored as list of 2 floats).
        self._tex_coords: List[List[float]] = []

        # All supported mesh groups, indexed by group name.
        self._groups: Dict[str, MeshGroup] = {}

        # A container that MTL material attribute dicts can be fetched from by string key.
        self._material_library: MaterialLibrary = None

        # Resource manager that can be used to load internally referenced assets
        self._resource_manager = resource_manager

        self._logger = util.get_class_logger(__name__, self)

        self.load_from_obj_asset(asset_key)
예제 #4
0
 def __init__(self):
     self.logger = util.get_class_logger(__name__, self)
     super(NavMapView, self).__init__()