aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/noise__value_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/noise__value_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/noise__value_8cpp-source.html414
1 files changed, 414 insertions, 0 deletions
diff --git a/docs/doxygen/nel/noise__value_8cpp-source.html b/docs/doxygen/nel/noise__value_8cpp-source.html
new file mode 100644
index 00000000..14ce02b9
--- /dev/null
+++ b/docs/doxygen/nel/noise__value_8cpp-source.html
@@ -0,0 +1,414 @@
+<!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>noise_value.cpp</h1><a href="noise__value_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
+00027
+00028 <font class="preprocessor">#include "<a class="code" href="noise__value_8h.html">3d/noise_value.h</a>"</font>
+00029 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
+00030
+00031 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00032
+00033 <font class="keyword">namespace </font>NL3D
+00034 {
+00035
+00036
+00037 <font class="comment">// 3 level: best quality/speed ratio.</font>
+<a name="l00038"></a><a class="code" href="noise__value_8cpp.html#a0">00038</a> <font class="preprocessor">#define NL3D_NOISE_LEVEL 3</font>
+<a name="l00039"></a><a class="code" href="noise__value_8cpp.html#a1">00039</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_NOISE_GRID_SIZE_SHIFT 5</font>
+<a name="l00040"></a><a class="code" href="noise__value_8cpp.html#a2">00040</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_NOISE_GRID_SIZE (1&lt;&lt;NL3D_NOISE_GRID_SIZE_SHIFT)</font>
+00041 <font class="preprocessor"></font><font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a162">NL3D_OO255</a>= 1.0f / 255;
+00042
+00043 <font class="comment">// ***************************************************************************</font>
+00044 <font class="comment">// ***************************************************************************</font>
+00045 <font class="comment">// ***************************************************************************</font>
+00046
+00047 <font class="comment">// ***************************************************************************</font>
+<a name="l00049"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html">00049</a> <font class="comment">class CRandomGrid3D</font>
+00050 {
+00051 <font class="keyword">public</font>:
+00052
+00053 <font class="comment">// generate a random grid, with same seed.</font>
+<a name="l00054"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#a0">00054</a> CRandomGrid3D()
+00055 {
+00056 <font class="comment">//seed</font>
+00057 srand(0);
+00058
+00059 <font class="comment">// init the grid</font>
+00060 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>&lt;<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>++)
+00061 {
+00062 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&lt;<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+00063 {
+00064 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&lt;<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+00065 {
+00066 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= <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>&lt;&lt;<a class="code" href="noise__value_8cpp.html#a1">NL3D_NOISE_GRID_SIZE_SHIFT</a>) + (<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>&lt;&lt;(<a class="code" href="noise__value_8cpp.html#a1">NL3D_NOISE_GRID_SIZE_SHIFT</a>*2));
+00067 <font class="comment">// take higher bits of rand gives better result.</font>
+00068 uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= rand() &gt;&gt; 5;
+00069 _Texture3d[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>]= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>&amp;255;
+00070 }
+00071 }
+00072 }
+00073
+00074 <font class="comment">// init sizes.</font>
+00075 uint i;
+00076 <font class="comment">// sum of sizes must be 1, and each level must be /2.</font>
+00077 <font class="keywordtype">float</font> sizeSum=0;
+00078 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>; i++)
+00079 {
+00080 _Sizes[i]= 1.0f / (1&lt;&lt;i);
+00081 sizeSum+= _Sizes[i];
+00082 }
+00083 <font class="comment">// normalize</font>
+00084 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>; i++)
+00085 {
+00086 _Sizes[i]/= sizeSum;
+00087 }
+00088
+00089 <font class="comment">// init LevelPhases.</font>
+00090 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>; i++)
+00091 {
+00092 _LevelPhase[i].x= <a class="code" href="namespaceNLMISC.html#a212">frand</a>(<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>);
+00093 _LevelPhase[i].y= <a class="code" href="namespaceNLMISC.html#a212">frand</a>(<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>);
+00094 _LevelPhase[i].z= <a class="code" href="namespaceNLMISC.html#a212">frand</a>(<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>);
+00095 }
+00096 <font class="comment">// not for level 0.</font>
+00097 _LevelPhase[0]= CVector::Null;
+00098 }
+00099
+00100 <font class="comment">// x/y/z are use to lookup directly in the grid 3D.</font>
+<a name="l00101"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#d0">00101</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">float</font> evalNearest(<font class="keyword">const</font> CVector &amp;pos)
+00102 {
+00103 <font class="comment">// compute integer part.</font>
+00104 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.x);
+00105 sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.y);
+00106 sint <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.z);
+00107 <font class="comment">// index in texture.</font>
+00108 uint ux= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00109 uint uy= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00110 uint uz= <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00111
+00112 <font class="comment">// read the texture.</font>
+00113 <font class="keywordtype">float</font> turb= lookup(ux,uy,uz);
+00114
+00115 <font class="keywordflow">return</font> turb*<a class="code" href="namespaceNL3D.html#a162">NL3D_OO255</a>;
+00116 }
+00117
+00118 <font class="comment">// x/y/z are use to lookup directly in the grid 3D.</font>
+<a name="l00119"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#d1">00119</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">float</font> evalBiLinear(<font class="keyword">const</font> CVector &amp;pos)
+00120 {
+00121 <font class="comment">// compute integer part.</font>
+00122 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.x);
+00123 sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.y);
+00124 sint <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(pos.z);
+00125 <font class="comment">// index in texture.</font>
+00126 uint ux= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00127 uint uy= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00128 uint uz= <a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00129 uint ux2= (<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00130 uint uy2= (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00131 uint uz2= (<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>+1)&amp; (<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>-1);
+00132 <font class="comment">// delta.</font>
+00133 <font class="keywordtype">float</font> dx2;
+00134 <font class="keywordtype">float</font> dy2;
+00135 <font class="keywordtype">float</font> dz2;
+00136 easeInEaseOut(dx2, pos.x-<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>);
+00137 easeInEaseOut(dy2, pos.y-<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
+00138 easeInEaseOut(dz2, pos.z-<a class="code" href="driver__opengl__extension__def_8h.html#a366">z</a>);
+00139 <font class="keywordtype">float</font> dx= 1-dx2;
+00140 <font class="keywordtype">float</font> dy= 1-dy2;
+00141 <font class="keywordtype">float</font> dz= 1-dz2;
+00142 <font class="comment">// TriLinear in texture3D.</font>
+00143 <font class="keywordtype">float</font> turb=0;
+00144 <font class="keywordtype">float</font> dxdy= dx*dy;
+00145 turb+= lookup(ux,uy,uz)* dxdy*dz;
+00146 turb+= lookup(ux,uy,uz2)* dxdy*dz2;
+00147 <font class="keywordtype">float</font> dxdy2= dx*dy2;
+00148 turb+= lookup(ux,uy2,uz)* dxdy2*dz;
+00149 turb+= lookup(ux,uy2,uz2)* dxdy2*dz2;
+00150 <font class="keywordtype">float</font> dx2dy= dx2*dy;
+00151 turb+= lookup(ux2,uy,uz)* dx2dy*dz;
+00152 turb+= lookup(ux2,uy,uz2)* dx2dy*dz2;
+00153 <font class="keywordtype">float</font> dx2dy2= dx2*dy2;
+00154 turb+= lookup(ux2,uy2,uz)* dx2dy2*dz;
+00155 turb+= lookup(ux2,uy2,uz2)* dx2dy2*dz2;
+00156
+00157 <font class="comment">// End!</font>
+00158 <font class="keywordflow">return</font> turb*<a class="code" href="namespaceNL3D.html#a162">NL3D_OO255</a>;
+00159 }
+00160
+00161
+00162 <font class="comment">// get size according to level</font>
+<a name="l00163"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#d2">00163</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">float</font> getLevelSize(uint <a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>)
+00164 {
+00165 <font class="keywordflow">return</font> _Sizes[<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>];
+00166 }
+00167
+00168 <font class="comment">// get an additional level phase.</font>
+<a name="l00169"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#d3">00169</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keyword">const</font> CVector &amp;getLevelPhase(uint <a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>)
+00170 {
+00171 <font class="keywordflow">return</font> _LevelPhase[<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>];
+00172 }
+00173
+00174
+00175 <font class="comment">// **************</font>
+00176 <font class="keyword">private</font>:
+00177
+00178 <font class="keyword">static</font> uint8 _Texture3d[<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>*<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>*<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>];
+00179 <font class="keyword">static</font> <font class="keywordtype">float</font> _Sizes[<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>];
+00180 <font class="keyword">static</font> CVector _LevelPhase[<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>];
+00181
+00182
+00183 <font class="comment">// lookup with no mod.</font>
+<a name="l00184"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#f0">00184</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">float</font> lookup(uint ux, uint uy, uint uz)
+00185 {
+00186 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= ux + (uy&lt;&lt;<a class="code" href="noise__value_8cpp.html#a1">NL3D_NOISE_GRID_SIZE_SHIFT</a>) + (uz&lt;&lt;(<a class="code" href="noise__value_8cpp.html#a1">NL3D_NOISE_GRID_SIZE_SHIFT</a>*2));
+00187 <font class="keywordflow">return</font> _Texture3d[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>];
+00188 }
+00189
+00190 <font class="comment">// easineasout</font>
+<a name="l00191"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#f1">00191</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> easeInEaseOut(<font class="keywordtype">float</font> &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>)
+00192 {
+00193 <font class="comment">// cubic such that f(0)=0, f'(0)=0, f(1)=1, f'(1)=0.</font>
+00194 <font class="keywordtype">float</font> x2=<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+00195 <font class="keywordtype">float</font> x3=x2*<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>;
+00196 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= -2*x3 + 3*x2;
+00197 }
+00198
+00199 };
+00200
+00201
+<a name="l00202"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#r0">00202</a> uint8 CRandomGrid3D::_Texture3d[<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>*<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>*<a class="code" href="noise__value_8cpp.html#a2">NL3D_NOISE_GRID_SIZE</a>];
+<a name="l00203"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#r1">00203</a> <font class="keywordtype">float</font> CRandomGrid3D::_Sizes[<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>];
+<a name="l00204"></a><a class="code" href="classNL3D_1_1CRandomGrid3D.html#r2">00204</a> CVector CRandomGrid3D::_LevelPhase[<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>];
+00205
+00206 <font class="comment">// just to init the static arrays.</font>
+00207 <font class="keyword">static</font> CRandomGrid3D <a class="code" href="namespaceNL3D.html#a163">NL3D_RandomGrid3D</a>;
+00208
+00209
+00210 <font class="comment">// ***************************************************************************</font>
+00211 <font class="comment">// ***************************************************************************</font>
+00212 <font class="comment">// ***************************************************************************</font>
+00213
+00214
+00215 <font class="comment">// ***************************************************************************</font>
+<a name="l00216"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#c1">00216</a> <font class="keywordtype">float</font> CNoiseValue::evalRandom(<font class="keyword">const</font> CVector &amp;pos)<font class="keyword"> const</font>
+00217 <font class="keyword"></font>{
+00218 <font class="keywordflow">return</font> CRandomGrid3D::evalNearest(pos);
+00219 }
+00220
+00221
+00222 <font class="comment">// ***************************************************************************</font>
+<a name="l00223"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#c0">00223</a> <font class="keywordtype">float</font> CNoiseValue::noise(<font class="keyword">const</font> CVector &amp;pos)<font class="keyword"> const</font>
+00224 <font class="keyword"></font>{
+00225 <font class="comment">// eval "fractaly".</font>
+00226 <font class="keywordtype">float</font> turb;
+00227
+00228 <font class="preprocessor">#if (NL3D_NOISE_LEVEL != 3)</font>
+00229 <font class="preprocessor"></font> CVector vd= pos;
+00230 turb=0;
+00231 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>&lt;<a class="code" href="noise__value_8cpp.html#a0">NL3D_NOISE_LEVEL</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>++)
+00232 {
+00233 <font class="comment">// Add the influence of the ith level.</font>
+00234 turb+= CRandomGrid3D::getLevelSize(<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>) *
+00235 CRandomGrid3D::evalBiLinear(vd + CRandomGrid3D::getLevelPhase(<a class="code" href="driver__opengl__extension__def_8h.html#a387">level</a>) );
+00236 <font class="comment">// Next level at higher frequency</font>
+00237 vd*= 2;
+00238 }
+00239 <font class="preprocessor">#else</font>
+00240 <font class="preprocessor"></font> <font class="comment">// special case. unrolled loop.</font>
+00241 <font class="comment">// level 0 has no phase.</font>
+00242 turb= CRandomGrid3D::getLevelSize(0) *
+00243 CRandomGrid3D::evalBiLinear(pos);
+00244 <font class="comment">// level 1</font>
+00245 turb+= CRandomGrid3D::getLevelSize(1) *
+00246 CRandomGrid3D::evalBiLinear(pos*2 + CRandomGrid3D::getLevelPhase(1) );
+00247 <font class="comment">// level 2</font>
+00248 turb+= CRandomGrid3D::getLevelSize(2) *
+00249 CRandomGrid3D::evalBiLinear(pos*4 + CRandomGrid3D::getLevelPhase(2) );
+00250 <font class="preprocessor">#endif</font>
+00251 <font class="preprocessor"></font>
+00252 <font class="keywordflow">return</font> turb;
+00253 }
+00254
+00255
+00256
+00257 <font class="comment">// ***************************************************************************</font>
+<a name="l00258"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#a0">00258</a> CNoiseValue::CNoiseValue()
+00259 {
+00260 <a class="code" href="classNL3D_1_1CNoiseValue.html#m0">Abs</a>= 0;
+00261 <a class="code" href="classNL3D_1_1CNoiseValue.html#m1">Rand</a>= 1;
+00262 <a class="code" href="classNL3D_1_1CNoiseValue.html#m2">Frequency</a>= 1;
+00263 }
+00264
+00265
+00266 <font class="comment">// ***************************************************************************</font>
+<a name="l00267"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#a1">00267</a> CNoiseValue::CNoiseValue(<font class="keywordtype">float</font> abs, <font class="keywordtype">float</font> rand, <font class="keywordtype">float</font> freq)
+00268 {
+00269 <a class="code" href="classNL3D_1_1CNoiseValue.html#m0">Abs</a>= abs;
+00270 <a class="code" href="classNL3D_1_1CNoiseValue.html#m1">Rand</a>= rand;
+00271 <a class="code" href="classNL3D_1_1CNoiseValue.html#m2">Frequency</a>= freq;
+00272 }
+00273
+00274
+00275 <font class="comment">// ***************************************************************************</font>
+<a name="l00276"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#a2">00276</a> <font class="keywordtype">float</font> CNoiseValue::eval(<font class="keyword">const</font> CVector &amp;posInWorld)<font class="keyword"> const</font>
+00277 <font class="keyword"></font>{
+00278 <font class="comment">// A single cube in the Grid3d correspond to Frequency==1.</font>
+00279 <font class="comment">// So enlarging size of the grid3d do not affect the frequency aspect.</font>
+00280 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CNoiseValue.html#m0">Abs</a> + <a class="code" href="classNL3D_1_1CNoiseValue.html#m1">Rand</a> * <a class="code" href="classNL3D_1_1CNoiseValue.html#c0">noise</a>(posInWorld*<a class="code" href="classNL3D_1_1CNoiseValue.html#m2">Frequency</a>);
+00281 }
+00282
+00283
+00284 <font class="comment">// ***************************************************************************</font>
+<a name="l00285"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#a3">00285</a> <font class="keywordtype">float</font> CNoiseValue::evalOneLevelRandom(<font class="keyword">const</font> CVector &amp;posInWorld)<font class="keyword"> const</font>
+00286 <font class="keyword"></font>{
+00287 <font class="comment">// A single cube in the Grid3d correspond to Frequency==1.</font>
+00288 <font class="comment">// So enlarging size of the grid3d do not affect the frequency aspect.</font>
+00289 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CNoiseValue.html#m0">Abs</a> + <a class="code" href="classNL3D_1_1CNoiseValue.html#m1">Rand</a> * <a class="code" href="classNL3D_1_1CNoiseValue.html#c1">evalRandom</a>(posInWorld*<a class="code" href="classNL3D_1_1CNoiseValue.html#m2">Frequency</a>);
+00290 }
+00291
+00292
+00293 <font class="comment">// ***************************************************************************</font>
+<a name="l00294"></a><a class="code" href="classNL3D_1_1CNoiseValue.html#a4">00294</a> <font class="keywordtype">void</font> CNoiseValue::serial(IStream &amp;f)
+00295 {
+00296 (void)f.serialVersion(0);
+00297 f.serial(<a class="code" href="classNL3D_1_1CNoiseValue.html#m0">Abs</a>);
+00298 f.serial(<a class="code" href="classNL3D_1_1CNoiseValue.html#m1">Rand</a>);
+00299 f.serial(<a class="code" href="classNL3D_1_1CNoiseValue.html#m2">Frequency</a>);
+00300 }
+00301
+00302
+00303 <font class="comment">// ***************************************************************************</font>
+00304 <font class="comment">// ***************************************************************************</font>
+00305 <font class="comment">// ***************************************************************************</font>
+00306
+00307
+00308 <font class="comment">// ***************************************************************************</font>
+<a name="l00309"></a><a class="code" href="classNL3D_1_1CNoiseColorGradient.html#a0">00309</a> <font class="keywordtype">void</font> CNoiseColorGradient::eval(<font class="keyword">const</font> CVector &amp;posInWorld, CRGBAF &amp;result)<font class="keyword"> const</font>
+00310 <font class="keyword"></font>{
+00311 <font class="comment">// test if not null grads.</font>
+00312 uint nGrads= <a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m1">Gradients</a>.size();
+00313 <font class="keywordflow">if</font>(nGrads==0)
+00314 <font class="keywordflow">return</font>;
+00315 <font class="comment">// if only one color, easy</font>
+00316 <font class="keywordflow">if</font>(nGrads==1)
+00317 {
+00318 result= <a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m1">Gradients</a>[0];
+00319 }
+00320 <font class="keywordflow">else</font>
+00321 {
+00322 <font class="comment">// eval noise</font>
+00323 <font class="keywordtype">float</font> f= <a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m0">NoiseValue</a>.eval(posInWorld) * (nGrads-1);
+00324 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(f, 0.f, (<font class="keywordtype">float</font>)(nGrads-1));
+00325 <font class="comment">// look up in table of gradients.</font>
+00326 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(f);
+00327 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, 0U, nGrads-2);
+00328 <font class="comment">// fractionnal part.</font>
+00329 f= f-<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>;
+00330 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(f, 0, 1);
+00331 <font class="comment">// interpolate the gradient.</font>
+00332 result= <a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m1">Gradients</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>]*(1-f) + <a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m1">Gradients</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>+1]*f;
+00333 }
+00334 }
+00335
+00336 <font class="comment">// ***************************************************************************</font>
+<a name="l00337"></a><a class="code" href="classNL3D_1_1CNoiseColorGradient.html#a1">00337</a> <font class="keywordtype">void</font> CNoiseColorGradient::serial(IStream &amp;f)
+00338 {
+00339 (void)f.serialVersion(0);
+00340 f.serial(<a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m0">NoiseValue</a>);
+00341 f.serialCont(<a class="code" href="classNL3D_1_1CNoiseColorGradient.html#m1">Gradients</a>);
+00342 }
+00343
+00344
+00345
+00346 } <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>