diff --git a/examples/viewer.py b/examples/viewer.py index c479482554..21241ace67 100644 --- a/examples/viewer.py +++ b/examples/viewer.py @@ -53,24 +53,25 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: ) # Compute environment camera resolution based on the number of environments to render in the window. - surface_size: tuple(int, int) = ( + window_size: mn.Vector2 = ( self.sim_settings["window_width"], self.sim_settings["window_height"], ) - grid_size: tuple(int, int) = ReplayRenderer.environment_grid_size(self.num_env) - camera_resolution: tuple(int, int) = ( - surface_size[0] / grid_size[0], - surface_size[1] / grid_size[1], - ) - self.sim_settings["width"] = camera_resolution[0] - self.sim_settings["height"] = camera_resolution[1] configuration = self.Configuration() configuration.title = "Habitat Sim Interactive Viewer" - configuration.size = surface_size + configuration.size = window_size Application.__init__(self, configuration) self.fps: float = 60.0 + # Compute environment camera resolution based on the number of environments to render in the window. + grid_size: mn.Vector2i = ReplayRenderer.environment_grid_size(self.num_env) + camera_resolution: mn.Vector2 = mn.Vector2(self.framebuffer_size) / mn.Vector2( + grid_size + ) + self.sim_settings["width"] = camera_resolution[0] + self.sim_settings["height"] = camera_resolution[1] + # draw Bullet debug line visualizations (e.g. collision meshes) self.debug_bullet_draw = False # draw active contact point debug line visualizations @@ -138,11 +139,12 @@ def __init__(self, sim_settings: Dict[str, Any]) -> None: # text object transform in window space is Projection matrix times Translation Matrix # put text in top left of window self.window_text_transform = mn.Matrix3.projection( - mn.Vector2(surface_size) + self.framebuffer_size ) @ mn.Matrix3.translation( - mn.Vector2( - surface_size[0] * -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, - surface_size[1] * HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + mn.Vector2(self.framebuffer_size) + * mn.Vector2( + -HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, + HabitatSimInteractiveViewer.TEXT_DELTA_FROM_CENTER, ) ) self.shader = shaders.VectorGL2D()