A surface of triangles idx(3, m) (1-based) through points xyz(3, n), of
color rgba: unlit and transparent (seen from both sides, writing no
depth: planes, cones' sides), or, given normals, lit by the scene's
lights: opaque, or translucent if an alpha is below 1 (drawn after the
opaque scene, sorted by depth by the bounding sphere sphere);
two_sided: both faces drawn and lit. colors: a color per vertex
(4, n), times rgba.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | xyz(:,:) |
(3, n) vertices |
||
| integer, | intent(in) | :: | idx(:,:) |
(3, m) triangles, vertex numbers (1-based) |
||
| real(kind=wp), | intent(in) | :: | rgba(4) |
color [r, g, b, a] (0 to 1) |
||
| real(kind=wp), | intent(in), | optional | :: | normals(:,:) |
(3, n): lit |
|
| real(kind=wp), | intent(in), | optional | :: | colors(:,:) |
(4, n) |
|
| logical, | intent(in), | optional | :: | two_sided |
(lit) both faces (default: front only) |
|
| real(kind=wp), | intent(in), | optional | :: | sphere(4) |
(lit, translucent) center and radius |
function surface_node(xyz, idx, rgba, normals, colors, two_sided, sphere) result(node) real(wp), intent(in) :: xyz(:,:) !! (3, n) vertices integer, intent(in) :: idx(:,:) !! (3, m) triangles, vertex numbers (1-based) real(wp), intent(in) :: rgba(4) !! color [r, g, b, a] (0 to 1) real(wp), intent(in), optional :: normals(:,:) !! (3, n): lit real(wp), intent(in), optional :: colors(:,:) !! (4, n) logical, intent(in), optional :: two_sided !! (lit) both faces (default: front only) real(wp), intent(in), optional :: sphere(4) !! (lit, translucent) center and radius type(c_ptr) :: node real(c_float), dimension(:,:), pointer :: v, n, uv, c integer(c_int32_t), dimension(:), pointer :: indices integer :: nv, ni, flags, i logical :: lit, translucent node = c_null_ptr nv = size(xyz, 2) ni = size(idx) if (nv < 3 .or. ni < 3) return lit = present(normals) flags = 1 if (lit) then translucent = rgba(4) < 1.0_wp if (present(colors)) translucent = translucent .or. any(colors(4, :) < 1.0_wp) flags = 0 if (translucent) flags = flags + 8 if (present(two_sided)) then if (two_sided) flags = flags + 16 end if end if if (present(colors)) flags = flags + 32 node = vkf_mesh_create(int(nv, c_int), int(ni, c_int), real(rgba, c_float), c_null_ptr, c_null_ptr, & int(flags, c_int)) if (.not. c_associated(node)) return call mesh_arrays(node, nv, ni, v, n, uv, indices) v = real(xyz, c_float) if (lit) then n = real(normals, c_float) else n = 0.0_c_float n(3, :) = 1.0_c_float end if uv = 0.0_c_float indices = int(reshape(idx, [ni]) - 1, c_int32_t) if (present(colors)) then call c_f_pointer(vkf_mesh_array(node, 5_c_int), c, [4, nv]) do i = 1, nv c(:, i) = real(colors(:, i) * rgba, c_float) end do end if if (lit .and. iand(flags, 8) /= 0 .and. present(sphere)) & call check_status(vkf_mesh_set_bound(node, real(sphere(1), c_double), real(sphere(2), c_double), & real(sphere(3), c_double), real(sphere(4), c_double)), 'shapes') end function surface_node