screen_position Function

private function screen_position(self, p, position) result(visible)

Where point p (root frame) is in the window, as HUD text positions: (x, y) from 0 to 1, left to right and bottom to top (as at the last frame). False if it is behind the eye (or before the first frame). E.g. to keep HUD text next to a moving object, each frame: a callout.

Type Bound

WindowProxy

Arguments

Type IntentOptional Attributes Name
class(WindowProxy), intent(in) :: self
real(kind=wp), intent(in) :: p(3)

root frame

real(kind=wp), intent(out) :: position(2)

(x, y), 0 to 1 from the bottom left

Return Value logical


Calls

proc~~screen_position~~CallsGraph proc~screen_position WindowProxy%screen_position proc~project project proc~screen_position->proc~project proc~view_camera view_camera proc~screen_position->proc~view_camera interface~vkf_viewer_pixel_ratio vkf_viewer_pixel_ratio proc~view_camera->interface~vkf_viewer_pixel_ratio interface~vkf_viewer_size vkf_viewer_size proc~view_camera->interface~vkf_viewer_size proc~aspect_ratio aspect_ratio proc~view_camera->proc~aspect_ratio proc~field_of_view View%field_of_view proc~view_camera->proc~field_of_view proc~get_camera WindowProxy%get_camera proc~view_camera->proc~get_camera proc~is_open WindowProxy%is_open proc~view_camera->proc~is_open proc~orthographic_bounds View%orthographic_bounds proc~view_camera->proc~orthographic_bounds proc~pick_camera pick_camera proc~view_camera->proc~pick_camera proc~projection_type View%projection_type proc~view_camera->proc~projection_type proc~aspect_ratio->interface~vkf_viewer_size proc~get_camera->proc~is_open interface~vkf_viewer_get_look_at vkf_viewer_get_look_at proc~get_camera->interface~vkf_viewer_get_look_at proc~rigid_inverse rigid_inverse proc~get_camera->proc~rigid_inverse proc~transform_camera transform_camera proc~get_camera->proc~transform_camera proc~world_to_view View%world_to_view proc~get_camera->proc~world_to_view proc~cross cross proc~pick_camera->proc~cross proc~world_to_view->proc~rigid_inverse proc~frame_to_root frame_to_root proc~world_to_view->proc~frame_to_root proc~identity_matrix identity_matrix proc~world_to_view->proc~identity_matrix proc~quat_from_vectors quat_from_vectors proc~world_to_view->proc~quat_from_vectors proc~quat_to_matrix quat_to_matrix proc~world_to_view->proc~quat_to_matrix proc~rotated rotated proc~world_to_view->proc~rotated proc~translation_matrix translation_matrix proc~world_to_view->proc~translation_matrix proc~frame_to_root->proc~rigid_inverse proc~world_matrix ReferenceFrame%world_matrix proc~frame_to_root->proc~world_matrix proc~quat_from_vectors->proc~cross proc~quat_normalize quat_normalize proc~quat_from_vectors->proc~quat_normalize proc~translation_matrix->proc~identity_matrix proc~world_matrix->proc~world_matrix proc~local_matrix ReferenceFrame%local_matrix proc~world_matrix->proc~local_matrix proc~frame_matrix frame_matrix proc~local_matrix->proc~frame_matrix proc~frame_matrix->proc~quat_to_matrix

Source Code

    logical function screen_position(self, p, position) result(visible)
        class(WindowProxy), intent(in) :: self
        real(wp), intent(in) :: p(3)                        !! root frame
        real(wp), intent(out) :: position(2)                !! (x, y), 0 to 1 from the bottom left
        type(PickCamera) :: cam
        real(wp) :: sx, sy, depth
        visible = .false.
        position = 0.0_wp
        if (.not. view_camera(self, 0.0_wp, 0.0_wp, cam)) return
        if (.not. project(cam, p, sx, sy, depth)) return            ! (offsets from the center, in pixels)
        position = 0.5_wp * ([sx / cam%half_w, sy / cam%half_h] + 1.0_wp)
        visible = .true.
    end function screen_position