GXInitSpecularDirv

C Specification

#include <revolution/gx.h>
#define GXInitSpecularDirv(lo,vec) \
(GXInitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2))

Arguments

lo pointer to a light object
vec direction vector
You may use an array of f32 type or structure.

Return Values

None.

Description

This macro function sets the direction of a specular light in the light object using a vector. This direction is used when the light object is used as a specular light. The memory for the light object must be allocated by the application. This function does not load any hardware registers. To load a light object into a hardware light, use GXLoadLightObjImm or GXLoadLightObjIndx.

The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix. In other words, it should be transformed to view space. The direction vector must be normalized.

A half-angle vector, needed for specular lighting, is automatically calculated from the input light direction (nx, ny, nz) by assuming the view vector as (0, 0, 1). If you specify the direction vector as (0, 0, 1), the half-angle vector becomes zero (no lighting effect) because the two vector directions are identical.

Note: This function should be used if the light object is used as specular light. You can activate a channel for specular lighting by setting the GXAttnFn argument in GXSetChanCtrl to GX_AF_SPEC. You must not use GXInitLightDir or GXInitLightPos to set a light object which will be used as a specular light. These functions will override any data set by the GXInitSpecularDir function.

In contrast to diffuse lights (including spotlights) that are considered local lights, a specular light is a parallel light (the specular light is so far away that all light rays oare perceived as parallel); only directional information can be specified. If you use a light object set by this function for diffuse light, it acts as a (pseudo) parallel diffuse light.

Example

You may set an array of f32 values as the vec argument.

//array use
f32  dir[3] = { 1.0f, 0.0f, 0.0f };
GXLightObj  myLightObj;

GXInitSpecularDirv( &myLightObj, dir );

(You can also use a structure which contains three f32 members (like the vec type of the matrix-vector library).

//structure use
typedef structure
{
    f32  x, y, z;
} Vec;

Vec         dir = { 1.0F, 0.0F, 0.0F };
GXLightObj  myLightObj;

GXInitSpecularDirv( &myLightObj, &dir );

See Also

GXInitSpecularDir

GXLightObj Initialization Flow

Revision History

03/01/2006 Initial version.