aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/flare__model_8cpp-source.html
blob: 8cac6370644bc0342e1172c12293d2608a31007c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- 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="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </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&lt;CRenderTrav *&gt;(Trav);
00063         CFlareModel                     *m    = NLMISC::safe_cast&lt;CFlareModel *&gt;(Model);
00064         IDriver                         *drv  = trav-&gt;getDriver();
00065         <font class="keywordflow">if</font> (trav-&gt;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>-&gt;WorldMatrix.getPos(); <font class="comment">// unstransformed pos       </font>
00071         <font class="keyword">const</font> CVector   pt = trav-&gt;ViewMatrix * upt;
00072 
00073 
00074 
00075         <font class="keywordflow">if</font> (pt.y &lt;= trav-&gt;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-&gt;Shape);
00081         CFlareShape *fs = NLMISC::safe_cast&lt;CFlareShape *&gt;((IShape *) m-&gt;Shape);
00082         
00083 
00084     <font class="keywordflow">if</font> (pt.y &gt; fs-&gt;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-&gt;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-&gt;getMaxViewDist();
00099                 distIntensity = distRatio &gt; fs-&gt;getMaxViewDistRatio() ? 1.f - (distRatio - fs-&gt;getMaxViewDistRatio()) / (1.f - fs-&gt;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-&gt;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-&gt;Left + trav-&gt;Right);
00106         <font class="keyword">const</font> <font class="keywordtype">float</font> middleZ = .5f * (trav-&gt;Bottom + trav-&gt;Top);
00107         <font class="keyword">const</font> sint xPos = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;&gt;1) + (sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> * (((trav-&gt;Near * pt.x) / pt.y) - middleX) / (trav-&gt;Right - trav-&gt;Left));
00108         <font class="keyword">const</font> sint yPos = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;&gt;1) - (sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> * (((trav-&gt;Near * pt.z) / pt.y) - middleZ) / (trav-&gt;Top - trav-&gt;Bottom));        
00109 
00110         <font class="comment">// read z-buffer value at the pos we are</font>
00111         <font class="keyword">static</font> std::vector&lt;float&gt; <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-&gt;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-&gt;Far) / (1.0 /trav-&gt;Near - 1.0 / trav-&gt;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> &gt; <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-&gt;getPersistence();
00122                 <font class="keywordflow">if</font> (fs == 0)
00123                 {
00124                         m-&gt;_Intensity = 0;                      
00125                         <font class="keywordflow">return</font>;
00126                 }
00127                 <font class="keywordflow">else</font>
00128                 {
00129                         m-&gt;_Intensity -= 1.f / p * (float)m-&gt;_Scene-&gt;getEllapsedTime(); 
00130                         <font class="keywordflow">if</font> (m-&gt;_Intensity &lt; 0.f) 
00131                         {                               
00132                                 m-&gt;_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-&gt;getPersistence();
00140                 <font class="keywordflow">if</font> (fs == 0)
00141                 {
00142                         m-&gt;_Intensity = 1;
00143                 }
00144                 <font class="keywordflow">else</font>
00145                 {
00146                         m-&gt;_Intensity += 1.f / p * (float)m-&gt;_Scene-&gt;getEllapsedTime(); 
00147                         <font class="keywordflow">if</font> (m-&gt;_Intensity &gt; 1.f) m-&gt;_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-&gt;activeVertexProgram(NULL);
00182         drv-&gt;setupModelMatrix(CMatrix::Identity);
00183         drv-&gt;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-&gt;Near + trav-&gt;Far); 
00189         <font class="keyword">const</font> <font class="keywordtype">float</font> zPosDivNear      = zPos / trav-&gt;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-&gt;Right - trav-&gt;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-&gt;Right - trav-&gt;Left));
00194         <font class="comment">//</font>
00195         <font class="keyword">const</font> <font class="keywordtype">float</font> aY = - ( (trav-&gt;Top - trav-&gt;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-&gt;Top - trav-&gt;Bottom));
00197 
00198         <font class="keyword">const</font> CVector I = trav-&gt;CamMatrix.getI();
00199         <font class="keyword">const</font> CVector J = trav-&gt;CamMatrix.getJ();
00200         <font class="keyword">const</font> CVector K = trav-&gt;CamMatrix.getK();
00201         <font class="comment">//</font>
00202         CRGBA            col;   
00203         CRGBA        flareColor = fs-&gt;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>&gt;&gt;1)) * (xPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;&gt;1)) + (yPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;&gt;1))*(yPos - (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;&gt;1)))))
00205                                                    / (float) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;&gt;1);
00206 
00207         <font class="comment">// check for dazzle and draw it</font>
00208         <font class="keywordflow">if</font> (fs-&gt;hasDazzle())
00209         {
00210                 <font class="keywordflow">if</font> (norm &lt; fs-&gt;getDazzleAttenuationRange())
00211                 {
00212                         <font class="keywordtype">float</font> dazzleIntensity = 1.f - norm / fs-&gt;getDazzleAttenuationRange();
00213                         CRGBA dazzleColor = fs-&gt;getDazzleColor(); 
00214                         col.modulateFromui(dazzleColor, (uint) (255.f * m-&gt;_Intensity * dazzleIntensity));
00215                         material.setColor(col);
00216                         material.setTexture(0, NULL);
00217         
00218                         <font class="keyword">const</font> CVector dazzleCenter = trav-&gt;CamPos + zPos * J;
00219                         <font class="keyword">const</font> CVector dI = (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&gt;&gt;1) * aX * I;
00220                         <font class="keyword">const</font> CVector dK = (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&gt;&gt;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-&gt;renderQuads(material, 0, 1);
00228                 }
00229         }               
00230         <font class="keywordflow">if</font> (!fs-&gt;getAttenuable() )
00231         {
00232                 col.modulateFromui(flareColor, (uint) (255.f * distIntensity * m-&gt;_Intensity));
00233         }
00234         <font class="keywordflow">else</font>
00235         {
00236                 <font class="keywordflow">if</font> (norm &gt; fs-&gt;getAttenuationRange() || fs-&gt;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-&gt;_Intensity * (1.f - norm / fs-&gt;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-&gt;getFlareSpacing() * ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &gt;&gt; 1) - xPos);
00251         <font class="keyword">const</font> <font class="keywordtype">float</font> dY = fs-&gt;getFlareSpacing() * ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &gt;&gt; 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-&gt;getFirstFlareKeepSize())
00259         {
00260                 tex = fs-&gt;getTexture(0);
00261                 <font class="keywordflow">if</font> (tex)
00262                 {
00263                         size = fs-&gt;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-&gt;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 &lt; <a class="code" href="namespaceNL3D.html#a39">MaxFlareNum</a>; ++k)
00282         {
00283                 tex = fs-&gt;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-&gt;getRelativePos(k)) + bX) * I 
00289                                      +  zPos * J + (aY * (yPos + dY * fs-&gt;getRelativePos(k)) + bY) * K + trav-&gt;CamMatrix.getPos(); 
00290 
00291 
00292                         
00293 
00294                         size = fs-&gt;getSize(k) / trav-&gt;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-&gt;renderQuads(material, 0, 1);               
00301                 }
00302                 
00303         }               
00304         this-&gt;<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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>