pick_camera Function

public pure function pick_camera(eye, center, up, perspective, fovy, aspect, ortho, width, height, x, y, tolerance) result(cam)

The camera of a pick: eye, center and up (root frame), a perspective projection (fovy, degrees, and aspect) or an orthographic one (ortho: left, right, bottom, top), a viewport of width x height framebuffer pixels, the cursor (x, y: -1 to 1, y up) and the tolerance (framebuffer pixels).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: eye(3)

the camera (root frame)

real(kind=wp), intent(in) :: center(3)

the camera (root frame)

real(kind=wp), intent(in) :: up(3)

the camera (root frame)

logical, intent(in) :: perspective

(true: perspective; false: orthographic)

real(kind=wp), intent(in) :: fovy

vertical field of view (degrees; perspective)

real(kind=wp), intent(in) :: aspect

width / height (perspective)

real(kind=wp), intent(in) :: ortho(4)

left, right, bottom, top (orthographic)

integer, intent(in) :: width

the viewport (framebuffer pixels)

integer, intent(in) :: height

the viewport (framebuffer pixels)

real(kind=wp), intent(in) :: x

the cursor (-1 to 1, y up)

real(kind=wp), intent(in) :: y

the cursor (-1 to 1, y up)

real(kind=wp), intent(in) :: tolerance

(framebuffer pixels)

Return Value type(PickCamera)


Calls

proc~~pick_camera~~CallsGraph proc~pick_camera pick_camera proc~cross cross proc~pick_camera->proc~cross

Called by

proc~~pick_camera~~CalledByGraph proc~pick_camera pick_camera proc~view_camera view_camera proc~view_camera->proc~pick_camera proc~cursor_ray WindowProxy%cursor_ray proc~cursor_ray->proc~view_camera proc~screen_position WindowProxy%screen_position proc~screen_position->proc~view_camera proc~window_pick WindowProxy%window_pick proc~window_pick->proc~view_camera proc~drag_handle drag_handle proc~drag_handle->proc~cursor_ray proc~grab_handle grab_handle proc~grab_handle->proc~cursor_ray proc~hover_handle hover_handle proc~hover_handle->proc~window_pick proc~dispatch_event dispatch_event proc~dispatch_event->proc~drag_handle proc~dispatch_event->proc~grab_handle proc~dispatch_event->proc~hover_handle proc~release_handle release_handle proc~dispatch_event->proc~release_handle proc~release_handle->proc~hover_handle proc~dispatch_events dispatch_events proc~dispatch_events->proc~dispatch_event proc~frame WindowProxy%frame proc~frame->proc~dispatch_events proc~resize WindowProxy%resize proc~resize->proc~frame proc~run WindowProxy%run proc~run->proc~frame

Source Code

    pure function pick_camera(eye, center, up, perspective, fovy, aspect, ortho, width, height, x, y, tolerance) &
            result(cam)
        real(wp), intent(in) :: eye(3), center(3), up(3)    !! the camera (root frame)
        real(wp), intent(in) :: fovy                        !! vertical field of view (degrees; perspective)
        real(wp), intent(in) :: aspect                      !! width / height (perspective)
        real(wp), intent(in) :: ortho(4)                    !! left, right, bottom, top (orthographic)
        real(wp), intent(in) :: x, y                        !! the cursor (-1 to 1, y up)
        real(wp), intent(in) :: tolerance                   !! (framebuffer pixels)
        logical, intent(in) :: perspective                  !! (true: perspective; false: orthographic)
        integer, intent(in) :: width, height                !! the viewport (framebuffer pixels)
        type(PickCamera) :: cam
        real(wp) :: f(3), r(3), d
        f = center - eye
        d = norm2(f)
        if (d > 0.0_wp) f = f / d
        r = cross(f, up)
        if (norm2(r) > 0.0_wp) r = r / norm2(r)
        cam%eye = eye
        cam%forward = f
        cam%right = r
        cam%up = cross(r, f)
        cam%perspective = perspective
        cam%tan_y = tan(0.5_wp * fovy * pi / 180.0_wp)
        cam%aspect = aspect
        cam%ortho = ortho
        cam%half_w = 0.5_wp * max(1, width)
        cam%half_h = 0.5_wp * max(1, height)
        cam%x = x
        cam%y = y
        cam%tolerance = tolerance
        cam%near = 1.0e-6_wp * max(d, tiny(1.0_wp))          ! (as the renderer's near plane)
    end function pick_camera