project Function

public function project(cam, p, sx, sy, depth) result(visible)

The screen offset (framebuffer pixels) of point p (root frame) from the cursor, and its depth; false if it is behind the eye.

Arguments

Type IntentOptional Attributes Name
type(PickCamera), intent(in) :: cam

the camera and cursor of the pick

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

the point (root frame)

real(kind=wp), intent(out) :: sx

offset from the cursor (framebuffer pixels, y up)

real(kind=wp), intent(out) :: sy

offset from the cursor (framebuffer pixels, y up)

real(kind=wp), intent(out) :: depth

(scene units)

Return Value logical


Called by

proc~~project~~CalledByGraph proc~project project proc~point_pick point_pick proc~point_pick->proc~project proc~screen_position WindowProxy%screen_position proc~screen_position->proc~project proc~segment_pick segment_pick proc~segment_pick->proc~project proc~sphere_near sphere_near proc~sphere_near->proc~project proc~curve_pick curve_pick proc~curve_pick->proc~point_pick proc~curve_pick->proc~segment_pick proc~curve_pick->proc~sphere_near proc~marker_pick marker_pick proc~marker_pick->proc~point_pick proc~pick ReferenceFrame%pick proc~pick->proc~point_pick proc~segment_artist_pick segment_artist_pick proc~segment_artist_pick->proc~segment_pick proc~time_pick TimeHandle%time_pick proc~time_pick->proc~point_pick proc~time_pick->proc~pick proc~vector_pick VectorHandle%vector_pick proc~vector_pick->proc~point_pick proc~vector_pick->proc~segment_pick proc~vector_pick->proc~pick proc~drawable_pick DrawableTrajectory%drawable_pick proc~drawable_pick->proc~curve_pick proc~drawable_pick->proc~marker_pick proc~drawable_pick->proc~pick proc~drawable_pick->proc~segment_artist_pick proc~model_pick Model%model_pick proc~model_pick->proc~pick proc~sphere_pick Sphere%sphere_pick proc~sphere_pick->proc~pick proc~terrain_pick TerrainBody%terrain_pick proc~terrain_pick->proc~pick proc~window_pick WindowProxy%window_pick proc~window_pick->proc~pick proc~hover_handle hover_handle proc~hover_handle->proc~window_pick proc~dispatch_event dispatch_event 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

    logical function project(cam, p, sx, sy, depth) result(visible)
        type(PickCamera), intent(in) :: cam                 !! the camera and cursor of the pick
        real(wp), intent(in) :: p(3)                        !! the point (root frame)
        real(wp), intent(out) :: sx, sy                     !! offset from the cursor (framebuffer pixels, y up)
        real(wp), intent(out) :: depth                      !! (scene units)
        real(wp) :: v(3), nx, ny
        v = p - cam%eye
        depth = dot_product(v, cam%forward)
        sx = huge(1.0_wp)
        sy = huge(1.0_wp)
        visible = .false.
        if (cam%perspective) then
            if (depth <= cam%near) return
            nx = dot_product(v, cam%right) / (depth * cam%tan_y * cam%aspect)
            ny = dot_product(v, cam%up) / (depth * cam%tan_y)
        else
            nx = (2.0_wp * dot_product(v, cam%right) - (cam%ortho(1) + cam%ortho(2))) / (cam%ortho(2) - cam%ortho(1))
            ny = (2.0_wp * dot_product(v, cam%up) - (cam%ortho(3) + cam%ortho(4))) / (cam%ortho(4) - cam%ortho(3))
        end if
        sx = (nx - cam%x) * cam%half_w
        sy = (ny - cam%y) * cam%half_h
        visible = .true.
    end function project