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
|
<!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_face.cpp</h1><a href="ps__face_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__face_8h.html">3d/ps_face.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="ps__iterator_8h.html">3d/ps_iterator.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="quat_8h.html">nel/misc/quat.h</a>"</font>
00033
00034
00035
00036 <font class="keyword">namespace </font>NL3D
00037 {
00038
00039 <font class="keyword">using</font> <a class="code" href="classNLMISC_1_1CQuat.html">NLMISC::CQuat</a>;
00040
00042 <font class="comment">// CPSFace implementation //</font>
00044 <font class="comment"></font>
<a name="l00050"></a><a class="code" href="classNL3D_1_1CPSFaceHelper.html">00050</a> <font class="comment"></font><font class="keyword">class </font>CPSFaceHelper
00051 {
00052 <font class="keyword">public</font>:
00053 <font class="keyword">template</font> <<font class="keyword">class</font> T, <font class="keyword">class</font> U>
<a name="l00054"></a><a class="code" href="classNL3D_1_1CPSFaceHelper.html#d0">00054</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CPSFaceHelper.html#d0">drawFaces</a>(T posIt, U indexIt, CPSFace &f, uint size, uint32 srcStep)
00055 {
00056 PARTICLES_CHECK_MEM;
00057 <a class="code" href="debug_8h.html#a6">nlassert</a>(f._Owner);
00058 IDriver *driver = f.getDriver();
00059
00060 f.updateMatBeforeRendering(driver);
00061
00062 CVertexBuffer &vb = f.getNeededVB();
00063 uint8 *currVertex;
00064
00065 <font class="comment">// number of left faces to draw, number of faces to process at once</font>
00066 uint32 leftFaces = size, toProcess;
00067 f._Owner->incrementNbDrawnParticles(size); <font class="comment">// for benchmark purpose </font>
00068 f.setupDriverModelMatrix();
00069 driver->activeVertexBuffer(vb);
00070 <font class="keywordflow">if</font> (f.isMultiTextureEnabled())
00071 {
00072 f.setupMaterial(f._Tex, driver, f._Mat);
00073 }
00074 <font class="keywordtype">float</font> sizeBuf[CPSQuad::quadBufSize];
00075 <font class="keywordtype">float</font> *ptSize;
00076 T endPosIt;
00077
00078 <font class="comment">// if constant size is used, the pointer points always the same float </font>
00079 uint32 ptSizeIncrement = f._SizeScheme ? 1 : 0;
00080
00081 <font class="keywordflow">if</font> (f._PrecompBasis.size()) <font class="comment">// do we use precomputed basis ?</font>
00082 {
00083 <font class="keywordflow">do</font>
00084 {
00085 toProcess = leftFaces > CPSQuad::quadBufSize ? CPSQuad::quadBufSize : leftFaces;
00086 currVertex = (uint8 *) vb.getVertexCoordPointer() ;
00087 <font class="keywordflow">if</font> (f._SizeScheme)
00088 {
00089 ptSize = (<font class="keywordtype">float</font> *) (f._SizeScheme->make(f._Owner, size - leftFaces, sizeBuf, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep));
00090 }
00091 <font class="keywordflow">else</font>
00092 {
00093 ptSize = &f._ParticleSize;
00094 }
00095 f.updateVbColNUVForRender(vb, size - leftFaces, toProcess, srcStep);
00096 <font class="keyword">const</font> uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> = vb.getVertexSize();
00097 endPosIt = posIt + toProcess;
00098 <font class="keywordflow">do</font>
00099 {
00100 <font class="keyword">const</font> CPlaneBasis &currBasis = f._PrecompBasis[*indexIt].Basis;
00101 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00102 ((CVector *) currVertex)->x = (*posIt).x + *ptSize * currBasis.X.x;
00103 ((CVector *) currVertex)->y = (*posIt).y + *ptSize * currBasis.X.y;
00104 ((CVector *) currVertex)->z = (*posIt).z + *ptSize * currBasis.X.z;
00105 currVertex += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00106
00107 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00108 ((CVector *) currVertex)->x = (*posIt).x + *ptSize * currBasis.Y.x;
00109 ((CVector *) currVertex)->y = (*posIt).y + *ptSize * currBasis.Y.y;
00110 ((CVector *) currVertex)->z = (*posIt).z + *ptSize * currBasis.Y.z;
00111 currVertex += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00112
00113 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00114 ((CVector *) currVertex)->x = (*posIt).x - *ptSize * currBasis.X.x;
00115 ((CVector *) currVertex)->y = (*posIt).y - *ptSize * currBasis.X.y;
00116 ((CVector *) currVertex)->z = (*posIt).z - *ptSize * currBasis.X.z;
00117 currVertex += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00118
00119 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00120 ((CVector *) currVertex)->x = (*posIt).x - *ptSize * currBasis.Y.x;
00121 ((CVector *) currVertex)->y = (*posIt).y - *ptSize * currBasis.Y.y;
00122 ((CVector *) currVertex)->z = (*posIt).z - *ptSize * currBasis.Y.z;
00123 currVertex += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00124 ptSize += ptSizeIncrement;
00125 ++indexIt;
00126 ++posIt;
00127 }
00128 <font class="keywordflow">while</font> (posIt != endPosIt);
00129 driver->renderQuads(f._Mat, 0, toProcess);
00130 leftFaces -= toProcess;
00131 }
00132 <font class="keywordflow">while</font> (leftFaces);
00133 }
00134 <font class="keywordflow">else</font>
00135 {
00136 <font class="comment">// must compute each particle basis at each time</font>
00137 <font class="keyword">static</font> CPlaneBasis planeBasis[CPSQuad::quadBufSize]; <font class="comment">// buffer to compute each particle basis</font>
00138 CPlaneBasis *currBasis;
00139 uint32 ptPlaneBasisIncrement = f._PlaneBasisScheme ? 1 : 0;
00140 <font class="keyword">const</font> uint32 vSize = vb.getVertexSize();
00141 <font class="keywordflow">do</font>
00142 {
00143 toProcess = leftFaces > CPSQuad::quadBufSize ? CPSQuad::quadBufSize : leftFaces;
00144 currVertex = (uint8 *) vb.getVertexCoordPointer() ;
00145 <font class="keywordflow">if</font> (f._SizeScheme)
00146 {
00147 ptSize = (<font class="keywordtype">float</font> *) (f._SizeScheme->make(f._Owner, size - leftFaces, sizeBuf, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep));
00148 }
00149 <font class="keywordflow">else</font>
00150 {
00151 ptSize = &f._ParticleSize;
00152 }
00153
00154 <font class="keywordflow">if</font> (f._PlaneBasisScheme)
00155 {
00156 currBasis = (CPlaneBasis *) (f._PlaneBasisScheme->make(f._Owner, size - leftFaces, planeBasis, <font class="keyword">sizeof</font>(CPlaneBasis), toProcess, <font class="keyword">true</font>, srcStep));
00157 }
00158 <font class="keywordflow">else</font>
00159 {
00160 currBasis = &f._PlaneBasis;
00161 }
00162 f.updateVbColNUVForRender(vb, size - leftFaces, toProcess, srcStep);
00163 endPosIt = posIt + toProcess;
00164 <font class="keywordflow">do</font>
00165 {
00166 <font class="comment">// we use this instead of the + operator, because we avoid 4 constructor calls this way</font>
00167 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00168 ((CVector *) currVertex)->x = (*posIt).x + *ptSize * currBasis->X.x;
00169 ((CVector *) currVertex)->y = (*posIt).y + *ptSize * currBasis->X.y;
00170 ((CVector *) currVertex)->z = (*posIt).z + *ptSize * currBasis->X.z;
00171 currVertex += vSize;
00172
00173 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00174 ((CVector *) currVertex)->x = (*posIt).x + *ptSize * currBasis->Y.x;
00175 ((CVector *) currVertex)->y = (*posIt).y + *ptSize * currBasis->Y.y;
00176 ((CVector *) currVertex)->z = (*posIt).z + *ptSize * currBasis->Y.z;
00177 currVertex += vSize;
00178
00179 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00180 ((CVector *) currVertex)->x = (*posIt).x - *ptSize * currBasis->X.x;
00181 ((CVector *) currVertex)->y = (*posIt).y - *ptSize * currBasis->X.y;
00182 ((CVector *) currVertex)->z = (*posIt).z - *ptSize * currBasis->X.z;
00183 currVertex += vSize;
00184
00185 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, currVertex);
00186 ((CVector *) currVertex)->x = (*posIt).x - *ptSize * currBasis->Y.x;
00187 ((CVector *) currVertex)->y = (*posIt).y - *ptSize * currBasis->Y.y;
00188 ((CVector *) currVertex)->z = (*posIt).z - *ptSize * currBasis->Y.z;
00189 currVertex += vSize;
00190 ptSize += ptSizeIncrement;
00191 ++posIt;
00192 currBasis += ptPlaneBasisIncrement;
00193 }
00194 <font class="keywordflow">while</font> (posIt != endPosIt);
00195 driver->renderQuads(f._Mat, 0, toProcess);
00196 leftFaces -= toProcess;
00197 }
00198 <font class="keywordflow">while</font> (leftFaces);
00199 }
00200 PARTICLES_CHECK_MEM;
00201 }
00202 };
00203
<a name="l00205"></a><a class="code" href="classNL3D_1_1CPSFace.html#a0">00205</a> CPSFace::CPSFace(CSmartPtr<ITexture> tex) : CPSQuad(tex)
00206 {
00207 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"Face"</font>);
00208 }
00209
<a name="l00211"></a><a class="code" href="classNL3D_1_1CPSFace.html#b0">00211</a> <font class="keywordtype">void</font> CPSFace::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>)
00212 {
00213 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font>
00214 {
00215 <a class="code" href="classNL3D_1_1CPSParticle.html#a8">showTool</a>();
00216 <font class="keywordflow">return</font>;
00217 }
00218 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>)
00219 {
00220
00221 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.size()) <font class="comment">// do we use precomputed basis ?</font>
00222 {
00223 <font class="comment">// rotate all precomputed basis </font>
00224 <font class="keywordflow">for</font> (std::vector< CPlaneBasisPair >::iterator it = <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.end(); ++it)
00225 {
00226 <font class="comment">// not optimized at all, but this will apply to very few elements anyway...</font>
00227 CMatrix mat;
00228 mat.rotate(CQuat(it->Axis, ellapsedTime * it->AngularVelocity));
00229 CVector n = mat * it->Basis.getNormal();
00230 it->Basis = CPlaneBasis(n);
00231 }
00232 }
00233 <font class="keywordflow">return</font>;
00234 }
00235 <font class="keywordflow">else</font> <font class="comment">// check this is the right pass</font>
00236 <font class="keywordflow">if</font> (!
00237 ( (pass == <a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a> && <a class="code" href="classNL3D_1_1CPSQuad.html#a1">hasTransparentFaces</a>())
00238 || (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a> && <a class="code" href="classNL3D_1_1CPSQuad.html#a2">hasOpaqueFaces</a>())
00239 )
00240 )
00241 {
00242 <font class="keywordflow">return</font>;
00243 }
00244
00245
00246
00247 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize()) <font class="keywordflow">return</font>;
00248 uint32 <a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>;
00249 uint numToProcess;
00250 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>, numToProcess);
00251 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>;
00252
00253
00254 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a> == (1 << 16))
00255 {
00257 std::vector<uint32>::const_iterator indexIt = <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.begin();
00258
00260 CPSFaceHelper::drawFaces(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(),
00261 indexIt,
00262 *<font class="keyword">this</font>,
00263 numToProcess,
00264 <a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>
00265 );
00266 }
00267 <font class="keywordflow">else</font>
00268 {
00270 CAdvance1616Iterator<std::vector<uint32>::const_iterator, <font class="keyword">const</font> uint32>
00271 indexIt(<a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.begin(), 0, <a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>);
00272 CPSFaceHelper::drawFaces(<a class="code" href="namespaceNL3D.html#a199">TIteratorVectStep1616</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), 0, <a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>),
00273 indexIt,
00274 *<font class="keyword">this</font>,
00275 numToProcess,
00276 <a class="code" href="classNL3D_1_1CPSFace.html#b0">step</a>
00277 );
00278 }
00279
00280 }
00281
00282
<a name="l00284"></a><a class="code" href="classNL3D_1_1CPSFace.html#a1">00284</a> <font class="keywordtype">void</font> CPSFace::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00285 {
00286 f.serialVersion(1);
00287 CPSQuad::serial(f);
00288 CPSRotated3DPlaneParticle::serialPlaneBasisScheme(f);
00289
00290 <font class="keywordflow">if</font> (f.isReading())
00291 {
00292 uint32 nbConfigurations;
00293 f.serial(nbConfigurations);
00294 <font class="keywordflow">if</font> (nbConfigurations)
00295 {
00296 f.serial(_MinAngularVelocity, _MaxAngularVelocity);
00297 }
00298 hintRotateTheSame(nbConfigurations, _MinAngularVelocity, _MaxAngularVelocity);
00299
00300 init();
00301 }
00302 <font class="keywordflow">else</font>
00303 {
00304 uint32 nbConfigurations = _PrecompBasis.size();
00305 f.serial(nbConfigurations);
00306 <font class="keywordflow">if</font> (nbConfigurations)
00307 {
00308 f.serial(_MinAngularVelocity, _MaxAngularVelocity);
00309 }
00310 }
00311 }
00312
00313
00316 <font class="keyword">static</font> CVector <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>(<font class="keywordtype">void</font>)
00317 {
00318 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>((<font class="keywordtype">float</font>) ((rand() % 20000) - 10000)
00319 ,(<font class="keywordtype">float</font>) ((rand() % 20000) - 10000)
00320 ,(<font class="keywordtype">float</font>) ((rand() % 20000) - 10000)
00321 );
00322 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.normalize();
00323 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00324 }
00325
<a name="l00327"></a><a class="code" href="classNL3D_1_1CPSFace.html#a3">00327</a> <font class="keywordtype">void</font> CPSFace::hintRotateTheSame(uint32 nbConfiguration
00328 , <font class="keywordtype">float</font> minAngularVelocity
00329 , <font class="keywordtype">float</font> maxAngularVelocity
00330 )
00331 {
00332 <a class="code" href="classNL3D_1_1CPSFace.html#n0">_MinAngularVelocity</a> = minAngularVelocity;
00333 <a class="code" href="classNL3D_1_1CPSFace.html#n1">_MaxAngularVelocity</a> = maxAngularVelocity;
00334 <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.resize(nbConfiguration);
00335 <font class="keywordflow">if</font> (nbConfiguration)
00336 {
00337 <font class="comment">// each precomp basis is created randomly;</font>
00338 <font class="keywordflow">for</font> (uint k = 0; k < nbConfiguration; ++k)
00339 {
00340 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>();
00341 <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>[k].Basis = CPlaneBasis(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
00342 <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>[k].Axis = <a class="code" href="namespaceNL3D.html#a421">MakeRandomUnitVect</a>();
00343 <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>[k].AngularVelocity = minAngularVelocity
00344 + (rand() % 20000) / 20000.f * (maxAngularVelocity - minAngularVelocity);
00345
00346 }
00347 <font class="comment">// we need to do this because nbConfs may have changed</font>
00348 <a class="code" href="classNL3D_1_1CPSFace.html#b4">fillIndexesInPrecompBasis</a>();
00349 }
00350 }
00351
<a name="l00353"></a><a class="code" href="classNL3D_1_1CPSFace.html#b4">00353</a> <font class="keywordtype">void</font> CPSFace::fillIndexesInPrecompBasis(<font class="keywordtype">void</font>)
00354 {
00355 <font class="keyword">const</font> uint32 nbConf = <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.size();
00356 <font class="keywordflow">if</font> (_Owner)
00357 {
00358 <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.resize( <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize() );
00359 }
00360 <font class="keywordflow">for</font> (std::vector<uint32>::iterator it = <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.end(); ++it)
00361 {
00362 *it = rand() % nbConf;
00363 }
00364 }
00365
<a name="l00367"></a><a class="code" href="classNL3D_1_1CPSFace.html#b1">00367</a> <font class="keywordtype">void</font> CPSFace::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00368 {
00369 CPSQuad::newElement(emitterLocated, emitterIndex);
00370 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b1">newPlaneBasisElement</a>(emitterLocated, emitterIndex);
00371 <font class="keyword">const</font> uint32 nbConf = <a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.size();
00372 <font class="keywordflow">if</font> (nbConf) <font class="comment">// do we use precomputed basis ?</font>
00373 {
00374 <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>[<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getNewElementIndex()] = rand() % nbConf;
00375 }
00376 }
00377
<a name="l00379"></a><a class="code" href="classNL3D_1_1CPSFace.html#b2">00379</a> <font class="keywordtype">void</font> CPSFace::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00380 {
00381 CPSQuad::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00382 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b2">deletePlaneBasisElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00383 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.size()) <font class="comment">// do we use precomputed basis ?</font>
00384 {
00385 <font class="comment">// replace ourself by the last element...</font>
00386 <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>[<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize() - 1];
00387 }
00388 }
00389
<a name="l00391"></a><a class="code" href="classNL3D_1_1CPSFace.html#b3">00391</a> <font class="keywordtype">void</font> CPSFace::resize(uint32 size)
00392 {
00393 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
00394 <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#b3">resizePlaneBasis</a>(size);
00395 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSFace.html#n2">_PrecompBasis</a>.size()) <font class="comment">// do we use precomputed basis ?</font>
00396 {
00397 <a class="code" href="classNL3D_1_1CPSFace.html#n3">_IndexInPrecompBasis</a>.resize(size);
00398 }
00399 CPSQuad::resize(size);
00400 }
00401
00402 } <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>
|