Skip to content

Commit

Permalink
More adaptive 3D camera
Browse files Browse the repository at this point in the history
This lets us load models with larger geometric sizes
  • Loading branch information
sjackso committed Apr 15, 2019
1 parent 22dda03 commit 4268dfb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/athena/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ def __init__(self, window, camera, geometry):

def reset(self):
ratio = self._windowAspectRatio()
self.camera.lens().setPerspectiveProjection(45, ratio, .01, 1000)

aabb_size = self.aabb.max - self.aabb.min

cam_distance = 2 * max(aabb_size.x(), aabb_size.y(), aabb_size.z())
frustum_max = cam_distance * 2
frustum_min = frustum_max / 1e5

self.camera.lens().setPerspectiveProjection(45, ratio, frustum_min, frustum_max)
cam_loc = self.aabb.center + vec3d( cam_distance, 0, 0 )
self.camera.setPosition( cam_loc )
self.camera.setViewCenter( self.aabb.center )
Expand Down

0 comments on commit 4268dfb

Please sign in to comment.