index

Varkon MBS Programmers manual

# cre_light - Procedure

## Description

Creates a light source. Light sources are numbered from 0 to 7. When a new job is started Varkon automatically creates one light source (0) and turns it on. With cre_light() you can create 7 additional light sources. Once a light source is created you can alter it's characteristics by calling cre_light() on that light source again (including the default light source 0).

Too see the effect of a light source you must turn it on. Use light_on() to turn lights on and light_off() to turn lights off.

A light source can be configured as a distant light or a spotlight. A distant light is thought of as being so far away from the scene that the light rays are practically parallell. The direction of a distant light is given by the pos parameter ie. the same direction as from pos to BASIC coordinates (0,0,0). A distant light has either no spotang at all or a spotang equal to 180 degrees.

A spotlight has a true position given by pos and is always aimed at spotpos. The spreading angle is given by spotang and should be > 0 but not more than 90 degrees. A focus factor can be used to control the attenuation of the light from the center of the spot circle to its edge. A high value concentrates the light towards the center and a low value gives a more even distribution.

## Syntax

      cre_light(light, pos, spotpos, spotang, spotfocus);

      int    light;
      vector pos;
      vector spotpos;
      float  spotang;
      float  spotfocus;

## Principal parameters

light | - Light number 0 - 7
pos | - Distant light from pos to (0,0,0) or true position of a spotlight

## Optional parameters

spotpos | - The position at which the spotlight is aimed. Default = (0,0,0).
spotang | - The angle of the spot light cone (0-90) or 180 for a distant light. Default = 180.
spotfocus | - The focus factor, 0 = No focus and 100 equals full focus. Default = 0 = No focus.

## Examples

      cre_light(0, vec(1,1,1));

Makes lightsource 0 a distant light shining in the direction from (1,1,1) to (0,0,0).

      cre_light(1, vec(100,50,0), vec(20,20,10), 25, 50);

Makes lightsource 1 a spotlight placed in (100,50,0) aimed at (20,20,10) with a spotangle of 25 degrees and 50% focus.

      cre_light(1, vec(100,50,0), vec(20,20,10), 180, 50);

Same as above but the light becomes distant because of spotang = 180. Parameters spotpos and spotfocus are left without notice.

## Comments

The quality of images with spotlights depends on the number of triangles used by OpenGL to render the model. You can increase the number of triangels by increasing the curve accuracy factor.

See also:

get_light(), light_on(), light_off(), cre_color(), cre_material(), cacc_view()

Varkon version 1.19C svn# 120