The default camera (eye, center, up in view-frame coordinates) for a
viewport of aspect ratio aspect (width / height): OpenFrames' resetView.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(View), | intent(in) | :: | self | |||
| real(kind=wp), | intent(in) | :: | aspect |
viewport width / height |
||
| real(kind=wp), | intent(out) | :: | eye(3) |
the default camera (view-frame coordinates) |
||
| real(kind=wp), | intent(out) | :: | center(3) |
the default camera (view-frame coordinates) |
||
| real(kind=wp), | intent(out) | :: | up(3) |
the default camera (view-frame coordinates) |
subroutine home(self, aspect, eye, center, up) class(View), intent(in) :: self real(wp), intent(in) :: aspect !! viewport width / height real(wp), intent(out) :: eye(3), center(3), up(3) !! the default camera (view-frame coordinates) real(wp) :: c(3), r, dist, half_fovy, half_fovx, m(4,4) if (norm2(self%default_up) /= 0.0_wp) then eye = self%default_eye center = self%default_center up = self%default_up return end if c = 0.0_wp r = 0.0_wp if (associated(self%frame)) then call self%frame%bound(c, r) m = matmul(self%world_to_view(), frame_to_root(self, self%frame)) ! frame to view frame c = matmul(m(1:3, 1:3), c) + m(1:3, 4) end if if (self%default_distance > 0.0_wp) then r = self%default_distance else if (r <= 0.0_wp) then r = 1.0_wp end if dist = 2.0_wp * r if (self%projection == PERSPECTIVE) then half_fovy = 0.5_wp * self%fovy * pi / 180.0_wp half_fovx = atan(aspect * tan(half_fovy)) dist = r / sin(min(half_fovy, half_fovx)) end if center = c eye = c + [0.0_wp, -dist, 0.0_wp] up = [0.0_wp, 0.0_wp, 1.0_wp] end subroutine home