Navigation

Operators and Keywords

Function List:

C++ API

: material shiny
: material dull
: material metal
: material default
: material ([as, ds, ss])
: material ([as, ds, ss, se])
: material ([as, ds, ss, se, scr])
: material (hlist, …)
: mtypes = material ()
: refl_props = material (mtype_string)

Set reflectance properties for the lighting of surfaces and patches.

This function changes the ambient, diffuse, and specular strengths, as well as the specular exponent and specular color reflectance, of all patch and surface objects in the current axes. This can be used to simulate, to some extent, the reflectance properties of certain materials when used with light.

When called with a string, the aforementioned properties are set according to the values in the following table:

mtypeambient- strengthdiffuse- strengthspecular- strengthspecular- exponentspecular- color- reflectance
"shiny"0.30.60.9201.0
"dull"0.30.80.0101.0
"metal"0.30.31.0250.5
"default""default""default""default""default""default"

When called with a vector of three elements, the ambient, diffuse, and specular strengths of all patch and surface objects in the current axes are updated. An optional fourth vector element updates the specular exponent, and an optional fifth vector element updates the specular color reflectance.

A list of graphic handles can also be passed as the first argument. In this case, the properties of these handles and all child patch and surface objects will be updated.

Additionally, material can be called with a single output argument. If called without input arguments, a column cell vector mtypes with the strings for all available materials is returned. If the one input argument mtype_string is the name of a material, a 1x5 cell vector refl_props with the reflectance properties of that material is returned. In both cases, no graphic properties are changed.

See also: light, fill, mesh, patch, pcolor, surf, surface.

Demonstration 1

The following code

 clf;
 ## patch
 [x,y,z] = meshgrid (-2:0.2:2, -2:0.2:2, -2:0.2:2);
 val = x.^2 + y.^2 + z.^2;
 fv1 = isosurface (x, y, z, val, 1);
 h_patch = patch (fv1, "FaceColor", "r", "EdgeColor", "none", ...
                       "FaceLighting", "Gouraud");
 isonormals (x, y, z, val, h_patch);
 axis equal;  axis tight;
 view (3);
 box off;
 drawnow ();
 light ();
 material ([0 0.5 1 10 .5]);
 title ("material() with numeric input");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 ## surface
 hax = axes ();
 surf (hax, peaks, "LineStyle", "none", "FaceLighting", "Gouraud");
 view (3);
 light ();
 material metal;
 title ("material metal");

Produces the following figure

Figure 1

Package: octave