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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
<!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_ribbon_look_at.cpp</h1><a href="ps__ribbon__look__at_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__ribbon__look__at_8h.html">3d/ps_ribbon_look_at.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="ps__macro_8h.html">3d/ps_macro.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00032
00033 <font class="keyword">namespace </font>NL3D
00034 {
00035
00037 <font class="comment">// CPSRibbonLookAt implementation //</font>
00039 <font class="comment"></font>
00040 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a> = 10E-3f;
00041 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a217">NormEpsilon</a> = 10E-8f;
00042
00043
<a name="l00044"></a><a class="code" href="structNL3D_1_1CVectInfo.html">00044</a> <font class="keyword">struct </font>CVectInfo
00045 {
<a name="l00046"></a><a class="code" href="structNL3D_1_1CVectInfo.html#m0">00046</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> <a class="code" href="structNL3D_1_1CVectInfo.html#m0">Interp</a>;
<a name="l00047"></a><a class="code" href="structNL3D_1_1CVectInfo.html#m1">00047</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> <a class="code" href="structNL3D_1_1CVectInfo.html#m1">Proj</a>;
00048 };
00049 <font class="keyword">typedef</font> std::vector<CVectInfo> <a class="code" href="namespaceNL3D.html#a218">TRibbonVect</a>; <font class="comment">// a vector used for intermediate computations</font>
00050
<a name="l00051"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_3">00051</a> CPSRibbonLookAt::TVBMap CPSRibbonLookAt::_VBMap; <font class="comment">// index buffers with no color</font>
<a name="l00052"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_4">00052</a> CPSRibbonLookAt::TVBMap CPSRibbonLookAt::_ColoredVBMap; <font class="comment">// index buffer + colors </font>
00053
00054 <font class="comment">//======================================================= </font>
<a name="l00055"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z731_0">00055</a> CPSRibbonLookAt::CPSRibbonLookAt()
00056 {
00057 }
00058
00059 <font class="comment">//======================================================= </font>
<a name="l00060"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z731_1">00060</a> CPSRibbonLookAt::~CPSRibbonLookAt()
00061 {
00062 <font class="comment">// delete _DyingRibbons;</font>
00063 }
00064
00065 <font class="comment">//======================================================= </font>
<a name="l00066"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z731_2">00066</a> <font class="keywordtype">void</font> CPSRibbonLookAt::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00067 {
00071 sint ver = f.serialVersion(4);
00072 <font class="keywordflow">if</font> (ver > 3)
00073 {
00074 CPSRibbonBase::serial(f);
00075 }
00076 <font class="keywordflow">else</font>
00077 {
00078 CPSParticle::serial(f);
00079 }
00080 CPSColoredParticle::serialColorScheme(f);
00081 CPSSizedParticle::serialSizeScheme(f);
00082 serialMaterial(f);
00083 uint32 dummy = 0; <font class="comment">/* _NbDyingRibbons */</font>
00084 <font class="keywordflow">if</font> (ver <= 3)
00085 {
00086 f.serial(_SegDuration, _NbSegs, dummy <font class="comment">/*_NbDyingRibbons*/</font>);
00087 }
00088 ITexture *tex = NULL;
00089
00090 <font class="keywordflow">if</font> (ver > 2)
00091 {
00092 f.serial(_Parametric);
00093 }
00094
00095
00096 <font class="keywordflow">if</font> (!f.isReading())
00097 {
00098 tex = _Tex;
00099 f.serialPolyPtr(tex);
00100 }
00101 <font class="keywordflow">else</font>
00102 {
00103 f.serialPolyPtr(tex);
00104 setTexture(tex);
00105 setTailNbSeg(_NbSegs); <font class="comment">// force to build the vb</font>
00106 }
00107 }
00108
00109
00110 <font class="comment">//======================================================= </font>
<a name="l00111"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z732_0">00111</a> <font class="keywordtype">void</font> CPSRibbonLookAt::setTexture(CSmartPtr<ITexture> tex)
00112 {
00113 <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#n0">_Tex</a> = tex;
00114 <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#c0">updateMatAndVbForColor</a>();
00115 }
00116
00117
00118 <font class="comment">//======================================================= </font>
<a name="l00119"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a0">00119</a> <font class="keywordtype">void</font> CPSRibbonLookAt::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)
00120 {
00121 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>)
00122 {
00123 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n2">_Parametric</a>)
00124 {
00125 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b5">updateGlobals</a>();
00126 }
00127 }
00128 <font class="keywordflow">else</font>
00129 <font class="keywordflow">if</font> (
00130 (pass == <a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a> && <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a1">hasTransparentFaces</a>())
00131 || (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a> && <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a2">hasOpaqueFaces</a>())
00132 )
00133 {
00134 uint32 <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a0">step</a>;
00135 uint numToProcess;
00136 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a0">step</a>, numToProcess);
00137 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>;
00138
00140 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00141 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(ps.getGlobalColor());
00142
00147 <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#c1">displayRibbons</a>(numToProcess, <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a0">step</a>);
00148
00149 }
00150 <font class="keywordflow">else</font>
00151 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font>
00152 {
00153 <font class="comment">//showTool();</font>
00154 }
00155 }
00156
00157
00158 <font class="comment">//======================================================= </font>
<a name="l00159"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#b0">00159</a> <font class="keywordtype">void</font> CPSRibbonLookAt::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00160 {
00161 CPSRibbonBase::newElement(emitterLocated, emitterIndex);
00162 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b2">newColorElement</a>(emitterLocated, emitterIndex);
00163 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b1">newSizeElement</a>(emitterLocated, emitterIndex);
00164 }
00165
00166
00167 <font class="comment">//======================================================= </font>
<a name="l00168"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#b1">00168</a> <font class="keywordtype">void</font> CPSRibbonLookAt::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00169 {
00170 CPSRibbonBase::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00171 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b3">deleteColorElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00172 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b2">deleteSizeElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00173 }
00174
00175
00176 <font class="comment">//======================================================= </font>
<a name="l00177"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#b2">00177</a> <font class="keywordtype">void</font> CPSRibbonLookAt::resize(uint32 size)
00178 {
00179 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
00180 CPSRibbonBase::resize(size);
00181 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b4">resizeColor</a>(size);
00182 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b3">resizeSize</a>(size);
00183 }
00184
00185 <font class="comment">//======================================================= </font>
<a name="l00186"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#c0">00186</a> <font class="keywordtype">void</font> CPSRibbonLookAt::updateMatAndVbForColor(<font class="keywordtype">void</font>)
00187 {
00188 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#n0">_Tex</a>);
00189 }
00190
00191 <font class="comment">//======================================================= </font>
00192 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a452">MakeProj</a>(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &dest, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>)
00193 {
00194 <font class="keywordflow">if</font> (fabsf(src.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>) > <a class="code" href="namespaceNL3D.html#a217">NormEpsilon</a> * <a class="code" href="namespaceNL3D.html#a217">NormEpsilon</a>)
00195 {
00196 dest.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = src.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> / src.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00197 dest.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = src.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> / src.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00198 dest.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = src.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00199 }
00200 }
00201
00202 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a453">BuildSlice</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &mat, CVertexBuffer &vb, uint8 *currVert, uint32 vertexSize,
00203 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &I,
00204 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &K,
00205 TRibbonVect::iterator pos,
00206 TRibbonVect::iterator prev,
00207 TRibbonVect::iterator next,
00208 <font class="keywordtype">float</font> ribSize)
00210 {
00211 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVert);
00212 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVert);
00213 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> tangent;
00214
00215 <font class="keywordtype">float</font> invTgNorm; <font class="comment">// inverse of the' norm of the projected segment</font>
00216 <font class="keywordtype">float</font> tgNorm;
00217
00218 <font class="keywordflow">if</font> (prev->Proj.y > <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a> && next->Proj.y > <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a>) <font class="comment">// the 2 points are in front of the camera</font>
00219 {
00220 tangent = next->Proj - prev->Proj;
00221 tangent.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = 0;
00222 tgNorm = tangent.<a class="code" href="classNLMISC_1_1CVector.html#z331_2">norm</a>();
00223 <font class="keywordflow">if</font> (fabs(tgNorm) > 10E-8)
00224 {
00225 invTgNorm = 1.f / tgNorm;
00226 }
00227 <font class="keywordflow">else</font>
00228 {
00229 invTgNorm = 1.f;
00230 }
00231 <font class="comment">// build orthogonals vectors to tangent</font>
00232
00233 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = pos->Interp + ribSize * invTgNorm * (tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K - tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00234 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = pos->Interp + ribSize * invTgNorm * (- tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K + tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00235 }
00236 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (prev->Proj.y > <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a>) <font class="comment">// second point cross the near plane</font>
00237 {
00238 <font class="comment">// compute intersection point</font>
00239 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> inter;
00240 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> tInter;
00241 <font class="keywordflow">if</font> (fabsf(prev->Proj.y - next->Proj.y) > <a class="code" href="namespaceNL3D.html#a217">NormEpsilon</a>)
00242 {
00243 <font class="keywordtype">float</font> lambda = (next->Proj.y - <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a>) / (next->Proj.y - prev->Proj.y);
00244 inter = lambda * prev->Interp + (1.f - lambda) * next->Interp;
00245 <a class="code" href="namespaceNL3D.html#a452">MakeProj</a>(tInter, mat * inter);
00246 }
00247 <font class="keywordflow">else</font> <font class="comment">// </font>
00248 {
00249 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = pos->Interp;
00250 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = pos->Interp;
00251 <font class="keywordflow">return</font>;
00252 }
00253
00254 tangent = tInter - prev->Proj;
00255 tangent.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = 0;
00256
00257 tgNorm = tangent.<a class="code" href="classNLMISC_1_1CVector.html#z331_2">norm</a>();
00258 <font class="keywordflow">if</font> (fabs(tgNorm > 10E-8))
00259 {
00260 invTgNorm = 1.f / tgNorm;
00261 }
00262 <font class="keywordflow">else</font>
00263 {
00264 invTgNorm = 1.f;
00265 }
00266 <font class="comment">// build orthogonals vectors to tangent</font>
00267
00268 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = inter + ribSize * invTgNorm * (tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K - tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00269 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = inter + ribSize * invTgNorm * (- tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K + tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00270 }
00271 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (next->Proj.y > <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a>) <font class="comment">// first point cross the near plane</font>
00272 {
00273 <font class="comment">// compute intersection point</font>
00274 <font class="comment">// compute intersection point</font>
00275 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> inter;
00276 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> tInter;
00277 <font class="keywordflow">if</font> (fabsf(prev->Proj.y - next->Proj.y) > <a class="code" href="namespaceNL3D.html#a217">NormEpsilon</a>)
00278 {
00279 <font class="keywordtype">float</font> lambda = (next->Proj.y - <a class="code" href="namespaceNL3D.html#a216">ZEpsilon</a>) / (next->Proj.y - prev->Proj.y);
00280 inter = lambda * prev->Interp + (1.f - lambda) * next->Interp;
00281 <a class="code" href="namespaceNL3D.html#a452">MakeProj</a>(tInter, mat * inter);
00282 }
00283 <font class="keywordflow">else</font> <font class="comment">// </font>
00284 {
00285 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = pos->Interp;
00286 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = pos->Interp;
00287 <font class="keywordflow">return</font>;
00288 }
00289
00290 tangent = next->Proj - tInter;
00291 tangent.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = 0;
00292 tgNorm = tangent.<a class="code" href="classNLMISC_1_1CVector.html#z331_2">norm</a>();
00293 <font class="keywordflow">if</font> (fabs(tgNorm > 10E-8))
00294 {
00295 invTgNorm = 1.f / tgNorm;
00296 }
00297 <font class="keywordflow">else</font>
00298 {
00299 invTgNorm = 1.f;
00300 }
00301 <font class="comment">// build orthogonals vectors to tangent</font>
00302
00303 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = inter + ribSize * invTgNorm * (tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K - tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00304 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = inter + ribSize * invTgNorm * (- tangent.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * K + tangent.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * I);
00305
00306 }
00307 <font class="keywordflow">else</font> <font class="comment">// two points are not visible</font>
00308 {
00309 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) currVert = pos->Interp;
00310 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) (currVert + vertexSize) = pos->Interp;
00311 }
00312
00313 }
00314
00315
00316 <font class="comment">//========================================================================== </font>
<a name="l00317"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#c1">00317</a> <font class="keywordtype">void</font> CPSRibbonLookAt::displayRibbons(uint32 nbRibbons, uint32 srcStep)
00318 {
00319 <font class="keywordflow">if</font> (!nbRibbons) <font class="keywordflow">return</font>;
00320 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00321 CPSRibbonBase::updateLOD();
00322 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> < 2) <font class="keywordflow">return</font>;
00323
00324 <font class="keyword">const</font> <font class="keywordtype">float</font> date = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getSystemDate();
00325 uint8 *currVert;
00326
00327 CVBnPB &VBnPB = <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_1">getVBnPB</a>(); <font class="comment">// get the appropriate vb (build it if needed)</font>
00328 CVertexBuffer &VB = VBnPB.VB;
00329 CPrimitiveBlock &PB = VBnPB.PB;
00330
00331 <font class="keyword">const</font> uint32 vertexSize = VB.getVertexSize();
00332 uint colorOffset=0;
00333 <font class="keyword">const</font> uint32 vertexSizeX2 = vertexSize << 1;
00334 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> I = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->computeI();
00335 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> K = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->computeK();
00336
00337
00338 CMatrix mat = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->isInSystemBasis() ? <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a19">getViewMat</a>() * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a15">getSysMat</a>()
00339 : <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a19">getViewMat</a>();
00340 IDriver *drv = this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>();
00341 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00342 drv->activeVertexBuffer(VB);
00343 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->incrementNbDrawnParticles(nbRibbons); <font class="comment">// for benchmark purpose </font>
00344
00345 <font class="keyword">const</font> uint numRibbonBatch = <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_2">getNumRibbonsInVB</a>(); <font class="comment">// number of ribons to process at once</font>
00346
00347
00348 <font class="keyword">static</font> <a class="code" href="namespaceNL3D.html#a218">TRibbonVect</a> currRibbon;
00349 <font class="keyword">static</font> std::vector<float> sizes;
00350 <font class="keyword">static</font> std::vector<NLMISC::CRGBA> colors;
00351
00352
00353
00354
00355
00356 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> == 0) <font class="keywordflow">return</font>;
00357
00358 currRibbon.resize(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1);
00359 sizes.resize(numRibbonBatch);
00360
00361
00363 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00364 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme() != NULL)
00365 {
00366 CPSMaterial::forceModulateConstantColor(<font class="keyword">true</font>, ps.getGlobalColor());
00367 }
00368 <font class="keywordflow">else</font>
00369 {
00370 <a class="code" href="classNL3D_1_1CPSMaterial.html#a4">forceModulateConstantColor</a>(<font class="keyword">false</font>);
00371 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(ps.getGlobalColor());
00372 }
00373
00374 <font class="keywordflow">if</font> (_ColorScheme)
00375 {
00376 colorOffset = VB.getColorOff();
00377 colors.resize(numRibbonBatch);
00378 }
00379
00380
00381 uint toProcess;
00382 uint ribbonIndex = 0; <font class="comment">// index of the first ribbon in the batch being processed</font>
00383
00384 uint32 fpRibbonIndex = 0;
00385
00386 <font class="keywordflow">do</font>
00387 {
00388 toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (nbRibbons - ribbonIndex) <font class="comment">/* = left to do */</font>, numRibbonBatch);
00389
00390
00392 <font class="keyword">const</font> <font class="keywordtype">float</font> *ptCurrSize;
00393 uint32 ptCurrSizeIncrement;
00394 <font class="keywordflow">if</font> (_SizeScheme)
00395 {
00396 ptCurrSize = (<font class="keywordtype">float</font> *) <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>->make(this->_Owner, ribbonIndex, &sizes[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep);
00397 ptCurrSizeIncrement = 1;
00398 }
00399 <font class="keywordflow">else</font>
00400 {
00401 ptCurrSize = &<a class="code" href="classNL3D_1_1CPSSizedParticle.html#n0">_ParticleSize</a>;
00402 ptCurrSizeIncrement = 0;
00403 }
00404
00406 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *ptCurrColor=0;
00407 <font class="keywordflow">if</font> (_ColorScheme)
00408 {
00409 colors.resize(nbRibbons);
00410 ptCurrColor = (<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> *) <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>->make(this->_Owner, ribbonIndex, &colors[0], <font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>), toProcess, <font class="keyword">true</font>, srcStep);
00411 }
00412
00413 currVert = (uint8 *) VB.getVertexCoordPointer();
00414 <font class="keywordflow">for</font> (uint k = ribbonIndex; k < ribbonIndex + toProcess; ++k)
00415 {
00416
00417 TRibbonVect::iterator rIt = currRibbon.begin(), rItEnd = currRibbon.end(), rItEndMinusOne = rItEnd - 1;
00418
00420 <font class="comment">// interpolate and project points //</font>
00422 <font class="comment"> </font>
00423 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n2">_Parametric</a>)
00424 {
00425
00427 <font class="comment">// INCREMENTAL CASE //</font>
00429 <font class="comment"></font>
00430 <font class="comment">// the parent class has a method to get the ribbons positions</font>
00431 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b4">computeRibbon</a>((uint) (fpRibbonIndex >> 16), &rIt->Interp, <font class="keyword">sizeof</font>(CVectInfo));
00432 <font class="keywordflow">do</font>
00433 {
00434 <a class="code" href="namespaceNL3D.html#a452">MakeProj</a>(rIt->Proj, mat * rIt->Interp);
00435 ++rIt;
00436 }
00437 <font class="keywordflow">while</font> (rIt != rItEnd);
00438 }
00439 <font class="keywordflow">else</font>
00440 {
00442 <font class="comment">// PARAMETRIC CASE //</font>
00444 <font class="comment"> // we compute each pos thanks to the parametric curve </font>
00445 <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),
00446 &rIt->Interp, <font class="keyword">sizeof</font>(CVectInfo) );
00447 <font class="comment">// project each position now</font>
00448 <font class="keywordflow">do</font>
00449 {
00450 <a class="code" href="namespaceNL3D.html#a452">MakeProj</a>(rIt->Proj, mat * rIt->Interp);
00451 ++rIt;
00452 }
00453 <font class="keywordflow">while</font> (rIt != rItEnd);
00454 }
00455
00456 rIt = currRibbon.begin();
00457
00458
00459 <font class="comment">// setup colors</font>
00460 <font class="keywordflow">if</font> (_ColorScheme)
00461 {
00462 uint8 *currColVertex = currVert + colorOffset;
00463 uint colCount = (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1) << 1;
00464 <font class="keywordflow">do</font>
00465 {
00466 * (CRGBA *) currColVertex = *ptCurrColor;
00467 currColVertex += vertexSize;
00468 }
00469 <font class="keywordflow">while</font> (--colCount);
00470
00471 ++ptCurrColor;
00472 }
00473
00475 <font class="comment">// deals with first point </font>
00476 <a class="code" href="namespaceNL3D.html#a453">BuildSlice</a>(mat, VB, currVert, vertexSize, I, K, rIt, rIt, rIt + 1, *ptCurrSize);
00477 currVert += vertexSizeX2;
00478 ++rIt;
00479
00480
00481 <font class="comment">// deals with other points </font>
00482 <font class="keywordflow">for</font> (;;) <font class="comment">// we assume at least 2 segments, so we must have a middle point </font>
00483 {
00484 <font class="comment">// build 2 vertices with the right tangent. /* to project 2 */ is old projected point</font>
00485 <a class="code" href="namespaceNL3D.html#a453">BuildSlice</a>(mat, VB, currVert, vertexSize, I, K, rIt, rIt - 1, rIt + 1, *ptCurrSize);
00486 <font class="comment">// next position </font>
00487 ++rIt;
00488 <font class="keywordflow">if</font> (rIt == rItEndMinusOne) <font class="keywordflow">break</font>;
00489 <font class="comment">// next vertex </font>
00490 currVert += vertexSizeX2;
00491 }
00492 currVert += vertexSizeX2;
00493 <font class="comment">// last point.</font>
00494 <a class="code" href="namespaceNL3D.html#a453">BuildSlice</a>(mat, VB, currVert, vertexSize, I, K, rIt , rIt - 1, rIt, *ptCurrSize);
00495 ptCurrSize += ptCurrSizeIncrement;
00496 currVert += vertexSizeX2;
00497
00498 fpRibbonIndex += srcStep;
00499 }
00500
00501 PB.setNumTri((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> << 1) * toProcess);
00502 <font class="comment">// display the result</font>
00503 drv->render(PB, <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>);
00504 ribbonIndex += toProcess;
00505 }
00506 <font class="keywordflow">while</font> (ribbonIndex != nbRibbons);
00507 }
00508
00509 <font class="comment">//========================================================================== </font>
<a name="l00510"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a1">00510</a> <font class="keywordtype">bool</font> CPSRibbonLookAt::hasTransparentFaces(<font class="keywordtype">void</font>)
00511 {
00512 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#a3">getBlendingMode</a>() != CPSMaterial::alphaTest ;
00513 }
00514
00515
00516 <font class="comment">//========================================================================== </font>
<a name="l00517"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a2">00517</a> <font class="keywordtype">bool</font> CPSRibbonLookAt::hasOpaqueFaces(<font class="keywordtype">void</font>)
00518 {
00519 <font class="keywordflow">return</font> !<a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a1">hasTransparentFaces</a>();
00520 }
00521
00522 <font class="comment">//========================================================================== </font>
<a name="l00523"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#a3">00523</a> uint32 CPSRibbonLookAt::getMaxNumFaces(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00524 <font class="keyword"></font>{
00525 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00526 <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> * 2;
00527 }
00528
00529
00530
00531 <font class="comment">//========================================================================== </font>
<a name="l00532"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_1">00532</a> CPSRibbonLookAt::CVBnPB &CPSRibbonLookAt::getVBnPB()
00533 {
00534 <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_0">TVBMap</a> &map = <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> ? <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_3">_VBMap</a> : <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_4">_ColoredVBMap</a>;
00535 TVBMap::iterator it = map.find(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1);
00536 <font class="keywordflow">if</font> (it != map.end())
00537 {
00538 <font class="keywordflow">return</font> it->second;
00539 }
00540 <font class="keywordflow">else</font> <font class="comment">// must create this vb</font>
00541 {
00542 <font class="keyword">const</font> uint numRibbonInVB = <a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_2">getNumRibbonsInVB</a>();
00543 CVBnPB &VBnPB = map[<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1]; <font class="comment">// make an entry</font>
00544
00546 CVertexBuffer &vb = VBnPB.VB;
00547 vb.setVertexFormat(CVertexBuffer::PositionFlag |
00548 CVertexBuffer::TexCoord0Flag |
00549 (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> ? CVertexBuffer::PrimaryColorFlag : 0));
00550 vb.setNumVertices(2 * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1) * numRibbonInVB );
00551
00552 <font class="comment">// set the primitive block size</font>
00553 CPrimitiveBlock &pb = VBnPB.PB;
00554 pb.setNumTri((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> << 1) * numRibbonInVB);
00556 uint vbIndex = 0;
00557 uint pbIndex = 0;
00558 <font class="keywordflow">for</font> (uint i = 0; i < numRibbonInVB; ++i)
00559 {
00560 <font class="keywordflow">for</font> (uint k = 0; k < (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1); ++k)
00561 {
00562 vb.setTexCoord(vbIndex, 0, CUV((1.f - k / (<font class="keywordtype">float</font>) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>), 0));
00563 vb.setTexCoord(vbIndex + 1, 0, CUV((1.f - k / (<font class="keywordtype">float</font>) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>), 1));
00564 <font class="keywordflow">if</font> (k != <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>)
00565 {
00567 pb.setTri(pbIndex ++, vbIndex + 1, vbIndex + 2, vbIndex);
00568 pb.setTri(pbIndex ++, vbIndex + 1, vbIndex + 3, vbIndex + 2);
00569 }
00570 vbIndex += 2;
00571 }
00572 }
00573 <font class="keywordflow">return</font> VBnPB;
00574 }
00575 }
00576
00577 <font class="comment">//========================================================================== </font>
<a name="l00578"></a><a class="code" href="classNL3D_1_1CPSRibbonLookAt.html#z734_2">00578</a> uint CPSRibbonLookAt::getNumRibbonsInVB()<font class="keyword"> const</font>
00579 <font class="keyword"></font>{
00581 <font class="keyword">const</font> uint vertexInVB = 256;
00582 <font class="keywordflow">return</font> std::max(1u, (uint) (vertexInVB / (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1)));
00583 }
00584
00585 } <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>
|