Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix viewer.py framebuffer size mismatch. #2055

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions examples/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down