guPosLightHilite
Creates Light structures for positional lights and also sets the LookAt/Hilite structures
#include <ultra64.h> /* gu.h */
void guPosLightHilite(
PositionalLight *pl1,
PositionalLight *pl2,
Light *l1,
Light *l2,
LookAt *l,
Hilite *h,
float xEye,
float yEye,
float zEye,
float xOb,
float yOb,
float zOb,
float xUp,
float yUp,
float zUp,
int twidth,
int theight);
None
Gets the PositionalLight structures (the parameters of which have been set by the user), and returns them to the Light structures indicated by l1, l2. The light direction and intensity are determined by the positional relationship (distance and direction) between the light and the object being lit.
This function returns Light structures for two positional lights, and sets the x,y screen coordinate directions in the LookAt structure in order to render specular highlights. It also sets the texture offsets used for the rendering of two specular highlights in the Hilite structure. To return a Light structure for just one positional light without calculating values for specular highlights, you can use the guPosLight function.
To learn more about specular highlighting, see Section 11.7.4 "Specular Highlights" in the N64 Programming Manual.
Use this function to create the effect of attenuating positional lights. The function works well with small lighted objects (especially moving objects), but not with large objects (like terrain and walls). If there are numerous small moving objects, call this function for every moving object and use a separate Light structure for each. Note that both twidth and theight must be powers of 2.
The PositionalLight structure looks like this:
typedef struct {
float col[3]; /* Color (and intensity) */
float pos[3]; /* Position (absolute coordinates)*/
float a1, a2; /* Attenuation rate */
/* Actual color = col/(a1* distance + a2) */
} PositionalLight;
The Light structure looks like this:
typedef struct {
unsigned char col[3]; /* Diffuse light value (RGBA) */
char pad1;
unsigned char colc[3]; /* Copy of diffuse light (RGBA) */
char pad2;
signed char dir[3]; /* Direction toward light source (normalized) */
char pad3; /* IMPORTANT: dir must be less than 127 */
} Light_t;
typedef union {
Light_t l;
long long int force_structure_alignment[2];
} Light;
The LookAt structure looks like this:
typedef struct {
Light l[2];
} LookAt;
* Note that here the Light structure is not utilized in the normal way: l[0].dir is for the x,y,z components of the viewing space in the x direction of the screen space, while l[1].dir is for the x,y,z components of the viewing space in the y direction of the screen space.
The Hilite structure looks like this:
typedef struct {
int x1, y1, x2, y2; /* Texture offsets for highlight */
} Hilite_t;
typedef union {
Hilite_t h;
long int force_structure_alignment[4];
} Hilite;
gdSPDefLights, gSPLightColor, gSPNumLights, gSPSetLightsM, guLookAtHilite, and guPosLight
03/01/99 Completely rewritten.