index

Varkon MBS Programmers manual

# cre_material - Procedure

## Description

Links a material to a pen number and sets its parameters. Materials can only be visualized in graphics windows based on OpenGL. A graphics window based on X11 will only display the ambient color of the material.

Initially no pens are linked to materials and Varkon uses the standard colors of pens as set up in the ini-file or created interactively or with the cre_color() MBS routine. If a material is defined Varkon will use the characteristics of the material instead of the ordinary color when the specified pen is used. It is not reccommended to change the color of pen 0 and pen 1.

A material is defined by 4 different light components each with a red, green and blue (RGB) value between 0 and 255. A shininess factor may also be defined, a total of 13 int parameters which must all be set.

The ambient component sets how much ambient light the material reflects. The diffuse component sets the amount of diffuse light reflected and the specular component sets the amount of specular light reflected. The emitted component sets the amount of light emitted from the material itself (not reflected). The emitted component may be used to create a luminous material. Shininess is used to make the material dull or shiny.

## Syntax

      cre_material(pen, ar, ag, ab, dr, dg, db,
                        sr, sg, sb, er, eg, eb, sh);

      int pen;
      int ar,ag,ab;
      int dr,dg,db;
      int sr,sg,sb;
      int er,eg,eb;
      int s;

## Principal parameters

##

pen | - The pen number to link to the material. 2 - 255
ar | - Ambient red, 0 - 255
ag | - Ambient green, 0 - 255
ab | - Ambient blue, 0 - 255
dr | - Diffuse red, 0 - 255
dg | - Diffuse green, 0 - 255
db | - Diffuse blue, 0 - 255
sr | - Specular red, 0 - 255
sg | - Specular green, 0 - 255
sb | - Specular blue, 0 - 255
er | - Emitted red, 0 - 255
eg | - Emitted green, 0 - 255
eb | - Emitted blue, 0 - 255
sh | - Shininess, 0 - 255

## Optional parameters

None.

## Examples

      cre_material(1, 100, 0, 0, 100, 0, 0, 100, 0, 0, 0, 0, 0, 50);

A red material linked to pen 1 equally sensitive to ambient, diffuse and specular light but with no emitted light and relatively low shininess.

      cre_material(1, 50, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0);

A dark and dull red material.

## Comments

A complete description of how to use light and material parameters to create different effects is not possible to give here. Please check with the litterature on OpenGL and similar graphics software.

A quick guide could be to start with ambient only. Ambient produces no shading but gives the right colors. You could think of it as a sort of background light which is always present everywhere. Add diffuse light to produce more realistic shades. The object now becomes brighter so the ambient level may have to be reduced. Diffuse light reminds of the light you would expect from the sun with some cloudiness. Finally add specular to give a more shiny surface. Use the shininess factor to concentrate or spread the reflected light. Specular light reminds of the very sharp light directly from the sun with no cloudiness.

Note that the Varkon ini-file sets the common ambient, diffuse and specular parameters for all light sources but material_view() sets these for each material independantly.

See also:

get_material(), cre_color(), cre_light(), get_color()

Varkon version 1.19E svn# 121M