aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/water__height__map_8cpp-source.html
blob: 9ab72b5679d2c6f76f5c2fc72086b73d1a5c3c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
<!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="http://www.nevrax.org/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="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

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

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

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

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>water_height_map.cpp</h1><a href="water__height__map_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="water__height__map_8h.html">water_height_map.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="vector__2f_8h.html">nel/misc/vector_2f.h</a>"</font>
00032 <font class="preprocessor">#include &lt;algorithm&gt;</font>
00033 <font class="preprocessor">#include &lt;math.h&gt;</font>
00034 
00035 
00036 
00037 <font class="keyword">namespace </font>NL3D
00038 {
00039 
00040 <font class="comment">//===========================================================================================</font>
00041 
<a name="l00042"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a29">00042</a> CWaterHeightMap::CWaterHeightMap() : Date(-1),
00043                                                                          _WavesEnabled(false),
00044                                                                          _Damping(0.97f),
00045                                                                          _FilterWeight(4),
00046                                                                          _UnitSize(0.6f),
00047                                                                          _WaveIntensity(0),
00048                                                                          _WavePeriod(0),
00049                                                                          _WaveImpulsionRadius(3),
00050                                                                          _BorderWaves(true),
00051                                                                          _EmitEllapsedTime(0),
00052                                                                          _PropagateEllapsedTime(0),
00053                                                                          _PropagationTime(0.10f),
00054                                                                          _X(0),
00055                                                                          _Y(0),
00056                                                                          _NewX(0),
00057                                                                          _NewY(0),
00058                                                                          _CurrMap(0),
00059                                                                          _Size(0)
00060 {               
00061 }
00062 
00063 
00064 <font class="comment">//===========================================================================================</font>
00065 
<a name="l00066"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a31">00066</a> <font class="keywordtype">void</font>    CWaterHeightMap::setPropagationTime(<font class="keywordtype">float</font> time)
00067 {
00068         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a> = time;
00069         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a> = 0;
00070         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>; ++k)
00071         {       
00072                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c6">clearArea</a>(k, 0, 0, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1);
00073         }
00074 }
00075 
00076 <font class="comment">//===========================================================================================</font>
00077 
<a name="l00078"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c1">00078</a> <font class="keywordtype">void</font> CWaterHeightMap::updateUserPos()
00079 {
00080         <font class="keyword">const</font> sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a>;
00081         <font class="keyword">const</font> sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a>;
00082 
00083         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> != 0);
00084         <font class="keywordflow">if</font> ((uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> == <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> &amp;&amp; (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> == <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>) <font class="keywordflow">return</font>;
00085         <font class="keywordflow">if</font> ((uint) abs(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>) &lt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &amp;&amp; (uint) abs(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>) &lt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) <font class="comment">// are there common pixels with the previous location?</font>
00086         {
00087                 <font class="comment">// compute zone</font>
00088         
00089                 sint XDivSize;
00090                 <font class="keywordflow">if</font> ((sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> &gt;= 0) XDivSize = (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00091                 <font class="keywordflow">else</font> XDivSize = ((sint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> + 1) / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) - 1;
00092 
00093                 sint YDivSize;
00094                 <font class="keywordflow">if</font> ((sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> &gt;= 0) YDivSize = (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00095                 <font class="keywordflow">else</font> YDivSize = ((sint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> + 1) / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) - 1;
00096 
00097                 sint xDivSize;
00098                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &gt;= 0) xDivSize = (sint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00099                 <font class="keywordflow">else</font> xDivSize = ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1) / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) - 1;
00100 
00101                 sint yDivSize;
00102                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &gt;= 0) yDivSize = (sint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00103                 <font class="keywordflow">else</font> yDivSize = ((sint) (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + 1) / (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) - 1;
00104 
00105                 <font class="comment">// different zone -&gt; must decal datas</font>
00106                 <font class="keywordflow">if</font> (xDivSize != XDivSize || yDivSize != YDivSize)
00107                 {
00108                         sint left   = std::max(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>);
00109                         sint top    = std::max(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>);
00110                         sint right  = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, (sint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00111                         sint bottom = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, (sint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00112                         sint offsetX, offsetY;
00113                         <font class="keywordflow">if</font> (xDivSize != XDivSize) 
00114                         {
00115                                 offsetX = xDivSize &lt; XDivSize ?  <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> : -(sint)<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00116                         }
00117                         <font class="keywordflow">else</font>
00118                         {
00119                                 offsetX = 0;
00120                         }
00121 
00122                         <font class="keywordflow">if</font> (yDivSize != YDivSize) 
00123                         {
00124                                 offsetY = yDivSize &lt; YDivSize ?  <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> : -(sint)<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00125                         }
00126                         <font class="keywordflow">else</font>
00127                         {
00128                                 offsetY = 0;
00129                         }
00130 
00131                         sint orgX = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * XDivSize;
00132                         sint orgY = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * YDivSize;
00133                         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>; ++k)
00134                         {
00135                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c8">makeCpy</a>(k, (uint) (left - orgX + offsetX) , (uint) (top - orgY + offsetY),
00136                                                 (uint) (left - orgX), (uint) (top - orgY),
00137                                                 (uint) (right - left), (uint) (bottom - top));
00138                         }
00139                 }
00140                 
00141                 sint newOrgX = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * xDivSize;
00142                 sint newOrgY = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * yDivSize;
00143                 <font class="comment">// clear new area</font>
00144                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> == (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>)
00145                 {
00146                         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt; (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>)
00147                         {
00148                                 <font class="comment">// x, y, width, height</font>
00149                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00150                         }
00151                         <font class="keywordflow">else</font>
00152                         {
00153                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>);
00154                         }
00155                 }
00156                 <font class="keywordflow">else</font>
00157                 {
00158                         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &gt; (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>)
00159                         {
00160                                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> == (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>)
00161                                 {
00162                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00163                                 }
00164                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt; (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>)
00165                                 {
00166                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgX, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - newOrgY, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>));
00167                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00168                                 }
00169                                 <font class="keywordflow">else</font>
00170                                 {
00171                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>));
00172                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>);
00173                                 }
00174                         }
00175                         <font class="keywordflow">else</font>
00176                         {
00177                                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> == (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>)
00178                                 {
00179                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00180                                 }
00181                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt; (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>)
00182                                 {
00183                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00184                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>));
00185                                 }
00186                                 <font class="keywordflow">else</font>
00187                                 {
00188                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> -<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>));
00189                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - newOrgX, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - newOrgY, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>);
00190                                 }
00191                         }
00192                 }
00193                 
00194         }
00195         <font class="keywordflow">else</font>
00196         {
00197                 <font class="comment">// the new area has no common pixel's with the previous one</font>
00198                 <font class="comment">// clear the whole new area</font>
00199                 uint px = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00200                 uint py = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00201                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">clearZone</a>(px, py, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00202         }
00203 
00204         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> = (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00205         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> = (uint) <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00206 }
00207 
00208 
00209 
00210 <font class="comment">//===========================================================================================</font>
00211 
<a name="l00212"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c2">00212</a> <font class="keywordtype">void</font> CWaterHeightMap::animatePart(<font class="keywordtype">float</font> startTime, <font class="keywordtype">float</font> endTime)
00213 {
00214         <font class="keywordflow">if</font> (endTime &lt; 0.5f * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>)
00215         {
00216                 <font class="comment">// perform propagation</font>
00217                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c3">propagate</a>((uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * startTime / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>), (uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * endTime / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>));      
00218         }
00219         <font class="keywordflow">else</font>
00220         {
00221                 <font class="comment">//  end propagation and start filter</font>
00222                 <font class="keywordflow">if</font> (startTime &lt; 0.5f * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>)
00223                 {
00224                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c3">propagate</a>((uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * startTime / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>), <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);  
00225                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c4">filter</a>(0, (uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * (endTime / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a> - 0.5f)));
00226                 }
00227                 <font class="keywordflow">else</font>
00228                 {
00229                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c4">filter</a>((uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * (startTime  / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a> - 0.5f)), (uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * 2.f * (endTime  / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a> - 0.5f)));
00230                 }
00231         }
00232 }
00233 
00234 <font class="comment">//===========================================================================================</font>
00235 
<a name="l00236"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a0">00236</a> <font class="keywordtype">void</font> CWaterHeightMap::animate(<font class="keywordtype">float</font> deltaT)
00237 {       
00238         <font class="keywordflow">if</font> (deltaT &lt; 0) deltaT = 0;
00239         <font class="keywordflow">if</font> (deltaT &gt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>)
00240         {
00241                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c2">animatePart</a>(0, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>);
00242                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c5">swapBuffers</a>(deltaT);
00243                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a> = 0;
00244         }
00245         <font class="keywordflow">else</font>
00246         {
00247                 <font class="keyword">const</font> <font class="keywordtype">float</font> endTime   = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a> + deltaT;                
00248                 <font class="keyword">const</font> <font class="keywordtype">float</font> startTime = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a>;
00249 
00250                 <font class="keywordflow">if</font> (endTime &lt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>)
00251                 {
00252                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c2">animatePart</a>(startTime, endTime);
00253                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a> = endTime;
00254                 }
00255                 <font class="keywordflow">else</font>
00256                 {
00257                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c2">animatePart</a>(startTime, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o11">_PropagationTime</a>);
00258                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c5">swapBuffers</a>(deltaT);
00259                         <font class="comment">//animatePart(0, endTime - _PropagationTime);</font>
00260 
00261                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o10">_PropagateEllapsedTime</a> = 0 <font class="comment">/*endTime - _PropagationTime*/</font>;
00262                 }                               
00263         }
00264         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c0">animateWaves</a>(deltaT);
00265 }
00266 
00267 <font class="comment">//===========================================================================================</font>
00268 
<a name="l00269"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a1">00269</a> <font class="keywordtype">void</font>            CWaterHeightMap::setSize(uint32 size)
00270 {
00271         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &gt; 4);
00272         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>  = size;  
00273         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>; ++k)
00274         {
00275                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[k].resize(4 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00276                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c6">clearArea</a>(k, 0, 0, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1);
00277         }
00278         <font class="comment">//_Grad.resize(4 * _Size * _Size);              </font>
00279 }
00280 
00281 <font class="comment">//===========================================================================================</font>
00282 
<a name="l00283"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c8">00283</a> <font class="keywordtype">void</font>            CWaterHeightMap::makeCpy(uint buffer, uint dX, uint dY, uint sX, uint sY, uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
00284 {       
00285         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> == 0 || <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> == 0) <font class="keywordflow">return</font>;
00286         <a class="code" href="debug_8h.html#a6">nlassert</a>(dX &lt;= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00287         <a class="code" href="debug_8h.html#a6">nlassert</a>(dY &lt;= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00288         <a class="code" href="debug_8h.html#a6">nlassert</a>(sX &lt;= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00289         <a class="code" href="debug_8h.html#a6">nlassert</a>(sY &lt;= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>));
00290         <a class="code" href="debug_8h.html#a6">nlassert</a>(dX + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &lt;= 2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00291         <a class="code" href="debug_8h.html#a6">nlassert</a>(sX + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &lt;= 2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00292         <a class="code" href="debug_8h.html#a6">nlassert</a>(dY + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &lt;= 2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00293         <a class="code" href="debug_8h.html#a6">nlassert</a>(sY + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &lt;= 2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>);
00294         
00295         sint stepY;
00296         <font class="keywordtype">float</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, *dest;
00297 
00298         <font class="keyword">const</font> sint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00299         <font class="keywordflow">if</font> (dY  &lt;= sY)
00300         {
00301                 stepY = <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00302                 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>   =  &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[buffer][sX + sY * <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>];
00303                 dest  =  &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[buffer][dX + dY * <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>];
00304         }
00305         <font class="keywordflow">else</font>
00306         {
00307                 stepY = -<a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>;
00308                 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>   =  &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[buffer][sX + (sY + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - 1) * <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>];
00309                 dest  =  &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[buffer][dX + (dY + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - 1) * <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>];
00310         }
00311 
00312         sint k = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
00313         <font class="keywordflow">do</font>
00314         {
00315                 <font class="keywordflow">if</font> (dest &lt; <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>)
00316                 {
00317                         std::copy(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, dest);
00318                 }
00319                 <font class="keywordflow">else</font>
00320                 {
00321                         <font class="keywordtype">float</font> *rSrc  = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>  + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
00322                         <font class="keywordtype">float</font> *rDest = dest + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>;
00323                         <font class="keywordflow">do</font>
00324                         {
00325                                 --rSrc;
00326                                 --rDest;
00327                                 *rDest = *rSrc;
00328                         }
00329                         <font class="keywordflow">while</font> (rSrc != <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>);
00330                 }
00331                 <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>  += stepY;
00332                 dest += stepY;
00333         }
00334         <font class="keywordflow">while</font> (--k);
00335 }
00336 
00337 <font class="comment">//===========================================================================================</font>
00338 
<a name="l00339"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a3">00339</a> <font class="keywordtype">void</font>            CWaterHeightMap::setUserPos(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)
00340 {       
00341         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;      
00342         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;      
00343 }
00344 
00345 <font class="comment">//===========================================================================================</font>
00346 
<a name="l00347"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a4">00347</a> <font class="keywordtype">void</font>            CWaterHeightMap::getUserPos(sint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)<font class="keyword"> const</font>
00348 <font class="keyword"></font>{               
00349         <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = (sint) <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a>;
00350 }
00351 
00352 
00353 
00354 <font class="comment">//===========================================================================================</font>
00355 
<a name="l00356"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c3">00356</a> <font class="keywordtype">void</font>            CWaterHeightMap::propagate(uint start, uint end)
00357 {       
00358         start = std::max(1u, start);
00359         end   = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1), end);
00360         <font class="keyword">const</font> <font class="keywordtype">float</font> damping = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o2">_Damping</a>;
00361         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c9">clearBorder</a>(0);
00362         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c9">clearBorder</a>(1);
00363         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> != 0);
00364         sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00365         uint px = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00366         uint py = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00367         sint <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> = px + 1 + ((py + start) * (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1));   
00368         <font class="comment">//nlinfo("%d, %d, %d",  (_CurrMap + (NumWaterMap - 1)) % NumWaterMap,  _CurrMap, </font>
00369         <font class="keywordtype">float</font> *buf2 = &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[ (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + (<a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a> - 1)) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>][<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>];
00370         <font class="keywordtype">float</font> *buf1 = &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a>][<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>];  
00371         <font class="keywordtype">float</font> *dest = &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + 1) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>][<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>];
00372         
00373         <font class="keyword">const</font> sint  sizeX2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00374         <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = end - start;
00375         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt;= 0) <font class="keywordflow">return</font>;
00376         <font class="keywordflow">do</font>
00377         {
00378                 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 2;
00379                 <font class="keywordflow">do</font>
00380                 {
00381                         *dest   = damping * ( 0.5f * (buf1[1] + buf1[-1] + buf1[sizeX2] + buf1[- sizeX2]) - *buf2);                     
00382                         ++buf1;
00383                         ++buf2;
00384                         ++dest;
00385                 }
00386                 <font class="keywordflow">while</font> (--<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>);
00387                 buf1 = buf1 + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> + 2;
00388                 buf2 = buf2 + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> + 2;
00389                 dest = dest + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> + 2;
00390         }
00391         <font class="keywordflow">while</font> (--<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00392         
00393 }
00394 
00395 
00396 
00397 <font class="comment">//===========================================================================================</font>
00398 
<a name="l00399"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c4">00399</a> <font class="keywordtype">void</font>    CWaterHeightMap::filter(uint start, uint end)
00400 {       
00401         start = std::max(1u, start);
00402         end   = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1), end);
00403         <font class="keyword">const</font> <font class="keywordtype">float</font> blurCoeff = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o3">_FilterWeight</a>;
00404         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> != 0);
00405         sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00406         uint px = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00407         uint py = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00408         sint <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> = px + 1 + ((py + start) * (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1));
00409         <font class="keywordtype">float</font> *buf = &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[ (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + 1) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a> ][<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>];
00410         <font class="comment">//NLMISC::CVector2f *ptGrad = &amp;_Grad[offset];</font>
00411         <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = end - start;
00412         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt;= 0) <font class="keywordflow">return</font>;
00413         <font class="keyword">const</font> <font class="keywordtype">float</font> totalBlurCoeff = (1.f / (4.f + blurCoeff));
00414         <font class="keyword">const</font> sint  sizeX2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00415         <font class="keywordflow">do</font>
00416         {
00417                 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 2;
00418                 <font class="keywordflow">do</font>
00419                 {
00420                         *buf = totalBlurCoeff * (*buf * blurCoeff
00421                                                                                  + buf[1] 
00422                                                                                  + buf[-1]
00423                                                                                  + buf[sizeX2]
00424                                                                                  + buf[- sizeX2]
00425                                                                          );     
00426                         <font class="comment">// compute gradient</font>
00427                         <font class="comment">/*ptGrad-&gt;x = buf[1]                - buf[- 1];</font>
00428 <font class="comment">                        ptGrad-&gt;y = buf[sizeX2]     - buf[- sizeX2];*/</font>
00429 
00430                         ++buf;
00431                         <font class="comment">//++ptGrad;</font>
00432                 }
00433                 <font class="keywordflow">while</font> (--<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>);
00434                 buf    += <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> + 2;
00435                 <font class="comment">//ptGrad += _Size + 2;</font>
00436         }
00437         <font class="keywordflow">while</font> (--<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);    
00438 }
00439 
00440 <font class="comment">//===========================================================================================</font>
00441 
<a name="l00442"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c0">00442</a> <font class="keywordtype">void</font> CWaterHeightMap::animateWaves(<font class="keywordtype">float</font> deltaT)
00443 {
00444         <font class="keywordflow">if</font> (_WavesEnabled)
00445         {
00446                 uint numWaves;
00447                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o6">_WavePeriod</a> == 0)
00448                 {
00449                         numWaves = 1;
00450                 }
00451                 <font class="keywordflow">else</font>
00452                 {
00453                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o9">_EmitEllapsedTime</a> += deltaT;
00454                         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o9">_EmitEllapsedTime</a> &gt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o6">_WavePeriod</a>)
00455                         {
00456                                 numWaves = (uint) (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o9">_EmitEllapsedTime</a> / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o6">_WavePeriod</a>);
00457                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o9">_EmitEllapsedTime</a> -= numWaves * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o6">_WavePeriod</a>;
00458                                 <font class="keywordflow">if</font> (numWaves &gt; 10) numWaves = 10;
00459                         }
00460                         <font class="keywordflow">else</font>
00461                         {
00462                                 numWaves = 0;
00463                         }
00464                 }
00465                 
00466                 uint k;
00467                 <font class="comment">// generate automatic waves</font>
00468                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o8">_BorderWaves</a>)
00469                 {
00470                         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a> != 0)
00471                         {
00472                                 <font class="keywordflow">for</font> (k = 0; k &lt; numWaves; ++k)
00473                                 {
00474                                         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a> + rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a> + rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>);
00475                                 }
00476                         }
00477                 }
00478                 <font class="keywordflow">else</font>
00479                 {
00480                         <font class="keywordflow">switch</font>(rand() &amp; 3) <font class="comment">// choose a random border</font>
00481                         {
00482                                 <font class="keywordflow">case</font> 0: <font class="comment">// top border</font>
00483                                         <font class="keywordflow">for</font> (k = 0; k &lt; numWaves; ++k)
00484                                         {
00485                                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a> + (uint) rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>);
00486                                         }
00487                                 <font class="keywordflow">break</font>;
00488                                 <font class="keywordflow">case</font> 1: <font class="comment">// bottom border</font>
00489                                         <font class="keywordflow">for</font> (k = 0; k &lt; numWaves; ++k)
00490                                         {
00491                                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a> + (uint) rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>);
00492                                         }
00493                                 <font class="keywordflow">break</font>;
00494                                 <font class="keywordflow">case</font> 2: <font class="comment">// right border</font>
00495                                         <font class="keywordflow">for</font> (k = 0; k &lt; numWaves; ++k)
00496                                         {
00497                                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a> + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a> + (uint) rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>);
00498                                         }
00499                                 <font class="keywordflow">break</font>;
00500                                 <font class="keywordflow">case</font> 3: <font class="comment">// left border</font>
00501                                         <font class="keywordflow">for</font> (k = 0; k &lt; numWaves; ++k)
00502                                         {
00503                                                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o14">_NewX</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o15">_NewY</a> + (uint) rand() % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>);
00504                                         }
00505                                 <font class="keywordflow">break</font>;
00506                         }
00507         
00508                 }
00509         }
00510 }
00511 
00512 <font class="comment">//===========================================================================================</font>
00513 
<a name="l00514"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c5">00514</a> <font class="keywordtype">void</font> CWaterHeightMap::swapBuffers(<font class="keywordtype">float</font> deltaT)
00515 {
00516         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c1">updateUserPos</a>();
00517         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> = (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + 1) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>;
00518 }
00519 
00520 
00521 <font class="comment">//===========================================================================================</font>
00522 
<a name="l00523"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c7">00523</a> <font class="keywordtype">void</font> CWaterHeightMap::clearZone(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
00524 {
00525         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>; ++k)
00526         {
00527                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#c6">clearArea</a>(k, <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
00528         }
00529 }
00530 
00531 <font class="comment">//===========================================================================================</font>
00532 
<a name="l00533"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c6">00533</a> <font class="keywordtype">void</font> CWaterHeightMap::clearArea(uint8 currMap, sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
00534 {       
00535         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &gt; 1);
00536         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &gt;= 0);
00537         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &gt;= 0);
00538         uint sizex2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00539 
00540         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> &lt; 0)
00541         {               
00542                 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> += <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
00543                 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = 0;
00544                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &lt;= 0) <font class="keywordflow">return</font>;
00545         }
00546         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> &lt; 0)
00547         {
00548                 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> += <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
00549                 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> = 0;
00550                 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &lt;= 0) <font class="keywordflow">return</font>;
00551         }
00552         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> &gt; (sint) sizex2)
00553         {
00554                 <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> - (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a> - sizex2);
00555         }
00556 
00557         <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> &gt; (sint) sizex2)
00558         {
00559                 <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a> - sizex2);
00560         }
00561         
00562         <font class="keywordtype">float</font> *dest = &amp;*(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[  currMap  ].begin() + <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1) * <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
00563         <font class="keywordflow">do</font>
00564         {
00565                 std::fill(dest, dest + <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, 0.f);             
00566                 dest  += (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1);
00567         }
00568         <font class="keywordflow">while</font> (-- <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
00569 }
00570 
00571 
00572 
00573 <font class="comment">//===========================================================================================</font>
00574 
<a name="l00575"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">00575</a> <font class="keywordtype">void</font>    CWaterHeightMap::perturbate(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, sint radius, <font class="keywordtype">float</font> intensity)
00576 {
00577                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> != 0);
00578                 <a class="code" href="debug_8h.html#a6">nlassert</a>(radius &gt; 0);
00579                 sint orgX = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00580                 sint orgY = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00581                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#u0">TFloatVect</a> &amp;map = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + 1) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>];
00582                 <font class="keyword">const</font> uint sizeX2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00583                 <font class="keywordflow">for</font> (sint px = -radius + 1; px &lt; radius; ++px)
00584                 {
00585                         <font class="keywordflow">for</font> (sint py = -radius + 1; py &lt; radius; ++py)          
00586                         {       
00587                                 <font class="keywordflow">if</font> ((uint) (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + px - orgX) &lt; sizeX2 
00588                                         &amp;&amp; (uint) (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + py - orgY) &lt; sizeX2)
00589                                 {                                       
00590                                 
00591                                         <font class="keywordtype">float</font> dist = ((float) radius - sqrtf((<font class="keywordtype">float</font>) (px * px + py * py ))) / (float) radius;
00592                                         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = dist &lt; radius ? intensity * cosf(dist * (<font class="keywordtype">float</font>) NLMISC::Pi * 0.5f) : 0.f;
00593                                         map[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + px - orgX + sizeX2 * (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + py - orgY)] = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
00594                                 }
00595                         }
00596                 }
00597 }
00598 
00599 <font class="comment">//===========================================================================================</font>
00600 
<a name="l00601"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a6">00601</a> <font class="keywordtype">void</font>    CWaterHeightMap::perturbate(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &amp;pos, <font class="keywordtype">float</font> strenght, <font class="keywordtype">float</font> radius)
00602 {
00603         <font class="keyword">const</font> <font class="keywordtype">float</font> invUnitSize = 1.f / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o4">_UnitSize</a>;
00604         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a5">perturbate</a>((sint) (pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a> * invUnitSize), (sint) (pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a> * invUnitSize), (sint) radius, strenght);
00605 }
00606 
00607 <font class="comment">//===========================================================================================</font>
00608 
<a name="l00609"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a7">00609</a> <font class="keywordtype">void</font> CWaterHeightMap::perturbatePoint(sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="keywordtype">float</font> intensity)
00610 {       
00611         sint orgX = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00612         sint orgY = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00613         uint X = (uint) (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> - orgX);
00614         uint Y = (uint) (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> - orgY);     
00615         <font class="keywordflow">if</font> (X &lt; (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1)
00616                 &amp;&amp; Y &lt; (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1)
00617                 )
00618         {
00619                 <font class="keyword">const</font> uint sizex2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;         
00620                 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#u0">TFloatVect</a> &amp;map = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o17">_CurrMap</a> + 1) % <a class="code" href="namespaceNL3D.html#a300">NumWaterMap</a>];
00621                 map[X + sizex2 * Y] = intensity;                
00622         }
00623 }
00624 
00625 <font class="comment">//===========================================================================================</font>
00626 
<a name="l00627"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a8">00627</a> <font class="keywordtype">void</font>    CWaterHeightMap::perturbatePoint(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &amp;pos, <font class="keywordtype">float</font> strenght)
00628 {
00629         <font class="keyword">const</font> <font class="keywordtype">float</font> invUnitSize = 1.f / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o4">_UnitSize</a>;
00630         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a7">perturbatePoint</a>((sint) (pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a> * invUnitSize), (sint) (pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a> * invUnitSize), strenght);
00631 }
00632 
00633 <font class="comment">//===========================================================================================</font>
00634 
<a name="l00635"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#c9">00635</a> <font class="keywordtype">void</font>    CWaterHeightMap::clearBorder(uint currMap)
00636 {
00637         <font class="keywordtype">float</font> *map  = &amp;<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o16">_Map</a>[currMap][0];
00638         uint sizex2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00639 
00640         <font class="comment">// top and bottom</font>
00641 
00642         <font class="keywordtype">float</font> *up    = &amp;map[(<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>) + sizex2 * (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>)];
00643         <font class="keywordtype">float</font> *curr = up;
00644         <font class="keyword">const</font> <font class="keywordtype">float</font> *endUp = up + <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00645         <font class="keyword">const</font> uint  downOff  = (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1) * sizex2;
00646         <font class="keywordflow">do</font>
00647         {
00648                 *curr = curr[downOff] = 0.f;
00649                 ++curr;
00650         }
00651         <font class="keywordflow">while</font> (curr != endUp);
00652 
00653         <font class="comment">// right and left</font>
00654         curr  = up;
00655         <font class="keyword">const</font> <font class="keywordtype">float</font> *endLeft = up + downOff;
00656         <font class="keyword">const</font> uint  rightOff = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1;
00657         <font class="keywordflow">do</font>
00658         {
00659                 *curr = curr[rightOff] = 0.f;
00660                 curr += sizex2;
00661         }
00662         <font class="keywordflow">while</font> (curr != endLeft);
00663 }
00664 
00665 <font class="comment">//===========================================================================================</font>
00666 
<a name="l00667"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a15">00667</a> <font class="keywordtype">void</font> CWaterHeightMap::setWaves(<font class="keywordtype">float</font> intensity, <font class="keywordtype">float</font> period, uint radius, <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>)
00668 {
00669         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o5">_WaveIntensity</a>            = intensity;
00670         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o6">_WavePeriod</a>                       = period;
00671         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o7">_WaveImpulsionRadius</a>  = radius;
00672         <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o8">_BorderWaves</a>              = <a class="code" href="driver__opengl__extension__def_8h.html#a392">border</a>;
00673 
00674 }
00675 
00676 
00677 <font class="comment">//===========================================================================================</font>
00678 
<a name="l00679"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a26">00679</a> <font class="keywordtype">void</font> CWaterHeightMap::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)  <font class="keywordflow">throw</font>(NLMISC::EStream)
00680 {
00681         f.xmlPushBegin(<font class="stringliteral">"WaterHeightMap"</font>);                       
00682                 f.xmlSetAttrib (<font class="stringliteral">"NAME"</font>)                                 ;
00683                 f.serial (_Name);
00684         f.xmlPushEnd();
00685         (void)f.serialVersion(0);
00686         f.xmlSerial(_Size, <font class="stringliteral">"SIZE"</font>);
00687         <font class="keywordflow">if</font> (f.isReading())
00688         {
00689                 setSize(_Size);
00690         }
00691         f.xmlSerial(_Damping, <font class="stringliteral">"DAMPING"</font>);
00692         f.xmlSerial(_FilterWeight, <font class="stringliteral">"FILTER_WEIGHT"</font>);
00693         f.xmlSerial(_UnitSize, <font class="stringliteral">"WATER_UNIT_SIZE"</font>);      
00694         f.xmlSerial(_WavesEnabled, <font class="stringliteral">"WavesEnabled"</font>);
00695         <font class="keywordflow">if</font> (_WavesEnabled)
00696         {
00697                 f.xmlPush(<font class="stringliteral">"WavesParams"</font>);
00698                         f.xmlSerial(_WaveIntensity, <font class="stringliteral">"WAVE_INTENSITY"</font>);
00699                         f.xmlSerial(_WavePeriod, <font class="stringliteral">"WAVE_PERIOD"</font>);
00700                         f.xmlSerial(_WaveImpulsionRadius, <font class="stringliteral">"WAVE_IMPULSION_RADIUS"</font>);
00701                         f.xmlSerial(_BorderWaves, <font class="stringliteral">"BORDER_WAVES"</font>);
00702                         f.xmlSerial(_PropagationTime, <font class="stringliteral">"PROPAGATION_TIME"</font>);
00703                 f.xmlPop();
00704         }
00705         f.xmlPop();
00706 }
00707 
00708 
00709 
00710 
00711 <font class="comment">//*** perform a bilinear on 4 values</font>
00712 <font class="comment">//   0---1</font>
00713 <font class="comment">//   |   |</font>
00714 <font class="comment">//   3---2</font>
00715 <font class="keyword">static</font> <font class="keywordtype">float</font> <font class="keyword">inline</font> <a class="code" href="namespaceNL3D.html#a475">BilinFilter</a>(<font class="keywordtype">float</font> v0, <font class="keywordtype">float</font> v1, <font class="keywordtype">float</font> v2, <font class="keywordtype">float</font> v3, <font class="keywordtype">float</font> u, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
00716 {
00717         <font class="keyword">const</font> <font class="keywordtype">float</font> g = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * v3 + (1.f - <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) * v0;
00718         <font class="keyword">const</font> <font class="keywordtype">float</font> h = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> * v2 + (1.f - <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) * v1;
00719         <font class="keywordflow">return</font> u * h + (1.f - u) * g;
00720 }
00721 
00722 
00723 
00724 <font class="comment">//===========================================================================================</font>
00725 
<a name="l00726"></a><a class="code" href="classNL3D_1_1CWaterHeightMap.html#a9">00726</a> <font class="keywordtype">float</font>   CWaterHeightMap::getHeight(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &amp;pos)
00727 {
00728         <font class="keyword">const</font> <font class="keywordtype">float</font> invUnitSize = 1.f / <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o4">_UnitSize</a>;
00729         
00730         <font class="keyword">const</font> <font class="keywordtype">float</font> xPos = invUnitSize * pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a>; <font class="comment">// position in map space</font>
00731         <font class="keyword">const</font> <font class="keywordtype">float</font> yPos = invUnitSize * pos.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a>; <font class="comment">// position in map space</font>
00732 
00733         
00734         <font class="keywordflow">if</font> ((uint) xPos - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> &lt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1
00735                 &amp;&amp; (uint) yPos - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> &lt; <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1
00736                 )
00737 
00738         {
00739 
00740                 <font class="keyword">const</font> sint orgX = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o12">_X</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00741                 <font class="keyword">const</font> sint orgY = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> % <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>;
00742                 <font class="keyword">const</font> uint sizeX2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> &lt;&lt; 1;
00743 
00744         
00745                 <font class="keyword">const</font> sint  fxPos = (sint) floorf(xPos); 
00746                 <font class="keyword">const</font> sint  fyPos = (sint) floorf(yPos); 
00747 
00748         
00749                         
00750                         <font class="keyword">const</font> <font class="keywordtype">float</font> deltaU        = xPos - fxPos;
00751                         <font class="keyword">const</font> <font class="keywordtype">float</font> deltaV        = yPos - fyPos;
00752                         <font class="keyword">const</font> uint  <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>        = (uint) fxPos - orgX + sizeX2 * ( (uint) fyPos - orgY);
00753                         <font class="keyword">const</font> <font class="keywordtype">float</font> lambda        = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a12">getBufferRatio</a>();
00754                         <font class="keyword">const</font> <font class="keywordtype">float</font> *map1     = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a11">getPrevPointer</a>();
00755                         <font class="keyword">const</font> <font class="keywordtype">float</font> *map2     = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#a10">getPointer</a>();
00756 
00757                         <font class="keywordflow">return</font> <a class="code" href="namespaceNL3D.html#a475">BilinFilter</a>(lambda * map2[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>]                          + (1.f - lambda) * map1[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>        ],                        <font class="comment">// top left</font>
00758                                                            lambda * map2[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + 1]              + (1.f - lambda) * map1[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + 1],            <font class="comment">// top right</font>
00759                                                            lambda * map2[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + sizeX2 + 1] + (1.f - lambda) * map1[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + sizeX2 + 1], <font class="comment">// bottom right</font>
00760                                                            lambda * map2[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + sizeX2 ]    + (1.f - lambda) * map1[<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> + sizeX2 ],          <font class="comment">// bottom left</font>
00761                                                            deltaU,
00762                                                            deltaV
00763                                                            );
00764         }                                               
00765         <font class="keywordflow">else</font> <font class="keywordflow">return</font> 0;
00766 
00767 }
00768 
00769 } <font class="comment">// NL3D</font>
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>