diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/water__shape_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/water__shape_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/water__shape_8cpp-source.html | 749 |
1 files changed, 749 insertions, 0 deletions
diff --git a/docs/doxygen/nel/water__shape_8cpp-source.html b/docs/doxygen/nel/water__shape_8cpp-source.html new file mode 100644 index 00000000..961b83b6 --- /dev/null +++ b/docs/doxygen/nel/water__shape_8cpp-source.html @@ -0,0 +1,749 @@ +<!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_shape.cpp</h1><a href="water__shape_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__shape_8h.html">3d/water_shape.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="water__model_8h.html">3d/water_model.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="texture__bump_8h.html">3d/texture_bump.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="texture__blend_8h.html">3d/texture_blend.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="water__pool__manager_8h.html">3d/water_pool_manager.h</a>"</font> +00035 <font class="preprocessor">#include "<a class="code" href="water__height__map_8h.html">3d/water_height_map.h</a>"</font> +00036 <font class="preprocessor">#include <memory></font> +00037 +00038 +00039 <font class="keyword">namespace </font>NL3D { +00040 +00041 +00042 +00043 +00044 <font class="comment">// globals</font> +00045 +00046 +00047 +00048 <font class="comment">// common start for Water vertex programs</font> +00061 <font class="comment"></font><font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a301">WaterVPStartCode</a> = +00062 <font class="stringliteral">"!!VP1.0\n\</font> +00063 <font class="stringliteral"> ADD R1, c[7], -v[0]; #r1 = eye - vertex \n\</font> +00064 <font class="stringliteral"> DP3 R2, R1, R1; #r1 = eye - vertex, r2 = (eye - vertex)² \n\</font> +00065 <font class="stringliteral"> MAX R2, R2, c[16]; # avoid imprecision around 0 \n\</font> +00066 <font class="stringliteral"> RSQ R2, R2.x; #r1 = eye - vertex, r2 = 1/d(eye, vertex) \n\</font> +00067 <font class="stringliteral"> RCP R3, R2.x; \n\</font> +00068 <font class="stringliteral"> MAD R3, c[6].xxxx, -R3, c[6].yyyy; \n\</font> +00069 <font class="stringliteral"> MAX R3, c[5], R3; \n\</font> +00070 <font class="stringliteral"> MUL R0, R3, v[8]; #attenuate normal with distance \n\</font> +00071 <font class="stringliteral"> MUL R4.z, R3, v[0]; #attenuate height with distance \n\</font> +00072 <font class="stringliteral"> MOV R4.xyw, v[0]; \n\</font> +00073 <font class="stringliteral"> MOV R0.z, c[4].x; #set normal z to 1 \n\</font> +00074 <font class="stringliteral"> DP3 R3.x, R0, R0; \n\</font> +00075 <font class="stringliteral"> RSQ R3.x, R3.x; #normalize normal in R3 \n\</font> +00076 <font class="stringliteral"> MUL R0, R0, R3.x; \n\</font> +00077 <font class="stringliteral"> DP4 o[HPOS].x, c[0], R4; #transform vertex in view space \n\</font> +00078 <font class="stringliteral"> DP4 o[HPOS].y, c[1], R4; \n\</font> +00079 <font class="stringliteral"> DP4 o[HPOS].z, c[2], R4; \n\</font> +00080 <font class="stringliteral"> DP4 o[HPOS].w, c[3], R4; \n\</font> +00081 <font class="stringliteral"> MUL R1, R1, R2.x; #normalize r1, r1 = (eye - vertex).normed \n\</font> +00082 <font class="stringliteral"> DP4 o[FOGC].x, c[2], R4; #setup fog \n\</font> +00083 <font class="stringliteral">"</font>; +00084 +00085 <font class="comment">/*</font> +00086 <font class="comment">const char *WaterVPStartCode =</font> +00087 <font class="comment">"!!VP1.0\n\</font> +00088 <font class="comment"> ADD R1, c[7], -v[0]; #r1 = eye - vertex \n\</font> +00089 <font class="comment"> DP3 R2, R1, R1; #r1 = eye - vertex, r2 = (eye - vertex)² \n\</font> +00090 <font class="comment"> MAX R2, R2, c[16]; # avoid imprecision around 0 \n\</font> +00091 <font class="comment"> RSQ R2, R2.x; #r1 = eye - vertex, r2 = 1/d(eye, vertex) \n\</font> +00092 <font class="comment"> RCP R3, R2.x; \n\</font> +00093 <font class="comment"> MUL R3, c[6], R3; \n\</font> +00094 <font class="comment"> ADD R3, c[15], -R3; \n\</font> +00095 <font class="comment"> MAX R3, c[5], R3; \n\</font> +00096 <font class="comment"> MUL R0, R3, v[8]; #attenuate normal with distance \n\</font> +00097 <font class="comment"> MUL R4.z, R3, v[0]; #attenuate height with distance \n\</font> +00098 <font class="comment"> MOV R4.xyw, v[0]; \n\</font> +00099 <font class="comment"> MOV R0.z, c[4].x; #set normal z to 1 \n\</font> +00100 <font class="comment"> DP3 R3.x, R0, R0; \n\</font> +00101 <font class="comment"> RSQ R3.x, R3.x; #normalize normal in R3 \n\</font> +00102 <font class="comment"> MUL R0, R0, R3.x; \n\</font> +00103 <font class="comment"> DP4 o[HPOS].x, c[0], R4; #transform vertex in view space \n\</font> +00104 <font class="comment"> DP4 o[HPOS].y, c[1], R4; \n\</font> +00105 <font class="comment"> DP4 o[HPOS].z, c[2], R4; \n\</font> +00106 <font class="comment"> DP4 o[HPOS].w, c[3], R4; \n\</font> +00107 <font class="comment"> MUL R1, R1, R2.x; #normalize r1, r1 = (eye - vertex).normed \n\</font> +00108 <font class="comment"> DP4 o[FOGC].x, c[2], -R4; #setup fog \n\</font> +00109 <font class="comment">";</font> +00110 <font class="comment">*/</font> +00111 +00114 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a302">WaterVpBump2LayersCode</a> = <font class="stringliteral">"MUL R3, v[0], c[10]; #compute bump 0 uv's \n\</font> +00115 <font class="stringliteral"> ADD o[TEX0].xy, R3, c[9]; \n\</font> +00116 <font class="stringliteral"> MUL R3, v[0], c[12]; #compute bump 1 uv's \n\</font> +00117 <font class="stringliteral"> ADD o[TEX1].xy, R3, c[11]; \n\</font> +00118 <font class="stringliteral"> DP3 R2.x, R1, R0; \n\</font> +00119 <font class="stringliteral"> MUL R0, R0, R2.x; \n\</font> +00120 <font class="stringliteral"> ADD R2, R0, R0; \n\</font> +00121 <font class="stringliteral"> ADD R0, R2, -R1; #compute reflection vector \n\</font> +00122 <font class="stringliteral"> MAD o[TEX2].xy, R0, c[8], c[8]; \n\</font> +00123 <font class="stringliteral"> "</font>; +00124 +00127 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a303">WaterVpBump1LayersCode</a> = <font class="stringliteral">"MUL R3, v[0], c[12]; #compute bump 1 uv's \n\</font> +00128 <font class="stringliteral"> ADD o[TEX0].xy, R3, c[11]; \n\</font> +00129 <font class="stringliteral"> DP3 R2.x, R1, R0; \n\</font> +00130 <font class="stringliteral"> MUL R0, R0, R2.x; \n\</font> +00131 <font class="stringliteral"> ADD R2, R0, R0; \n\</font> +00132 <font class="stringliteral"> ADD R0, R2, -R1; #compute reflection vector \n\</font> +00133 <font class="stringliteral"> MAD o[TEX1].xy, R0, c[8], c[8]; \n\</font> +00134 <font class="stringliteral"> "</font>; +00135 +00138 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a304">WaterVpDiffuseMapStage3Code</a> = <font class="stringliteral">"DP4 o[TEX3].x, R4, c[13]; #compute uv for diffuse texture \n\</font> +00139 <font class="stringliteral"> DP4 o[TEX3].y, R4, c[14]; \n\</font> +00140 <font class="stringliteral"> "</font>; +00141 +00144 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a305">WaterVpDiffuseMapStage2Code</a> = <font class="stringliteral">"DP4 o[TEX2].x, R4, c[13]; #compute uv for diffuse texture \n\</font> +00145 <font class="stringliteral"> DP4 o[TEX2].y, R4, c[14]; \n\</font> +00146 <font class="stringliteral"> "</font>; +00147 +00150 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a306">WaterVpDiffuseMapStage1Code</a> = <font class="stringliteral">"DP4 o[TEX1].x, R4, c[13]; #compute uv for diffuse texture \n\</font> +00151 <font class="stringliteral"> DP4 o[TEX1].y, R4, c[14]; \n\</font> +00152 <font class="stringliteral"> "</font>; +00153 +00154 +00155 +00156 <font class="comment">// Envmap is setup in texture 0, no bump is used</font> +00157 <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="namespaceNL3D.html#a307">WaterVpNoBumpCode</a> = <font class="stringliteral">" DP3 R2.x, R1, R0; #project view vector on normal for symetry \n\</font> +00158 <font class="stringliteral"> MUL R0, R0, R2.x; \n\</font> +00159 <font class="stringliteral"> ADD R2, R0, R0; \n\</font> +00160 <font class="stringliteral"> ADD R0, R2, -R1; #compute reflection vector \n\</font> +00161 <font class="stringliteral"> MAD o[TEX0].xy, R0, c[8], c[8]; \n\</font> +00162 <font class="stringliteral"> DP4 o[FOGC].x, c[2], -R4; #setup fog \n\</font> +00163 <font class="stringliteral"> "</font>; +00164 +00165 +00166 <font class="comment">// static members</font> +00167 +<a name="l00168"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r0">00168</a> uint32 CWaterShape::_XScreenGridSize = 40; +<a name="l00169"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r1">00169</a> uint32 CWaterShape::_YScreenGridSize = 40; +<a name="l00170"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r3">00170</a> uint32 CWaterShape::_XGridBorder = 4; +<a name="l00171"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r4">00171</a> uint32 CWaterShape::_YGridBorder = 4; +<a name="l00172"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r2">00172</a> uint32 CWaterShape::_MaxGridSize; +<a name="l00173"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r5">00173</a> CVertexBuffer CWaterShape::_VB; +<a name="l00174"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r6">00174</a> std::vector<uint32> CWaterShape::_IBUpDown; +<a name="l00175"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r7">00175</a> std::vector<uint32> CWaterShape::_IBDownUp; +00176 <font class="comment">//NLMISC::CSmartPtr<IDriver> CWaterShape::_Driver;</font> +<a name="l00177"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r8">00177</a> <font class="keywordtype">bool</font> CWaterShape::_GridSizeTouched = <font class="keyword">true</font>; +<a name="l00178"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r9">00178</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump1; +<a name="l00179"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r10">00179</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump2; +<a name="l00180"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r11">00180</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump1Diffuse; +<a name="l00181"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r12">00181</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramBump2Diffuse; +<a name="l00182"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r13">00182</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoBump; +<a name="l00183"></a><a class="code" href="classNL3D_1_1CWaterShape.html#r14">00183</a> std::auto_ptr<CVertexProgram> CWaterShape::_VertexProgramNoBumpDiffuse; +00184 +00185 +00188 <font class="keyword">static</font> CVertexProgram *<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keywordtype">bool</font> diffuseMap, <font class="keywordtype">bool</font> bumpMap, <font class="keywordtype">bool</font> use2BumpMap) +00189 { +00190 std::string vp = <a class="code" href="namespaceNL3D.html#a301">WaterVPStartCode</a>; +00191 <font class="keywordflow">if</font> (bumpMap && use2BumpMap) +00192 { +00193 vp += <a class="code" href="namespaceNL3D.html#a302">WaterVpBump2LayersCode</a>; +00194 <font class="keywordflow">if</font> (diffuseMap) vp += <a class="code" href="namespaceNL3D.html#a304">WaterVpDiffuseMapStage3Code</a>; +00195 } +00196 <font class="keywordflow">else</font> +00197 <font class="keywordflow">if</font> (bumpMap) +00198 { +00199 vp += <a class="code" href="namespaceNL3D.html#a302">WaterVpBump2LayersCode</a>; +00200 <font class="keywordflow">if</font> (diffuseMap) vp += <a class="code" href="namespaceNL3D.html#a305">WaterVpDiffuseMapStage2Code</a>; +00201 } +00202 <font class="keywordflow">else</font> +00203 { +00204 vp += <a class="code" href="namespaceNL3D.html#a307">WaterVpNoBumpCode</a>; +00205 <font class="keywordflow">if</font> (diffuseMap) vp += <a class="code" href="namespaceNL3D.html#a306">WaterVpDiffuseMapStage1Code</a>; +00206 } +00207 +00208 vp += <font class="stringliteral">"\nEND"</font>; +00209 <font class="keywordflow">return</font> <font class="keyword">new</font> CVertexProgram(vp.c_str()); +00210 } +00211 +00212 +00213 +00214 <font class="comment">//============================================</font> +00215 <font class="comment">/*</font> +00216 <font class="comment"> * Constructor</font> +00217 <font class="comment"> */</font> +<a name="l00218"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z912_0">00218</a> CWaterShape::CWaterShape() : _WaterPoolID(0), _TransitionRatio(0.6f), _WaveHeightFactor(3), _ComputeLightmap(false) +00219 { +00220 <a class="code" href="classNL3D_1_1CWaterShape.html#o11">_DefaultPos</a>.setValue(<a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>); +00221 <a class="code" href="classNL3D_1_1CWaterShape.html#o12">_DefaultScale</a>.setValue(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, 1, 1)); +00222 <a class="code" href="classNL3D_1_1CWaterShape.html#o13">_DefaultRotQuat</a>.setValue(CQuat::Identity); +00223 +00224 <font class="keywordflow">for</font> (sint k = 0; k < 2; ++k) +00225 { +00226 <a class="code" href="classNL3D_1_1CWaterShape.html#o6">_HeightMapScale</a>[k].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(1, 1); +00227 <a class="code" href="classNL3D_1_1CWaterShape.html#o7">_HeightMapSpeed</a>[k].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0); +00228 <a class="code" href="classNL3D_1_1CWaterShape.html#o17">_HeightMapTouch</a>[k] = <font class="keyword">true</font>; +00229 } +00230 <a class="code" href="classNL3D_1_1CWaterShape.html#o8">_ColorMapMatColumn0</a>.<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(1, 0); +00231 <a class="code" href="classNL3D_1_1CWaterShape.html#o9">_ColorMapMatColumn1</a>.<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 1); +00232 <a class="code" href="classNL3D_1_1CWaterShape.html#o10">_ColorMapMatPos</a>.<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0); +00233 } +00234 +00235 <font class="comment">//============================================</font> +00236 +<a name="l00237"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z912_1">00237</a> CWaterShape::~CWaterShape() +00238 { +00239 <font class="keywordflow">if</font> ( +00240 (<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[0] && dynamic_cast<CTextureBlend *>((ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[0])) +00241 || (<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[1] && dynamic_cast<CTextureBlend *>((ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[1])) +00242 ) +00243 { +00244 <a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().unRegisterWaterShape(<font class="keyword">this</font>); +00245 } +00246 } +00247 +00248 <font class="comment">//============================================</font> +00249 +<a name="l00250"></a><a class="code" href="classNL3D_1_1CWaterShape.html#f0">00250</a> <font class="keywordtype">void</font> CWaterShape::initVertexProgram() +00251 { +00252 <font class="keyword">static</font> <font class="keywordtype">bool</font> created = <font class="keyword">false</font>; +00253 <font class="keywordflow">if</font> (!created) +00254 { +00255 +00256 <a class="code" href="classNL3D_1_1CWaterShape.html#r9">_VertexProgramBump1</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">false</font>, <font class="keyword">true</font>, <font class="keyword">false</font>)); +00257 <a class="code" href="classNL3D_1_1CWaterShape.html#r10">_VertexProgramBump2</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">false</font>, <font class="keyword">true</font>, <font class="keyword">true</font>)); +00258 +00259 <a class="code" href="classNL3D_1_1CWaterShape.html#r11">_VertexProgramBump1Diffuse</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">false</font>)); +00260 <a class="code" href="classNL3D_1_1CWaterShape.html#r12">_VertexProgramBump2Diffuse</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">true</font>, <font class="keyword">true</font>, <font class="keyword">true</font>)); +00261 +00262 <a class="code" href="classNL3D_1_1CWaterShape.html#r13">_VertexProgramNoBump</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">false</font>, <font class="keyword">false</font>, <font class="keyword">false</font>)); +00263 <a class="code" href="classNL3D_1_1CWaterShape.html#r14">_VertexProgramNoBumpDiffuse</a> = std::auto_ptr<CVertexProgram>(<a class="code" href="namespaceNL3D.html#a481">BuildWaterVP</a>(<font class="keyword">true</font>, <font class="keyword">false</font>, <font class="keyword">false</font>)); +00264 created = <font class="keyword">true</font>; +00265 } +00266 } +00267 +00268 +00269 <font class="comment">//============================================</font> +00270 +<a name="l00271"></a><a class="code" href="classNL3D_1_1CWaterShape.html#f1">00271</a> <font class="keywordtype">void</font> CWaterShape::setupVertexBuffer() +00272 { +00273 <font class="keyword">const</font> uint rotLength = (uint) ::ceilf(::sqrtf((float) ((<a class="code" href="classNL3D_1_1CWaterShape.html#r0">_XScreenGridSize</a> >> 1) * (<a class="code" href="classNL3D_1_1CWaterShape.html#r0">_XScreenGridSize</a> >> 1) +00274 + (<a class="code" href="classNL3D_1_1CWaterShape.html#r1">_YScreenGridSize</a> >> 1) * (<a class="code" href="classNL3D_1_1CWaterShape.html#r1">_YScreenGridSize</a> >> 1)))); +00275 <a class="code" href="classNL3D_1_1CWaterShape.html#r2">_MaxGridSize</a> = 2 * rotLength; +00276 <font class="keyword">const</font> uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> = <a class="code" href="classNL3D_1_1CWaterShape.html#r2">_MaxGridSize</a> + 2 * <a class="code" href="classNL3D_1_1CWaterShape.html#r3">_XGridBorder</a>; +00277 +00278 <a class="code" href="classNL3D_1_1CWaterShape.html#r5">_VB</a>.clearValueEx(); +00279 <a class="code" href="classNL3D_1_1CWaterShape.html#r5">_VB</a>.addValueEx (<a class="code" href="namespaceNL3D.html#a308">WATER_VB_POS</a>, CVertexBuffer::Float3); +00280 <a class="code" href="classNL3D_1_1CWaterShape.html#r5">_VB</a>.addValueEx (<a class="code" href="namespaceNL3D.html#a309">WATER_VB_DX</a>, CVertexBuffer::Float2); +00281 +00282 <a class="code" href="classNL3D_1_1CWaterShape.html#r5">_VB</a>.initEx(); +00283 <a class="code" href="classNL3D_1_1CWaterShape.html#r5">_VB</a>.setNumVertices((<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1) * 2); +00284 +00285 +00286 +00287 uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>; +00288 +00289 <font class="comment">// setup each index buffer</font> +00290 <font class="comment">// We need 2 vb, because, each time 2 lines of the vertex buffer are filled, we start at the beginning again</font> +00291 <font class="comment">// So we need 1 vb for triangle drawn up to down, and one other for triangle drawn down to top </font> +00292 +00293 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a>.resize(6 * <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>); +00294 <font class="keywordflow">for</font> (<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> < <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>; ++<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>) +00295 { +00296 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <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>; +00297 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00298 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 2 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1; +00299 +00300 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 3 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>; +00301 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 4 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00302 <a class="code" href="classNL3D_1_1CWaterShape.html#r6">_IBUpDown</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 5 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00303 +00304 } +00305 +00306 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a>.resize(6 * <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>); +00307 <font class="keywordflow">for</font> (<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> < <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>; ++<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>) +00308 { +00309 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <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>; +00310 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1; +00311 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 2 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00312 +00313 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 3 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>; +00314 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 4 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00315 <a class="code" href="classNL3D_1_1CWaterShape.html#r7">_IBDownUp</a> [ 6 * <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 5 ] = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> + 1 + (<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> + 1); +00316 +00317 } +00318 +00319 <a class="code" href="classNL3D_1_1CWaterShape.html#r8">_GridSizeTouched</a> = <font class="keyword">false</font>; +00320 } +00321 +00322 <font class="comment">//============================================</font> +00323 +<a name="l00324"></a><a class="code" href="classNL3D_1_1CWaterShape.html#a1">00324</a> CTransformShape *CWaterShape::createInstance(CScene &scene) +00325 { +00326 <a class="code" href="classNL3D_1_1CWaterShape.html#l0">CWaterModel</a> *wm = NLMISC::safe_cast<CWaterModel *>(scene.createModel(<a class="code" href="namespaceNL3D.html#a310">WaterModelClassId</a>) ); +00327 wm->Shape = <font class="keyword">this</font>; +00328 <font class="comment">// set default pos & scale</font> +00329 wm->ITransformable::setPos( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CWaterShape.html#o11">_DefaultPos</a>.getValue()).Value ); +00330 wm->ITransformable::setScale( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CWaterShape.html#o12">_DefaultScale</a>.getValue()).Value ); +00331 wm->ITransformable::setRotQuat( ((<a class="code" href="namespaceNL3D.html#a16">CAnimatedValueQuat</a>&)<a class="code" href="classNL3D_1_1CWaterShape.html#o13">_DefaultRotQuat</a>.getValue()).Value ); +00332 wm->_Scene = &scene; +00333 <font class="keywordflow">return</font> wm; +00334 } +00335 +00336 <font class="comment">//============================================</font> +00337 +<a name="l00338"></a><a class="code" href="classNL3D_1_1CWaterShape.html#a5">00338</a> <font class="keywordtype">float</font> CWaterShape::getNumTriangles (<font class="keywordtype">float</font> distance) +00339 { +00340 <font class="comment">// TODO</font> +00341 <font class="keywordflow">return</font> 0; +00342 } +00343 +00344 <font class="comment">//============================================</font> +00345 +<a name="l00346"></a><a class="code" href="classNL3D_1_1CWaterShape.html#a6">00346</a> <font class="keywordtype">void</font> CWaterShape::flushTextures (IDriver &driver) +00347 { +00348 <font class="comment">// Test if bump maps are supported by driver before to flush them. </font> +00349 <font class="keywordflow">if</font> ( +00350 (driver.supportTextureShaders() && driver.isTextureAddrModeSupported(CMaterial::OffsetTexture)) +00351 || driver.supportEMBM() +00352 ) +00353 { +00354 <font class="keywordflow">for</font> (uint k = 0; k < 2; ++k) +00355 { +00356 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k] != NULL) +00357 driver.setupTexture(*<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k]); +00358 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[k] != NULL) +00359 driver.setupTexture(*<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[k]); +00360 } +00361 } +00362 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o5">_ColorMap</a> != NULL) +00363 driver.setupTexture(*<a class="code" href="classNL3D_1_1CWaterShape.html#o5">_ColorMap</a>); +00364 } +00365 +00366 <font class="comment">//============================================</font> +00367 +<a name="l00368"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z913_7">00368</a> <font class="keywordtype">void</font> CWaterShape::setScreenGridSize(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>) +00369 { +00370 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> > 0 && <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a> > 0); +00371 <a class="code" href="classNL3D_1_1CWaterShape.html#r0">_XScreenGridSize</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>; +00372 <a class="code" href="classNL3D_1_1CWaterShape.html#r1">_YScreenGridSize</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>; +00373 <a class="code" href="classNL3D_1_1CWaterShape.html#r8">_GridSizeTouched</a> = <font class="keyword">true</font>; +00374 } +00375 +00376 <font class="comment">//============================================</font> +00377 +<a name="l00378"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z913_8">00378</a> <font class="keywordtype">void</font> CWaterShape::setGridBorderSize(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>) +00379 { +00380 <a class="code" href="classNL3D_1_1CWaterShape.html#r3">_XGridBorder</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>; +00381 <a class="code" href="classNL3D_1_1CWaterShape.html#r4">_YGridBorder</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>; +00382 <a class="code" href="classNL3D_1_1CWaterShape.html#r8">_GridSizeTouched</a> = <font class="keyword">true</font>; +00383 } +00384 +00385 <font class="comment">//============================================</font> +00386 +<a name="l00387"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z913_2">00387</a> <font class="keywordtype">void</font> CWaterShape::setShape(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CPolygon2D.html">NLMISC::CPolygon2D</a> &poly) +00388 { +00389 <a class="code" href="debug_8h.html#a6">nlassert</a>(poly.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>.size() != 0); <font class="comment">// empty poly not allowed</font> +00390 <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a> = poly; +00391 <a class="code" href="classNL3D_1_1CWaterShape.html#c0">computeBBox</a>(); +00392 } +00393 +00394 <font class="comment">//============================================</font> +00395 +<a name="l00396"></a><a class="code" href="classNL3D_1_1CWaterShape.html#c0">00396</a> <font class="keywordtype">void</font> CWaterShape::computeBBox() +00397 { +00398 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>.size() != 0); +00399 <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> <a class="code" href="bit__set_8cpp.html#a0">min</a>, max; +00400 min = max = <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>[0]; +00401 <font class="keywordflow">for</font> (uint k = 1; k < <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>.size(); ++k) +00402 { +00403 min.<a class="code" href="classNLMISC_1_1CVector2f.html#z340_4">minof</a>(min, <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>[k]); +00404 max.<a class="code" href="classNLMISC_1_1CVector2f.html#z340_5">maxof</a>(max, <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>[k]); +00405 } +00406 <a class="code" href="classNL3D_1_1CWaterShape.html#o0">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_3">setMinMax</a>(CVector(min.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a>, min.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a>, 0), CVector(max.<a class="code" href="classNLMISC_1_1CVector2f.html#m0">x</a>, max.<a class="code" href="classNLMISC_1_1CVector2f.html#m1">y</a>, 0)); +00407 <font class="comment">/* nlinfo("center x = %f, y = %f, z = %f", _BBox.getCenter().x, _BBox.getCenter().y, _BBox.getCenter().z);</font> +00408 <font class="comment"> nlinfo("halsize x = %f, y = %f, z = %f", _BBox.getHalfSize().x, _BBox.getHalfSize().y, _BBox.getHalfSize().z); */</font> +00409 } +00410 +00411 <font class="comment">//============================================</font> +00412 +<a name="l00413"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_3">00413</a> <font class="keywordtype">void</font> CWaterShape::setHeightMap(uint k, ITexture *hm) +00414 { +00415 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00416 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k]) +00417 { +00418 <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k] = <font class="keyword">new</font> CTextureBump; +00419 } +00420 static_cast<CTextureBump *>( (ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k])->forceNormalize(<font class="keyword">true</font>); +00421 static_cast<CTextureBump *>( (ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k])->setHeightMap(hm); +00422 <a class="code" href="classNL3D_1_1CWaterShape.html#o17">_HeightMapTouch</a>[k] = <font class="keyword">true</font>; <font class="comment">// must recompute normalization factor</font> +00423 } +00424 +00425 <font class="comment">//============================================</font> +00426 +<a name="l00427"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_4">00427</a> ITexture *CWaterShape::getHeightMap(uint k) +00428 { +00429 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00430 <font class="keywordflow">return</font> ((CTextureBump *) (ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k] )->getHeightMap(); +00431 } +00432 +00433 <font class="comment">//============================================</font> +00434 +<a name="l00435"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_5">00435</a> <font class="keyword">const</font> ITexture *CWaterShape::getHeightMap(uint k)<font class="keyword"> const</font> +00436 <font class="keyword"></font>{ +00437 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00438 <font class="keywordflow">return</font> ((CTextureBump *) (ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k] )->getHeightMap(); +00439 } +00440 +00441 <font class="comment">//============================================</font> +00442 +<a name="l00443"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z912_2">00443</a> <font class="keywordtype">void</font> CWaterShape::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00444 { +00445 sint ver = f.serialVersion(2); +00446 <font class="comment">// serial 'shape' </font> +00447 f.serial(_Poly); +00448 <font class="comment">// serial heightMap identifier</font> +00449 f.serial(_WaterPoolID); +00450 <font class="comment">//serial maps</font> +00451 ITexture *map = NULL; +00452 <font class="keywordflow">if</font> (f.isReading()) +00453 { +00454 f.serialPolyPtr(map); _EnvMap[0] = map; +00455 f.serialPolyPtr(map); _EnvMap[1] = map; +00456 f.serialPolyPtr(map); _BumpMap[0] = map; +00457 f.serialPolyPtr(map); _BumpMap[1] = map; +00458 f.serialPolyPtr(map); _ColorMap = map; +00459 computeBBox(); +00460 } +00461 <font class="keywordflow">else</font> +00462 { +00463 map = _EnvMap[0]; f.serialPolyPtr(map); +00464 map = _EnvMap[1]; f.serialPolyPtr(map); +00465 map = _BumpMap[0]; f.serialPolyPtr(map); +00466 map = _BumpMap[1]; f.serialPolyPtr(map); +00467 map = _ColorMap; f.serialPolyPtr(map); +00468 } +00469 +00470 f.serial(_HeightMapScale[0], _HeightMapScale[1], +00471 _HeightMapSpeed[0], _HeightMapSpeed[1]); +00472 +00473 f.serial(_ColorMapMatColumn0, _ColorMapMatColumn1, _ColorMapMatPos); +00474 +00475 <font class="comment">// serial default tracks</font> +00476 f.serial(_DefaultPos); +00477 f.serial(_DefaultScale); +00478 f.serial(_DefaultRotQuat); +00479 +00480 f.serial(_TransitionRatio); +00481 +00482 f.serial(_WaveHeightFactor); +00483 +00484 <font class="keywordflow">if</font> (ver >= 1) +00485 f.serial (_ComputeLightmap); +00486 +00487 <font class="keywordflow">if</font> (ver >= 2) +00488 f.serial (_DistMax); +00489 } +00490 +00491 <font class="comment">//============================================</font> +00492 +<a name="l00493"></a><a class="code" href="classNL3D_1_1CWaterShape.html#a2">00493</a> <font class="keywordtype">bool</font> CWaterShape::clip(<font class="keyword">const</font> std::vector<CPlane> &pyramid, <font class="keyword">const</font> CMatrix &worldMatrix) +00494 { +00495 <font class="keywordflow">for</font> (uint k = 0; k < pyramid.size(); ++k) +00496 { +00497 <font class="keywordflow">if</font> (! <a class="code" href="classNL3D_1_1CWaterShape.html#o0">_BBox</a>.<a class="code" href="classNLMISC_1_1CAABBox.html#z265_1">clipBack</a>(pyramid[k] * worldMatrix)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00498 } +00499 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00500 } +00501 +00502 <font class="comment">//============================================</font> +00503 +<a name="l00504"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_6">00504</a> <font class="keywordtype">void</font> CWaterShape::setHeightMapScale(uint k, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &scale) +00505 { +00506 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00507 <a class="code" href="classNL3D_1_1CWaterShape.html#o6">_HeightMapScale</a>[k] = scale; +00508 } +00509 +00510 <font class="comment">//============================================</font> +00511 +<a name="l00512"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_7">00512</a> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> CWaterShape::getHeightMapScale(uint k)<font class="keyword"> const</font> +00513 <font class="keyword"></font>{ +00514 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00515 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CWaterShape.html#o6">_HeightMapScale</a>[k]; +00516 } +00517 +00518 <font class="comment">//============================================</font> +00519 +<a name="l00520"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_8">00520</a> <font class="keywordtype">void</font> CWaterShape::setHeightMapSpeed(uint k, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &speed) +00521 { +00522 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00523 <a class="code" href="classNL3D_1_1CWaterShape.html#o7">_HeightMapSpeed</a>[k] = speed; +00524 } +00525 +00526 <font class="comment">//============================================</font> +00527 +<a name="l00528"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_9">00528</a> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> CWaterShape::getHeightMapSpeed(uint k)<font class="keyword"> const</font> +00529 <font class="keyword"></font>{ +00530 <a class="code" href="debug_8h.html#a6">nlassert</a>(k < 2); +00531 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CWaterShape.html#o7">_HeightMapSpeed</a>[k]; +00532 } +00533 +00534 <font class="comment">//============================================</font> +00535 +<a name="l00536"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_13">00536</a> <font class="keywordtype">void</font> CWaterShape::setColorMapMat(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &column0, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &column1, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &pos) +00537 { +00538 <a class="code" href="classNL3D_1_1CWaterShape.html#o8">_ColorMapMatColumn0</a> = column0; +00539 <a class="code" href="classNL3D_1_1CWaterShape.html#o9">_ColorMapMatColumn1</a> = column1; +00540 <a class="code" href="classNL3D_1_1CWaterShape.html#o10">_ColorMapMatPos</a> = pos; +00541 } +00542 +00543 <font class="comment">//============================================</font> +00544 +<a name="l00545"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_14">00545</a> <font class="keywordtype">void</font> CWaterShape::getColorMapMat(<a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &column0, <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &column1, <a class="code" href="classNLMISC_1_1CVector2f.html">NLMISC::CVector2f</a> &pos) +00546 { +00547 column0 = <a class="code" href="classNL3D_1_1CWaterShape.html#o8">_ColorMapMatColumn0</a>; +00548 column1 = <a class="code" href="classNL3D_1_1CWaterShape.html#o9">_ColorMapMatColumn1</a>; +00549 pos = <a class="code" href="classNL3D_1_1CWaterShape.html#o10">_ColorMapMatPos</a>; +00550 } +00551 +00552 <font class="comment">//============================================</font> +00553 +<a name="l00554"></a><a class="code" href="classNL3D_1_1CWaterShape.html#c1">00554</a> <font class="keywordtype">void</font> CWaterShape::envMapUpdate() +00555 { +00556 <font class="comment">// if the color map is a blend texture, we MUST be registered to the water pool manager, so that, the</font> +00557 <font class="comment">// setBlend message will be routed to this texture.</font> +00558 <font class="keywordflow">if</font> ( +00559 (<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[0] && dynamic_cast<CTextureBlend *>((ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[0])) +00560 || (<a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[1] && dynamic_cast<CTextureBlend *>((ITexture *) <a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[1])) +00561 ) +00562 { +00563 <font class="keywordflow">if</font> (!<a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().isWaterShapeObserver(<font class="keyword">this</font>)) +00564 { +00565 <a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().registerWaterShape(<font class="keyword">this</font>); +00566 } +00567 } +00568 <font class="keywordflow">else</font> +00569 { +00570 <font class="keywordflow">if</font> (<a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().isWaterShapeObserver(<font class="keyword">this</font>)) +00571 { +00572 <a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().unRegisterWaterShape(<font class="keyword">this</font>); +00573 } +00574 } +00575 } +00576 +00577 <font class="comment">//============================================</font> +00578 +<a name="l00579"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_10">00579</a> <font class="keywordtype">void</font> CWaterShape::setColorMap(ITexture *map) +00580 { +00581 <a class="code" href="classNL3D_1_1CWaterShape.html#o5">_ColorMap</a> = map; +00582 <font class="comment">//colorMapUpdate();</font> +00583 } +00584 +00585 <font class="comment">//============================================</font> +00586 +<a name="l00587"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z914_0">00587</a> <font class="keywordtype">void</font> CWaterShape::setEnvMap(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, ITexture *envMap) +00588 { +00589 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> < 2); +00590 <a class="code" href="classNL3D_1_1CWaterShape.html#o3">_EnvMap</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = envMap; +00591 } +00592 +00593 <font class="comment">//============================================</font> +00594 +<a name="l00595"></a><a class="code" href="classNL3D_1_1CWaterShape.html#z913_4">00595</a> <font class="keywordtype">void</font> CWaterShape::getShapeInWorldSpace(<a class="code" href="classNLMISC_1_1CPolygon.html">NLMISC::CPolygon</a> &poly)<font class="keyword"> const</font> +00596 <font class="keyword"></font>{ +00597 poly.<a class="code" href="classNLMISC_1_1CPolygon.html#m0">Vertices</a>.resize(<a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>.size()); +00598 <font class="comment">// compute the matrix of the object in world space, by using the default tracks</font> +00599 <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> objMat; +00600 objMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_0">identity</a>(); +00601 objMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z292_0">translate</a>(((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a> *) &<a class="code" href="classNL3D_1_1CWaterShape.html#o11">_DefaultPos</a>.getValue())->Value); +00602 objMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z292_4">rotate</a>(((<a class="code" href="namespaceNL3D.html#a16">CAnimatedValueQuat</a> *) &<a class="code" href="classNL3D_1_1CWaterShape.html#o13">_DefaultRotQuat</a>.getValue())->Value); +00603 objMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z292_6">scale</a>(((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a> *) &<a class="code" href="classNL3D_1_1CWaterShape.html#o12">_DefaultScale</a>.getValue())->Value); +00604 +00605 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>.size(); ++k) +00606 { +00607 poly.<a class="code" href="classNLMISC_1_1CPolygon.html#m0">Vertices</a>[k] = objMat * <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(<a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>[k].x, <a class="code" href="classNL3D_1_1CWaterShape.html#o1">_Poly</a>.<a class="code" href="classNLMISC_1_1CPolygon2D.html#m0">Vertices</a>[k].y, 0); +00608 } +00609 } +00610 +00611 +00612 <font class="comment">//============================================</font> +<a name="l00613"></a><a class="code" href="classNL3D_1_1CWaterShape.html#c2">00613</a> <font class="keywordtype">void</font> CWaterShape::updateHeightMapNormalizationFactors() +00614 { +00615 <font class="keywordflow">for</font> (uint k = 0; k < 2; ++k) +00616 { +00617 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o17">_HeightMapTouch</a>[k]) +00618 { +00619 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k] != NULL) +00620 { +00621 <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k]->generate(); +00622 <a class="code" href="classNL3D_1_1CWaterShape.html#o18">_HeightMapNormalizationFactor</a>[k] = NLMISC::safe_cast<CTextureBump *>((ITexture *)<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k])->getNormalizationFactor(); +00623 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k]->getReleasable()) +00624 { +00625 <a class="code" href="classNL3D_1_1CWaterShape.html#o4">_BumpMap</a>[k]->release(); +00626 } +00627 } +00628 <font class="keywordflow">else</font> +00629 { +00630 <a class="code" href="classNL3D_1_1CWaterShape.html#o18">_HeightMapNormalizationFactor</a>[k] = 1.f; +00631 } +00632 <a class="code" href="classNL3D_1_1CWaterShape.html#o17">_HeightMapTouch</a>[k] = <font class="keyword">false</font>; +00633 } +00634 } +00635 } +00636 +00637 +00638 +00639 <font class="comment">//======================================================//</font> +00640 <font class="comment">// WaveMakerShape //</font> +00641 <font class="comment">//======================================================//</font> +00642 +00643 +00644 <font class="comment">//============================================</font> +00645 +<a name="l00646"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#z918_0">00646</a> CWaveMakerShape::CWaveMakerShape() : _Period(1), +00647 _Radius(3), +00648 _PoolID(0), +00649 _Intensity(1), +00650 _ImpulsionMode(true) +00651 { +00652 } +00653 +00654 <font class="comment">//============================================</font> +00655 +<a name="l00656"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#z918_1">00656</a> CWaveMakerShape::~CWaveMakerShape() +00657 { +00658 } +00659 +00660 <font class="comment">//============================================</font> +00661 +<a name="l00662"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#z918_2">00662</a> <font class="keywordtype">void</font> CWaveMakerShape::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00663 { +00664 f.serialVersion(0); +00665 f.serial(_Period, _Radius, _Intensity, _PoolID, _ImpulsionMode); +00666 } +00667 +00668 <font class="comment">//============================================</font> +00669 +<a name="l00670"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#a1">00670</a> CTransformShape *CWaveMakerShape::createInstance(CScene &scene) +00671 { +00672 CWaveMakerModel *wmm = NLMISC::safe_cast<CWaveMakerModel *>(scene.createModel(<a class="code" href="namespaceNL3D.html#a311">WaveMakerModelClassId</a>) ); +00673 wmm->Shape = <font class="keyword">this</font>; +00674 <font class="comment">// set default pos & scale</font> +00675 wmm->ITransformable::setPos( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CWaveMakerShape.html#o5">_DefaultPos</a>.getValue()).Value ); +00676 wmm->_Scene = &scene; +00677 <font class="keywordflow">return</font> wmm; +00678 } +00679 +00680 <font class="comment">//============================================</font> +00681 +<a name="l00682"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#a2">00682</a> <font class="keywordtype">bool</font> CWaveMakerShape::clip(<font class="keyword">const</font> std::vector<CPlane> &pyramid, <font class="keyword">const</font> CMatrix &worldMatrix) +00683 { +00684 <font class="comment">// we just test if not too far</font> +00685 <font class="keyword">const</font> CWaterHeightMap &whm = <a class="code" href="namespaceNL3D.html#a480">GetWaterPoolManager</a>().getPoolByID(<a class="code" href="classNL3D_1_1CWaveMakerShape.html#o2">_PoolID</a>); +00686 <font class="keyword">const</font> <font class="keywordtype">float</font> maxDist = 0.5f * whm.getUnitSize() * whm.getSize(); +00687 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> pos = worldMatrix.getPos(); +00688 <font class="keywordflow">for</font> (std::vector<NLMISC::CPlane>::const_iterator it = pyramid.begin(); it != pyramid.end(); ++it) +00689 { +00690 <font class="keywordflow">if</font> ((*it) * pos > maxDist) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00691 } +00692 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00693 +00694 } +00695 +00696 <font class="comment">//============================================</font> +<a name="l00697"></a><a class="code" href="classNL3D_1_1CWaveMakerShape.html#a4">00697</a> <font class="keywordtype">void</font> CWaveMakerShape::getAABBox(<a class="code" href="classNLMISC_1_1CAABBox.html">NLMISC::CAABBox</a> &bbox)<font class="keyword"> const</font> +00698 <font class="keyword"></font>{ +00699 <font class="comment">// its just a point</font> +00700 bbox.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_0">setCenter</a>(<a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>); +00701 bbox.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_1">setHalfSize</a>(<a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>); +00702 } +00703 +00704 } <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> |