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<H2>C Specification</H2> 13<DL> 14 <DD> 15<PRE><CODE>#include <revolution/gx.h></CODE></PRE> 16 <DD> 17<PRE><CODE>#define GXInitSpecularDirv(lo,vec) \ 18(GXInitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2))</CODE></PRE> 19</DL> 20<H2>Arguments</H2> 21<TABLE border="1" cellpadding="3" cellspacing="0.1"> 22 <TBODY> 23 <TR> 24<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>lo</CODE></STRONG></EM></TD> 25<TD width="520">pointer to a light object</TD> 26 </TR> 27 <TR> 28<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>vec</CODE></STRONG></EM></TD> 29<TD width="520">direction vector <BR>You may use an array of <CODE>f32</CODE> type or structure.</TD> 30 </TR> 31 </TBODY> 32</TABLE> 33<H2>Return Values</H2> 34<P>None.</P> 35<H2>Description</H2> 36<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 <a href="GXLoadLightObjImm.html"><code>GXLoadLightObjImm</code></a> or <a href="GXLoadLightObjIndx.html"><code>GXLoadLightObjIndx</code></a>.</P> 37<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> 38<P>A half-angle vector, needed for specular lighting, is automatically calculated from the input light direction (<em>nx, ny, nz</em>) 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.</P> 39<P><B>Note:</B> 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 <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>. You must not use <a href="GXInitLightDir.html"><code>GXInitLightDir</code></a> or <a href="GXInitLightPos.html"><code>GXInitLightPos</code></a> to set a light object which will be used as a specular light. These functions will override any data set by the <a href="GXInitSpecularDir.html"><code>GXInitSpecularDir</code></a> function.</P> 40<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 set by this function for diffuse light, it acts as a (pseudo) parallel diffuse light.</P> 41<H2>Example</H2> 42<P>You may set an array of <CODE>f32</CODE> values as the <CODE>vec</CODE> argument.</P> 43<P><code>//array use<br> f32 dir[3] = { 1.0f, 0.0f, 0.0f };<br> GXLightObj myLightObj;<br> <br> GXInitSpecularDirv( &myLightObj, dir );</code></P> 44<P>(You can also use a structure which contains three <CODE>f32</CODE> members (like the <CODE>vec</CODE> type of the matrix-vector library).</P> 45<P><code>//structure use<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></P> 46<H2>See Also</H2> 47<P><CODE><A href="GXInitSpecularDir.html">GXInitSpecularDir</A></CODE></P> 48<P><A href="GXLightObjInitFlow.html"><CODE>GXLightObj</CODE> Initialization Flow</A></P> 49<H2>Revision History</H2> 50<P>03/01/2006 Initial version.</P> 51</BODY> 52</HTML>