ellipsoid_create Function

public function ellipsoid_create(radii, rgba, texture, n_lon, n_lat, night_texture, translucent) result(mesh)

An ellipsoid mesh node with semi-axes radii (x, y, z) and color (rgba, multiplying the texture), with an optional equirectangular texture and night texture (image handles; the night texture shows where the light is weak). n_lon and n_lat default to 128 and 64 segments. With translucent, a translucent surface (its material's alpha; drawn after the opaque scene, sorted by depth). Null on failure.

Arguments

Type IntentOptional Attributes Name
real(kind=c_double), intent(in), dimension(3) :: radii

semi-axes along x, y, z

real(kind=c_float), intent(in), dimension(4) :: rgba

color [r, g, b, a] (0 to 1)

type(c_ptr), intent(in), optional :: texture

image handle of the (day) texture

integer, intent(in), optional :: n_lon

segments in longitude (default 128)

integer, intent(in), optional :: n_lat

segments in latitude (default 64)

type(c_ptr), intent(in), optional :: night_texture

image handle of the night texture

logical, intent(in), optional :: translucent

a translucent surface (default false)

Return Value type(c_ptr)


Calls

proc~~ellipsoid_create~~CallsGraph proc~ellipsoid_create ellipsoid_create interface~vkf_mesh_create vkf_mesh_create proc~ellipsoid_create->interface~vkf_mesh_create interface~vkf_mesh_set_bound vkf_mesh_set_bound proc~ellipsoid_create->interface~vkf_mesh_set_bound proc~ellipsoid ellipsoid proc~ellipsoid_create->proc~ellipsoid proc~ellipsoid_size ellipsoid_size proc~ellipsoid_create->proc~ellipsoid_size proc~mesh_arrays mesh_arrays proc~ellipsoid_create->proc~mesh_arrays interface~vkf_mesh_array vkf_mesh_array proc~mesh_arrays->interface~vkf_mesh_array

Called by

proc~~ellipsoid_create~~CalledByGraph proc~ellipsoid_create ellipsoid_create proc~build_lod_mesh build_lod_mesh proc~build_lod_mesh->proc~ellipsoid_create proc~sphere_build_contents Sphere%sphere_build_contents proc~sphere_build_contents->proc~ellipsoid_create proc~sphere_build_contents->proc~build_lod_mesh proc~sphere_create sphere_create proc~sphere_create->proc~ellipsoid_create proc~sphere_update Sphere%sphere_update proc~sphere_update->proc~build_lod_mesh

Source Code

    function ellipsoid_create(radii, rgba, texture, n_lon, n_lat, night_texture, translucent) result(mesh)
        real(c_double), dimension(3), intent(in) :: radii   !! semi-axes along x, y, z
        real(c_float), dimension(4), intent(in) :: rgba     !! color [r, g, b, a] (0 to 1)
        type(c_ptr), intent(in), optional :: texture        !! image handle of the (day) texture
        type(c_ptr), intent(in), optional :: night_texture  !! image handle of the night texture
        integer, intent(in), optional :: n_lon              !! segments in longitude (default 128)
        integer, intent(in), optional :: n_lat              !! segments in latitude (default 64)
        logical, intent(in), optional :: translucent        !! a translucent surface (default false)
        type(c_ptr) :: mesh
        real(c_float), dimension(:,:), pointer :: xyz, normals, uv
        integer(c_int32_t), dimension(:), pointer :: indices
        type(c_ptr) :: tex, night
        integer :: nx, ny, n_vertices, n_indices
        integer(c_int) :: flags
        logical :: see_through
        nx = 128
        ny = 64
        if (present(n_lon)) nx = n_lon
        if (present(n_lat)) ny = n_lat
        tex = c_null_ptr
        if (present(texture)) tex = texture
        night = c_null_ptr
        if (present(night_texture)) night = night_texture
        see_through = .false.
        if (present(translucent)) see_through = translucent
        flags = merge(8_c_int, 0_c_int, see_through)
        call ellipsoid_size(nx, ny, n_vertices, n_indices)
        mesh = vkf_mesh_create(int(n_vertices, c_int), int(n_indices, c_int), rgba, tex, night, flags)
        if (.not. c_associated(mesh)) return
        call mesh_arrays(mesh, n_vertices, n_indices, xyz, normals, uv, indices)
        call ellipsoid(radii, nx, ny, xyz, normals, uv, indices)
        if (see_through) then
            if (vkf_mesh_set_bound(mesh, 0.0_c_double, 0.0_c_double, 0.0_c_double, maxval(radii)) /= 0) &
                write(*, '(a)') 'vkframes: could not set a translucent mesh''s bound'
        end if
    end function ellipsoid_create