set_material Subroutine

private subroutine set_material(self, ambient, diffuse, specular, emission, shininess)

The material (OpenFrames' setMaterial; each optional): ambient, diffuse, specular and emission colors ([r, g, b] or [r, g, b, a], 0 to 1) and shininess (0 to 128: the specular highlight's sharpness; 0 for none). The ambient and diffuse colors scale the body's color or texture (VSG's Phong); the specular color is reflected from the lights' specular parts. Defaults: ambient and diffuse white, no specular reflection or emission.

Type Bound

Sphere

Arguments

Type IntentOptional Attributes Name
class(Sphere), intent(inout) :: self
real(kind=wp), intent(in), optional :: ambient(:)

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

real(kind=wp), intent(in), optional :: diffuse(:)

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

real(kind=wp), intent(in), optional :: specular(:)

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

real(kind=wp), intent(in), optional :: emission(:)

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

real(kind=wp), intent(in), optional :: shininess

0 to 128 (< 0: 0)


Calls

proc~~set_material~~CallsGraph proc~set_material Sphere%set_material proc~apply_material apply_material proc~set_material->proc~apply_material proc~apply_material_to apply_material_to proc~apply_material->proc~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

Source Code

    subroutine set_material(self, ambient, diffuse, specular, emission, shininess)
        class(Sphere), intent(inout) :: self
        real(wp), intent(in), optional :: ambient(:), diffuse(:), specular(:), emission(:)  !! [r, g, b(, a)], 0 to 1
        real(wp), intent(in), optional :: shininess         !! 0 to 128 (< 0: 0)
        if (present(ambient)) self%ambient_(1:min(4, size(ambient))) = ambient(1:min(4, size(ambient)))
        if (present(diffuse)) self%diffuse_(1:min(4, size(diffuse))) = diffuse(1:min(4, size(diffuse)))
        if (present(specular)) self%specular_(1:min(4, size(specular))) = specular(1:min(4, size(specular)))
        if (present(emission)) self%emission_(1:min(4, size(emission))) = emission(1:min(4, size(emission)))
        if (present(shininess)) self%shininess_ = max(0.0_wp, shininess)
        call apply_material(self)
    end subroutine set_material