The screen offset (framebuffer pixels) of point p (root frame) from the cursor, and its depth; false if it is behind the eye.
| Type | Intent | Optional | 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) |
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