Lighting Functions
[Functions]


Functions

void EnableLight (counter Light, counter DoEnable)
 Enables or disables a light.
void EnableLightFixed (counter Light, counter DoEnable)
 Enables or disables a light fixed.
void ResetLight ()
 Resets all lighting settings to the default ones.
void SetAmbientLight (color Col)
 Sets the global ambient color.
void SetLightAmbientCol (color Col)
 Sets the ambient color of a light.
void SetLightAttenuation (counter Light, scalar C, scalar L, scalar Q)
 Sets the attenuation of the light with distance from its source.
void SetLightDiffuseCol (color Col)
 Sets the diffuse color of a light.
void SetLightPos (counter Light, scalar X, scalar Y, scalar Z, scalar W)
 Sets the position of a light.
void SetLightPos (counter Light, multivector P)
 Sets the position of a light.
void SetLightSpecularCol (color Col)
 Sets the specular color of a light.
void SetLightSpotCutOff (counter Light, scalar Angle)
 Sets the opening angle of a spot light.
void SetLightSpotDir (counter Light, scalar X, scalar Y, scalar Z)
 Sets the direction in which a light shines.
void SetLightSpotDir (counter Light, multivector D)
 Sets the direction in which a light shines.
void SetLightSpotExp (counter Light, scalar Exp)
 Sets the fuzzyness of the spot border.

Detailed Description

These functions allow you to influence the lighting of the visualizations. The functions presented here are basically only wrappers for the corresponding OpenGL lighting features. It may therefore be helpful to have a look at the OpenGL book.

One important aspects of lighting is that each light has three main light components:

  1. ambient,
  2. diffuse,
  3. specular.
These types of lights influence the lighting of an object in different ways. Here is an example script, where the standard light is switched off, so that you can play around with all the particular lighting settings and see the effect directly.

DefVarsE3();

:E3_DRAW_VEC_AS_POINT;
:Blue;
:A = -3*e1;
Dir = e1;
fSpotCutOff = 15;

EnableLight(0, 0);
EnableLight(1, 1);
EnableLightFixed(1,0);

SetAmbientLight(DWhite);

SetLightPos(1, A);

SetLightAmbientCol(1, Black);
SetLightDiffuseCol(1, MMagenta);
SetLightSpecularCol(1, MGray);

SetLightSpotDir(1, Dir);
SetLightSpotCutOff(1, fSpotCutOff);
SetLightSpotExp(1, 2);
SetLightAttenuation(1, 0.1, 0, 0);

:N3_SOLID;
:MWhite;
:SphereN3(0,0,0, 1);

DrawCone(A-0.05*Dir, Dir, tan(fSpotCutOff*RadPerDeg));

This generates the following visualization.

LightTest1_img1.jpg

The example script LightTest2.clu gives a nice example of an animated lighting effect. Here is a screenshot.

LightTest2_img1.jpg

Function Documentation

void EnableLight counter  Light,
counter  DoEnable
 

Enables or disables a light.

Parameters:
Light The Id-number of the light to enable or disable.
DoEnable If this is zero, the light is disabled, otherwise it is enabled.
Returns:
Nothing.
Since:
v1.4
There exists one standard light and seven optional lights. By default, only the standard light is switched on. The standard light has the Id number 0. The other lights have Ids 1 to 7.

void EnableLightFixed counter  Light,
counter  DoEnable
 

Enables or disables a light fixed.

Parameters:
Light The Id-number of the light to enable or disable.
DoEnable If this is zero, the light is not fixed, otherwise it is fixed.
Returns:
Nothing.
Since:
v1.4
If a light is fixed, it does not move together with the frame, when the frame is translated or rotated by the user. The standard light is always fixed. The other seven lights may either be fixed, or be elements of the visualization scene and move with it. By default they are all not fixed.

void ResetLight  ) 
 

Resets all lighting settings to the default ones.

Returns:
Nothing.

void SetAmbientLight color  Col  ) 
 

Sets the global ambient color.

Parameters:
Col The ambient color.
Since:
v1.4
The ambient color refers to a global light that has no position and no direction. If you set the ambient color to white, this has the same effect as having no lighting at all. Everything is then just drawn in the color given to it. If the ambient color is darker, then the additional, positional lights affect the lighting.

void SetLightAmbientCol color  Col  ) 
 

Sets the ambient color of a light.

Parameters:
Light The Id-number of the light to enable or disable.
Col The ambient color.
Returns:
Nothing.
Since:
v1.4

void SetLightAttenuation counter  Light,
scalar  C,
scalar  L,
scalar  Q
 

Sets the attenuation of the light with distance from its source.

Parameters:
Light The Id-number of the light to enable or disable.
C The constant attenuation component.
L The linear attenuation component.
Q The quadratic attenuation component.
Returns:
Nothing.
Since:
v1.4
This function allows you to specify the polynomial with describes the attenuation of the light with distance from its source.

void SetLightDiffuseCol color  Col  ) 
 

Sets the diffuse color of a light.

Parameters:
Light The Id-number of the light to enable or disable.
Col The diffuse color.
Returns:
Nothing.
Since:
v1.4

void SetLightPos counter  Light,
scalar  X,
scalar  Y,
scalar  Z,
scalar  W
 

Sets the position of a light.

Parameters:
Light The Id-number of the light to enable or disable.
X The x-component of the position vector.
Y The y-component of the position vector.
Z The z-component of the position vector.
W The homogeneous component of the position vector.
Returns:
Nothing.
Since:
v1.4
The position vector (X, Y, Z, \ W) is a projective vector. This is done, since it is also allowed to place a light at infinity, which you do by setting the homogeneous component to zero (W = 0).

void SetLightPos counter  Light,
multivector  P
 

Sets the position of a light.

Parameters:
Light The Id-number of the light to enable or disable.
P The position of the light.
Returns:
Nothing.
Since:
v1.4
The position vector P is always transformed into a projective vector. This is done, since it is also allowed to place a light at infinity, which you do by setting the homogeneous component to zero.

void SetLightSpecularCol color  Col  ) 
 

Sets the specular color of a light.

Parameters:
Light The Id-number of the light to enable or disable.
Col The specular color.
Returns:
Nothing.
Since:
v1.4

void SetLightSpotCutOff counter  Light,
scalar  Angle
 

Sets the opening angle of a spot light.

Parameters:
Light The Id-number of the light to enable or disable.
Angle The opening angle of the light cone.
Returns:
Nothing.
Since:
v1.4

void SetLightSpotDir counter  Light,
scalar  X,
scalar  Y,
scalar  Z
 

Sets the direction in which a light shines.

Parameters:
Light The Id-number of the light to enable or disable.
X The x-component of the direction vector.
Y The y-component of the direction vector.
Z The z-component of the direction vector.
Returns:
Nothing.
Since:
v1.4

void SetLightSpotDir counter  Light,
multivector  D
 

Sets the direction in which a light shines.

Parameters:
Light The Id-number of the light to enable or disable.
D The direction in which the light shines. This has to be a Euclidean vector.
Returns:
Nothing.
Since:
v1.4

void SetLightSpotExp counter  Light,
scalar  Exp
 

Sets the fuzzyness of the spot border.

Parameters:
Light The Id-number of the light to enable or disable.
Exp The spot exponent.
Returns:
Nothing.
Since:
v1.4