1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 8<TITLE>GXInitSpecularDirv</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">GXInitSpecularDirv</H1> 12 13<H2>Syntax</H2> 14<dl><dd><pre class="construction"> 15#include <revolution/gx.h> 16 17#define GXInitSpecularDirv(lo,vec) \ 18 (GXInitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)) 19</pre></dd></dl> 20 21<H2>Arguments</H2> 22<TABLE class="arguments" border="1" > 23 <TBODY> 24 <TR> 25<TH>lo</TH> 26<TD>Pointer to a light object.</TD> 27 </TR> 28 <TR> 29<TH>vec</TH> 30<TD>Direction vector. You may use an <CODE>f32</CODE>-type array or structure.</TD> 31 </TR> 32 </TBODY> 33</TABLE> 34 35<H2>Return Values</H2> 36<P>None.</P> 37 38<H2>Description</H2> 39<P>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 the <A href="GXLoadLightObjImm.html"><CODE>GXLoadLightObjImm</CODE></A> or <A href="GXLoadLightObjIndx.html"><CODE>GXLoadLightObjIndx</CODE></A> function.</P> 40<P>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.</P> 41<P>The half-angle vector, necessary for specular lighting, is automatically calculated from the input light direction (<SPAN class="argument">nx</SPAN>, <SPAN class="argument">ny</SPAN>, <SPAN class="argument">nz</SPAN>) by assuming the view vector as (0, 0, 1). If you specify the input direction vector as (0, 0, 1), the half-angle vector becomes zero (no lighting effect) because the two vector directions are identical.</P> 42<P><B>Note:</B> This function must be used if the light object is used as specular light. You can activate a channel for specular lighting by setting the <code><a href="../Enumerated_Types/GXAttnFn.html">GXAttnFn</a></code> argument in <code><a href="GXSetChanCtrl.html">GXSetChanCtrl</a></code> to <code><a href="../Enumerated_Types/GXAttnFn.html">GX_AF_SPEC</a></code>. Do use the <A href="GXInitLightDir.html"><CODE>GXInitLightDir</CODE></A> or <A href="GXInitLightPos.html"><CODE>GXInitLightPos</CODE></A> function to set a light object which will be used as a specular light. These functions will destroy any data set by the <A href="GXInitSpecularDir.html"><CODE>GXInitSpecularDir</CODE></A> function.</P> 43<P>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 which is set by this function for diffuse light, it acts as a (pseudo) parallel diffuse light.</P> 44 45<H2>Example</H2> 46<P>You may set an array of <CODE>f32</CODE> values as the <SPAN class="argument">vec</SPAN> vector.</P> 47<dl><dd><CODE>// Using an array<BR> f32 dir[3] = { 1.0f, 0.0f, 0.0f };<BR> GXLightObj myLightObj;<BR> <BR> GXInitSpecularDirv( &myLightObj, dir );</CODE></dd></dl> 48<P>You can also use a structure which contains three <CODE>f32</CODE> members (like the matrix-vector library's <CODE>Vec</CODE> type).</P> 49<dl><dd><CODE>// Using a structure<br> typedef structure<br> {<br> f32 x, y, z;<br> } Vec;<br> <br> Vec dir = { 1.0F, 0.0F, 0.0F };<br> GXLightObj myLightObj;<br> <br> GXInitSpecularDirv( &myLightObj, &dir );</CODE></dd></dl> 50 51<H2>See Also</H2> 52<P class="reference"> 53<A href="GXInitSpecularDir.html">GXInitSpecularDir</A>, 54<A href="GXLightObjInitFlow.html">GXLightObj Initialization Flow</A> 55</P> 56 57<H2>Revision History</H2> 58<P> 592006/03/01 Initial version.<br> 60</P> 61 62<hr><p>CONFIDENTIAL</p></body> 63</HTML>