surface_node Function

private function surface_node(xyz, idx, rgba, normals, colors, two_sided, sphere) result(node)

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.

Arguments

Type IntentOptional 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

Return Value type(c_ptr)


Calls

proc~~surface_node~~CallsGraph proc~surface_node surface_node interface~vkf_mesh_array vkf_mesh_array proc~surface_node->interface~vkf_mesh_array interface~vkf_mesh_create vkf_mesh_create proc~surface_node->interface~vkf_mesh_create interface~vkf_mesh_set_bound vkf_mesh_set_bound proc~surface_node->interface~vkf_mesh_set_bound proc~check_status check_status proc~surface_node->proc~check_status proc~mesh_arrays mesh_arrays proc~surface_node->proc~mesh_arrays proc~mesh_arrays->interface~vkf_mesh_array

Called by

proc~~surface_node~~CalledByGraph proc~surface_node surface_node proc~make_cone make_cone proc~make_cone->proc~surface_node proc~make_plane make_plane proc~make_plane->proc~surface_node proc~make_polyhedron make_polyhedron proc~make_polyhedron->proc~surface_node proc~cone_build_contents PolyhedralCone%cone_build_contents proc~cone_build_contents->proc~make_cone proc~cone_set_line_color PolyhedralCone%cone_set_line_color proc~cone_set_line_color->proc~make_cone proc~elliptic_set_primary_angles EllipticCone%elliptic_set_primary_angles proc~elliptic_set_primary_angles->proc~make_cone proc~plane_build_contents RadialPlane%plane_build_contents proc~plane_build_contents->proc~make_plane proc~plane_set_line_color RadialPlane%plane_set_line_color proc~plane_set_line_color->proc~make_plane proc~plane_set_parameters RadialPlane%plane_set_parameters proc~plane_set_parameters->proc~make_plane proc~poly_build_contents Polyhedron%poly_build_contents proc~poly_build_contents->proc~make_polyhedron proc~poly_set_draw_mode Polyhedron%poly_set_draw_mode proc~poly_set_draw_mode->proc~make_polyhedron proc~poly_set_line_color Polyhedron%poly_set_line_color proc~poly_set_line_color->proc~make_polyhedron proc~poly_set_line_width Polyhedron%poly_set_line_width proc~poly_set_line_width->proc~make_polyhedron proc~poly_set_opacity Polyhedron%poly_set_opacity proc~poly_set_opacity->proc~make_polyhedron proc~rect_set_primary_angles RectangularCone%rect_set_primary_angles proc~rect_set_primary_angles->proc~make_cone proc~remove_vertex_colors Polyhedron%remove_vertex_colors proc~remove_vertex_colors->proc~make_polyhedron proc~set_cone_color PolyhedralCone%set_cone_color proc~set_cone_color->proc~make_cone proc~set_cone_length PolyhedralCone%set_cone_length proc~set_cone_length->proc~make_cone proc~set_draw_mode PolyhedralCone%set_draw_mode proc~set_draw_mode->proc~make_cone proc~set_edges Polyhedron%set_edges proc~set_edges->proc~make_polyhedron proc~set_face_color Polyhedron%set_face_color proc~set_face_color->proc~make_polyhedron proc~set_faces Polyhedron%set_faces proc~set_faces->proc~make_polyhedron proc~set_grid Polyhedron%set_grid proc~set_grid->proc~make_polyhedron proc~set_lit Polyhedron%set_lit proc~set_lit->proc~make_polyhedron proc~set_plane_color RadialPlane%set_plane_color proc~set_plane_color->proc~make_plane proc~set_point_color Polyhedron%set_point_color proc~set_point_color->proc~make_polyhedron proc~set_point_size Polyhedron%set_point_size proc~set_point_size->proc~make_polyhedron proc~set_smooth Polyhedron%set_smooth proc~set_smooth->proc~make_polyhedron proc~set_triangles Polyhedron%set_triangles proc~set_triangles->proc~make_polyhedron proc~set_two_sided Polyhedron%set_two_sided proc~set_two_sided->proc~make_polyhedron proc~set_vertex_angles PolyhedralCone%set_vertex_angles proc~set_vertex_angles->proc~make_cone proc~set_vertex_colors Polyhedron%set_vertex_colors proc~set_vertex_colors->proc~make_polyhedron proc~set_vertices Polyhedron%set_vertices proc~set_vertices->proc~make_polyhedron

Source Code

    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