apply_material_to Subroutine

private subroutine apply_material_to(self, mesh)

The material, with the diffuse color times the body's color (without a texture), and the twilight, on mesh mesh (if not null).

Arguments

Type IntentOptional Attributes Name
type(Sphere), intent(in) :: self
type(c_ptr), intent(in) :: mesh

a mesh handle (null: nothing done)


Calls

proc~~apply_material_to~~CallsGraph proc~apply_material_to apply_material_to 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 proc~name ReferenceFrame%name proc~apply_material_to->proc~name 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~~apply_material_to~~CalledByGraph proc~apply_material_to apply_material_to proc~apply_material apply_material proc~apply_material->proc~apply_material_to proc~build_lod_mesh build_lod_mesh proc~build_lod_mesh->proc~apply_material_to proc~set_material Sphere%set_material proc~set_material->proc~apply_material proc~set_opacity Sphere%set_opacity proc~set_opacity->proc~apply_material proc~set_twilight Sphere%set_twilight proc~set_twilight->proc~apply_material proc~sphere_build_contents Sphere%sphere_build_contents proc~sphere_build_contents->proc~apply_material proc~sphere_build_contents->proc~build_lod_mesh proc~sphere_set_color Sphere%sphere_set_color proc~sphere_set_color->proc~apply_material proc~sphere_update Sphere%sphere_update proc~sphere_update->proc~build_lod_mesh

Source Code

    subroutine apply_material_to(self, mesh)
        type(Sphere), intent(in) :: self
        type(c_ptr), intent(in) :: mesh                     !! a mesh handle (null: nothing done)
        real(wp) :: diffuse(4)
        if (.not. c_associated(mesh)) return
        diffuse = self%diffuse_
        if (.not. self%textured) diffuse = diffuse * self%color()
        if (self%translucent) diffuse(4) = diffuse(4) * self%opacity_      ! (the shader's alpha: the diffuse color's)
        if (mesh_set_material(mesh, real(self%ambient_, c_float), real(diffuse, c_float), &
                              real(self%specular_, c_float), real(self%emission_, c_float), &
                              real(self%shininess_, c_float)) /= 0) &
            write(*, '(a)') 'vkframes: Sphere '//self%name()//': could not set the material'
        if (vkf_mesh_set_twilight(mesh, real(self%twilight_, c_float)) /= 0) &
            write(*, '(a)') 'vkframes: Sphere '//self%name()//': could not set the twilight'
    end subroutine apply_material_to