SYNOPSIS
#include <agar/core.h> #include <agar/sg.h>
DESCRIPTION
The
SG_Light node defines a light source in a
SG(3) scene-graph.
Each light source is associated with a priority number, which determines
which lights are used in the rendering.
The number of lights supported for rendering is dependent on the renderer
implementation.
INHERITANCE HIERARCHY
AG_Object(3)-> SG_Node(3)-> SG_Light.
INITIALIZATION
SG_Light * SG_LightNew (SG_Node *parent, const char *name)
void SG_LightAmbient (SG_Light *lt, M_Color c)
void SG_LightDiffuse (SG_Light *lt, M_Color c)
void SG_LightSpecular (SG_Light *lt, M_Color c)
void SG_LightSpot (SG_Light *lt, M_Real cutoff, M_Real exponent, M_Vector3 dir)
The SG_LightNew() function allocates, initializes, and attaches a SG_Light object.
The functions SG_LightAmbient(), SG_LightDiffuse() and SG_LightSpecular() configure the colors associated with the ambient, diffuse and specular components of the light source.
SG_LightSpot() sets the spot parameters of the light source. cutoff specifies the cutoff angle in degrees, exponent specifies the light intensity (the higher the exponent, the more focused the light source; a value of 0 provides uniform distribution), and dir is the direction vector. If the cutoff angle is < 180 degrees, the light source is directional, otherwise it is treated as a point source and the direction vector is ignored.
INTERNAL WIDGET API
The SG_LightSetup() function sets up the renderer states associated with a light, prior to rendering. This function is usually invoked from the draw() operation of an SG_View(3) (or derived) widget, prior to rendering a scene.
STRUCTURE DATA
For the
SG_Light object:
int pri | Priority of light source when number of sources is limited (0 = highest priority). |
M_Color ambient | Ambient color component of source. |
M_Color diffuse | Diffuse color component of source. |
M_Color specular | Specular color component of source. |
M_Real spot_cutoff | Spotlight cutoff angle (or 180 for point source). |
M_Real spot_exponent | Spotlight intensity distribution. |
M_Vector3 spot_dir | Spotlight direction. |
M_Real Kc | Constant light attenuation factor. |
M_Real Kl | Linear light attenuation factor. |
M_Real Kq | Quadratic light attenuation factor. |
SEE ALSO
HISTORY
The
SG_Light node class first appeared in
Agar 1.6.0.