diff options
Diffstat (limited to 'docs/doxygen/nel/water__height__map_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/water__height__map_8cpp-source.html | 838 |
1 files changed, 838 insertions, 0 deletions
diff --git a/docs/doxygen/nel/water__height__map_8cpp-source.html b/docs/doxygen/nel/water__height__map_8cpp-source.html new file mode 100644 index 00000000..9ab72b56 --- /dev/null +++ b/docs/doxygen/nel/water__height__map_8cpp-source.html @@ -0,0 +1,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> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </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> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="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> + + +<!-- 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> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </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 <algorithm></font> +00033 <font class="preprocessor">#include <math.h></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 < <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> << 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 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> && (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>) < <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> && (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>) < <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> >= 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> >= 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> >= 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> >= 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 -> 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 < 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 < 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 < <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> < (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> > (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> < (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> < (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 < 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 < 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 < 0) deltaT = 0; +00239 <font class="keywordflow">if</font> (deltaT > <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 < <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 > 4); +00272 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> = size; +00273 <font class="keywordflow">for</font> (uint k = 0; k < <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> << 1, <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 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 <= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>)); +00287 <a class="code" href="debug_8h.html#a6">nlassert</a>(dY <= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>)); +00288 <a class="code" href="debug_8h.html#a6">nlassert</a>(sX <= (2 * <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a>)); +00289 <a class="code" href="debug_8h.html#a6">nlassert</a>(sY <= (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> <= 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> <= 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> <= 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> <= 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> << 1; +00299 <font class="keywordflow">if</font> (dY <= 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> = &<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 = &<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> = &<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 = &<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 < <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 &<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="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> << 1)); +00368 <font class="comment">//nlinfo("%d, %d, %d", (_CurrMap + (NumWaterMap - 1)) % NumWaterMap, _CurrMap, </font> +00369 <font class="keywordtype">float</font> *buf2 = &<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 = &<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 = &<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> << 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> <= 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> << 1)); +00409 <font class="keywordtype">float</font> *buf = &<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 = &_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> <= 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> << 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->x = buf[1] - buf[- 1];</font> +00428 <font class="comment"> ptGrad->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> > <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 > 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 < 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() & 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 < 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 < 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 < 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 < 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 < <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> > 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> >= 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> >= 0); +00538 uint sizex2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 1; +00539 +00540 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> < 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> <= 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> < 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> <= 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> > (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> > (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 = &*(<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> << 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> << 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 > 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> &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> << 1; +00583 <font class="keywordflow">for</font> (sint px = -radius + 1; px < radius; ++px) +00584 { +00585 <font class="keywordflow">for</font> (sint py = -radius + 1; py < 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) < sizeX2 +00588 && (uint) (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> + py - orgY) < 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 < 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> &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 < (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 1) +00616 && Y < (<a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 1) +00617 ) +00618 { +00619 <font class="keyword">const</font> uint sizex2 = <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> << 1; +00620 <a class="code" href="classNL3D_1_1CWaterHeightMap.html#u0">TFloatVect</a> &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> &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 = &<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> << 1; +00639 +00640 <font class="comment">// top and bottom</font> +00641 +00642 <font class="keywordtype">float</font> *up = &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> &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> &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> < <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o18">_Size</a> - 1 +00735 && (uint) yPos - <a class="code" href="classNL3D_1_1CWaterHeightMap.html#o13">_Y</a> < <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> << 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> </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> |