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
|
<!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=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/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>noise_3d.cpp</h1><a href="noise__3d_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2002 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 <font class="preprocessor">#include "<a class="code" href="noise__3d_8h.html">noise_3d.h</a>"</font>
00028 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00029
00030 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00031
00032 <font class="keyword">namespace </font>NL3D
00033 {
00034
00035 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00036"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a0">00036</a> CNoise3d::CNoise3d (IDriver *pDriver)
00037 {
00038 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a> = NULL;
00039 <a class="code" href="classNL3D_1_1CNoise3d.html#o14">_Driver</a> = pDriver;
00040 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> = 0;
00041 <a class="code" href="classNL3D_1_1CNoise3d.html#o15">_IsDriverSupportEnvCombine4</a> = <font class="keyword">true</font>;
00042 }
00043
00044 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00045"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a1">00045</a> CNoise3d::~CNoise3d ()
00046 {
00047 <font class="comment">// delete _Mem; // done by CTertureMem destructor</font>
00048 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>;
00049 <font class="keyword">delete</font> [] <a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>;
00050 }
00051
00052 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00053"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a2">00053</a> <font class="keywordtype">void</font> CNoise3d::init (uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint32 h, uint32 d)
00054 {
00055 uint32 i;
00056
00057 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>);
00058 h = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (h);
00059 d = <a class="code" href="namespaceNLMISC.html#a223">raiseToNextPowerOf2</a> (d);
00060 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> > 64) <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = 64;
00061 <font class="keywordflow">if</font> (h > 64) h = 64;
00062 <font class="keywordflow">if</font> (d > 64) d = 64;
00063 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> < 4) <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = 4;
00064 <font class="keywordflow">if</font> (h < 4) h = 4;
00065 <font class="keywordflow">if</font> (d < 4) d = 4;
00066 <a class="code" href="classNL3D_1_1CNoise3d.html#o0">_Width</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
00067 <a class="code" href="classNL3D_1_1CNoise3d.html#o1">_Height</a> = h;
00068 <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a> = d;
00069 uint32 vdpo2 = <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>);
00070
00071 <a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a> = 1 << (vdpo2 / 2);
00072 <font class="keywordflow">if</font> ((vdpo2 & 1) != 0)
00073 <a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a> = 2 << (vdpo2 / 2);
00074 <font class="keywordflow">else</font>
00075 <a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a> = 1 << (vdpo2 / 2);
00076
00077 <a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a> = 1.0f / <a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>;
00078 <a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a> = 1.0f / <a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>;
00079
00080 <a class="code" href="classNL3D_1_1CNoise3d.html#o5">_Mem</a> = <font class="keyword">new</font> uint8[<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*d];
00081
00082 <font class="comment">// Create initial noise</font>
00083 <font class="keywordflow">for</font> (i = 0; i < (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>*h*d); i++)
00084 <a class="code" href="classNL3D_1_1CNoise3d.html#o5">_Mem</a>[i] = (uint8)(256.0f*rand()/RAND_MAX);
00085
00086 <a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a> = <font class="keyword">new</font> CUV [<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>];
00087 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>; i++)
00088 {
00089 <a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[i].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a> = ((float)rand())/RAND_MAX;
00090 <a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[i].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a> = ((float)rand())/RAND_MAX;
00091 }
00092
00093 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a> = <font class="keyword">new</font> CTextureMem (<a class="code" href="classNL3D_1_1CNoise3d.html#o5">_Mem</a>, <a class="code" href="classNL3D_1_1CNoise3d.html#o0">_Width</a>*<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>*<a class="code" href="classNL3D_1_1CNoise3d.html#o1">_Height</a>*<a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>, <font class="keyword">true</font>, <font class="keyword">false</font>, <a class="code" href="classNL3D_1_1CNoise3d.html#o0">_Width</a>*<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>, <a class="code" href="classNL3D_1_1CNoise3d.html#o1">_Height</a>*<a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>,
00094 CBitmap::Alpha);
00095 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>->setWrapS(ITexture::Repeat);
00096 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>->setWrapT(ITexture::Repeat);
00097 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff);
00098 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>->touch();
00099 <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>->generate();
00100
00101 <font class="keywordflow">if</font> (_IsDriverSupportEnvCombine4)
00102 {
00103 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a> = <font class="keyword">new</font> CMaterial();
00104 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z551_0">initUnlit</a>();
00105 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#a0">setShader</a> (CMaterial::Cloud);
00106 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z541_0">setTexture</a> (0, <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>);
00107 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z541_0">setTexture</a> (1, <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>);
00108 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z547_0">setColor</a> (CRGBA(255,255,255,255));
00109 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z542_0">setBlend</a> (<font class="keyword">true</font>);
00110 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z542_1">setBlendFunc</a>(CMaterial::one, CMaterial::one);
00111 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z546_0">setZFunc</a> (CMaterial::always);
00112 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z546_1">setZWrite</a> (<font class="keyword">false</font>);
00113 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_0">setVertexFormat</a> (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
00114 CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag);
00115 }
00116 <font class="keywordflow">else</font>
00117 {
00118 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a> = <font class="keyword">new</font> CMaterial();
00119 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z551_0">initUnlit</a>();
00120 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#a0">setShader</a> (CMaterial::Normal);
00121 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z541_0">setTexture</a> (0, <a class="code" href="classNL3D_1_1CNoise3d.html#o6">_Tex</a>);
00122 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z547_0">setColor</a> (CRGBA(255,255,255,255));
00123 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z542_0">setBlend</a> (<font class="keyword">true</font>);
00124 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z542_1">setBlendFunc</a>(CMaterial::one, CMaterial::one);
00125 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z546_0">setZFunc</a> (CMaterial::always);
00126 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z546_1">setZWrite</a> (<font class="keyword">false</font>);
00127 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_0">setVertexFormat</a> (CVertexBuffer::PositionFlag | CVertexBuffer::PrimaryColorFlag |
00128 CVertexBuffer::TexCoord0Flag);
00129 }
00130 }
00131
00132 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00133"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a4">00133</a> <font class="keywordtype">void</font> CNoise3d::render2passes (CQuadUV &qc, <font class="keywordtype">float</font> wpos, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>)
00134 {
00135 <font class="comment">// For the moment we do it in 2 passes : because wpos is a position between slice we have to do :</font>
00136 <font class="comment">// [ At0*wpos+At1*(1-wpos) ] * alpha</font>
00137 <font class="comment">// this is done like that :</font>
00138 <font class="comment">// At0*[wpos*alpha] + At1*[(1-wpos)*alpha] </font>
00139
00140 wpos = fmodf (wpos, 1.0f);
00141 uint32 nSlice1 = (uint32)(wpos * <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>), nSlice2;
00142 <font class="keywordflow">if</font> (nSlice1 == (<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>-1))
00143 nSlice2 = 0;
00144 <font class="keywordflow">else</font>
00145 nSlice2 = 1 + nSlice1;
00146 <font class="comment">// If wpos is just on slice1 alpha must be one</font>
00147 <font class="keywordtype">float</font> alphaPos = 1.0f - <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>*(wpos - (((float)nSlice1) / <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>));
00148
00149 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> == <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a5">getNumVertices</a>())
00150 {
00151 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a4">setNumVertices</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>+8);
00152 }
00153
00154 uint32 nVSize = <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a9">getVertexSize</a> ();
00155 CVector *pVertices = (CVector*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_18">getVertexCoordPointer</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>);
00156 *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00157 *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00158 *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00159 *pVertices = qc.V3; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00160 *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00161 *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00162 *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00163 *pVertices = qc.V3;
00164
00165 CUV *pUV = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>, 0);
00166 *pUV = CUV(qc.Uv0.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv0.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00167 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00168 *pUV = CUV(qc.Uv1.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv1.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00169 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00170 *pUV = CUV(qc.Uv2.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv2.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00171 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00172 *pUV = CUV(qc.Uv3.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv3.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00173 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00174
00175 *pUV = CUV(qc.Uv0.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv0.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00176 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00177 *pUV = CUV(qc.Uv1.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv1.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00178 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00179 *pUV = CUV(qc.Uv2.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv2.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00180 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00181 *pUV = CUV(qc.Uv3.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv3.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00182
00183 uint8 finalAlpha = (uint8)(255*alphaPos*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>);
00184
00185 uint8 *pColA = (uint8*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_21">getColorPointer</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>) + 3;
00186 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00187 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00188 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00189 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00190
00191 finalAlpha = (uint8)(255*(1.0f-alphaPos)*<a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>);
00192
00193 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00194 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00195 *pColA = finalAlpha; pColA = ((uint8*)pColA) + nVSize;
00196 *pColA = finalAlpha;
00197
00198 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> += 8;
00199 }
00200
00201 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00202"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a3">00202</a> <font class="keywordtype">void</font> CNoise3d::render (CQuadUV &qc, <font class="keywordtype">float</font> wpos, <font class="keywordtype">float</font> intensity)
00203 {
00204 <font class="comment">// [ At0*wpos+At1*(1-wpos) ] * alpha</font>
00205
00206 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CNoise3d.html#o15">_IsDriverSupportEnvCombine4</a>)
00207 {
00208 <a class="code" href="classNL3D_1_1CNoise3d.html#a4">render2passes</a> (qc, wpos, intensity);
00209 <font class="keywordflow">return</font>;
00210 }
00211
00212 <a class="code" href="classNL3D_1_1CNoise3d.html#o7">_Intensity</a> = intensity;
00213
00214 wpos = wpos - floorf (wpos);
00215 uint32 nSlice1 = (uint32)(wpos * <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>), nSlice2;
00216 <font class="keywordflow">if</font> (nSlice1 == (<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>-1))
00217 nSlice2 = 0;
00218 <font class="keywordflow">else</font>
00219 nSlice2 = 1 + nSlice1;
00220 <font class="comment">// If wpos is just on slice1 alpha must be one</font>
00221 <font class="keywordtype">float</font> alphaPos = 1.0f - <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>*(wpos - (((float)nSlice1) / <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>));
00222
00223 uint8 nAlphaPos = (uint8)(255*alphaPos);
00224
00225 uint32 nVSize = <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a9">getVertexSize</a> ();
00226
00227 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> == <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a5">getNumVertices</a>())
00228 {
00229 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a4">setNumVertices</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>+4);
00230 }
00231
00232 CVector *pVertices = (CVector*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_18">getVertexCoordPointer</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>);
00233 *pVertices = qc.V0; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00234 *pVertices = qc.V1; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00235 *pVertices = qc.V2; pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00236 *pVertices = qc.V3;
00237
00238 CUV *pUV = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>, 0);
00239 *pUV = CUV(qc.Uv0.U/<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv0.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00240 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00241 *pUV = CUV(qc.Uv1.U/<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv1.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00242 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00243 *pUV = CUV(qc.Uv2.U/<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv2.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00244 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00245 *pUV = CUV(qc.Uv3.U/<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv3.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00246
00247 pUV = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>, 1);
00248 *pUV = CUV(qc.Uv0.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv0.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00249 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00250 *pUV = CUV(qc.Uv1.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv1.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00251 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00252 *pUV = CUV(qc.Uv2.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv2.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00253 pUV = (CUV*)( ((uint8*)pUV) + nVSize );
00254 *pUV = CUV(qc.Uv3.U*<a class="code" href="classNL3D_1_1CNoise3d.html#o9">_ScaleW</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>, qc.Uv3.V*<a class="code" href="classNL3D_1_1CNoise3d.html#o10">_ScaleH</a>+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>);
00255
00256 uint8 *pColA = (uint8*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_21">getColorPointer</a>(<a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>) + 3;
00257 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00258 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00259 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00260 *pColA = nAlphaPos;
00261
00262 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> += 4;
00263 }
00264
00265 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00266"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a5">00266</a> <font class="keywordtype">void</font> CNoise3d::renderGrid (uint32 nbw, uint32 nbh, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint32 h,
00267 <font class="keywordtype">float</font> UStart, <font class="keywordtype">float</font> VStart, <font class="keywordtype">float</font> WStart, <font class="keywordtype">float</font> dU, <font class="keywordtype">float</font> dV, <font class="keywordtype">float</font> dW, <font class="keywordtype">float</font> intensity)
00268 {
00269
00270 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CNoise3d.html#o15">_IsDriverSupportEnvCombine4</a>)
00271 {
00272 <a class="code" href="classNL3D_1_1CNoise3d.html#a6">renderGrid2passes</a> (nbw, nbh, <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, h, UStart, VStart, WStart, dU, dV, dW, intensity);
00273 <font class="keywordflow">return</font>;
00274 }
00275
00276 <a class="code" href="classNL3D_1_1CNoise3d.html#o7">_Intensity</a> = intensity;
00277
00278 uint32 i, j, nSlice1, nSlice2;
00279 <font class="keywordtype">float</font> wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
00280 CVector *pVertices;
00281 CUV *pUV0, *pUV1;
00282 uint8 *pColA, nAlphaPos;
00283 uint32 nVSize = <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a9">getVertexSize</a> ();
00284
00285 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a5">getNumVertices</a>() < nbw*nbh*4)
00286 {
00287 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a4">setNumVertices</a> (nbw*nbh*4);
00288 }
00289
00290 dU = (UStart+dU) /<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>;
00291 dV = (VStart+dV) /<a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>;
00292 UStart = UStart / <a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>;
00293 VStart = VStart / <a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>;
00294
00295 pVertices = (CVector*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_18">getVertexCoordPointer</a>(0);
00296 pUV0 = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (0, 0);
00297 pUV1 = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (0, 1);
00298 pColA = (uint8*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_21">getColorPointer</a>(0) + 3;
00299
00300 <font class="keywordflow">for</font> (j = 0; j < nbh; ++j)
00301 {
00302 <font class="keywordflow">for</font> (i = 0; i < nbw; ++i)
00303 {
00304 wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
00305 wpos = wpos - floorf (wpos);
00306 nSlice1 = (uint32)(wpos * <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>);
00307 <font class="keywordflow">if</font> (nSlice1 == (<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>-1))
00308 nSlice2 = 0;
00309 <font class="keywordflow">else</font>
00310 nSlice2 = 1 + nSlice1;
00311 <font class="comment">// If wpos is just on slice1 alpha must be one</font>
00312 nAlphaPos = (uint8)( 255*(1.0f - <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>*(wpos - (((float)nSlice1) / <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>))) );
00313
00314 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00315 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00316 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00317 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00318
00319 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00320 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00321 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00322 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00323
00324 pUV1->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV1->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
00325 pUV1->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV1->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
00326 pUV1->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV1->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
00327 pUV1->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV1->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV1 = (CUV*)( ((uint8*)pUV1) + nVSize );
00328
00329 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00330 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00331 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00332 *pColA = nAlphaPos; pColA = ((uint8*)pColA) + nVSize;
00333 }
00334 }
00335
00336 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> = nbw*nbh*4;
00337 }
00338
00339 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00340"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a6">00340</a> <font class="keywordtype">void</font> CNoise3d::renderGrid2passes (uint32 nbw, uint32 nbh, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, uint32 h,
00341 <font class="keywordtype">float</font> UStart, <font class="keywordtype">float</font> VStart, <font class="keywordtype">float</font> WStart, <font class="keywordtype">float</font> dU, <font class="keywordtype">float</font> dV, <font class="keywordtype">float</font> dW, <font class="keywordtype">float</font> intensity)
00342 {
00343 uint32 i, j, nSlice1, nSlice2;
00344 <font class="keywordtype">float</font> wpos, oneOverNbWNbH = 1.0f / (nbw*nbh);
00345 CVector *pVertices;
00346 CUV *pUV0;
00347 uint8 *pColA, nFinalAlpha;
00348 uint32 nVSize = <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a9">getVertexSize</a> ();
00349
00350 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a5">getNumVertices</a>() < 2*nbw*nbh*4)
00351 {
00352 <a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#a4">setNumVertices</a> (2*nbw*nbh*4);
00353 }
00354
00355 dU = (UStart+dU) /<a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>;
00356 dV = (VStart+dV) /<a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>;
00357 UStart = UStart / <a class="code" href="classNL3D_1_1CNoise3d.html#o3">_NbSliceW</a>;
00358 VStart = VStart / <a class="code" href="classNL3D_1_1CNoise3d.html#o4">_NbSliceH</a>;
00359
00360 pVertices = (CVector*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_18">getVertexCoordPointer</a>(0);
00361 pUV0 = (CUV*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_20">getTexCoordPointer</a> (0, 0);
00362 pColA = (uint8*)<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>.<a class="code" href="classNL3D_1_1CVertexBuffer.html#z899_21">getColorPointer</a>(0) + 3;
00363
00364 <font class="keywordflow">for</font> (j = 0; j < nbh; ++j)
00365 {
00366 <font class="keywordflow">for</font> (i = 0; i < nbw; ++i)
00367 {
00368 wpos = (float)WStart+dW*(i+(float)j*nbw)*oneOverNbWNbH;
00369 wpos = fmodf (wpos, 1.0f);
00370 nSlice1 = (uint32)(wpos * <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>);
00371 <font class="keywordflow">if</font> (nSlice1 == (<a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>-1))
00372 nSlice2 = 0;
00373 <font class="keywordflow">else</font>
00374 nSlice2 = 1 + nSlice1;
00375 <font class="comment">// If wpos is just on slice1 alpha must be one</font>
00376 <font class="keywordtype">float</font> alphaPos = 1.0f - <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>*(wpos - (((float)nSlice1) / <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>));
00377
00378 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00379 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00380 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00381 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00382 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00383 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)j*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00384 *pVertices = CVector((<font class="keywordtype">float</font>)(i+1)*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00385 *pVertices = CVector((<font class="keywordtype">float</font>)i*<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>, (<font class="keywordtype">float</font>)(j+1)*h, 0.0f); pVertices = (CVector*)( ((uint8*)pVertices) + nVSize );
00386
00387 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00388 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00389 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00390 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice1].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00391
00392 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00393 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = VStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00394 pUV0->U = dU+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00395 pUV0->U = UStart+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m0">U</a>; pUV0->V = dV+<a class="code" href="classNL3D_1_1CNoise3d.html#o8">_OffS</a>[nSlice2].<a class="code" href="classNLMISC_1_1CUV.html#m1">V</a>; pUV0 = (CUV*)( ((uint8*)pUV0) + nVSize );
00396
00397 nFinalAlpha = (uint8)(255*alphaPos*intensity);
00398
00399 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00400 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00401 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00402 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00403
00404 nFinalAlpha = (uint8)(255*(1.0f-alphaPos)*intensity);
00405
00406 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00407 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00408 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00409 *pColA = nFinalAlpha; pColA = ((uint8*)pColA) + nVSize;
00410 }
00411 }
00412 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> = 2*4*nbw*nbh;
00413 }
00414
00415 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00416"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a7">00416</a> <font class="keywordtype">void</font> CNoise3d::flush ()
00417 {
00418 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CNoise3d.html#o15">_IsDriverSupportEnvCombine4</a>)
00419 {
00420 <a class="code" href="classNL3D_1_1CNoise3d.html#a8">flush2passes</a> ();
00421 <font class="keywordflow">return</font>;
00422 }
00423
00424 <a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>-><a class="code" href="classNL3D_1_1CMaterial.html#z547_0">setColor</a>(CRGBA(0,0,0,(uint8)(255*<a class="code" href="classNL3D_1_1CNoise3d.html#o7">_Intensity</a>)));
00425 <a class="code" href="classNL3D_1_1CNoise3d.html#o14">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>);
00426 <a class="code" href="classNL3D_1_1CNoise3d.html#o14">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (*<a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>, 0, <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>/4);
00427 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> = 0;
00428 }
00429
00430 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00431"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a8">00431</a> <font class="keywordtype">void</font> CNoise3d::flush2passes ()
00432 {
00433 <a class="code" href="classNL3D_1_1CNoise3d.html#o14">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a38">activeVertexBuffer</a> (<a class="code" href="classNL3D_1_1CNoise3d.html#o12">_VertexBuffer</a>);
00434 <a class="code" href="classNL3D_1_1CNoise3d.html#o14">_Driver</a>-><a class="code" href="classNL3D_1_1IDriver.html#a45">renderQuads</a> (*<a class="code" href="classNL3D_1_1CNoise3d.html#o13">_Mat</a>, 0, <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a>/4);
00435 <a class="code" href="classNL3D_1_1CNoise3d.html#o11">_NbVertices</a> = 0;
00436 }
00437
00438 <font class="comment">// Accessors</font>
00439 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00440"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a9">00440</a> uint32 CNoise3d::getWidth ()
00441 {
00442 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CNoise3d.html#o0">_Width</a>;
00443 }
00444
00445 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00446"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a10">00446</a> uint32 CNoise3d::getHeight ()
00447 {
00448 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CNoise3d.html#o1">_Height</a>;
00449 }
00450
00451 <font class="comment">// ------------------------------------------------------------------------------------------------</font>
<a name="l00452"></a><a class="code" href="classNL3D_1_1CNoise3d.html#a11">00452</a> uint32 CNoise3d::getDepth ()
00453 {
00454 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CNoise3d.html#o2">_Depth</a>;
00455 }
00456
00457 } <font class="comment">// namespace NL3D</font>
00458
</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>
|