ray Subroutine

public pure subroutine ray(cam, origin, dir)

The ray from the eye through the cursor (root frame; dir a unit vector).

Arguments

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

the camera and cursor of the pick

real(kind=wp), intent(out) :: origin(3)

the ray (root frame; dir: a unit vector)

real(kind=wp), intent(out) :: dir(3)

the ray (root frame; dir: a unit vector)


Called by

proc~~ray~~CalledByGraph proc~ray ray proc~cursor_ray WindowProxy%cursor_ray proc~cursor_ray->proc~ray proc~pick_ellipsoid pick_ellipsoid proc~pick_ellipsoid->proc~ray proc~drag_handle drag_handle proc~drag_handle->proc~cursor_ray proc~grab_handle grab_handle proc~grab_handle->proc~cursor_ray proc~model_pick Model%model_pick proc~model_pick->proc~pick_ellipsoid proc~sphere_pick Sphere%sphere_pick proc~sphere_pick->proc~pick_ellipsoid proc~terrain_pick TerrainBody%terrain_pick proc~terrain_pick->proc~pick_ellipsoid proc~dispatch_event dispatch_event proc~dispatch_event->proc~drag_handle proc~dispatch_event->proc~grab_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 subroutine ray(cam, origin, dir)
        type(PickCamera), intent(in) :: cam                 !! the camera and cursor of the pick
        real(wp), intent(out) :: origin(3), dir(3)          !! the ray (root frame; dir: a unit vector)
        if (cam%perspective) then
            origin = cam%eye
            dir = cam%forward + cam%x * cam%tan_y * cam%aspect * cam%right + cam%y * cam%tan_y * cam%up
            dir = dir / norm2(dir)
        else
            origin = cam%eye + cam%right * (cam%ortho(1) + 0.5_wp * (cam%x + 1.0_wp) * (cam%ortho(2) - cam%ortho(1))) &
                             + cam%up * (cam%ortho(3) + 0.5_wp * (cam%y + 1.0_wp) * (cam%ortho(4) - cam%ortho(3)))
            dir = cam%forward
        end if
    end subroutine ray