<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: csgfx/vertexlight.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csgfx/vertexlight.h</h1><a href="vertexlight_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 2005 by Marten Svanfeldt</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00007"></a>00007 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00010"></a>00010 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00011"></a>00011 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00012"></a>00012 <span class="comment"> Library General Public License for more details.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00015"></a>00015 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00016"></a>00016 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#ifndef __CS_CSGFX_VERTEXLIGHT_H__</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#define __CS_CSGFX_VERTEXLIGHT_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="csqsqrt_8h.html" title="Fast computation of sqrt(x) and 1/sqrt(x).">csqsqrt.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="math_8h.html" title="Generic mathematic utility functions.">csgeom/math.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="transfrm_8h.html" title="Transformation from one coordinate system to another.">csgeom/transfrm.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="vector3_8h.html" title="3D vector.">csgeom/vector3.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="lightsvcache_8h.html" title="Helper to cache names of shader variables relevant to lighting.">csgfx/lightsvcache.h</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="vertexlistwalker_8h.html" title="Helper to access elements from renderbuffers.">csgfx/vertexlistwalker.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="cscolor_8h.html" title="Floating-point color.">csutil/cscolor.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="rbuflock_8h.html" title="Helper class for convenient locking/unlocking of an iRenderBuffer.">cstool/rbuflock.h</a>"</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="light_8h.html" title="Light interfaces.">iengine/light.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="movable_8h.html" title="Movable - position and orientation of an object.">iengine/movable.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="shader_8h.html" title="Shader-related interfaces.">ivideo/shader/shader.h</a>"</span> <a name="l00034"></a>00034 <a name="l00042"></a><a class="code" href="structcsLightProperties.html">00042</a> <span class="keyword">struct </span><a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a> <a name="l00043"></a>00043 { <a name="l00045"></a><a class="code" href="structcsLightProperties.html#92b6b817b39986a435909f663e6cb0c4">00045</a> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> <a class="code" href="structcsLightProperties.html#92b6b817b39986a435909f663e6cb0c4" title="Attenuation coefficients (for CLQ attenuation).">attenuationConsts</a>; <a name="l00047"></a><a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d">00047</a> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> <a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d" title="Light position (object space).">posObject</a>; <a name="l00052"></a><a class="code" href="structcsLightProperties.html#e768acfd67befdb3fe2c5d2b911033fa">00052</a> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> <a class="code" href="structcsLightProperties.html#e768acfd67befdb3fe2c5d2b911033fa" title="Light direction (object space).">dirObject</a>; <a name="l00054"></a><a class="code" href="structcsLightProperties.html#b2130f8509d6ea50c2b9eb64f7d340c8">00054</a> <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a> <a class="code" href="structcsLightProperties.html#b2130f8509d6ea50c2b9eb64f7d340c8" title="Light diffuse color.">color</a>; <a name="l00056"></a><a class="code" href="structcsLightProperties.html#e845dd083248858d825a97ee7fccf70d">00056</a> <span class="keywordtype">float</span> <a class="code" href="structcsLightProperties.html#e845dd083248858d825a97ee7fccf70d" title="Spotlight inner falloff.">spotFalloffInner</a>; <a name="l00058"></a><a class="code" href="structcsLightProperties.html#adce8ecf9f7134416f1a89a8f93e6e8b">00058</a> <span class="keywordtype">float</span> <a class="code" href="structcsLightProperties.html#adce8ecf9f7134416f1a89a8f93e6e8b" title="Spotlight outer falloff.">spotFalloffOuter</a>; <a name="l00060"></a><a class="code" href="structcsLightProperties.html#544f97bd9287abc998da9b0fe2742da8">00060</a> <a class="code" href="group__engine3d__light.html#ge4baf0a9f20299ab4c39397c9bfbe264" title="Type of lightsource.">csLightType</a> <a class="code" href="structcsLightProperties.html#544f97bd9287abc998da9b0fe2742da8" title="Light type.">type</a>; <a name="l00062"></a><a class="code" href="structcsLightProperties.html#059fff1f2cb5b9b50936d6e90bf3a646">00062</a> <a class="code" href="group__engine3d__light.html#g0040eead4e75eb362c14a866cce0f728">csLightAttenuationMode</a> <a class="code" href="structcsLightProperties.html#059fff1f2cb5b9b50936d6e90bf3a646" title="Light attenuation mode.">attenuationMode</a>; <a name="l00064"></a><a class="code" href="structcsLightProperties.html#c24e9622435a640e48e012d20b9ddc05">00064</a> <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a> <a class="code" href="structcsLightProperties.html#c24e9622435a640e48e012d20b9ddc05" title="Specular color.">specular</a>; <a name="l00065"></a>00065 <a name="l00066"></a><a class="code" href="structcsLightProperties.html#b84b5a097dc0620e03bec7194d1d0990">00066</a> <a class="code" href="structcsLightProperties.html#b84b5a097dc0620e03bec7194d1d0990">csLightProperties</a> () : <a class="code" href="structcsLightProperties.html#e845dd083248858d825a97ee7fccf70d" title="Spotlight inner falloff.">spotFalloffInner</a>(0.0f), <a class="code" href="structcsLightProperties.html#adce8ecf9f7134416f1a89a8f93e6e8b" title="Spotlight outer falloff.">spotFalloffOuter</a>(0.0f), <a name="l00067"></a>00067 <a class="code" href="structcsLightProperties.html#544f97bd9287abc998da9b0fe2742da8" title="Light type.">type</a>(<a class="code" href="group__engine3d__light.html#gge4baf0a9f20299ab4c39397c9bfbe264f7e1a9262208f00851f4076b8b278d11" title="Point light.">CS_LIGHT_POINTLIGHT</a>) {} <a name="l00072"></a><a class="code" href="structcsLightProperties.html#5ff989bfe1c7eefa122ca7c70813472c">00072</a> <a class="code" href="structcsLightProperties.html#b84b5a097dc0620e03bec7194d1d0990">csLightProperties</a> (<span class="keywordtype">size_t</span> lightNum, <a class="code" href="classcsLightShaderVarCache.html" title="Helper to cache names of shader variables relevant to lighting.">csLightShaderVarCache</a>& svcache, <a name="l00073"></a>00073 <span class="keyword">const</span> <a class="code" href="structiShaderVarStack.html">iShaderVarStack</a>* Stacks) <a name="l00074"></a>00074 { <a name="l00075"></a>00075 <a class="code" href="group__util.html#gbe4f44c93bfeee85c507a999dccf21dd" title="An identifier for a string.">csStringID</a> id; <a name="l00076"></a>00076 <a class="code" href="classcsShaderVariable.html" title="Storage class for &quot;shader vars&quot;, inheritable variables in the shader system...">csShaderVariable</a>* sv; <a name="l00077"></a>00077 <span class="keyword">const</span> <a class="code" href="structiArrayReadOnly.html" title="Array interface template, read-only.">iArrayReadOnly<csShaderVariable*></a>* stacks = Stacks; <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00080"></a>00080 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f14806a210cc5239118693476863ac87700" title="Attenuation vector.">csLightShaderVarCache::lightAttenuation</a>); <a name="l00081"></a>00081 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00082"></a>00082 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#92b6b817b39986a435909f663e6cb0c4" title="Attenuation coefficients (for CLQ attenuation).">attenuationConsts</a>); <a name="l00083"></a>00083 <a name="l00084"></a>00084 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00085"></a>00085 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f143a732fb887c0a37a1b165f7b99a7d7e2" title="Position (object space).">csLightShaderVarCache::lightPosition</a>); <a name="l00086"></a>00086 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00087"></a>00087 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d" title="Light position (object space).">posObject</a>); <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00090"></a>00090 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f142bab269297a155024d619b18c0d90806" title="Direction (object space).">csLightShaderVarCache::lightDirection</a>); <a name="l00091"></a>00091 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00092"></a>00092 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#e768acfd67befdb3fe2c5d2b911033fa" title="Light direction (object space).">dirObject</a>); <a name="l00093"></a>00093 <a name="l00094"></a>00094 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00095"></a>00095 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f14709238ed1b49834b099ee8173a26b0fb" title="Diffuse color.">csLightShaderVarCache::lightDiffuse</a>); <a name="l00096"></a>00096 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00097"></a>00097 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#b2130f8509d6ea50c2b9eb64f7d340c8" title="Light diffuse color.">color</a>); <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00100"></a>00100 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f1490816983c9a3069d039e61f80d6f6db9" title="Spot inner falloff.">csLightShaderVarCache::lightInnerFalloff</a>); <a name="l00101"></a>00101 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00102"></a>00102 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#e845dd083248858d825a97ee7fccf70d" title="Spotlight inner falloff.">spotFalloffInner</a>); <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00105"></a>00105 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f1474203b72905f6d2c05e5983bfd78ddbd" title="Spot outer falloff.">csLightShaderVarCache::lightOuterFalloff</a>); <a name="l00106"></a>00106 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00107"></a>00107 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#adce8ecf9f7134416f1a89a8f93e6e8b" title="Spotlight outer falloff.">spotFalloffOuter</a>); <a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="keywordtype">int</span> t = <a class="code" href="group__engine3d__light.html#gge4baf0a9f20299ab4c39397c9bfbe264f7e1a9262208f00851f4076b8b278d11" title="Point light.">CS_LIGHT_POINTLIGHT</a>; <a name="l00110"></a>00110 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00111"></a>00111 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f14df9edeb325a83b31ec59aff840f57551" title="Light type (csLightType casted to int).">csLightShaderVarCache::lightType</a>); <a name="l00112"></a>00112 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00113"></a>00113 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (t); <a name="l00114"></a>00114 <a class="code" href="structcsLightProperties.html#544f97bd9287abc998da9b0fe2742da8" title="Light type.">type</a> = (<a class="code" href="group__engine3d__light.html#ge4baf0a9f20299ab4c39397c9bfbe264" title="Type of lightsource.">csLightType</a>)t; <a name="l00115"></a>00115 <a name="l00116"></a>00116 t = <a class="code" href="group__engine3d__light.html#gg0040eead4e75eb362c14a866cce0f728b39b476b187c7b9040eac807cc41d5c3" title="no attenuation: light * 1">CS_ATTN_NONE</a>; <a name="l00117"></a>00117 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00118"></a>00118 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f145bff9a9618e8160e16d73f6f311fecb0" title="Attenuation mode (csLightAttenuationMode casted to int).">csLightShaderVarCache::lightAttenuationMode</a>); <a name="l00119"></a>00119 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00120"></a>00120 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (t); <a name="l00121"></a>00121 <a class="code" href="structcsLightProperties.html#059fff1f2cb5b9b50936d6e90bf3a646" title="Light attenuation mode.">attenuationMode</a> = (<a class="code" href="group__engine3d__light.html#g0040eead4e75eb362c14a866cce0f728">csLightAttenuationMode</a>)t; <a name="l00122"></a>00122 <a name="l00123"></a>00123 <span class="keywordtype">id</span> = svcache.<a class="code" href="classcsLightShaderVarCache.html#e0f9be818f1e7d1a2f54f53f9f633f44" title="Obtain the name for for a lighting-relevant shader variable whose name also depends...">GetLightSVId</a> (lightNum, <a name="l00124"></a>00124 <a class="code" href="classcsLightShaderVarCache.html#1469cb5d4a87149a2ea0ba70de230f146c43c0821928d5cd00bfb5161fee700a" title="Specular color.">csLightShaderVarCache::lightSpecular</a>); <a name="l00125"></a>00125 <span class="keywordflow">if</span> ((stacks-><a class="code" href="structiArrayReadOnly.html#a17db8fd7343b9837f8c4183f21bfba0" title="Return the number of elements in the array.">GetSize</a>() > id) && ((sv = stacks-><a class="code" href="structiArrayReadOnly.html#4a09769cbe113928a44a96a4583280be" title="Get an element (const).">Get</a> (<span class="keywordtype">id</span>)) != 0)) <a name="l00126"></a>00126 sv-><a class="code" href="classcsShaderVariable.html#aafa1bae521b26644794c9d65a84974a" title="Retrieve an int.">GetValue</a> (<a class="code" href="structcsLightProperties.html#c24e9622435a640e48e012d20b9ddc05" title="Specular color.">specular</a>); <a name="l00127"></a>00127 } <a name="l00128"></a>00128 }; <a name="l00129"></a>00129 <a name="l00133"></a><a class="code" href="structcsNoAttenuation.html">00133</a> <span class="keyword">struct </span><a class="code" href="structcsNoAttenuation.html" title="No attenuation.">csNoAttenuation</a> <a name="l00134"></a>00134 { <a name="l00135"></a><a class="code" href="structcsNoAttenuation.html#98437373d5c083c106f02b832e300855">00135</a> <a class="code" href="structcsNoAttenuation.html#98437373d5c083c106f02b832e300855">csNoAttenuation</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& <span class="comment">/*light*/</span>) <a name="l00136"></a>00136 {} <a name="l00137"></a>00137 <a name="l00138"></a>00138 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00139"></a><a class="code" href="structcsNoAttenuation.html#3a3d83e49babf0ac69442ce9172f4054">00139</a> <span class="keywordtype">void</span> <a class="code" href="structcsNoAttenuation.html#3a3d83e49babf0ac69442ce9172f4054">operator() </a>(<span class="keywordtype">float</span> <span class="comment">/*distance*/</span>, <span class="keywordtype">float</span> & <span class="comment">/*dp*/</span>)<span class="keyword"> const</span> <a name="l00140"></a>00140 <span class="keyword"> </span>{} <a name="l00141"></a>00141 }; <a name="l00142"></a>00142 <a name="l00147"></a><a class="code" href="structcsLinearAttenuation.html">00147</a> <span class="keyword">struct </span><a class="code" href="structcsLinearAttenuation.html" title="Linear attenuation.">csLinearAttenuation</a> <a name="l00148"></a>00148 { <a name="l00149"></a><a class="code" href="structcsLinearAttenuation.html#abbc32657791567bc918de80940b36f8">00149</a> <a class="code" href="structcsLinearAttenuation.html#abbc32657791567bc918de80940b36f8">csLinearAttenuation</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light) <a name="l00150"></a>00150 { <a name="l00151"></a>00151 <a class="code" href="structcsLinearAttenuation.html#83381d452a2ad120c2634e8f3b8581d8">invrad</a> = 1/light.<a class="code" href="structcsLightProperties.html#92b6b817b39986a435909f663e6cb0c4" title="Attenuation coefficients (for CLQ attenuation).">attenuationConsts</a>.<a class="code" href="classcsVector3.html#823fdba459ff91e8a5e6834ded7c815f" title="The X component of the vector.">x</a>; <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <a name="l00154"></a>00154 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00155"></a><a class="code" href="structcsLinearAttenuation.html#5f1bef94236f94931b9b7490db80db03">00155</a> <span class="keywordtype">void</span> <a class="code" href="structcsLinearAttenuation.html#5f1bef94236f94931b9b7490db80db03">operator() </a>(<span class="keywordtype">float</span> distance, <span class="keywordtype">float</span>& dp)<span class="keyword"> const</span> <a name="l00156"></a>00156 <span class="keyword"> </span>{ <a name="l00157"></a>00157 dp = <a class="code" href="group__geom__utils.html#g79291314e7548d3eb1df274158908235" title="Returns bigger of a and b.">csMax</a> (dp * (1 - distance * <a class="code" href="structcsLinearAttenuation.html#83381d452a2ad120c2634e8f3b8581d8">invrad</a>), 0.0f); <a name="l00158"></a>00158 } <a name="l00159"></a>00159 <a name="l00160"></a><a class="code" href="structcsLinearAttenuation.html#83381d452a2ad120c2634e8f3b8581d8">00160</a> <span class="keywordtype">float</span> <a class="code" href="structcsLinearAttenuation.html#83381d452a2ad120c2634e8f3b8581d8">invrad</a>; <a name="l00161"></a>00161 }; <a name="l00162"></a>00162 <a name="l00167"></a><a class="code" href="structcsInverseAttenuation.html">00167</a> <span class="keyword">struct </span><a class="code" href="structcsInverseAttenuation.html" title="Inverse linear attenuation.">csInverseAttenuation</a> <a name="l00168"></a>00168 { <a name="l00169"></a><a class="code" href="structcsInverseAttenuation.html#89d785e753d881ee23ad49c0afce07de">00169</a> <a class="code" href="structcsInverseAttenuation.html#89d785e753d881ee23ad49c0afce07de">csInverseAttenuation</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& <span class="comment">/*light*/</span>) <a name="l00170"></a>00170 {} <a name="l00171"></a>00171 <a name="l00172"></a>00172 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00173"></a><a class="code" href="structcsInverseAttenuation.html#bdd820d39a4c22b647efd0650a05840f">00173</a> <span class="keywordtype">void</span> <a class="code" href="structcsInverseAttenuation.html#bdd820d39a4c22b647efd0650a05840f">operator() </a>(<span class="keywordtype">float</span> distance, <span class="keywordtype">float</span>& dp)<span class="keyword"> const</span> <a name="l00174"></a>00174 <span class="keyword"> </span>{ <a name="l00175"></a>00175 dp = dp / distance; <a name="l00176"></a>00176 } <a name="l00177"></a>00177 }; <a name="l00178"></a>00178 <a name="l00179"></a>00179 <a name="l00184"></a><a class="code" href="structcsRealisticAttenuation.html">00184</a> <span class="keyword">struct </span><a class="code" href="structcsRealisticAttenuation.html" title="Inverse quadratic attenuation.">csRealisticAttenuation</a> <a name="l00185"></a>00185 { <a name="l00186"></a><a class="code" href="structcsRealisticAttenuation.html#b8d4033b4c003165e2c70a39602cc433">00186</a> <a class="code" href="structcsRealisticAttenuation.html#b8d4033b4c003165e2c70a39602cc433">csRealisticAttenuation</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& <span class="comment">/*light*/</span>) <a name="l00187"></a>00187 {} <a name="l00188"></a>00188 <a name="l00189"></a>00189 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00190"></a><a class="code" href="structcsRealisticAttenuation.html#c83d1c67874df11c5208eee27defc4f3">00190</a> <span class="keywordtype">void</span> <a class="code" href="structcsRealisticAttenuation.html#c83d1c67874df11c5208eee27defc4f3">operator() </a>(<span class="keywordtype">float</span> distance, <span class="keywordtype">float</span>& dp)<span class="keyword"> const</span> <a name="l00191"></a>00191 <span class="keyword"> </span>{ <a name="l00192"></a>00192 dp = dp / (distance*distance); <a name="l00193"></a>00193 } <a name="l00194"></a>00194 }; <a name="l00195"></a>00195 <a name="l00200"></a><a class="code" href="structcsCLQAttenuation.html">00200</a> <span class="keyword">struct </span><a class="code" href="structcsCLQAttenuation.html" title="Constant, Linear, Quadratic attenuation Out = in /(const + distance*lin + distance^2*quad)...">csCLQAttenuation</a> <a name="l00201"></a>00201 { <a name="l00202"></a><a class="code" href="structcsCLQAttenuation.html#58d825fb574688279d1b62517cd8884a">00202</a> <a class="code" href="structcsCLQAttenuation.html#58d825fb574688279d1b62517cd8884a">csCLQAttenuation</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light) <a name="l00203"></a>00203 : <a class="code" href="structcsCLQAttenuation.html#c753967c7ebddaed97208bd57e73226c">attnVec</a> (light.attenuationConsts) <a name="l00204"></a>00204 {} <a name="l00205"></a>00205 <a name="l00206"></a>00206 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00207"></a><a class="code" href="structcsCLQAttenuation.html#cdfdc36d97116ca9a97d190360df2fb7">00207</a> <span class="keywordtype">void</span> <a class="code" href="structcsCLQAttenuation.html#cdfdc36d97116ca9a97d190360df2fb7">operator() </a>(<span class="keywordtype">float</span> distance, <span class="keywordtype">float</span>& dp)<span class="keyword"> const</span> <a name="l00208"></a>00208 <span class="keyword"> </span>{ <a name="l00209"></a>00209 dp = dp/(<a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> (1.0, distance, distance*distance)*<a class="code" href="structcsCLQAttenuation.html#c753967c7ebddaed97208bd57e73226c">attnVec</a>); <a name="l00210"></a>00210 } <a name="l00211"></a>00211 <a name="l00212"></a><a class="code" href="structcsCLQAttenuation.html#c753967c7ebddaed97208bd57e73226c">00212</a> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> <a class="code" href="structcsCLQAttenuation.html#c753967c7ebddaed97208bd57e73226c">attnVec</a>; <a name="l00213"></a>00213 }; <a name="l00214"></a>00214 <a name="l00215"></a>00215 <a name="l00221"></a>00221 <span class="keyword">template</span><<span class="keyword">class</span> AttenuationProc> <a name="l00222"></a><a class="code" href="classcsPointLightProc.html">00222</a> <span class="keyword">class </span><a class="code" href="classcsPointLightProc.html" title="Preform pointlight lighting calculation without shadowing.">csPointLightProc</a> <a name="l00223"></a>00223 { <a name="l00224"></a>00224 <span class="keyword">public</span>: <a name="l00225"></a><a class="code" href="classcsPointLightProc.html#83710bb5e91c8552a4a5d80c1aee9c77">00225</a> <a class="code" href="classcsPointLightProc.html#83710bb5e91c8552a4a5d80c1aee9c77">csPointLightProc</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <span class="keywordtype">float</span> blackLimit = 0.0001f) <a name="l00226"></a>00226 : attn (light), blackLimit (blackLimit) <a name="l00227"></a>00227 { <a name="l00228"></a>00228 lightPos = light.<a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d" title="Light position (object space).">posObject</a>; <a name="l00229"></a>00229 } <a name="l00230"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html">00230</a> <span class="keyword">class </span><a class="code" href="classcsPointLightProc_1_1PerVertex.html">PerVertex</a> <a name="l00231"></a>00231 { <a name="l00232"></a>00232 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> direction; <a name="l00233"></a>00233 <span class="keywordtype">float</span> invDistance; <a name="l00234"></a>00234 <span class="keywordtype">float</span> a; <a name="l00235"></a>00235 <span class="keywordtype">float</span> dp; <a name="l00236"></a>00236 <span class="keywordtype">bool</span> vertexLit; <a name="l00237"></a>00237 <span class="keyword">public</span>: <a name="l00238"></a>00238 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00239"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#94e05c3a161746bd4efc65b619a91558">00239</a> <a class="code" href="classcsPointLightProc_1_1PerVertex.html#94e05c3a161746bd4efc65b619a91558">PerVertex</a> (<span class="keyword">const</span> <a class="code" href="classcsPointLightProc.html" title="Preform pointlight lighting calculation without shadowing.">csPointLightProc</a>& parent, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &v, <a name="l00240"></a>00240 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &n) <a name="l00241"></a>00241 { <a name="l00242"></a>00242 direction = parent.<a class="code" href="classcsPointLightProc.html#a39adccf7c3a14f10a5a9089cfc54777">lightPos</a>-v; <a name="l00243"></a>00243 <span class="keywordtype">float</span> distance = <a class="code" href="group__floating__point.html#g9859e75fb5b3a67f9082e45fe02d80cd" title="This routine computes sqrt(x) very quickly on Intel and PowerPC platforms.">csQsqrt</a> (direction.<a class="code" href="classcsVector3.html#4f8fb0ed2df4d38898bbcda746c47552" title="Return the squared norm (magnitude) of this vector.">SquaredNorm</a> ()); <a name="l00244"></a>00244 invDistance = 1.0f/distance; <a name="l00245"></a>00245 dp = (direction*n) * invDistance; <a name="l00246"></a>00246 <span class="keywordflow">if</span> ((vertexLit = (dp > parent.<a class="code" href="classcsPointLightProc.html#691058f780de49bee8763ace83ef27ce">blackLimit</a>))) <a name="l00247"></a>00247 { <a name="l00248"></a>00248 a = 1.0f; <a name="l00249"></a>00249 parent.<a class="code" href="classcsPointLightProc.html#f3242e506e2fdda5a2efdf8423a61a3f">attn</a> (distance, a); <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <span class="keywordflow">else</span> <a name="l00252"></a>00252 a = 0.0f; <a name="l00253"></a>00253 } <a name="l00254"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#0f7dfbc70883f6d11cc5cc0aacc70372">00254</a> <span class="keywordtype">bool</span> <a class="code" href="classcsPointLightProc_1_1PerVertex.html#0f7dfbc70883f6d11cc5cc0aacc70372">IsLit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> vertexLit; } <a name="l00255"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#9363cb1c5fed77fef7bcf6f1ce07020f">00255</a> <span class="keywordtype">float</span> <a class="code" href="classcsPointLightProc_1_1PerVertex.html#9363cb1c5fed77fef7bcf6f1ce07020f">Attenuation</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a; } <a name="l00256"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#61f57b9d694686f4e0aa49b04776b861">00256</a> <span class="keywordtype">float</span> <a class="code" href="classcsPointLightProc_1_1PerVertex.html#61f57b9d694686f4e0aa49b04776b861">DiffuseAttenuated</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a*dp; } <a name="l00257"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#ae06c84811209ee2bccf1347ebe3c2f6">00257</a> <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& <a class="code" href="classcsPointLightProc_1_1PerVertex.html#ae06c84811209ee2bccf1347ebe3c2f6">LightDirection</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> direction; } <a name="l00258"></a><a class="code" href="classcsPointLightProc_1_1PerVertex.html#81471b8b28c1334fbaa09032ccbd3216">00258</a> <span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code" href="classcsPointLightProc_1_1PerVertex.html#81471b8b28c1334fbaa09032ccbd3216">LightInvDistance</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> invDistance; } <a name="l00259"></a>00259 }; <a name="l00260"></a>00260 <span class="keyword">private</span>: <a name="l00261"></a>00261 AttenuationProc attn; <a name="l00262"></a>00262 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> lightPos; <span class="comment">//localspace</span> <a name="l00263"></a>00263 <span class="keywordtype">float</span> blackLimit; <a name="l00264"></a>00264 }; <a name="l00265"></a>00265 <a name="l00271"></a>00271 <span class="keyword">template</span><<span class="keyword">class</span> AttenuationProc> <a name="l00272"></a><a class="code" href="classcsDirectionalLightProc.html">00272</a> <span class="keyword">class </span><a class="code" href="classcsDirectionalLightProc.html" title="Preform directional light lighting calculation without shadowing.">csDirectionalLightProc</a> <a name="l00273"></a>00273 { <a name="l00274"></a>00274 <span class="keyword">public</span>: <a name="l00275"></a><a class="code" href="classcsDirectionalLightProc.html#2ed17375bbfde46f98e0c868bdf53e83">00275</a> <a class="code" href="classcsDirectionalLightProc.html#2ed17375bbfde46f98e0c868bdf53e83">csDirectionalLightProc</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00276"></a>00276 <span class="keywordtype">float</span> blackLimit = 0.0001f) : attn (light), <a name="l00277"></a>00277 blackLimit (blackLimit) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 lightPos = light.<a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d" title="Light position (object space).">posObject</a>; <a name="l00280"></a>00280 lightDir = light.<a class="code" href="structcsLightProperties.html#e768acfd67befdb3fe2c5d2b911033fa" title="Light direction (object space).">dirObject</a>; <a name="l00281"></a>00281 } <a name="l00282"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html">00282</a> <span class="keyword">class </span><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html">PerVertex</a> <a name="l00283"></a>00283 { <a name="l00284"></a>00284 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> direction; <a name="l00285"></a>00285 <span class="keywordtype">float</span> invDistance; <a name="l00286"></a>00286 <span class="keywordtype">float</span> a; <a name="l00287"></a>00287 <span class="keywordtype">float</span> dp; <a name="l00288"></a>00288 <span class="keywordtype">bool</span> vertexLit; <a name="l00289"></a>00289 <span class="keyword">public</span>: <a name="l00290"></a>00290 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00291"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#50d43234e06e3584194a7c2025bc0f93">00291</a> <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#50d43234e06e3584194a7c2025bc0f93">PerVertex</a> (<span class="keyword">const</span> <a class="code" href="classcsDirectionalLightProc.html" title="Preform directional light lighting calculation without shadowing.">csDirectionalLightProc</a>& parent, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &v, <a name="l00292"></a>00292 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &n) <a name="l00293"></a>00293 { <a name="l00294"></a>00294 <span class="comment">//compute gouraud shading..</span> <a name="l00295"></a>00295 dp = -parent.<a class="code" href="classcsDirectionalLightProc.html#62999635cd3afcf0d54756b63ce341a9">lightDir</a>*n; <a name="l00296"></a>00296 <span class="keywordflow">if</span> ((vertexLit = (dp > parent.<a class="code" href="classcsDirectionalLightProc.html#bfb1180991065be1eba4e215e3a46f63">blackLimit</a>))) <a name="l00297"></a>00297 { <a name="l00298"></a>00298 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> direction = parent.<a class="code" href="classcsDirectionalLightProc.html#f40bff1bcad6c0712ebc156e6ad6e700">lightPos</a>-v; <a name="l00299"></a>00299 a = 1.0f; <a name="l00300"></a>00300 <span class="keywordtype">float</span> distance = <a class="code" href="group__floating__point.html#g9859e75fb5b3a67f9082e45fe02d80cd" title="This routine computes sqrt(x) very quickly on Intel and PowerPC platforms.">csQsqrt</a>(direction.<a class="code" href="classcsVector3.html#4f8fb0ed2df4d38898bbcda746c47552" title="Return the squared norm (magnitude) of this vector.">SquaredNorm</a> ()); <a name="l00301"></a>00301 invDistance = 1.0f/distance; <a name="l00302"></a>00302 parent.<a class="code" href="classcsDirectionalLightProc.html#562fc4850edd5def42088dd5342aeb52">attn</a> (distance, a); <a name="l00303"></a>00303 } <a name="l00304"></a>00304 <span class="keywordflow">else</span> <a name="l00305"></a>00305 { <a name="l00306"></a>00306 invDistance = 0.0f; <a name="l00307"></a>00307 a = 0.0f; <a name="l00308"></a>00308 } <a name="l00309"></a>00309 } <a name="l00310"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#624135ba2c32728b750677eef6ce8c89">00310</a> <span class="keywordtype">bool</span> <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#624135ba2c32728b750677eef6ce8c89">IsLit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> vertexLit; } <a name="l00311"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#7458e1cd0a74b89b0721bb10b25e41cc">00311</a> <span class="keywordtype">float</span> <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#7458e1cd0a74b89b0721bb10b25e41cc">Attenuation</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a; } <a name="l00312"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#7f5465085fe9eab1b1bc2945fe1a19d6">00312</a> <span class="keywordtype">float</span> <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#7f5465085fe9eab1b1bc2945fe1a19d6">DiffuseAttenuated</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a*dp; } <a name="l00313"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#5ade8e3c9c7b75761cf3a4a93a335170">00313</a> <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#5ade8e3c9c7b75761cf3a4a93a335170">LightDirection</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> direction; } <a name="l00314"></a><a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#91d2c954e0412b3457382b9c5e4593ba">00314</a> <span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code" href="classcsDirectionalLightProc_1_1PerVertex.html#91d2c954e0412b3457382b9c5e4593ba">LightInvDistance</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> invDistance; } <a name="l00315"></a>00315 }; <a name="l00316"></a>00316 <span class="keyword">private</span>: <a name="l00317"></a>00317 AttenuationProc attn; <a name="l00318"></a>00318 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> lightPos; <span class="comment">//localspace</span> <a name="l00319"></a>00319 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> lightDir; <span class="comment">//localspace</span> <a name="l00320"></a>00320 <span class="keywordtype">float</span> blackLimit; <a name="l00321"></a>00321 }; <a name="l00322"></a>00322 <a name="l00328"></a>00328 <span class="keyword">template</span><<span class="keyword">class</span> AttenuationProc> <a name="l00329"></a><a class="code" href="classcsSpotLightProc.html">00329</a> <span class="keyword">class </span><a class="code" href="classcsSpotLightProc.html" title="Perform spotlight lighting calculation without shadowing.">csSpotLightProc</a> <a name="l00330"></a>00330 { <a name="l00331"></a>00331 <span class="keyword">public</span>: <a name="l00332"></a><a class="code" href="classcsSpotLightProc.html#43c69aa82823c8f755daca245e5eb882">00332</a> <a class="code" href="classcsSpotLightProc.html#43c69aa82823c8f755daca245e5eb882">csSpotLightProc</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00333"></a>00333 <span class="keywordtype">float</span> blackLimit = 0.0001f) : attn (light), <a name="l00334"></a>00334 blackLimit (blackLimit) <a name="l00335"></a>00335 { <a name="l00336"></a>00336 lightPos = light.<a class="code" href="structcsLightProperties.html#e43d67e69c7492634a4f82427decb97d" title="Light position (object space).">posObject</a>; <a name="l00337"></a>00337 lightDir = light.<a class="code" href="structcsLightProperties.html#e768acfd67befdb3fe2c5d2b911033fa" title="Light direction (object space).">dirObject</a>; <a name="l00338"></a>00338 <a name="l00339"></a>00339 falloffInner = light.<a class="code" href="structcsLightProperties.html#e845dd083248858d825a97ee7fccf70d" title="Spotlight inner falloff.">spotFalloffInner</a>; <a name="l00340"></a>00340 falloffOuter = light.<a class="code" href="structcsLightProperties.html#adce8ecf9f7134416f1a89a8f93e6e8b" title="Spotlight outer falloff.">spotFalloffOuter</a>; <a name="l00341"></a>00341 } <a name="l00342"></a>00342 <a name="l00343"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html">00343</a> <span class="keyword">class </span><a class="code" href="classcsSpotLightProc_1_1PerVertex.html">PerVertex</a> <a name="l00344"></a>00344 { <a name="l00345"></a>00345 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> direction; <a name="l00346"></a>00346 <span class="keywordtype">float</span> invDistance; <a name="l00347"></a>00347 <span class="keywordtype">float</span> a; <a name="l00348"></a>00348 <span class="keywordtype">float</span> cosfact; <a name="l00349"></a>00349 <span class="keywordtype">bool</span> vertexLit; <a name="l00350"></a>00350 <span class="keyword">public</span>: <a name="l00351"></a>00351 <a class="code" href="cssysdef_8h.html#28e20ab0f0f6398b95a4c0674b65751e">CS_FORCEINLINE_TEMPLATEMETHOD</a> <a name="l00352"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#ca16db5516339cc2011d135768bfd8a1">00352</a> <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#ca16db5516339cc2011d135768bfd8a1">PerVertex</a> (<span class="keyword">const</span> <a class="code" href="classcsSpotLightProc.html" title="Perform spotlight lighting calculation without shadowing.">csSpotLightProc</a>& parent, <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &v, <a name="l00353"></a>00353 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> &n) <a name="l00354"></a>00354 { <a name="l00355"></a>00355 <span class="comment">//compute gouraud shading..</span> <a name="l00356"></a>00356 direction = parent.<a class="code" href="classcsSpotLightProc.html#ba15c0245bf76320376ee780bd095ada">lightPos</a>-v; <a name="l00357"></a>00357 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> dirUnit (direction.<a class="code" href="classcsVector3.html#dfe6a123b665375450d78bf47eee2b77" title="Returns the unit vector in the direction of this vector.">Unit</a> ()); <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="comment">//compute gouraud shading..</span> <a name="l00360"></a>00360 <span class="keywordtype">float</span> dp = dirUnit*n; <a name="l00361"></a>00361 <span class="keywordflow">if</span> (dp > parent.<a class="code" href="classcsSpotLightProc.html#4f23bc574b2babb27d096a255658f2e9">blackLimit</a>) <a name="l00362"></a>00362 { <a name="l00363"></a>00363 cosfact = <a name="l00364"></a>00364 <a class="code" href="group__geom__utils.html#g5aa770bf13eb4b8ee00f34ae9ef64567" title="Performs a smooth interpolation of a on range min to max.">csSmoothStep</a> (-(dirUnit*parent.<a class="code" href="classcsSpotLightProc.html#8839a5074277ad96dc66a0e5149b9389">lightDir</a>), <a name="l00365"></a>00365 parent.<a class="code" href="classcsSpotLightProc.html#c69eb93f534a83c6d22242fcf02a5232">falloffInner</a>, parent.<a class="code" href="classcsSpotLightProc.html#045a60b9fce1d0f181c3331abc560db2">falloffOuter</a>); <a name="l00366"></a>00366 <span class="keywordflow">if</span> ((vertexLit = (cosfact > 0))) <a name="l00367"></a>00367 { <a name="l00368"></a>00368 cosfact *= dp; <a name="l00369"></a>00369 <span class="keywordtype">float</span> distance = <a class="code" href="group__floating__point.html#g9859e75fb5b3a67f9082e45fe02d80cd" title="This routine computes sqrt(x) very quickly on Intel and PowerPC platforms.">csQsqrt</a>(direction.<a class="code" href="classcsVector3.html#4f8fb0ed2df4d38898bbcda746c47552" title="Return the squared norm (magnitude) of this vector.">SquaredNorm</a> ()); <a name="l00370"></a>00370 invDistance = 1.0f/distance; <a name="l00371"></a>00371 a = 1.0f; <a name="l00372"></a>00372 parent.<a class="code" href="classcsSpotLightProc.html#9c8c738d2b1f4c62378c3326a38fbda3">attn</a> (distance, a); <a name="l00373"></a>00373 } <a name="l00374"></a>00374 <span class="keywordflow">else</span> <a name="l00375"></a>00375 { <a name="l00376"></a>00376 invDistance = 0.0f; <a name="l00377"></a>00377 a = 0.0f; <a name="l00378"></a>00378 } <a name="l00379"></a>00379 } <a name="l00380"></a>00380 <span class="keywordflow">else</span> <a name="l00381"></a>00381 { <a name="l00382"></a>00382 invDistance = 0.0f; <a name="l00383"></a>00383 a = 0.0f; <a name="l00384"></a>00384 cosfact = 0.0f; <a name="l00385"></a>00385 vertexLit = <span class="keyword">false</span>; <a name="l00386"></a>00386 } <a name="l00387"></a>00387 } <a name="l00388"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#0ed63e168469654c6228eaeb0fb00ccd">00388</a> <span class="keywordtype">bool</span> <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#0ed63e168469654c6228eaeb0fb00ccd">IsLit</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> vertexLit; } <a name="l00389"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#4aa7f2249f5a39e19a8167f242fecfb6">00389</a> <span class="keywordtype">float</span> <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#4aa7f2249f5a39e19a8167f242fecfb6">Attenuation</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a; } <a name="l00390"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#f99c15c86a82ecf064e68aa96dc63249">00390</a> <span class="keywordtype">float</span> <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#f99c15c86a82ecf064e68aa96dc63249">DiffuseAttenuated</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a*cosfact; } <a name="l00391"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#5a6517174c28f38d1ec30da63f22bea5">00391</a> <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#5a6517174c28f38d1ec30da63f22bea5">LightDirection</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> direction; } <a name="l00392"></a><a class="code" href="classcsSpotLightProc_1_1PerVertex.html#9c5e7885fc71a259822f5c523d39275b">00392</a> <span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code" href="classcsSpotLightProc_1_1PerVertex.html#9c5e7885fc71a259822f5c523d39275b">LightInvDistance</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> invDistance; } <a name="l00393"></a>00393 }; <a name="l00394"></a>00394 <span class="keyword">private</span>: <a name="l00395"></a>00395 AttenuationProc attn; <a name="l00396"></a>00396 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> lightPos; <span class="comment">//localspace</span> <a name="l00397"></a>00397 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> lightDir; <span class="comment">//localspace</span> <a name="l00398"></a>00398 <span class="keywordtype">float</span> blackLimit; <a name="l00399"></a>00399 <span class="keywordtype">float</span> falloffInner, falloffOuter; <a name="l00400"></a>00400 }; <a name="l00401"></a>00401 <a name="l00405"></a><a class="code" href="structiVertexLightCalculator.html">00405</a> <span class="keyword">struct </span><a class="code" href="structiVertexLightCalculator.html" title="Interface to calculate lighting for a number of vertices.">iVertexLightCalculator</a> <a name="l00406"></a>00406 { <a name="l00407"></a>00407 <span class="keyword">public</span>: <a name="l00408"></a><a class="code" href="structiVertexLightCalculator.html#eb75f4f79d3cfa0f02d6f214a4cd7ad4">00408</a> <span class="keyword">virtual</span> <a class="code" href="structiVertexLightCalculator.html#eb75f4f79d3cfa0f02d6f214a4cd7ad4">~iVertexLightCalculator</a>() {} <a name="l00409"></a>00409 <a name="l00421"></a>00421 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structiVertexLightCalculator.html#d83d81813c8eaa97643c03317e53b5e3" title="Compute lighting, overwrite the destination colors.">CalculateLighting</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00422"></a>00422 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00423"></a>00423 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00424"></a>00424 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0) <span class="keyword">const</span> = 0; <a name="l00425"></a>00425 <a name="l00430"></a>00430 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structiVertexLightCalculator.html#100ed4b7f74265ce7b5f86461b135568" title="Compute lighting, add lit colors to the destination colors.">CalculateLightingAdd</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00431"></a>00431 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00432"></a>00432 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00433"></a>00433 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0) <span class="keyword">const</span> = 0; <a name="l00434"></a>00434 <a name="l00439"></a>00439 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structiVertexLightCalculator.html#4ba960a22f9b704ff499f5f70d73e8da" title="Compute lighting, multiply lit colors with destination colors.">CalculateLightingMul</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00440"></a>00440 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00441"></a>00441 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00442"></a>00442 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0) <span class="keyword">const</span> = 0; <a name="l00443"></a>00443 }; <a name="l00444"></a>00444 <a name="l00450"></a>00450 <span class="keyword">template</span><<span class="keyword">class</span> LightProc> <a name="l00451"></a><a class="code" href="classcsVertexLightCalculator.html">00451</a> <span class="keyword">class </span><a class="code" href="classcsVertexLightCalculator.html" title="iVertexLightCalculator implementation that takes one of csPointLightProc, csDirectionalLightProc...">csVertexLightCalculator</a> : <span class="keyword">public</span> <a class="code" href="structiVertexLightCalculator.html" title="Interface to calculate lighting for a number of vertices.">iVertexLightCalculator</a> <a name="l00452"></a>00452 { <a name="l00453"></a>00453 <span class="keyword">struct </span>OpAssign <a name="l00454"></a>00454 { <a name="l00455"></a>00455 OpAssign (<a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& d, <span class="keyword">const</span> <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& x) { d = x; } <a name="l00456"></a>00456 }; <a name="l00457"></a>00457 <span class="keyword">struct </span>OpAdd <a name="l00458"></a>00458 { <a name="l00459"></a>00459 OpAdd (<a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& d, <span class="keyword">const</span> <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& x) { d += x; } <a name="l00460"></a>00460 }; <a name="l00461"></a>00461 <span class="keyword">struct </span>OpMul <a name="l00462"></a>00462 { <a name="l00463"></a>00463 OpMul (<a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& d, <span class="keyword">const</span> <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a>& x) { d *= x; } <a name="l00464"></a>00464 }; <a name="l00465"></a>00465 <span class="keyword">template</span><<span class="keyword">typename</span> Op, <span class="keywordtype">int</span> zeroDest, <span class="keywordtype">int</span> diffuse, <span class="keywordtype">int</span> specular> <a name="l00466"></a>00466 <span class="keywordtype">void</span> CalculateLightingODS (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00467"></a>00467 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00468"></a>00468 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00469"></a>00469 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor)<span class="keyword"> const</span> <a name="l00470"></a>00470 <span class="keyword"> </span>{ <a name="l00471"></a>00471 <span class="keywordflow">if</span> (!diffuse && !specular) <span class="keywordflow">return</span>; <a name="l00472"></a>00472 <a name="l00473"></a>00473 <span class="comment">// setup the light calculator</span> <a name="l00474"></a>00474 LightProc lighter (light); <a name="l00475"></a>00475 <a class="code" href="classcsVertexListWalker.html" title="Helper class to make it easier to iterate over elements from renderbuffers, with...">csVertexListWalker<float, csVector3></a> vbLock (vb, 3); <a name="l00476"></a>00476 <a class="code" href="classcsVertexListWalker.html" title="Helper class to make it easier to iterate over elements from renderbuffers, with...">csVertexListWalker<float, csVector3></a> nbLock (nb, 3); <a name="l00477"></a>00477 <a class="code" href="classcsRenderBufferLock.html" title="Helper class for convenient locking/unlocking of an iRenderBuffer.">csRenderBufferLock<csColor, iRenderBuffer*></a> color (litColor); <a name="l00478"></a>00478 <a class="code" href="classcsRenderBufferLock.html" title="Helper class for convenient locking/unlocking of an iRenderBuffer.">csRenderBufferLock<csColor, iRenderBuffer*></a> spec (specColor); <a name="l00479"></a>00479 <a name="l00480"></a>00480 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < numvert; i++) <a name="l00481"></a>00481 { <a name="l00482"></a>00482 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> v (*vbLock); <a name="l00483"></a>00483 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> n (*nbLock); <a name="l00484"></a>00484 <span class="keyword">typename</span> LightProc::PerVertex pv (lighter, v, n); <a name="l00485"></a>00485 <span class="keywordflow">if</span> (pv.IsLit()) <a name="l00486"></a>00486 { <a name="l00487"></a>00487 <span class="keywordflow">if</span> (diffuse) <a name="l00488"></a>00488 { <a name="l00489"></a>00489 Op op (color[i], pv.DiffuseAttenuated() * light.<a class="code" href="structcsLightProperties.html#b2130f8509d6ea50c2b9eb64f7d340c8" title="Light diffuse color.">color</a>); <a name="l00490"></a>00490 } <a name="l00491"></a>00491 <span class="keywordflow">if</span> (specular) <a name="l00492"></a>00492 { <a name="l00493"></a>00493 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> vertToEye = eyePos - v; <a name="l00494"></a>00494 <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a> halfvec = pv.LightDirection() * pv.LightInvDistance(); <a name="l00495"></a>00495 halfvec += vertToEye.<a class="code" href="classcsVector3.html#dfe6a123b665375450d78bf47eee2b77" title="Returns the unit vector in the direction of this vector.">Unit</a>(); <a name="l00496"></a>00496 <span class="keywordtype">float</span> specDP = halfvec.<a class="code" href="classcsVector3.html#dfe6a123b665375450d78bf47eee2b77" title="Returns the unit vector in the direction of this vector.">Unit</a>() * n; <a name="l00497"></a>00497 Op op (spec[i], pow (specDP, shininess) * light.<a class="code" href="structcsLightProperties.html#c24e9622435a640e48e012d20b9ddc05" title="Specular color.">specular</a> * pv.Attenuation()); <a name="l00498"></a>00498 } <a name="l00499"></a>00499 } <a name="l00500"></a>00500 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (zeroDest) <a name="l00501"></a>00501 { <a name="l00502"></a>00502 <a class="code" href="classcsColor.html" title="A class used to represent a color in RGB space.">csColor</a> nullColor (0.0f, 0.0f, 0.0f); <a name="l00503"></a>00503 <span class="keywordflow">if</span> (diffuse) <a name="l00504"></a>00504 { <a name="l00505"></a>00505 Op op (color[i], nullColor); <a name="l00506"></a>00506 } <a name="l00507"></a>00507 <span class="keywordflow">if</span> (specular) <a name="l00508"></a>00508 { <a name="l00509"></a>00509 Op op (spec[i], nullColor); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 } <a name="l00512"></a>00512 ++vbLock; ++nbLock; <a name="l00513"></a>00513 } <a name="l00514"></a>00514 } <a name="l00515"></a>00515 <span class="keyword">template</span><<span class="keyword">typename</span> Op, <span class="keywordtype">int</span> zeroDest, <span class="keywordtype">int</span> diffuse> <a name="l00516"></a>00516 <span class="keywordtype">void</span> CalculateLightingOD (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00517"></a>00517 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00518"></a>00518 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00519"></a>00519 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor)<span class="keyword"> const</span> <a name="l00520"></a>00520 <span class="keyword"> </span>{ <a name="l00521"></a>00521 <span class="keywordflow">if</span> (specColor != 0) <a name="l00522"></a>00522 CalculateLightingODS<Op, zeroDest, diffuse, 1> (light, eyePos, shininess, <a name="l00523"></a>00523 numvert, vb, nb, litColor, specColor); <a name="l00524"></a>00524 <span class="keywordflow">else</span> <a name="l00525"></a>00525 CalculateLightingODS<Op, zeroDest, diffuse, 0> (light, eyePos, shininess, <a name="l00526"></a>00526 numvert, vb, nb, litColor, specColor); <a name="l00527"></a>00527 } <a name="l00528"></a>00528 <span class="keyword">template</span><<span class="keyword">typename</span> Op, <span class="keywordtype">int</span> zeroDest> <a name="l00529"></a>00529 <span class="keywordtype">void</span> CalculateLightingO (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00530"></a>00530 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00531"></a>00531 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00532"></a>00532 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor)<span class="keyword"> const</span> <a name="l00533"></a>00533 <span class="keyword"> </span>{ <a name="l00534"></a>00534 <span class="keywordflow">if</span> (litColor != 0) <a name="l00535"></a>00535 CalculateLightingOD<Op, zeroDest, 1> (light, eyePos, shininess, numvert, <a name="l00536"></a>00536 vb, nb, litColor, specColor); <a name="l00537"></a>00537 <span class="keywordflow">else</span> <a name="l00538"></a>00538 CalculateLightingOD<Op, zeroDest, 0> (light, eyePos, shininess, numvert, <a name="l00539"></a>00539 vb, nb, litColor, specColor); <a name="l00540"></a>00540 } <a name="l00541"></a>00541 <span class="keyword">public</span>: <a name="l00542"></a><a class="code" href="classcsVertexLightCalculator.html#aedab2fd86bf8b775fd6094a548dd0e2">00542</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcsVertexLightCalculator.html#aedab2fd86bf8b775fd6094a548dd0e2" title="Compute lighting, overwrite the destination colors.">CalculateLighting</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00543"></a>00543 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00544"></a>00544 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00545"></a>00545 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0)<span class="keyword"> const</span> <a name="l00546"></a>00546 <span class="keyword"> </span>{ <a name="l00547"></a>00547 CalculateLightingO<OpAssign, 1> (light, eyePos, shininess, <a name="l00548"></a>00548 numvert, vb, nb, litColor, specColor); <a name="l00549"></a>00549 } <a name="l00550"></a>00550 <a name="l00551"></a><a class="code" href="classcsVertexLightCalculator.html#e65b7a5ea83645796d132d45165cc3fa">00551</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcsVertexLightCalculator.html#e65b7a5ea83645796d132d45165cc3fa" title="Compute lighting, add lit colors to the destination colors.">CalculateLightingAdd</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00552"></a>00552 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00553"></a>00553 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00554"></a>00554 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0)<span class="keyword"> const</span> <a name="l00555"></a>00555 <span class="keyword"> </span>{ <a name="l00556"></a>00556 CalculateLightingO<OpAdd, 0> (light, eyePos, shininess, numvert, vb, nb, <a name="l00557"></a>00557 litColor, specColor); <a name="l00558"></a>00558 } <a name="l00559"></a>00559 <a name="l00560"></a><a class="code" href="classcsVertexLightCalculator.html#a640569c5ed0ba68853b32a95d7a3136">00560</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcsVertexLightCalculator.html#a640569c5ed0ba68853b32a95d7a3136" title="Compute lighting, multiply lit colors with destination colors.">CalculateLightingMul</a> (<span class="keyword">const</span> <a class="code" href="structcsLightProperties.html" title="Light properties, as needed by the attenuation and lighting functors.">csLightProperties</a>& light, <a name="l00561"></a>00561 <span class="keyword">const</span> <a class="code" href="classcsVector3.html" title="A 3D vector.">csVector3</a>& eyePos, <span class="keywordtype">float</span> shininess, <a name="l00562"></a>00562 <span class="keywordtype">size_t</span> numvert, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* vb, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* nb, <a name="l00563"></a>00563 <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* litColor, <a class="code" href="structiRenderBuffer.html" title="This is a general buffer.">iRenderBuffer</a>* specColor = 0)<span class="keyword"> const</span> <a name="l00564"></a>00564 <span class="keyword"> </span>{ <a name="l00565"></a>00565 CalculateLightingO<OpMul, 0> (light, eyePos, shininess, numvert, vb, nb, <a name="l00566"></a>00566 litColor, specColor); <a name="l00567"></a>00567 } <a name="l00568"></a>00568 }; <a name="l00569"></a>00569 <a name="l00570"></a>00570 <span class="preprocessor">#endif //__CS_VERTEXLIGHT_H__</span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>