##### Ninja Library - Light Function

# njCreateLight

Sets a light source type and establishes (registers) a new light

### FORMAT

`

  void njCreateLight( *ptr, lsrc )
  NJS_LIGHT *ptr
  Int lsrc

`

### PARAMETER

  `*ptr` | Pointer to light source
  `lsrc` | Light source types

### RETURN

  None

### DESCRIPTION

  Sets a light source type and establishes (registers) a new light.

  Lighting calculation is controlled mainly by the direction of light and principle line of the polygon (principle line of the vertex) and the distance between the light and vertex (or representative point of the mode). Light irradiated to a polygon is executed basically at a light beam to principle line angle between 90 and 180 degrees, and is lighter nearer 180 degrees. When less than 90 degrees, light is not irradiated. Addtionally, it is weaker if the distance is very far. (However, parallel lighting is excluded.)

  Only NJD_DIR_LIGHT|NJD_SIMPLE_LIGHT (BASIC model) is calculated between 0-180 degrees.

  Types of light source (lsrc) are listed below.

  BASIC Model : Corresponds to the `njDrawObject()` and `njFastDrawObject()` function types. `(njFastDrawObject()` type is only luminance.)

  Single Light Source Models

  Value | Meaning
  NJD_AMBIENT | Environment light source: Equally lighter on all surfaces.
  NJD_DIR_LIGHT | Parallel light source: Rather than distance, lightens in the direction specified by njSetLightDirection or the direction determined following execution of njRotateLightX matrix, etc. The light flag NJD_SIMPLE_LIGHT can also be added to this light source.
  NJD_POINT_LIGHT | Point light source: Light is irradiated from the point specified by njSetLightLocation or the point to which it is moved after execution of njTranslateLight matrix, etc. The light flags NJD_SIMPLE_LIGHT and NJD_BLOCK_LIGHT can also be added to this light source.
  NJD_SPOT_LIGHT | Spotlight: Light is irradiated from a cone interior provided by a specified light direction and position, the same as the parallel and point light sources, and by the angle specified by njSetLightAngle. The light flags NJD_SIMPLE_LIGHT and NJD_BLOCK_LIGHTcan be added to the spotlight.

  Compound Light Source Models

  NJD_SPEC_DIR (NJD_SPEC_POINT) | Parallel light source with highlighting (point light source): Specula highlights lighten under the angle condition specified by njSetLightAngle. For others, it is the same as parallel lighting (point light source). The light flag NJD_SIMPLE_LIGHT can be added. (Only the point light source can specify NJD_BLOCK_LIGHT.)
  NJD_LAMBERT_DIR (NJD_LAMBERT_POINT) | LAMBERT model: Light is irradiated according to standard light source models including parallel (point) and environment lighting. The light flag NJD_SIMPLE_LIGHT can be added. (Only the point light source can specify NJD_BLOCK_LIGHT.)
  NJD_PHONG_DIR (NJD_PHONG_POINT) | Phong model: Light is irradiated according to the standard light source models including parallel (point), environment and specula lighting. The light flag NJD_SIMPLE_LIGHT can be added. (Only the point light source can specify NJD_BLOCK_LIGHT.)

  Other Flags

  NJD_SIMPLE_LIGHT | In principle, the calculation should be simplified to make the light source calculation faster. However, quality may be influenced at times. Use the or-operator for set up, such as NJD_SPEC_POINT|NJD_SIMPLE_LIGHT.
  NJD_BLOCK_LIGHT | As the distance operation is executed at representative points rather than every vertex, the light source calculation should be faster. However, there may be a large influence on quality on a case-by-case basis. Depending on the model used, the expected effect may not be attained. Directions for use are the same as that for NJD_SIMPLE_LIGHT.

  User Set (Callback) Light

  NJD_USER_LIGHT | Calls the light source function created by the user.

  CHUNK Model : Corresponds to the njCnkDrawObject function. Environment light is only for scenes (system).

  NJD_SPEC_DIR (NJD_SPEC_POINT) | Parallel light source (point light source) with highlights: Specula highlights can be turned off by specula ignore flag (NJD_FST_IS), making it the same as the parallel light source (point light source).
  NJD_SPOT_LIGHT | Spotlight: Light is irradiated inside the cone created by the light direction and position, the same as the parallel light source, and by the angle specified by njSetLightAngle.

### EXAMPLE

      #include <Shinobi.h>
      	:
      NJS_LIGHT light;
      sbInitSystem( NJD_RESOLUTION_VGA, NJD_FRAMEBUFFER_MODE_RGB565, 1);
      /* Register parallel light source */
      njCreateLight(&light, NJD_DIR_LIGHT);
      	:
      /* njDeleteLight(), njLightOff() functions needs to be called
        in order to cancel parallel light */
      njDrawObject(...);
      	:

### REFERENCE

  `njDrawObject()
  njFastDrawObject()
  njCnkDrawObject()
  `

njCreateLight

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999