njCreateLight | Japanese
    <-|INDEX|->
Defines a light source type and registers a new light.

### FORMAT

      #include <NINJA.H>
      void njCreateLight( *ptr, lsrc )
      NJS_LIGHT *ptr
      Int lsrc

### PARAMETERS

*ptr
  light pointer
lsrc
  light type

### RETURN VALUE

  None

### ERROR VALUE

  None

### FUNCTION

  The principle factors involved in light calculation are the directions of rays and lines normal to polygons (or to vertices), and the distance between the light and the vertices (or representative point in the model). In principle, the angle between the incident rays and the lines normal to an illuminated polygon will be 90 to 180 degrees. The closer the angle is to 180 degrees, the brighter the lighting, and illumination completely vanishes if the angle becomes less than 90 degrees.
  Further illumination is attenuated with distance (except with parallel light sources).

| The angular calculation range for NJD_DIR_LIGHT|NJD_SIMPLE_LIGHT only is 0 to 180 degrees.

### EXAMPLE

      #include <NINJA.H>
      ...........

      NJS_LIGHT light;

      njInitSystem();

      /* Define parallel light source */
      njCreateLight(&light, NJD_DIR_LIGHT);
      ...........

      /*  A parallel light source remains effective
       *  for all model functions until njDeleteLight
       *  or AnjCreateLightOff is called.
       */
      njDrawObject(...);
      ...........

### NOTES

- Currently, njDrawObject and njDrawModel are required in order for lighting to be effective. The light types (lsrc) are as follows.

## 1. Single light model

NJD_AMBIENT
  Ambient light: All surfaces are equally illuminated.

NJD_DIR_LIGHT
  Parallel light: Illumination is unaffected by distance in the direction specified by njSetLightDirection or in the direction resulting from matrix rotation by functions such as njRotateLightX.
  The light flag NJD_SIMPLE_LIGHT can be added to this type of light source.

NJD_POINT_LIGHT
  Point light source: Radial illumination from the point source specified by njSetLightLocation or from the translated point location resulting from matrix transformations such as njTranslateLight.
  The light flags NJD_SIMPLE_LIGHT and NJD_BLOCK_LIGHT can be added to this type of light source.

NJD_SPOT_LIGHT
  Spotlight: With this light source type, the direction and position of lighting are determined in the same manner as with parallel lighting and point lighting.
  This type of light source illuminates a circular area whose angular size is determined by the njSetLightAngle function. The light flags NJD_SIMPLE_LIGHT and NJD_BLOCK_LIGHT can be added to this type of light source.

## 2. Compound light models

NJD_SPEC_DIR(NJD_SPEC_POINT)
  Parallel light source with highlighting (point light source): The angle of specular highlighting is determined by njSetLightAngle.
  Otherwise, behavior is the same as with parallel lighting (point light source).
  The light flag NJD_SIMPLE_LIGHT can be added to this type of light source. (NJD_BLOCK_LIGHT can also be specified, but only with point lighting.)

NJD_LAMBERT_DIR(NJD_LAMBERT_POINT)
  Lambert model: This illumination uses a parallel light source (point light source) that is governed by a standard lighting model including ambient light.
  The light flag NJD_SIMPLE_LIGHT can be added to this type of light source.
  (NJD_BLOCK_LIGHT can also be specified, but only with point lighting.)

NJD_PHONG_DIR(NJD_PHONG_POINT)
  Phong model: This illumination uses a parallel light source (point light source) that is governed by a standard lighting model including ambient light and specular light.
  The light flag NJD_SIMPLE_LIGHT can be added to this type of light source. (NJD_BLOCK_LIGHT can also be specified, but only with point lighting.)

## 3. Other flags

NJD_SIMPLE_LIGHT
  This flag generally makes calculation simpler and faster, but may have an effect on quality.
  This flag is specified using an OR operator; e.g. NJD_SPEC_POINT|NJD_SIMPLE_LIGHT.

NJD_BLOCK_LIGHT
  This flag makes light calculation faster limiting distance calculation to a single representative point, rather than to all vertices.
  However, it can greatly affect quality, and the expected benefit is not achieved with some models.
  This flag is used in the same manner as NJD_SIMPLE_LIGHT.

## 4. User-defined (callback) light

NJD_USER_LIGHT
  Calls a user-defined light function.

### RELATED TOPICS

  njDrawObject
  njDrawModel()

njCreateLight |
    <-|INDEX|->