N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## gdSPDefLights

Syntax

    #include "gbi.h"

    typedef struct {
      Ambienta;
      Lightl[M];
    } LightsM;

    LightsM gdSPDefLightsM(
       unsigned char ar,
       unsigned char ag,
       unsigned char ab,

       unsigned char d1r,
       unsigned char d1g,
       unsigned char d1b,

       unsigned char n1x,
       unsigned char n1y,
       unsigned char n1z,
    ...
       unsigned char dMr,
       unsigned char dMg,
       unsigned char dMb,
       unsigned char nMx,
       unsigned char nMy,
       unsigned char nMz)

Arguments

- ar, ag, ab are the red, green, blue components of ambient light color.
- d1r, d1g, d1b are the red, green, blue components of first diffuse light color.
- n1x, n1y, n1z are the x, y, z components of first diffuse light direction.
- dMr, dMg, dMb are the red, green, blue components of Mth diffuse light color.
- nMx, nMy, nMz are the x, y, z components of Mth diffuse light direction.

Explanation
It loads parameters defining the lights into light structures. The diffuse light direction coordinates specify the direction from the origin to the diffuse light.
The macro name is actually gdSPDefLightsM where the letter M represents the number of diffuse lights in the scene. In the macro and in the structure (LightsM), M must be an actual integer in the range of 0 to 7.
For example, with three diffuse lights, the command is gdSPDefLights3, and the corresponding structure is Lights3. In this case, arguments for colors of the ambient light and both colors and directions of 3 diffuse lights must be supplied. When M is 0, only the arguments for colors of the ambient light need be supplied.
Example
The following code defines an ambient and a diffuse light in a variable named "lite." The ambient color is a very dark gray, while the diffuse color is a bright red. As this example shows, the diffuse light direction vector does not need to be normalized. If the scale of the model view matrix is S and the magnitude of the light direction is L then try to keep 1 < L*S < 23040.

    Lights1 lite = gdSPDefLights1(
    0x05, 0x05, 0x05, /* amb col */
    0xc0, 0x00, 0x00, /* col 1   */
    13,   25,  30);   /* dir 1   */

The variable (lite in this example) may be used in the gSPSetLights macro or the gSPLight macro to set the lighting state of the RSP.
See Also
gSPSetLights

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1998