diff options
Diffstat (limited to 'docs/doxygen/nel/flare__model_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/flare__model_8cpp-source.html | 378 |
1 files changed, 378 insertions, 0 deletions
diff --git a/docs/doxygen/nel/flare__model_8cpp-source.html b/docs/doxygen/nel/flare__model_8cpp-source.html new file mode 100644 index 00000000..0d131c73 --- /dev/null +++ b/docs/doxygen/nel/flare__model_8cpp-source.html @@ -0,0 +1,378 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>flare_model.cpp</h1><a href="flare__model_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000, 2001 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="flare__model_8h.html">3d/flare_model.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="flare__shape_8h.html">3d/flare_shape.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="dru_8h.html">3d/dru.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="render__trav_8h.html">3d/render_trav.h</a>"</font> +00035 +00036 +00037 +00038 <font class="keyword">namespace </font>NL3D { +00039 +00040 +00041 <font class="comment">/*</font> +00042 <font class="comment"> * Constructor</font> +00043 <font class="comment"> */</font> +<a name="l00044"></a><a class="code" href="classNL3D_1_1CFlareModel.html#a0">00044</a> CFlareModel::CFlareModel() : _Intensity(0) +00045 { +00046 <a class="code" href="classNL3D_1_1CTransform.html#a0">setTransparency</a>(<font class="keyword">true</font>); +00047 <a class="code" href="classNL3D_1_1CTransform.html#a1">setOpacity</a>(<font class="keyword">false</font>); +00048 } +00049 +<a name="l00050"></a><a class="code" href="classNL3D_1_1CFlareModel.html#d0">00050</a> <font class="keywordtype">void</font> CFlareModel::registerBasic() +00051 { +00052 <font class="comment">// register the model and his observers</font> +00053 CMOT::registerModel(<a class="code" href="namespaceNL3D.html#a38">FlareModelClassId</a>, <a class="code" href="namespaceNL3D.html#a277">TransformShapeId</a>, CFlareModel::creator); +00054 CMOT::registerObs(<a class="code" href="namespaceNL3D.html#a232">RenderTravId</a>, <a class="code" href="namespaceNL3D.html#a38">FlareModelClassId</a>, CFlareRenderObs::creator); +00055 } +00056 +00057 +00058 +00059 +<a name="l00060"></a><a class="code" href="classNL3D_1_1CFlareRenderObs.html#a0">00060</a> <font class="keywordtype">void</font> CFlareRenderObs::traverse(IObs *caller) +00061 { +00062 CRenderTrav *trav = NLMISC::safe_cast<CRenderTrav *>(Trav); +00063 CFlareModel *m = NLMISC::safe_cast<CFlareModel *>(Model); +00064 IDriver *drv = trav->getDriver(); +00065 <font class="keywordflow">if</font> (trav->isCurrentPassOpaque()) <font class="keywordflow">return</font>; +00066 +00067 +00068 +00069 <font class="comment">// transform the flare on screen </font> +00070 <font class="keyword">const</font> CVector upt = <a class="code" href="classNL3D_1_1IBaseRenderObs.html#m0">HrcObs</a>->WorldMatrix.getPos(); <font class="comment">// unstransformed pos </font> +00071 <font class="keyword">const</font> CVector pt = trav->ViewMatrix * upt; +00072 +00073 +00074 +00075 <font class="keywordflow">if</font> (pt.y <= trav->Near) +00076 { +00077 <font class="keywordflow">return</font>; <font class="comment">// flare behind us</font> +00078 } +00079 +00080 <a class="code" href="debug_8h.html#a6">nlassert</a>(m->Shape); +00081 CFlareShape *fs = NLMISC::safe_cast<CFlareShape *>((IShape *) m->Shape); +00082 +00083 +00084 <font class="keywordflow">if</font> (pt.y > fs->getMaxViewDist()) +00085 { +00086 <font class="keywordflow">return</font>; <font class="comment">// flare too far away</font> +00087 } +00088 +00089 <font class="keywordtype">float</font> distIntensity; +00090 +00091 <font class="keywordflow">if</font> (fs->getFlareAtInfiniteDist()) +00092 { +00093 distIntensity = 1.f; +00094 } +00095 <font class="keywordflow">else</font> +00096 { +00097 <font class="comment">// compute a color ratio for attenuation with distance</font> +00098 <font class="keyword">const</font> <font class="keywordtype">float</font> distRatio = pt.y / fs->getMaxViewDist(); +00099 distIntensity = distRatio > fs->getMaxViewDistRatio() ? 1.f - (distRatio - fs->getMaxViewDistRatio()) / (1.f - fs->getMaxViewDistRatio()) : 1.f; +00100 } +00101 +00102 <font class="comment">// compute position on screen</font> +00103 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>; +00104 drv->getWindowSize(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>); +00105 <font class="keyword">const</font> <font class="keywordtype">float</font> middleX = .5f * (trav->Left + trav->Right); +00106 <font class="keyword">const</font> <font class="keywordtype">float</font> middleZ = .5f * (trav->Bottom + trav->Top); +00107 <font class="keyword">const</font> sint xPos = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>>1) + (sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> * (((trav->Near * pt.x) / pt.y) - middleX) / (trav->Right - trav->Left)); +00108 <font class="keyword">const</font> sint yPos = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>>>1) - (sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> * (((trav->Near * pt.z) / pt.y) - middleZ) / (trav->Top - trav->Bottom)); +00109 +00110 <font class="comment">// read z-buffer value at the pos we are</font> +00111 <font class="keyword">static</font> std::vector<float> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>(1); +00112 <a class="code" href="classNLMISC_1_1CRect.html">NLMISC::CRect</a> rect(xPos, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - yPos, 1, 1); +00113 drv->getZBufferPart(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, rect); +00114 +00115 <font class="comment">// project in screen space</font> +00116 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a> = (float) (1.0 - (1.0 / pt.y - 1.0 / trav->Far) / (1.0 /trav->Near - 1.0 / trav->Far)); +00117 +00118 +00119 <font class="keywordflow">if</font> (!<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.size() || <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a> > <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>[0]) <font class="comment">// test against z-buffer</font> +00120 { +00121 <font class="keywordtype">float</font> p = fs->getPersistence(); +00122 <font class="keywordflow">if</font> (fs == 0) +00123 { +00124 m->_Intensity = 0; +00125 <font class="keywordflow">return</font>; +00126 } +00127 <font class="keywordflow">else</font> +00128 { +00129 m->_Intensity -= 1.f / p * (float)m->_Scene->getEllapsedTime(); +00130 <font class="keywordflow">if</font> (m->_Intensity < 0.f) +00131 { +00132 m->_Intensity = 0.f; +00133 <font class="keywordflow">return</font>; <font class="comment">// nothing to draw</font> +00134 } +00135 } +00136 } +00137 <font class="keywordflow">else</font> +00138 { +00139 <font class="keywordtype">float</font> p = fs->getPersistence(); +00140 <font class="keywordflow">if</font> (fs == 0) +00141 { +00142 m->_Intensity = 1; +00143 } +00144 <font class="keywordflow">else</font> +00145 { +00146 m->_Intensity += 1.f / p * (float)m->_Scene->getEllapsedTime(); +00147 <font class="keywordflow">if</font> (m->_Intensity > 1.f) m->_Intensity = 1.f; +00148 } +00149 } +00150 +00151 <font class="keyword">static</font> CMaterial material; +00152 <font class="keyword">static</font> CVertexBuffer vb; +00153 +00154 <font class="keyword">static</font> <font class="keywordtype">bool</font> setupDone = <font class="keyword">false</font>; +00155 +00156 +00157 <font class="keywordflow">if</font> (!setupDone) +00158 { +00159 material.setBlend(<font class="keyword">true</font>); +00160 material.setBlendFunc(CMaterial::one, CMaterial::one); +00161 material.setZWrite(<font class="keyword">false</font>); +00162 material.setZFunc(CMaterial::always); +00163 material.setLighting(<font class="keyword">false</font>); +00164 material.setDoubleSided(<font class="keyword">true</font>); +00165 +00166 <font class="comment">// setup vertex buffer</font> +00167 vb.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag); +00168 vb.setNumVertices(4); +00169 vb.setTexCoord(0, 0, <a class="code" href="classNLMISC_1_1CUV.html">NLMISC::CUV</a>(1, 0)); +00170 vb.setTexCoord(1, 0, <a class="code" href="classNLMISC_1_1CUV.html">NLMISC::CUV</a>(1, 1)); +00171 vb.setTexCoord(2, 0, <a class="code" href="classNLMISC_1_1CUV.html">NLMISC::CUV</a>(0, 1)); +00172 vb.setTexCoord(3, 0, <a class="code" href="classNLMISC_1_1CUV.html">NLMISC::CUV</a>(0, 0)); +00173 +00174 setupDone = <font class="keyword">true</font>; +00175 } +00176 +00177 +00178 +00179 +00180 <font class="comment">// setup driver </font> +00181 drv->activeVertexProgram(NULL); +00182 drv->setupModelMatrix(CMatrix::Identity); +00183 drv->activeVertexBuffer(vb); +00184 +00185 +00186 <font class="comment">// we don't change the fustrum to draw 2d shapes : it is costly, and we need to restore it after the drawing has been done</font> +00187 <font class="comment">// we setup Z to be (near + far) / 2, and setup x and y to get the screen coordinates we want</font> +00188 <font class="keyword">const</font> <font class="keywordtype">float</font> zPos = 0.5f * (trav->Near + trav->Far); +00189 <font class="keyword">const</font> <font class="keywordtype">float</font> zPosDivNear = zPos / trav->Near; +00190 +00191 <font class="comment">// compute the coeeff so that x = ax * px + bx; y = ax * py + by</font> +00192 <font class="keyword">const</font> <font class="keywordtype">float</font> aX = ( (trav->Right - trav->Left) / (float) <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>) * zPosDivNear; +00193 <font class="keyword">const</font> <font class="keywordtype">float</font> bX = zPosDivNear * (middleX - 0.5f * (trav->Right - trav->Left)); +00194 <font class="comment">//</font> +00195 <font class="keyword">const</font> <font class="keywordtype">float</font> aY = - ( (trav->Top - trav->Bottom) / (float) <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>) * zPosDivNear; +00196 <font class="keyword">const</font> <font class="keywordtype">float</font> bY = zPosDivNear * (middleZ + 0.5f * (trav->Top - trav->Bottom)); +00197 +00198 <font class="keyword">const</font> CVector I = trav->CamMatrix.getI(); +00199 <font class="keyword">const</font> CVector J = trav->CamMatrix.getJ(); +00200 <font class="keyword">const</font> CVector K = trav->CamMatrix.getK(); +00201 <font class="comment">//</font> +00202 CRGBA col; +00203 CRGBA flareColor = fs->getColor(); +00204 <font class="keyword">const</font> <font class="keywordtype">float</font> norm = sqrtf((<font class="keywordtype">float</font>) (((xPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>>1)) * (xPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>>1)) + (yPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>>>1))*(yPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>>>1))))) +00205 / (float) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>>1); +00206 +00207 <font class="comment">// check for dazzle and draw it</font> +00208 <font class="keywordflow">if</font> (fs->hasDazzle()) +00209 { +00210 <font class="keywordflow">if</font> (norm < fs->getDazzleAttenuationRange()) +00211 { +00212 <font class="keywordtype">float</font> dazzleIntensity = 1.f - norm / fs->getDazzleAttenuationRange(); +00213 CRGBA dazzleColor = fs->getDazzleColor(); +00214 col.modulateFromui(dazzleColor, (uint) (255.f * m->_Intensity * dazzleIntensity)); +00215 material.setColor(col); +00216 material.setTexture(0, NULL); +00217 +00218 <font class="keyword">const</font> CVector dazzleCenter = trav->CamPos + zPos * J; +00219 <font class="keyword">const</font> CVector dI = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>>1) * aX * I; +00220 <font class="keyword">const</font> CVector dK = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>>>1) * bX * K; +00221 +00222 vb.setVertexCoord(0, dazzleCenter + dI + dK); +00223 vb.setVertexCoord(1, dazzleCenter + dI - dK); +00224 vb.setVertexCoord(2, dazzleCenter - dI - dK); +00225 vb.setVertexCoord(3, dazzleCenter - dI + dK); +00226 +00227 drv->renderQuads(material, 0, 1); +00228 } +00229 } +00230 <font class="keywordflow">if</font> (!fs->getAttenuable() ) +00231 { +00232 col.modulateFromui(flareColor, (uint) (255.f * distIntensity * m->_Intensity)); +00233 } +00234 <font class="keywordflow">else</font> +00235 { +00236 <font class="keywordflow">if</font> (norm > fs->getAttenuationRange() || fs->getAttenuationRange() == 0.f) +00237 { +00238 <font class="keywordflow">return</font>; <font class="comment">// nothing to draw; </font> +00239 } +00240 col.modulateFromui(flareColor, (uint) (255.f * distIntensity * m->_Intensity * (1.f - norm / fs->getAttenuationRange() ))); +00241 } +00242 +00243 +00244 material.setColor(col); +00245 +00246 CVector scrPos; <font class="comment">// vector that will map to the center of the flare on scree</font> +00247 +00248 <font class="comment">// process each flare</font> +00249 <font class="comment">// delta for each new Pos </font> +00250 <font class="keyword">const</font> <font class="keywordtype">float</font> dX = fs->getFlareSpacing() * ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> >> 1) - xPos); +00251 <font class="keyword">const</font> <font class="keywordtype">float</font> dY = fs->getFlareSpacing() * ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> >> 1) - yPos); +00252 +00253 <font class="keywordtype">float</font> size; <font class="comment">// size of the current flare</font> +00254 +00255 uint k = 0; +00256 ITexture *tex; +00257 +00258 <font class="keywordflow">if</font> (fs->getFirstFlareKeepSize()) +00259 { +00260 tex = fs->getTexture(0); +00261 <font class="keywordflow">if</font> (tex) +00262 { +00263 size = fs->getSize(0); +00264 +00265 vb.setVertexCoord(0, upt + size * (I + K) ); +00266 vb.setVertexCoord(1, upt + size * (I - K) ); +00267 vb.setVertexCoord(2, upt + size * (-I - K) ); +00268 vb.setVertexCoord(3, upt + size * (-I + K) ); +00269 +00270 +00271 material.setTexture(0, tex); +00272 drv->renderQuads(material, 0, 1); +00273 k = 1; +00274 } +00275 } +00276 <font class="keywordflow">else</font> +00277 { +00278 k = 0; +00279 } +00280 +00281 <font class="keywordflow">for</font> (; k < <a class="code" href="namespaceNL3D.html#a39">MaxFlareNum</a>; ++k) +00282 { +00283 tex = fs->getTexture(k); +00284 <font class="keywordflow">if</font> (tex) +00285 { +00286 <font class="comment">// compute vector that map to the center of the flare</font> +00287 +00288 scrPos = (aX * (xPos + dX * fs->getRelativePos(k)) + bX) * I +00289 + zPos * J + (aY * (yPos + dY * fs->getRelativePos(k)) + bY) * K + trav->CamMatrix.getPos(); +00290 +00291 +00292 +00293 +00294 size = fs->getSize(k) / trav->Near; +00295 vb.setVertexCoord(0, scrPos + size * (I + K) ); +00296 vb.setVertexCoord(1, scrPos + size * (I - K) ); +00297 vb.setVertexCoord(2, scrPos + size * (-I - K) ); +00298 vb.setVertexCoord(3, scrPos + size * (-I + K) ); +00299 material.setTexture(0, tex); +00300 drv->renderQuads(material, 0, 1); +00301 } +00302 +00303 } +00304 this-><a class="code" href="classNL3D_1_1IObs.html#z620_0">traverseSons</a>(); +00305 } +00306 +00307 +00308 +00309 } <font class="comment">// NL3D</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |