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>GXInitLightAttnA</TITLE> 9</HEAD> 10<BODY> 11<H1 align="left">GXInitLightAttnA</H1> 12<H2>C Specification</H2> 13<DL> 14 <DD> 15 <PRE><CODE>#include <revolution/gx.h></CODE></PRE> 16 <DD> 17 <PRE><CODE>void GXInitLightAttnA( 18 <A href="../Structures/GXLightObj.html">GXLightObj</A>* lt_obj, 19 f32 a0, 20 f32 a1, 21 f32 a2 );</CODE></PRE> 22</DL> 23<H2>Arguments</H2> 24<TABLE border="1" cellpadding="3" cellspacing="0.1"> 25 <TBODY> 26 <TR> 27<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>lt_obj</CODE></STRONG></EM></TD> 28<TD width="520">pointer to a light object</TD> 29 </TR> 30 <TR> 31<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a0</CODE></STRONG></EM></TD> 32<TD width="520">angular attenuation coefficient</TD> 33 </TR> 34 <TR> 35<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a1</CODE></STRONG></EM></TD> 36<TD width="520">angular attenuation coefficient</TD> 37 </TR> 38 <TR> 39<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE>a2</CODE></STRONG></EM></TD> 40<TD width="520">angular attenuation coefficient</TD> 41 </TR> 42 </TBODY> 43</TABLE> 44<H2>Return Values</H2> 45<P>None.</P> 46<H2>Description</H2> 47<P>This function sets coefficients used in the lighting attenuation calculation in a given light object. The application must allocate memory for the light object. The arguments <code>a0</code>, <code>a1</code> and <code>a2</code> are used for angular (spotlight) attenuation. The attenuation function is:</P> 48<P><CITE><EM>atten = <U>clamp0(<STRONG> a2</STRONG> * cos(theta)^2 +</U></EM><U> <EM><STRONG>a1</STRONG></EM> * <EM>cos(theta) +</EM> <EM><STRONG>a0</STRONG></EM> )</U><BR> <EM><STRONG> k2</STRONG></EM> <EM>* d^2 +</EM> <EM><STRONG>k1</STRONG></EM> * <EM>d +</EM> <STRONG><EM>k0</EM></STRONG></CITE></P> 49<P>Here <CODE>cos(theta)</CODE> is the cosine of the angle between the normal vector of the light and the vector from the light's position to the vertex. <CODE>d</CODE> is the distance from the light position to the vertex. The coefficients <CODE>k0</CODE> through <CODE>k2</CODE> can be set using <a href="GXInitLightAttnK.html"><code>GXInitLightAttnK</code></a>. You can set both the <CODE>a0</CODE> through <CODE>a2</CODE> and <CODE>k0</CODE> through <CODE>k2</CODE> coefficients with <a href="GXInitLightAttn.html"><code>GXInitLightAttn</code></a>. The light color will be multiplied by the <em>atten</em> factor when the attenuation function for the color channel referencing this light is set to <code>GX_AF_SPOT</code> (see <a href="GXSetChanCtrl.html"><code>GXSetChanCtrl</code></a>).</P> 50<P>All coefficients are represented with a 20-bit floating point format (1-bit sign, 8-bit exponent, and 11-bit significand) in the hardware, as for other arguments associated with vertex lighting. Be aware of possible rounding errors as a result.</P> 51<P>Be aware that this function does not load any hardware registers directly. 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> 52<P>The function <a href="GXInitLightSpot.html"><code>GXInitLightSpot</code></a> can conveniently be used to set the angle attenuation coefficients based on several spotlight types. The function <a href="GXInitLightDistAttn.html"><code>GXInitLightDistAtten</code></a> can be used to set the distance attenuation coefficients using one of the several common attenuation functions.</P> 53<H2>See Also</H2> 54<P><CODE><A href="GXInitLightAttn.html">GXInitLightAttn</A></CODE><BR> <CODE><A href="GXInitLightAttnK.html">GXInitLightAttnK</A></CODE><BR> <CODE><A href="GXGetLightAttnA.html">GXGetLightAttnA</A></CODE><BR> <CODE><A href="GXSetChanCtrl.html">GXSetChanCtrl</A></CODE></P> 55<P><A href="GXLightObjInitFlow.html"><CODE>GXLightObj</CODE> Initialization Flow</A></P> 56<H2>Revision History</H2> 57<P>2006/03/01 Initial version.</P> 58<hr> 59<P>CONFIDENTIAL</p> 60</BODY> 61</HTML>