mesh_set_material Function

public function mesh_set_material(mesh, ambient, diffuse, specular, emissive, shininess) result(status)

Set a lit mesh's material: ambient, diffuse, specular and emissive colors (rgba) and shininess (VSG's Phong: the ambient color scales the diffuse color reflected from ambient light). Returns 0, or -1 on failure (e.g. a mesh without a material).

Arguments

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

mesh handle (vkf_mesh_create)

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

colors (rgba, 0 to 1)

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

colors (rgba, 0 to 1)

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

colors (rgba, 0 to 1)

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

colors (rgba, 0 to 1)

real(kind=c_float), intent(in) :: shininess

Phong exponent

Return Value integer(kind=c_int)


Calls

proc~~mesh_set_material~~CallsGraph proc~mesh_set_material mesh_set_material 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~~mesh_set_material~~CalledByGraph proc~mesh_set_material mesh_set_material proc~apply_color apply_color proc~apply_color->proc~mesh_set_material proc~apply_material_to apply_material_to proc~apply_material_to->proc~mesh_set_material proc~vector_show_state VectorHandle%vector_show_state proc~vector_show_state->proc~mesh_set_material 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_region_color ShadowCones%set_region_color proc~set_region_color->proc~apply_color proc~shadow_build_contents ShadowCones%shadow_build_contents proc~shadow_build_contents->proc~apply_color proc~vector_build_contents VectorHandle%vector_build_contents proc~vector_build_contents->proc~vector_show_state proc~vector_set_color VectorHandle%vector_set_color proc~vector_set_color->proc~vector_show_state 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

    integer(c_int) function mesh_set_material(mesh, ambient, diffuse, specular, emissive, shininess) result(status)
        type(c_ptr), intent(in) :: mesh  !! mesh handle (vkf_mesh_create)
        real(c_float), dimension(4), intent(in) :: ambient, diffuse, specular, emissive  !! colors (rgba, 0 to 1)
        real(c_float), intent(in) :: shininess  !! Phong exponent
        real(c_float), dimension(:), pointer :: m
        type(c_ptr) :: buffer
        buffer = vkf_mesh_material(mesh)
        if (.not. c_associated(buffer)) then
            status = -1
            return
        end if
        call c_f_pointer(buffer, m, [19])
        m(1:4) = ambient
        m(5:8) = diffuse
        m(9:12) = specular
        m(13:16) = emissive
        m(17) = shininess
        status = vkf_mesh_material_changed(mesh)
    end function mesh_set_material