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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
<!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> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><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="/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>
<!-- 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> </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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>ps_tail_dot.cpp</h1><a href="ps__tail__dot_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 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="ps__tail__dot_8h.html">3d/ps_tail_dot.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="ps__macro_8h.html">3d/ps_macro.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="particle__system_8h.html">3d/particle_system.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="texture__mem_8h.html">3d/texture_mem.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="smart__ptr_8h.html">nel/misc/smart_ptr.h</a>"</font>
00034
00035 <font class="preprocessor">#include <memory></font>
00036
00037 <font class="keyword">namespace </font>NL3D
00038 {
00039 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> <a class="code" href="namespaceNL3D.html#a214">GradientB2W</a>[] = {<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>(0, 0, 0, 0), <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>(255, 255, 255, 255) };
00040
00042 <font class="keyword">static</font> ITexture *<a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>()
00043 {
00044 std::auto_ptr<CTextureMem> tex(<font class="keyword">new</font> CTextureMem((uint8 *) &GradientB2W,
00045 <font class="keyword">sizeof</font>(GradientB2W),
00046 <font class="keyword">false</font>, <font class="comment">/* dont delete */</font>
00047 <font class="keyword">false</font>, <font class="comment">/* not a file */</font>
00048 2, 1)
00049 );
00050 tex->setWrapS(ITexture::Clamp);
00051 tex->setShareName(<font class="stringliteral">"#GradBW"</font>);
00052 <font class="keywordflow">return</font> tex.release();
00053 }
00054
00055
00057 <font class="comment">// CPSTailDot implementation //</font>
00059 <font class="comment"></font>
<a name="l00060"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_3">00060</a> CPSTailDot::TVBMap CPSTailDot::_VBMap; <font class="comment">// index / vertex buffers with no color</font>
<a name="l00061"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_4">00061</a> CPSTailDot::TVBMap CPSTailDot::_FadedVBMap; <font class="comment">// index / vertex buffers for constant color with fading</font>
<a name="l00062"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_5">00062</a> CPSTailDot::TVBMap CPSTailDot::_ColoredVBMap; <font class="comment">// index / vertex buffer + colors</font>
<a name="l00063"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_6">00063</a> CPSTailDot::TVBMap CPSTailDot::_FadedColoredVBMap; <font class="comment">// index / vertex buffer + faded colors</font>
00064
00065 <font class="comment">//======================================================= </font>
<a name="l00066"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z736_0">00066</a> CPSTailDot::CPSTailDot() : _ColorFading(false), _GlobalColor(false), _Touch(true)
00067 {
00068 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#z729_2">setInterpolationMode</a>(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#s7s3">Linear</a>);
00069 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#z730_2">setSegDuration</a>(0.06f);
00070 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"TailDot"</font>);
00071 }
00072
00073 <font class="comment">//======================================================= </font>
<a name="l00074"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z736_1">00074</a> CPSTailDot::~CPSTailDot()
00075 {
00076 <font class="comment">// delete _DyingRibbons;</font>
00077 }
00078
00079 <font class="comment">//======================================================= </font>
<a name="l00080"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z736_2">00080</a> <font class="keywordtype">void</font> CPSTailDot::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00081 {
00082
00083 sint ver = f.serialVersion(3);
00084 <font class="keywordflow">if</font> (ver == 1)
00085 {
00086 <a class="code" href="debug_8h.html#a6">nlassert</a>(f.isReading());
00087
00090 sint ver2 = f.serialVersion(2);
00091
00092 <font class="comment">// here is CPSLocatedBindable::serial(f)</font>
00093 sint ver3 = f.serialVersion(4);
00094 f.serialPtr(_Owner);
00095 <font class="keywordflow">if</font> (ver3 > 1) f.serialEnum(_LOD);
00096 <font class="keywordflow">if</font> (ver3 > 2) f.serial(_Name);
00097 <font class="keywordflow">if</font> (ver3 > 3)
00098 {
00099 <font class="keywordflow">if</font> (f.isReading())
00100 {
00101 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>;
00102 f.serial(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00103 setExternID(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00104 }
00105 <font class="keywordflow">else</font>
00106 {
00107 f.serial(_ExternID);
00108 }
00109 }
00110
00111 <font class="keywordflow">if</font> (ver2 >= 2)
00112 {
00113 <font class="keywordtype">bool</font> bDisableAutoLOD;
00114 f.serial(bDisableAutoLOD);
00115 disableAutoLOD(bDisableAutoLOD);
00116 }
00117
00118 uint32 tailNbSegs;
00119 <font class="keywordtype">bool</font> colorFading;
00120 <font class="keywordtype">bool</font> systemBasisEnabled;
00121
00122 CPSColoredParticle::serialColorScheme(f);
00123 f.serial(tailNbSegs, colorFading, systemBasisEnabled);
00124
00125 _ColorFading = colorFading;
00126 _NbSegs = tailNbSegs >> 1;
00127 <font class="keywordflow">if</font> (_NbSegs < 2) _NbSegs = 2;
00128 setInterpolationMode(Linear);
00129 serialMaterial(f);
00130
00131
00132 <a class="code" href="debug_8h.html#a6">nlassert</a>(_Owner);
00133 resize(_Owner->getMaxSize());
00134 initDateVect();
00135 resetFromOwner();
00136 }
00137
00138 <font class="keywordflow">if</font> (ver >= 2)
00139 {
00140 CPSRibbonBase::serial(f);
00141 CPSColoredParticle::serialColorScheme(f);
00142 CPSMaterial::serialMaterial(f);
00143 <font class="keywordtype">bool</font> colorFading = _ColorFading;
00144 f.serial(colorFading);
00145 _ColorFading = colorFading;
00146 <font class="keywordflow">if</font> (ver >= 3)
00147 {
00148 uint32 tailNbSegs = _NbSegs;
00149 f.serial(tailNbSegs);
00150 }
00151 <font class="keywordflow">if</font> (f.isReading())
00152 {
00153 setTailNbSeg(_NbSegs);
00154 touch();
00155 }
00156 }
00157 }
00158
00159
00160 <font class="comment">//======================================================= </font>
<a name="l00161"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#a0">00161</a> <font class="keywordtype">void</font> CPSTailDot::step(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt)
00162 {
00163 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>)
00164 {
00165 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n2">_Parametric</a>)
00166 {
00167 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b5">updateGlobals</a>();
00168 }
00169 }
00170 <font class="keywordflow">else</font>
00171 <font class="keywordflow">if</font> (
00172 (pass == <a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a> && <a class="code" href="classNL3D_1_1CPSTailDot.html#a1">hasTransparentFaces</a>())
00173 || (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a> && <a class="code" href="classNL3D_1_1CPSTailDot.html#a2">hasOpaqueFaces</a>())
00174 )
00175 {
00176 uint32 <a class="code" href="classNL3D_1_1CPSTailDot.html#a0">step</a>;
00177 uint numToProcess;
00178 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSTailDot.html#a0">step</a>, numToProcess);
00179 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>;
00180
00182 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00183 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(ps.getGlobalColor());
00184
00189 <a class="code" href="classNL3D_1_1CPSTailDot.html#c1">displayRibbons</a>(numToProcess, <a class="code" href="classNL3D_1_1CPSTailDot.html#a0">step</a>);
00190
00191 }
00192 <font class="keywordflow">else</font>
00193 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font>
00194 {
00195 <font class="comment">//showTool();</font>
00196 }
00197 }
00198
00199
00200 <font class="comment">//======================================================= </font>
<a name="l00201"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#b0">00201</a> <font class="keywordtype">void</font> CPSTailDot::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00202 {
00203 CPSRibbonBase::newElement(emitterLocated, emitterIndex);
00204 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b2">newColorElement</a>(emitterLocated, emitterIndex);
00205 }
00206
00207
00208 <font class="comment">//======================================================= </font>
<a name="l00209"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#b1">00209</a> <font class="keywordtype">void</font> CPSTailDot::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00210 {
00211 CPSRibbonBase::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00212 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b3">deleteColorElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00213 }
00214
00215
00216 <font class="comment">//======================================================= </font>
<a name="l00217"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#b2">00217</a> <font class="keywordtype">void</font> CPSTailDot::resize(uint32 size)
00218 {
00219 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
00220 CPSRibbonBase::resize(size);
00221 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b4">resizeColor</a>(size);
00222 }
00223
00224 <font class="comment">//======================================================= </font>
<a name="l00225"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#c0">00225</a> <font class="keywordtype">void</font> CPSTailDot::updateMatAndVbForColor(<font class="keywordtype">void</font>)
00226 {
00227 <a class="code" href="classNL3D_1_1CPSTailDot.html#c2">touch</a>();
00228 }
00229
00230 <font class="comment">//========================================================================== </font>
<a name="l00231"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#c1">00231</a> <font class="keywordtype">void</font> CPSTailDot::displayRibbons(uint32 nbRibbons, uint32 srcStep)
00232 {
00233 <font class="keywordflow">if</font> (!nbRibbons) <font class="keywordflow">return</font>;
00234 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00235 CPSRibbonBase::updateLOD();
00236 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> < 2) <font class="keywordflow">return</font>;
00237 <font class="keyword">const</font> <font class="keywordtype">float</font> date = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getSystemDate();
00238 uint8 *currVert;
00239 CVBnPB &VBnPB = <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_1">getVBnPB</a>(); <font class="comment">// get the appropriate vb (built it if needed)</font>
00240 CVertexBuffer &VB = VBnPB.VB;
00241 CPrimitiveBlock &PB = VBnPB.PB;
00242 <font class="keyword">const</font> uint32 vertexSize = VB.getVertexSize();
00243 uint colorOffset=0;
00244
00245 IDriver *drv = this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>();
00246 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00247 drv->activeVertexBuffer(VB);
00248 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->incrementNbDrawnParticles(nbRibbons); <font class="comment">// for benchmark purpose </font>
00249 <font class="keyword">const</font> uint numRibbonBatch = <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_2">getNumRibbonsInVB</a>(); <font class="comment">// number of ribons to process at once </font>
00250 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> == 0) <font class="keywordflow">return</font>;
00251
00253 <font class="comment">// Material setup //</font>
00255 <font class="comment"> CParticleSystem &ps = *(_Owner->getOwner());</font>
00256 <font class="keywordtype">bool</font> useGlobalColor = ps.getColorAttenuationScheme() != NULL;
00257 <font class="keywordflow">if</font> (useGlobalColor != <a class="code" href="classNL3D_1_1CPSTailDot.html#o1">_GlobalColor</a>)
00258 {
00259 <a class="code" href="classNL3D_1_1CPSTailDot.html#c2">touch</a>();
00260 }
00261 <a class="code" href="classNL3D_1_1CPSTailDot.html#c3">updateMaterial</a>();
00262 <a class="code" href="classNL3D_1_1CPSTailDot.html#c4">setupGlobalColor</a>();
00263 <font class="comment">//</font>
00264 <font class="keywordflow">if</font> (_ColorScheme)
00265 {
00266 colorOffset = VB.getColorOff();
00267 }
00268
00270 <font class="comment">// Compute ribbons //</font>
00272 <font class="comment"> </font>
00273 uint toProcess;
00274 uint ribbonIndex = 0; <font class="comment">// index of the first ribbon in the batch being processed </font>
00275 uint32 fpRibbonIndex = 0; <font class="comment">// fixed point index in source</font>
00276 <font class="keywordflow">do</font>
00277 {
00278 toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (nbRibbons - ribbonIndex) <font class="comment">/* = left to do */</font>, numRibbonBatch);
00279 currVert = (uint8 *) VB.getVertexCoordPointer();
00280
00282 <font class="keywordflow">if</font> (_ColorScheme)
00283 {
00284 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>->makeN(this->_Owner, ribbonIndex, currVert + colorOffset, vertexSize, toProcess, <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1, srcStep);
00285 }
00286 uint k = toProcess;
00288 <font class="comment">// interpolate and project points the result is directly setup in the vertex buffer //</font>
00290 <font class="comment"> if (!_Parametric)</font>
00291 {
00292
00294 <font class="comment">// INCREMENTAL CASE //</font>
00296 <font class="comment"> do</font>
00297 {
00298 <font class="comment">// the parent class has a method to get the ribbons positions</font>
00299 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b4">computeRibbon</a>((uint) (fpRibbonIndex >> 16), (CVector *) currVert, vertexSize);
00300 currVert += vertexSize * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1);
00301 fpRibbonIndex += srcStep;
00302 }
00303 <font class="keywordflow">while</font> (--k);
00304 }
00305 <font class="keywordflow">else</font>
00306 {
00308 <font class="comment">// PARAMETRIC CASE //</font>
00310 <font class="comment"> do</font>
00311 {
00312 <font class="comment">// we compute each pos thanks to the parametric curve </font>
00313 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->integrateSingle(date - <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a> * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1), <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a>, <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1, (uint) (fpRibbonIndex >> 16),
00314 (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert, vertexSize);
00315 currVert += vertexSize * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1);
00316 fpRibbonIndex += srcStep;
00317 }
00318 <font class="keywordflow">while</font> (--k);
00319
00320 }
00321 PB.setNumLine(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> * toProcess);
00322 <font class="comment">// display the result</font>
00323 drv->render(PB, <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>);
00324 ribbonIndex += toProcess;
00325 }
00326 <font class="keywordflow">while</font> (ribbonIndex != nbRibbons);
00327 }
00328
00329 <font class="comment">//========================================================================== </font>
<a name="l00330"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#a1">00330</a> <font class="keywordtype">bool</font> CPSTailDot::hasTransparentFaces(<font class="keywordtype">void</font>)
00331 {
00332 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#a3">getBlendingMode</a>() != CPSMaterial::alphaTest ;
00333 }
00334
00335
00336 <font class="comment">//========================================================================== </font>
<a name="l00337"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#a2">00337</a> <font class="keywordtype">bool</font> CPSTailDot::hasOpaqueFaces(<font class="keywordtype">void</font>)
00338 {
00339 <font class="keywordflow">return</font> !<a class="code" href="classNL3D_1_1CPSTailDot.html#a1">hasTransparentFaces</a>();
00340 }
00341
00342 <font class="comment">//========================================================================== </font>
<a name="l00343"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#a3">00343</a> uint32 CPSTailDot::getMaxNumFaces(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00344 <font class="keyword"></font>{
00345 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00346 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize() * <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n0">_NbSegs</a>;
00347 }
00348
00349
00350
00351 <font class="comment">//========================================================================== </font>
<a name="l00352"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_1">00352</a> CPSTailDot::CVBnPB &CPSTailDot::getVBnPB()
00353 {
00355 <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_0">TVBMap</a> &map = <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> ? (<a class="code" href="classNL3D_1_1CPSTailDot.html#o0">_ColorFading</a> ? <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_6">_FadedColoredVBMap</a> : <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_5">_ColoredVBMap</a>) <font class="comment">// per ribbon colo�r</font>
00356 : (<a class="code" href="classNL3D_1_1CPSTailDot.html#o0">_ColorFading</a> ? <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_4">_FadedVBMap</a> : <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_3">_VBMap</a>); <font class="comment">// global color</font>
00357 TVBMap::iterator it = map.find(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1);
00358 <font class="keywordflow">if</font> (it != map.end())
00359 {
00360 <font class="keywordflow">return</font> it->second;
00361 }
00362 <font class="keywordflow">else</font> <font class="comment">// must create this vb, with few different size, it is still interseting, though they are only destroyed at exit</font>
00363 {
00364 <font class="keyword">const</font> uint numRibbonInVB = <a class="code" href="classNL3D_1_1CPSTailDot.html#z738_2">getNumRibbonsInVB</a>();
00365 CVBnPB &VBnPB = map[<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1]; <font class="comment">// make an entry</font>
00366
00370 CVertexBuffer &vb = VBnPB.VB;
00371 vb.setVertexFormat(CVertexBuffer::PositionFlag
00372 |(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> || <a class="code" href="classNL3D_1_1CPSTailDot.html#o0">_ColorFading</a> ? CVertexBuffer::PrimaryColorFlag : 0)
00373 | (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> && <a class="code" href="classNL3D_1_1CPSTailDot.html#o0">_ColorFading</a> ? CVertexBuffer::TexCoord0Flag : 0));
00374
00375 vb.setNumVertices((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1) * numRibbonInVB ); <font class="comment">// 1 seg = 1 line + terminal vertices</font>
00376
00377 <font class="comment">// set the primitive block size</font>
00378 CPrimitiveBlock &pb = VBnPB.PB;
00379 pb.setNumLine(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> * numRibbonInVB);
00381 uint vbIndex = 0;
00382 uint pbIndex = 0;
00383 <font class="keywordflow">for</font> (uint i = 0; i < numRibbonInVB; ++i)
00384 {
00385 <font class="keywordflow">for</font> (uint k = 0; k < (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1); ++k)
00386 {
00387
00388 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> && <a class="code" href="classNL3D_1_1CPSTailDot.html#o0">_ColorFading</a>)
00389 {
00390 vb.setTexCoord(vbIndex, 0, 0.5f - 0.5f * ((<font class="keywordtype">float</font>) k / <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>), 0);
00391 }
00392 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (_ColorFading)
00393 {
00394 uint8 intensity = (uint8) (255 * (1.f - ((float) k / <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>)));
00395 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col(intensity, intensity, intensity, intensity);
00396 vb.setColor(vbIndex, col);
00397 }
00398
00400 <font class="keywordflow">if</font> (k != <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>)
00401 {
00402 pb.setLine(pbIndex ++, vbIndex, vbIndex + 1);
00403 }
00404 ++vbIndex;
00405 }
00406 }
00407 <font class="keywordflow">return</font> VBnPB;
00408 }
00409 }
00410
00411 <font class="comment">//========================================================================== </font>
<a name="l00412"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#z738_2">00412</a> uint CPSTailDot::getNumRibbonsInVB()<font class="keyword"> const</font>
00413 <font class="keyword"></font>{
00415 <font class="keyword">const</font> uint vertexInVB = 256;
00416 <font class="keywordflow">return</font> std::max(1u, (uint) (vertexInVB / (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1)));
00417 }
00418
00419
00420 <font class="comment">//========================================================================== </font>
<a name="l00421"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#c3">00421</a> <font class="keywordtype">void</font> CPSTailDot::updateMaterial()
00422 {
00423 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSTailDot.html#o2">_Touch</a>) <font class="keywordflow">return</font>;
00424
00425 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CRefPtr.html">NLMISC::CRefPtr<ITexture></a> ptGradTexture;
00426
00427 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00428 <font class="keywordflow">if</font> (_ColorScheme)
00429 { <font class="comment">// PER RIBBON COLOR</font>
00430 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
00431 {
00432 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// global color + fading + per ribbon color</font>
00433 {
00434 <font class="comment">// the first stage is used to get fading * global color</font>
00435 <font class="comment">// the second stage multiply the result by the diffuse colot</font>
00436 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00437 {
00438 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>();
00439 }
00440 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00441 CPSMaterial::forceTexturedMaterialStages(2); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00442 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Constant);
00443 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Previous, CMaterial::Diffuse);
00444 }
00445 <font class="keywordflow">else</font> <font class="comment">// per ribbon color with global color </font>
00446 {
00447 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00448 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Diffuse, CMaterial::Constant);
00449 }
00450 }
00451 <font class="keywordflow">else</font>
00452 {
00453 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// per ribbon color, fading</font>
00454 {
00455 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00456 {
00457 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>();
00458 }
00459 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00460 CPSMaterial::forceTexturedMaterialStages(1);
00461 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00462 }
00463 <font class="keywordflow">else</font> <font class="comment">// per color ribbon with no fading, and no global color</font>
00464 {
00465 CPSMaterial::forceTexturedMaterialStages(0); <font class="comment">// no texture use constant diffuse only</font>
00466 }
00467 }
00468 }
00469 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR</font>
00470 {
00471 <font class="keywordflow">if</font> (_ColorFading)
00472 {
00473 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// use constant color 0 * diffuse, 1 stage needed</font>
00474 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Diffuse, CMaterial::Constant);
00475 }
00476 <font class="keywordflow">else</font> <font class="comment">// constant color</font>
00477 {
00478 CPSMaterial::forceTexturedMaterialStages(0); <font class="comment">// no texture use constant diffuse only </font>
00479 }
00480 }
00481
00482 <a class="code" href="classNL3D_1_1CPSTailDot.html#o2">_Touch</a> = <font class="keyword">false</font>;
00483 }
00484
00485 <font class="comment">//========================================================================== </font>
<a name="l00486"></a><a class="code" href="classNL3D_1_1CPSTailDot.html#c4">00486</a> <font class="keywordtype">void</font> CPSTailDot::setupGlobalColor()
00487 {
00489 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00490 <font class="keywordflow">if</font> (_ColorScheme)
00491 {
00492 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, ps.getGlobalColor());
00493 }
00494 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR with / without fading</font>
00495 {
00496 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
00497 {
00498 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col;
00499 col.<a class="code" href="classNLMISC_1_1CRGBA.html#a9">modulateFromColor</a>(ps.getGlobalColor(), <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00500 <font class="keywordflow">if</font> (_ColorFading)
00501 {
00502 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, col);
00503 }
00504 <font class="keywordflow">else</font> <font class="comment">// color attenuation, no fading : </font>
00505 {
00506 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(col);
00507 }
00508 }
00509 <font class="keywordflow">else</font>
00510 {
00511 <font class="keywordflow">if</font> (_ColorFading)
00512 {
00513 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00514 }
00515 <font class="keywordflow">else</font> <font class="comment">// constant color</font>
00516 {
00517 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00518 }
00519 }
00520 }
00521 }
00522
00523
00524
00525
00526 } <font class="comment">// NL3D</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|