build_lod_mesh Subroutine

private subroutine build_lod_mesh(self, k, compile)

Build level-of-detail mesh k (lod_segments(k) segments around) and add it to the level-of-detail node (compiled for the windows if compile).

Arguments

Type IntentOptional Attributes Name
type(Sphere), intent(inout) :: self
integer, intent(in) :: k

index into lod_segments

logical, intent(in) :: compile

true: compile it now (the sphere is shown)


Calls

proc~~build_lod_mesh~~CallsGraph proc~build_lod_mesh build_lod_mesh interface~vkf_compile_node vkf_compile_node proc~build_lod_mesh->interface~vkf_compile_node interface~vkf_sphere_lod_add vkf_sphere_lod_add proc~build_lod_mesh->interface~vkf_sphere_lod_add proc~apply_material_to apply_material_to proc~build_lod_mesh->proc~apply_material_to proc~ellipsoid_create ellipsoid_create proc~build_lod_mesh->proc~ellipsoid_create proc~name ReferenceFrame%name proc~build_lod_mesh->proc~name proc~apply_material_to->proc~name interface~vkf_mesh_set_twilight vkf_mesh_set_twilight proc~apply_material_to->interface~vkf_mesh_set_twilight proc~color~2 ReferenceFrame%color proc~apply_material_to->proc~color~2 proc~mesh_set_material mesh_set_material proc~apply_material_to->proc~mesh_set_material 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 interface~vkf_mesh_material vkf_mesh_material proc~mesh_set_material->interface~vkf_mesh_material interface~vkf_mesh_material_changed vkf_mesh_material_changed proc~mesh_set_material->interface~vkf_mesh_material_changed

Called by

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

Source Code

    subroutine build_lod_mesh(self, k, compile)
        type(Sphere), intent(inout) :: self
        integer, intent(in) :: k                            !! index into lod_segments
        logical, intent(in) :: compile                      !! true: compile it now (the sphere is shown)
        type(c_ptr) :: mesh
        mesh = ellipsoid_create(self%built_radii, [1.0_c_float, 1.0_c_float, 1.0_c_float, 1.0_c_float], self%image, &
                                lod_segments(k), lod_segments(k) / 2, self%night, translucent=self%translucent)
        if (.not. c_associated(mesh)) then
            write(*, '(a,i0,a)') 'vkframes: Sphere '//self%name()//': could not build its ', lod_segments(k), '-segment mesh'
            return
        end if
        self%lod_mesh(k) = mesh
        call apply_material_to(self, mesh)
        if (compile) then
            if (vkf_compile_node(mesh) /= 0) write(*, '(a)') 'vkframes: Sphere '//self%name()//': could not compile a mesh'
        end if
        if (vkf_sphere_lod_add(self%lod_node, mesh, int(lod_segments(k), c_int)) /= 0) &
            write(*, '(a)') 'vkframes: Sphere '//self%name()//': could not add a mesh'
    end subroutine build_lod_mesh