aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/landscape_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/landscape_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/landscape_8cpp-source.html3621
1 files changed, 3621 insertions, 0 deletions
diff --git a/docs/doxygen/nel/landscape_8cpp-source.html b/docs/doxygen/nel/landscape_8cpp-source.html
new file mode 100644
index 00000000..f8e7e02f
--- /dev/null
+++ b/docs/doxygen/nel/landscape_8cpp-source.html
@@ -0,0 +1,3621 @@
+<!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>landscape.cpp</h1><a href="landscape_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000 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
+00029 <font class="preprocessor">#include "<a class="code" href="landscape_8h.html">3d/landscape.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="bsphere_8h.html">nel/misc/bsphere.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="texture__file_8h.html">3d/texture_file.h</a>"</font>
+00032 <font class="preprocessor">#include "<a class="code" href="texture__far_8h.html">3d/texture_far.h</a>"</font>
+00033 <font class="preprocessor">#include "<a class="code" href="landscape__profile_8h.html">3d/landscape_profile.h</a>"</font>
+00034 <font class="preprocessor">#include "<a class="code" href="height__map_8h.html">nel/3d/height_map.h</a>"</font>
+00035 <font class="preprocessor">#include "<a class="code" href="tile__noise__map_8h.html">3d/tile_noise_map.h</a>"</font>
+00036 <font class="preprocessor">#include "<a class="code" href="vegetable__manager_8h.html">3d/vegetable_manager.h</a>"</font>
+00037 <font class="preprocessor">#include "<a class="code" href="vegetable_8h.html">3d/vegetable.h</a>"</font>
+00038 <font class="preprocessor">#include "<a class="code" href="landscape__vegetable__block_8h.html">3d/landscape_vegetable_block.h</a>"</font>
+00039 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
+00040 <font class="preprocessor">#include "<a class="code" href="tile__vegetable__desc_8h.html">3d/tile_vegetable_desc.h</a>"</font>
+00041 <font class="preprocessor">#include "<a class="code" href="texture__dlm_8h.html">3d/texture_dlm.h</a>"</font>
+00042 <font class="preprocessor">#include "<a class="code" href="patchdlm__context_8h.html">3d/patchdlm_context.h</a>"</font>
+00043 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font>
+00044
+00045
+00046 <font class="preprocessor">#include "<a class="code" href="vertex__program_8h.html">3d/vertex_program.h</a>"</font>
+00047
+00048
+00049
+00050 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00051 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00052
+00053
+00054 <font class="keyword">namespace </font>NL3D
+00055 {
+00056
+00057
+00058 <font class="comment">// ***************************************************************************</font>
+00059 <font class="comment">/* </font>
+00060 <font class="comment"> Target is 20K faces in frustum.</font>
+00061 <font class="comment"> So 80K faces at same time</font>
+00062 <font class="comment"> So 160K elements (bin tree).</font>
+00063 <font class="comment"> A good BlockSize (in my opinion) is EstimatedMaxSize / 10, to have less memory leak as possible,</font>
+00064 <font class="comment"> and to make not so many system allocation.</font>
+00065 <font class="comment"></font>
+00066 <font class="comment"> NL3D_TESSRDR_ALLOC_BLOCKSIZE is 2 times less, because elements are in Far zone or in Near zone only</font>
+00067 <font class="comment"> (approx same size...)</font>
+00068 <font class="comment">*/</font>
+<a name="l00069"></a><a class="code" href="landscape_8cpp.html#a0">00069</a> <font class="preprocessor">#define NL3D_TESS_ALLOC_BLOCKSIZE 16000</font>
+<a name="l00070"></a><a class="code" href="landscape_8cpp.html#a1">00070</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_TESSRDR_ALLOC_BLOCKSIZE 8000</font>
+00071 <font class="preprocessor"></font>
+00072
+00073 <font class="comment">// ***************************************************************************</font>
+00074 <font class="comment">// This value is important for the precision of the priority list</font>
+<a name="l00075"></a><a class="code" href="landscape_8cpp.html#a2">00075</a> <font class="preprocessor">#define NL3D_REFINE_PLIST_DIST_STEP 0.0625</font>
+00076 <font class="preprocessor"></font><font class="comment">/* This value is important, because faces will be inserted at maximum at this entry in the priority list.</font>
+00077 <font class="comment"> If not so big (eg 50 meters), a big bunch of faces may be inserted in this entry, which may cause slow down</font>
+00078 <font class="comment"> sometimes, when all this bunch comes to 0 in the priority list.</font>
+00079 <font class="comment"> To avoid such a thing, see CTessFacePriorityList::init(), and use of NL3D_REFINE_PLIST_DIST_MAX_MOD.</font>
+00080 <font class="comment"> Here, distMax= 2048*0.0625= 128</font>
+00081 <font class="comment">*/</font>
+<a name="l00082"></a><a class="code" href="landscape_8cpp.html#a3">00082</a> <font class="preprocessor">#define NL3D_REFINE_PLIST_NUM_ENTRIES 2048</font>
+<a name="l00083"></a><a class="code" href="landscape_8cpp.html#a4">00083</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_REFINE_PLIST_DIST_MAX_MOD 0.7f</font>
+00084 <font class="preprocessor"></font><font class="comment">// For the Split priority list only, numbers of quadrants. MergeList has 0 quadrants.</font>
+<a name="l00085"></a><a class="code" href="landscape_8cpp.html#a5">00085</a> <font class="preprocessor">#define NL3D_REFINE_PLIST_SPLIT_NUMQUADRANT 16</font>
+00086 <font class="preprocessor"></font>
+00087
+00088 <font class="comment">/*</font>
+00089 <font class="comment"> OverHead size of one RollingTable of priority list is 8 * (NL3D_REFINE_PLIST_NUM_ENTRIES)</font>
+00090 <font class="comment"> So here, it is "only" 16K.</font>
+00091 <font class="comment"></font>
+00092 <font class="comment"> Since we have 2 Priority list and 16 quadrants for the split one, the total overhead is 18*12.8= 288K</font>
+00093 <font class="comment">*/</font>
+00094
+00095
+00096 <font class="comment">// ***************************************************************************</font>
+00097 <font class="comment">// Size (in cases) of the quadgrid. must be e power of 2.</font>
+<a name="l00098"></a><a class="code" href="classNL3D_1_1CLandscape.html#z493_3">00098</a> <font class="keyword">const</font> uint CLandscape::_PatchQuadGridSize= 128;
+00099 <font class="comment">// Size of a case of the quadgrid.</font>
+<a name="l00100"></a><a class="code" href="classNL3D_1_1CLandscape.html#z493_4">00100</a> <font class="keyword">const</font> <font class="keywordtype">float</font> CLandscape::_PatchQuadGridEltSize= 16;
+00101
+00102
+00103 <font class="comment">// ***************************************************************************</font>
+00104
+00105 <font class="comment">// Bitmap Cross</font>
+00106
+<a name="l00107"></a><a class="code" href="classNL3D_1_1CTextureCross.html">00107</a> <font class="keyword">class </font>CTextureCross : <font class="keyword">public</font> ITexture
+00108 {
+00109 <font class="keyword">public</font>:
+<a name="l00115"></a><a class="code" href="classNL3D_1_1CTextureCross.html#a0">00115</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CTextureCross.html#a0">doGenerate</a>()
+00116 {
+00117 <font class="comment">// Resize</font>
+00118 <a class="code" href="classNLMISC_1_1CBitmap.html#a15">resize</a> (16, 16);
+00119
+00120 <font class="comment">// Cross</font>
+00121 <font class="keyword">static</font> <font class="keyword">const</font> uint32 cross[16*16]=
+00122 {
+00123 <font class="comment">// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15</font>
+00124 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+00125 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00126 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00127 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00128 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00129 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00130 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00131 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00132 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00133 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00134 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00135 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00136 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00137 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00138 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
+00139 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+00140 };
+00141
+00142 <font class="comment">// Null</font>
+00143 memcpy (&amp;<a class="code" href="classNLMISC_1_1CBitmap.html#n0">_Data</a>[0][0], cross, 16*16*4);
+00144 }
+00145
+00146 <font class="comment">// Dummy serial...</font>
+<a name="l00147"></a><a class="code" href="classNL3D_1_1CTextureCross.html#a1">00147</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CTextureCross.html#a1">serial</a>(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream) {<a class="code" href="debug_8h.html#a12">nlstop</a>;}
+00148 <a class="code" href="classNL3D_1_1CTextureCross.html#a2">NLMISC_DECLARE_CLASS</a>(CTextureCross);
+00149 };
+00150
+00151
+00152 <font class="comment">// ***************************************************************************</font>
+<a name="l00153"></a><a class="code" href="structNL3D_1_1EBadBind.html#a2">00153</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *EBadBind::what() <font class="keyword">const</font> <font class="keywordflow">throw</font>()
+00154 {
+00155 sint numErr= 0;
+00156 <font class="keyword">const</font> sint NErrByLines= 4;
+00157
+00158 _Output= <font class="stringliteral">"Landscape Bind Error in (3DSMax indices!! (+1) ): "</font>;
+00159
+00160 <a class="code" href="classstd_1_1list.html">std::list&lt;CBindError&gt;</a>::const_iterator it;
+00161 <font class="keywordflow">for</font>(it= BindErrors.begin();it!=BindErrors.end(); it++, numErr++)
+00162 {
+00163 <font class="keywordtype">char</font> tmp[256];
+00164 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= it-&gt;ZoneId &amp; 255;
+00165 sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= it-&gt;ZoneId &gt;&gt; 8;
+00166 sprintf(tmp, <font class="stringliteral">"zone%3d_%c%c.patch%3d; "</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1, (<font class="keywordtype">char</font>)(<font class="charliteral">'A'</font>+(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>/26)), (<font class="keywordtype">char</font>)(<font class="charliteral">'A'</font>+(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>%26)), it-&gt;PatchId+1);
+00167 <font class="keywordflow">if</font>( (numErr%NErrByLines) == 0)
+00168 _Output+= <font class="stringliteral">"\n"</font>;
+00169 _Output+= tmp;
+00170 }
+00171 <font class="keywordflow">return</font> _Output.c_str();
+00172 }
+00173
+00174
+00175 <font class="comment">// ***************************************************************************</font>
+00176 <font class="comment">// Init BlockAllcoator with standard BlockMemory.</font>
+<a name="l00177"></a><a class="code" href="classNL3D_1_1CLandscape.html#a0">00177</a> CLandscape::CLandscape() :
+00178 TessFaceAllocator(<a class="code" href="landscape_8cpp.html#a0">NL3D_TESS_ALLOC_BLOCKSIZE</a>),
+00179 TessVertexAllocator(<a class="code" href="landscape_8cpp.html#a0">NL3D_TESS_ALLOC_BLOCKSIZE</a>),
+00180 TessNearVertexAllocator(<a class="code" href="landscape_8cpp.html#a1">NL3D_TESSRDR_ALLOC_BLOCKSIZE</a>),
+00181 TessFarVertexAllocator(<a class="code" href="landscape_8cpp.html#a1">NL3D_TESSRDR_ALLOC_BLOCKSIZE</a>),
+00182 TileMaterialAllocator(<a class="code" href="landscape_8cpp.html#a1">NL3D_TESSRDR_ALLOC_BLOCKSIZE</a>),
+00183 TileFaceAllocator(<a class="code" href="landscape_8cpp.html#a1">NL3D_TESSRDR_ALLOC_BLOCKSIZE</a>),
+00184 _Far0VB(CLandscapeVBAllocator::Far0),
+00185 _Far1VB(CLandscapeVBAllocator::Far1),
+00186 _TileVB(CLandscapeVBAllocator::Tile)
+00187 {
+00188 <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>.resize(NL3D::NbTilesMax);
+00189
+00190 <font class="comment">// Resize the vectors of sert of render pass for the far texture</font>
+00191 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>.resize (<a class="code" href="classNL3D_1_1CLandscape.html#f0">getRdrPassIndexWithSize</a> (<a class="code" href="landscape_8h.html#a1">NL_MAX_SIZE_OF_TEXTURE_EDGE</a>, <a class="code" href="landscape_8h.html#a1">NL_MAX_SIZE_OF_TEXTURE_EDGE</a>)+1);
+00192
+00193 <font class="comment">// Far texture not initialized till initTileBanks is not called</font>
+00194 <a class="code" href="classNL3D_1_1CLandscape.html#o16">_FarInitialized</a>=<font class="keyword">false</font>;
+00195
+00196 <font class="comment">// Init far lighting with White/black</font>
+00197 <a class="code" href="classNL3D_1_1CLandscape.html#z483_0">setupStaticLight</a> (CRGBA(255,255,255), CRGBA(0,0,0), 1.f);
+00198 <font class="comment">// Default material for pointLights</font>
+00199 <a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>= CRGBA::White;
+00200
+00201
+00202 fill(<a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>.begin(), <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>.end(), (CTileInfo*)NULL);
+00203
+00204 <a class="code" href="classNL3D_1_1CLandscape.html#o4">_FarTransition</a>= 10; <font class="comment">// 10 meters.</font>
+00205 <a class="code" href="classNL3D_1_1CLandscape.html#o1">_TileDistNear</a>=100.f;
+00206 <a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a>= 0.001f;
+00207 <a class="code" href="classNL3D_1_1CLandscape.html#o3">_RefineMode</a>=<font class="keyword">true</font>;
+00208
+00209 <a class="code" href="classNL3D_1_1CLandscape.html#o5">_TileMaxSubdivision</a>= 0;
+00210
+00211 <a class="code" href="classNL3D_1_1CLandscape.html#o11">_NFreeLightMaps</a>= 0;
+00212
+00213 <font class="comment">// By default Automatic light comes from up.</font>
+00214 <a class="code" href="classNL3D_1_1CLandscape.html#o18">_AutomaticLighting</a> = <font class="keyword">false</font>;
+00215 <a class="code" href="classNL3D_1_1CLandscape.html#o19">_AutomaticLightDir</a>= -CVector::K;
+00216
+00217 <font class="comment">// By default, noise is enabled.</font>
+00218 <a class="code" href="classNL3D_1_1CLandscape.html#z494_0">_NoiseEnabled</a>= <font class="keyword">true</font>;
+00219
+00220 <font class="comment">// By default, we compute Geomorph and Alpha in software.</font>
+00221 <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>= <font class="keyword">false</font>;
+00222 <a class="code" href="classNL3D_1_1CLandscape.html#o6">_VPThresholdChange</a>= <font class="keyword">false</font>;
+00223
+00224 <a class="code" href="classNL3D_1_1CLandscape.html#z491_5">_RenderMustRefillVB</a>= <font class="keyword">false</font>;
+00225
+00226 <font class="comment">// priority list.</font>
+00227 <a class="code" href="classNL3D_1_1CLandscape.html#z495_3">_OldRefineCenterSetuped</a>= <font class="keyword">false</font>;
+00228 <a class="code" href="classNL3D_1_1CLandscape.html#z495_0">_SplitPriorityList</a>.init(<a class="code" href="landscape_8cpp.html#a2">NL3D_REFINE_PLIST_DIST_STEP</a>, <a class="code" href="landscape_8cpp.html#a3">NL3D_REFINE_PLIST_NUM_ENTRIES</a>, <a class="code" href="landscape_8cpp.html#a4">NL3D_REFINE_PLIST_DIST_MAX_MOD</a>, <a class="code" href="landscape_8cpp.html#a5">NL3D_REFINE_PLIST_SPLIT_NUMQUADRANT</a>);
+00229 <font class="comment">// See updateRefine* Doc in tesselation.cpp for why the merge list do not need quadrants.</font>
+00230 <a class="code" href="classNL3D_1_1CLandscape.html#z495_1">_MergePriorityList</a>.init(<a class="code" href="landscape_8cpp.html#a2">NL3D_REFINE_PLIST_DIST_STEP</a>, <a class="code" href="landscape_8cpp.html#a3">NL3D_REFINE_PLIST_NUM_ENTRIES</a>, <a class="code" href="landscape_8cpp.html#a4">NL3D_REFINE_PLIST_DIST_MAX_MOD</a>, 0);
+00231 <font class="comment">// just for getTesselatedPos to work properly.</font>
+00232 <a class="code" href="classNL3D_1_1CLandscape.html#z495_2">_OldRefineCenter</a>= CVector::Null;
+00233
+00234 <font class="comment">// create / Init the vegetable manager.</font>
+00235 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>= <font class="keyword">new</font> CVegetableManager(<a class="code" href="landscape__def_8h.html#a8">NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_UNLIT</a>, <a class="code" href="landscape__def_8h.html#a9">NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_LIGHTED</a>);
+00236
+00237 <font class="comment">// Init vegetable setup.</font>
+00238 <a class="code" href="classNL3D_1_1CLandscape.html#z496_2">_VegetableManagerEnabled</a>= <font class="keyword">false</font>;
+00239 <a class="code" href="classNL3D_1_1CLandscape.html#z496_3">_DriverOkForVegetable</a>= <font class="keyword">false</font>;
+00240 <font class="comment">// default global vegetable color, used for dynamic lighting only (arbitrary).</font>
+00241 <a class="code" href="classNL3D_1_1CLandscape.html#z499_5">_DLMGlobalVegetableColor</a>.set(180, 180, 180);
+00242
+00243 <a class="code" href="classNL3D_1_1CLandscape.html#z497_0">_PZBModelPosition</a>= CVector::Null;
+00244
+00245
+00246 <font class="comment">// Default: no updateLighting.</font>
+00247 <a class="code" href="classNL3D_1_1CLandscape.html#z498_7">_ULFrequency</a>= 0;
+00248 <a class="code" href="classNL3D_1_1CLandscape.html#z498_5">_ULPrecTimeInit</a>= <font class="keyword">false</font>;
+00249 <font class="comment">// Default: no textureFar created.</font>
+00250 <a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>= 0;
+00251 <a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a>= 0;
+00252 <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>= NULL;
+00253 <a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>= 0;
+00254 <font class="comment">// Default: no patch created</font>
+00255 <a class="code" href="classNL3D_1_1CLandscape.html#z498_12">_ULTotalNearPixels</a>= 0;
+00256 <a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a>= 0;
+00257 <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>= NULL;
+00258 <a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>= 0;
+00259
+00260
+00261 <font class="comment">// Dynamic Lighting.</font>
+00262 <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>= <font class="keyword">new</font> CTextureDLM(<a class="code" href="landscape__def_8h.html#a13">NL3D_LANDSCAPE_DLM_WIDTH</a>, <a class="code" href="landscape__def_8h.html#a14">NL3D_LANDSCAPE_DLM_HEIGHT</a>);
+00263 <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>= <font class="keyword">new</font> CPatchDLMContextList;
+00264 <a class="code" href="classNL3D_1_1CLandscape.html#z499_4">_DLMMaxAttEnd</a>= 30.f;
+00265
+00266
+00267 <font class="comment">// Alloc some global space for tri rendering.</font>
+00268 <font class="keywordflow">if</font>( CLandscapeGlobals::PassTriArray.size() &lt; 1000 )
+00269 CLandscapeGlobals::PassTriArray.resize( 1000 );
+00270
+00271 }
+00272 <font class="comment">// ***************************************************************************</font>
+<a name="l00273"></a><a class="code" href="classNL3D_1_1CLandscape.html#a1">00273</a> CLandscape::~CLandscape()
+00274 {
+00275 <a class="code" href="classNL3D_1_1CLandscape.html#z477_3">clear</a>();
+00276
+00277 <font class="comment">// release the VegetableManager.</font>
+00278 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>;
+00279 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>= NULL;
+00280
+00281 <font class="comment">// Dynamic Lighting.</font>
+00282 <font class="comment">// smartPtr delete</font>
+00283 <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>= NULL;
+00284 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>;
+00285 <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>= NULL;
+00286 }
+00287
+00288
+00289 <font class="comment">// ***************************************************************************</font>
+<a name="l00290"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_0">00290</a> <font class="keywordtype">void</font> CLandscape::init()
+00291 {
+00292 <font class="comment">// Fill Far mat.</font>
+00293 <font class="comment">// Must init his BlendFunction here!!! becaus it switch between blend on/off during rendering.</font>
+00294 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.initUnlit();
+00295 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setSrcBlend(CMaterial::srcalpha);
+00296 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setDstBlend(CMaterial::invsrcalpha);
+00297
+00298 <font class="comment">// FarMaterial: pass trhough Alpha from diffuse.</font>
+00299 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvOpAlpha(0, CMaterial::Replace);
+00300 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvArg0Alpha(0, CMaterial::Diffuse, CMaterial::SrcAlpha);
+00301 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvOpAlpha(1, CMaterial::Replace);
+00302 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvArg0Alpha(1, CMaterial::Diffuse, CMaterial::SrcAlpha);
+00303 <font class="comment">// FarMaterial: Add RGB from static lightmap and dynamic lightmap</font>
+00304 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvOpRGB(0, CMaterial::Replace);
+00305 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
+00306 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvOpRGB(1, CMaterial::Add);
+00307 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvArg0RGB(1, CMaterial::Texture, CMaterial::SrcColor);
+00308 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.texEnvArg1RGB(1, CMaterial::Previous, CMaterial::SrcColor);
+00309
+00310
+00311 <font class="comment">// Init material for tile.</font>
+00312 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.initUnlit();
+00313
+00314 <font class="comment">// init quadGrid.</font>
+00315 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.create(<a class="code" href="classNL3D_1_1CLandscape.html#z493_3">_PatchQuadGridSize</a>, <a class="code" href="classNL3D_1_1CLandscape.html#z493_4">_PatchQuadGridEltSize</a>);
+00316 }
+00317
+00318
+00319 <font class="comment">// ***************************************************************************</font>
+<a name="l00320"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_2">00320</a> <font class="keywordtype">void</font> CLandscape::setThreshold (<font class="keywordtype">float</font> thre)
+00321 {
+00322 thre= max(thre, 0.f);
+00323 <font class="keywordflow">if</font>(thre != <a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a>)
+00324 {
+00325 <a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a>= thre;
+00326 <a class="code" href="classNL3D_1_1CLandscape.html#o6">_VPThresholdChange</a>= <font class="keyword">true</font>;
+00327 }
+00328 }
+00329
+00330
+00331 <font class="comment">// ***************************************************************************</font>
+<a name="l00332"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_0">00332</a> <font class="keywordtype">void</font> CLandscape::setTileNear (<font class="keywordtype">float</font> tileNear)
+00333 {
+00334 tileNear= max(tileNear, <a class="code" href="classNL3D_1_1CLandscape.html#o4">_FarTransition</a>);
+00335
+00336 <font class="keywordflow">if</font>(tileNear!=<a class="code" href="classNL3D_1_1CLandscape.html#o1">_TileDistNear</a>)
+00337 {
+00338 <a class="code" href="classNL3D_1_1CLandscape.html#o1">_TileDistNear</a>= tileNear;
+00339 <a class="code" href="classNL3D_1_1CLandscape.html#c4">resetRenderFarAndDeleteVBFV</a>();
+00340 }
+00341
+00342 }
+00343
+00344
+00345 <font class="comment">// ***************************************************************************</font>
+<a name="l00346"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_6">00346</a> <font class="keywordtype">void</font> CLandscape::setTileMaxSubdivision (uint tileDiv)
+00347 {
+00348 <a class="code" href="debug_8h.html#a6">nlassert</a>(tileDiv&gt;=0 &amp;&amp; tileDiv&lt;=4);
+00349
+00350 <font class="keywordflow">if</font>(tileDiv!=<a class="code" href="classNL3D_1_1CLandscape.html#o5">_TileMaxSubdivision</a>)
+00351 {
+00352 <a class="code" href="classNL3D_1_1CLandscape.html#o5">_TileMaxSubdivision</a>= tileDiv;
+00353 <font class="comment">// Force at Tile==0. Nex refine will split correctly.</font>
+00354 <a class="code" href="classNL3D_1_1CLandscape.html#c5">forceMergeAtTileLevel</a>();
+00355 }
+00356 }
+00357 <font class="comment">// ***************************************************************************</font>
+<a name="l00358"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_7">00358</a> uint CLandscape::getTileMaxSubdivision ()
+00359 {
+00360 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#o5">_TileMaxSubdivision</a>;
+00361 }
+00362
+00363
+00364 <font class="comment">// ***************************************************************************</font>
+<a name="l00365"></a><a class="code" href="classNL3D_1_1CLandscape.html#c4">00365</a> <font class="keywordtype">void</font> CLandscape::resetRenderFarAndDeleteVBFV()
+00366 {
+00367 <font class="comment">// For all patch of all zones.</font>
+00368 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00369 {
+00370 ((*it).second)-&gt;resetRenderFarAndDeleteVBFV();
+00371 }
+00372 }
+00373
+00374
+00375 <font class="comment">// ***************************************************************************</font>
+<a name="l00376"></a><a class="code" href="classNL3D_1_1CLandscape.html#c5">00376</a> <font class="keywordtype">void</font> CLandscape::forceMergeAtTileLevel()
+00377 {
+00378 <font class="comment">// For all patch of all zones.</font>
+00379 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00380 {
+00381 ((*it).second)-&gt;forceMergeAtTileLevel();
+00382 }
+00383 }
+00384
+00385
+00386 <font class="comment">// ***************************************************************************</font>
+<a name="l00387"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_1">00387</a> <font class="keywordtype">bool</font> CLandscape::addZone(<font class="keyword">const</font> CZone &amp;newZone)
+00388 {
+00389 <font class="comment">// -1. Update globals</font>
+00390 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (CVector::Null);
+00391 <font class="comment">// NB: adding a zone may add vertices in VB in visible patchs (because of binds)=&gt; buffers are locked.</font>
+00392
+00393 uint16 zoneId= newZone.getZoneId();
+00394
+00395 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId)!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+00396 {
+00397 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00398 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00399 }
+00400 <a class="code" href="classNL3D_1_1CLandscape.html#l2">CZone</a> *zone= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CLandscape.html#l2">CZone</a>;
+00401
+00402 <font class="comment">// copy zone.</font>
+00403 zone-&gt;build(newZone);
+00404
+00405 <font class="comment">// Affect the current lighting of pointLight to the zone.</font>
+00406 <a class="code" href="classNL3D_1_1CLandscape.html#u10">ItLightGroupColorMap</a> itLGC= <a class="code" href="classNL3D_1_1CLandscape.html#o20">_LightGroupColorMap</a>.begin();
+00407 <font class="keywordflow">while</font>( itLGC != <a class="code" href="classNL3D_1_1CLandscape.html#o20">_LightGroupColorMap</a>.end() )
+00408 {
+00409 zone-&gt;_PointLightArray.setPointLightFactor(itLGC-&gt;first, itLGC-&gt;second);
+00410 itLGC++;
+00411 }
+00412
+00413
+00414 <font class="comment">// apply the landscape heightField, modifying BBoxes.</font>
+00415 zone-&gt;applyHeightField(*<font class="keyword">this</font>);
+00416
+00417 <font class="comment">// compile the zone for this landscape.</font>
+00418 zone-&gt;compile(<font class="keyword">this</font>, <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>);
+00419
+00420 <font class="comment">// For test of _PatchQuadGrid erase.</font>
+00421 CAABBox zoneBBForErase= zone-&gt;getZoneBB().getAABBox();
+00422 <font class="comment">// Avoid precision problems by enlarging a little bbox size of zone for erase</font>
+00423 zoneBBForErase.setHalfSize( zoneBBForErase.getHalfSize() * 1.1f);
+00424
+00425 <font class="comment">// add patchs of this zone to the quadgrid.</font>
+00426 <font class="keywordflow">for</font>(sint i= 0; i&lt;zone-&gt;getNumPatchs(); i++)
+00427 {
+00428 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= ((<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l2">CZone</a>*)zone)-&gt;getPatch(i);
+00429 CPatchIdentEx paId;
+00430 paId.ZoneId= zoneId;
+00431 paId.PatchId= i;
+00432 paId.Patch= pa;
+00433 CAABBox bb= pa-&gt;buildBBox();
+00434 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.insert(bb.getMin(), bb.getMax(), paId);
+00435 <font class="comment">// NB: the bbox of zone is used to remove patch. Hence it is VERY important that zoneBBox includes</font>
+00436 <font class="comment">// all patchs bbox (else some patchs entries may not be deleted in removeZone()).</font>
+00437 <a class="code" href="debug_8h.html#a6">nlassert</a>(zoneBBForErase.include(bb));
+00438 }
+00439
+00440 <font class="comment">// Must realase VB Buffers</font>
+00441 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00442
+00443 <font class="comment">// Because bind may add faces in other (visible) zones because of enforced split, we must check</font>
+00444 <font class="comment">// and update any FaceVector.</font>
+00445 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00446
+00447 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00448 }
+00449 <font class="comment">// ***************************************************************************</font>
+<a name="l00450"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_2">00450</a> <font class="keywordtype">bool</font> CLandscape::removeZone(uint16 zoneId)
+00451 {
+00452 <font class="comment">// -1. Update globals</font>
+00453 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (CVector::Null);
+00454 <font class="comment">// NB: remove a zone may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00455
+00456 <font class="comment">// find the zone.</font>
+00457 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId)==<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+00458 {
+00459 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00460 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00461 }
+00462 <a class="code" href="classNL3D_1_1CLandscape.html#l2">CZone</a> *zone= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>[zoneId];
+00463
+00464
+00465 <font class="comment">// delete patchs from this zone to the quadgrid.</font>
+00466 <font class="comment">// use the quadgrid itself to find where patch are. do this using bbox of zone.</font>
+00467 CAABBox zoneBBForErase= zone-&gt;getZoneBB().getAABBox();
+00468 <font class="comment">// Avoid precision problems by enlarging a little bbox size of zone for erase</font>
+00469 zoneBBForErase.setHalfSize( zoneBBForErase.getHalfSize() * 1.1f);
+00470 <font class="comment">// select iterators in the area of this zone.</font>
+00471 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.clearSelection();
+00472 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.select(zoneBBForErase.getMin(), zoneBBForErase.getMax());
+00473 <font class="comment">// for each patch, remove it if from deleted zone.</font>
+00474 CQuadGrid&lt;CPatchIdentEx&gt;::CIterator it;
+00475 sint nPatchRemoved= 0;
+00476 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.begin(); it!= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.end();)
+00477 {
+00478 <font class="comment">// if the patch belong to the zone to remove</font>
+00479 <font class="keywordflow">if</font>( (*it).ZoneId== zone-&gt;getZoneId() )
+00480 {
+00481 <font class="comment">// remove from the quadgrid.</font>
+00482 it= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.erase(it);
+00483 nPatchRemoved++;
+00484 }
+00485 <font class="keywordflow">else</font>
+00486 it++;
+00487 }
+00488 <font class="comment">// verify we have removed all patch in the quadGrid for this zone</font>
+00489 <a class="code" href="debug_8h.html#a6">nlassert</a>(nPatchRemoved==zone-&gt;getNumPatchs());
+00490
+00491
+00492 <font class="comment">// remove the zone.</font>
+00493 zone-&gt;release(<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>);
+00494 <font class="keyword">delete</font> zone;
+00495
+00496 <font class="comment">// Must realase VB Buffers</font>
+00497 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00498
+00499 <font class="comment">// because of forceMerge() at unbind, removeZone() can cause change in faces in other (visible) zones.</font>
+00500 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00501
+00502 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00503 }
+00504 <font class="comment">// ***************************************************************************</font>
+<a name="l00505"></a><a class="code" href="classNL3D_1_1CLandscape.html#z481_2">00505</a> <font class="keywordtype">void</font> CLandscape::getZoneList(std::vector&lt;uint16&gt; &amp;zoneIds)<font class="keyword"> const</font>
+00506 <font class="keyword"></font>{
+00507 zoneIds.clear();
+00508 zoneIds.reserve(<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.size());
+00509 std::map&lt;uint16, CZone*&gt;::const_iterator it;
+00510 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00511 {
+00512 zoneIds.push_back((*it).first);
+00513 }
+00514 }
+00515 <font class="comment">// ***************************************************************************</font>
+<a name="l00516"></a><a class="code" href="classNL3D_1_1CLandscape.html#z481_3">00516</a> <font class="keywordtype">void</font> CLandscape::buildZoneName(sint zoneId, std::string &amp;zoneName)
+00517 {
+00518 <font class="keywordtype">char</font> tmp[256];
+00519 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>= zoneId &amp; 255;
+00520 sint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>= zoneId &gt;&gt; 8;
+00521 sprintf(tmp, <font class="stringliteral">"%d_%c%c"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1, (<font class="keywordtype">char</font>)(<font class="charliteral">'A'</font>+(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>/26)), (<font class="keywordtype">char</font>)(<font class="charliteral">'A'</font>+(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>%26)));
+00522 zoneName= tmp;
+00523 }
+00524 <font class="comment">// ***************************************************************************</font>
+<a name="l00525"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_3">00525</a> <font class="keywordtype">void</font> CLandscape::clear()
+00526 {
+00527 <font class="comment">// Build the list of zoneId.</font>
+00528 vector&lt;uint16&gt; zoneIds;
+00529 <a class="code" href="classNL3D_1_1CLandscape.html#z481_2">getZoneList</a>(zoneIds);
+00530
+00531 <font class="comment">// Remove each zone one by one.</font>
+00532 sint i;
+00533 <font class="keywordflow">for</font>(i=0;i&lt;(sint)zoneIds.size();i++)
+00534 {
+00535 <a class="code" href="debug_8h.html#a9">nlverify</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z477_2">removeZone</a>(zoneIds[i]));
+00536 }
+00537
+00538 <font class="comment">// ensure the quadgrid is empty.</font>
+00539 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.clear();
+00540
+00541
+00542 <font class="comment">// If not done, delete all VBhards allocated.</font>
+00543 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.clear();
+00544 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.clear();
+00545 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.clear();
+00546
+00547
+00548 <font class="comment">// Reset All Far Texture and unlink _ULRootTextureFar ciruclarList.</font>
+00549 <font class="comment">// First "free" the Free list. </font>
+00550 <font class="keywordflow">for</font>(i=0;i&lt;(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>.size();i++)
+00551 {
+00552 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[i].clear();
+00553 }
+00554 <font class="comment">// Then free all Far RdrPass.</font>
+00555 <a class="code" href="classNL3D_1_1CLandscape.html#u7">ItSPRenderPassSet</a> itFar;
+00556 <font class="comment">// unitl set is empty</font>
+00557 <font class="keywordflow">while</font>( (itFar= <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.begin()) != <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.end())
+00558 {
+00559 <font class="comment">// erase with link update.</font>
+00560 <a class="code" href="classNL3D_1_1CLandscape.html#c11">eraseFarRenderPassFromSet</a>(*itFar);
+00561 }
+00562
+00563
+00564 <font class="comment">// reset driver.</font>
+00565 <a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>= NULL;
+00566 }
+00567
+00568 <font class="comment">// ***************************************************************************</font>
+<a name="l00569"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_0">00569</a> <font class="keywordtype">void</font> CLandscape::setDriver(IDriver *drv)
+00570 {
+00571 <a class="code" href="debug_8h.html#a6">nlassert</a>(drv);
+00572 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a> != drv)
+00573 {
+00574 <a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>= drv;
+00575
+00576 <font class="comment">// Does the driver support VertexShader???</font>
+00577 <font class="comment">// only if VP supported by GPU.</font>
+00578 <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>= (<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>-&gt;isVertexProgramSupported() &amp;&amp; !<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>-&gt;isVertexProgramEmulated());
+00579
+00580
+00581 <font class="comment">// Does the driver has sufficient requirements for Vegetable???</font>
+00582 <font class="comment">// only if VP supported by GPU, and Only if max vertices allowed.</font>
+00583 <a class="code" href="classNL3D_1_1CLandscape.html#z496_3">_DriverOkForVegetable</a>= <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a> &amp;&amp; (<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>-&gt;getMaxVerticesByVertexBufferHard()&gt;=(uint)<a class="code" href="landscape__def_8h.html#a10">NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX</a>);
+00584
+00585 }
+00586 }
+00587
+00588 <font class="comment">// ***************************************************************************</font>
+<a name="l00589"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_1">00589</a> <font class="keywordtype">void</font> CLandscape::clip(<font class="keyword">const</font> CVector &amp;refineCenter, <font class="keyword">const</font> std::vector&lt;CPlane&gt; &amp;pyramid)
+00590 {
+00591 <font class="comment">// -1. Update globals</font>
+00592 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (refineCenter);
+00593 <font class="comment">// NB: clip may add/remove vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00594
+00595
+00596 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00597 {
+00598 (*it).second-&gt;clip(pyramid);
+00599 }
+00600
+00601 <font class="comment">// Must realase VB Buffers</font>
+00602 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00603
+00604 <font class="comment">// clip() should not cause change in faces in visible patchs.</font>
+00605 <font class="comment">// It should not happens, but check for security.</font>
+00606 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z490_19">_TessBlockModificationRoot</a>.getNextToModify()==NULL);
+00607 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00608
+00609 }
+00610 <font class="comment">// ***************************************************************************</font>
+<a name="l00611"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_2">00611</a> <font class="keywordtype">void</font> CLandscape::refine(<font class="keyword">const</font> CVector &amp;refineCenter)
+00612 {
+00613 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a77">ProfNRefineFaces</a>, 0);
+00614 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a78">ProfNRefineComputeFaces</a>, 0);
+00615 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a79">ProfNRefineLeaves</a>, 0);
+00616 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a80">ProfNSplits</a>, 0);
+00617 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a81">ProfNMerges</a>, 0);
+00618 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a82">ProfNRefineInTileTransition</a>, 0);
+00619 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a83">ProfNRefineWithLowDistance</a>, 0);
+00620 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a84">ProfNSplitsPass</a>, 0);
+00621
+00622 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#o3">_RefineMode</a>)
+00623 <font class="keywordflow">return</font>;
+00624
+00625 <font class="comment">// Update the priority list.</font>
+00626 <font class="comment">// ==========================</font>
+00627 CTessFacePListNode rootSplitTessFaceToUpdate;
+00628 CTessFacePListNode rootMergeTessFaceToUpdate;
+00629 <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CLandscape.html#z495_3">_OldRefineCenterSetuped</a> )
+00630 {
+00631 <font class="comment">// If never refine, and setup OldRefineCetner</font>
+00632 <a class="code" href="classNL3D_1_1CLandscape.html#z495_3">_OldRefineCenterSetuped</a>= <font class="keyword">true</font>;
+00633 <a class="code" href="classNL3D_1_1CLandscape.html#z495_2">_OldRefineCenter</a>= refineCenter;
+00634
+00635 <font class="comment">// then shift all faces</font>
+00636 <a class="code" href="classNL3D_1_1CLandscape.html#z495_0">_SplitPriorityList</a>.shiftAll(rootSplitTessFaceToUpdate);
+00637 <a class="code" href="classNL3D_1_1CLandscape.html#z495_1">_MergePriorityList</a>.shiftAll(rootMergeTessFaceToUpdate);
+00638 }
+00639 <font class="keywordflow">else</font>
+00640 {
+00641 <font class="comment">// else, compute delta between positions</font>
+00642 CVector diff= refineCenter - <a class="code" href="classNL3D_1_1CLandscape.html#z495_2">_OldRefineCenter</a>;
+00643 <a class="code" href="classNL3D_1_1CLandscape.html#z495_2">_OldRefineCenter</a>= refineCenter;
+00644
+00645 <font class="comment">// and shift according to distance of deplacement.</font>
+00646 <a class="code" href="classNL3D_1_1CLandscape.html#z495_0">_SplitPriorityList</a>.shift(diff, rootSplitTessFaceToUpdate);
+00647 <a class="code" href="classNL3D_1_1CLandscape.html#z495_1">_MergePriorityList</a>.shift(diff, rootMergeTessFaceToUpdate);
+00648 }
+00649
+00650
+00651 <font class="comment">// Refine Faces which may need it.</font>
+00652 <font class="comment">// ==========================</font>
+00653 <font class="comment">// Update globals</font>
+00654 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (refineCenter);
+00655 <font class="comment">// NB: refine may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00656
+00657 <font class="comment">// Increment the update date.</font>
+00658 CLandscapeGlobals::CurrentDate++;
+00659
+00660 <font class="comment">// Because CTessFacePriorityList::insert use it.</font>
+00661 <a class="code" href="namespaceNL3D.html#a360">OptFastFloorBegin</a>();
+00662
+00663 <font class="comment">/* While there is still face in list, update them</font>
+00664 <font class="comment"> NB: updateRefine() always insert the face in _***PriorityList, so face is removed from </font>
+00665 <font class="comment"> root***TessFaceToUpdate list.</font>
+00666 <font class="comment"> NB: it is possible ( with enforced merge() ) that faces dissapears from root***TessFaceToUpdate list </font>
+00667 <font class="comment"> before they are traversed here. It is why we must use a Circular list system, and not an array of elements.</font>
+00668 <font class="comment"> Basically. TessFaces are ALWAYS in a list, either in one of the entry list in _***PriorityList, or in</font>
+00669 <font class="comment"> root***TessFaceToUpdate list.</font>
+00670 <font class="comment"></font>
+00671 <font class="comment"> It is newTessFace() and deleteTessFace() which insert/remove the nodes in the list.</font>
+00672 <font class="comment"> */</font>
+00673 <font class="comment">// Update the Merge priority list.</font>
+00674 <font class="keywordflow">while</font>( rootMergeTessFaceToUpdate.nextInPList() != &amp;rootMergeTessFaceToUpdate )
+00675 {
+00676 <font class="comment">// Get the face.</font>
+00677 <a class="code" href="classNL3D_1_1CLandscape.html#l0">CTessFace</a> *face= static_cast&lt;CTessFace*&gt;(rootMergeTessFaceToUpdate.nextInPList());
+00678
+00679 <font class="comment">// update the refine of this face. This may lead in deletion (merge) of other faces which are still in </font>
+00680 <font class="comment">// root***TessFaceToUpdate, but it's work.</font>
+00681 face-&gt;updateRefineMerge();
+00682 }
+00683
+00684
+00685 <font class="comment">// Update the Split priority list.</font>
+00686 <font class="keywordflow">do</font>
+00687 {
+00688 <a class="code" href="landscape__profile_8h.html#a2">NL3D_PROFILE_LAND_ADD</a>(<a class="code" href="namespaceNL3D.html#a84">ProfNSplitsPass</a>, 1);
+00689
+00690 <font class="comment">// Append the new leaves, to the list of triangles to update</font>
+00691 rootSplitTessFaceToUpdate.appendPList(<a class="code" href="classNL3D_1_1CLandscape.html#z495_4">_RootNewLeaves</a>);
+00692
+00693 <font class="comment">// While triangle to test for split exists</font>
+00694 <font class="keywordflow">while</font>( rootSplitTessFaceToUpdate.nextInPList() != &amp;rootSplitTessFaceToUpdate )
+00695 {
+00696 <font class="comment">// Get the face.</font>
+00697 <a class="code" href="classNL3D_1_1CLandscape.html#l0">CTessFace</a> *face= static_cast&lt;CTessFace*&gt;(rootSplitTessFaceToUpdate.nextInPList());
+00698
+00699 <font class="comment">// update the refine of this face.</font>
+00700 face-&gt;updateRefineSplit();
+00701 }
+00702
+00703 }
+00704 <font class="comment">// do it until we are sure no more split is needed, ie no more faces are created</font>
+00705 <font class="keywordflow">while</font>( <a class="code" href="classNL3D_1_1CLandscape.html#z495_4">_RootNewLeaves</a>.nextInPList() != &amp;<a class="code" href="classNL3D_1_1CLandscape.html#z495_4">_RootNewLeaves</a> );
+00706
+00707 <font class="comment">// Because CTessFacePriorityList::insert use it.</font>
+00708 <a class="code" href="namespaceNL3D.html#a361">OptFastFloorEnd</a>();
+00709
+00710
+00711 <font class="comment">// Before unlockBuffers, test for vegetable IG creation.</font>
+00712 {
+00713 <a class="code" href="hierarchical__timer_8h.html#a4">H_AUTO</a>( NL3D_Vegetable_Update );
+00714
+00715 <font class="comment">// Because CLandscapeVegetableBlock::update() use OptFastFloor..</font>
+00716 <a class="code" href="namespaceNL3D.html#a360">OptFastFloorBegin</a>();
+00717
+00718 <font class="comment">// For each vegetableBlock, test IG creation</font>
+00719 CLandscapeVegetableBlock *vegetBlock= <a class="code" href="classNL3D_1_1CLandscape.html#z496_4">_VegetableBlockList</a>.begin();
+00720 <font class="keywordflow">for</font>(;vegetBlock!=NULL; vegetBlock= (CLandscapeVegetableBlock*)vegetBlock-&gt;Next)
+00721 {
+00722 vegetBlock-&gt;update(refineCenter, <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>);
+00723 }
+00724
+00725 <font class="comment">// update lighting for vegetables</font>
+00726 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;updateLighting();
+00727
+00728 <font class="comment">// Stop fastFloor optim.</font>
+00729 <a class="code" href="namespaceNL3D.html#a361">OptFastFloorEnd</a>();
+00730 }
+00731
+00732
+00733 <font class="comment">// Must realase VB Buffers</font>
+00734 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00735
+00736 <font class="comment">// refine() may cause change in faces in visible patchs.</font>
+00737 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00738
+00739 }
+00740
+00741
+00742 <font class="comment">// ***************************************************************************</font>
+<a name="l00743"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_4">00743</a> <font class="keywordtype">void</font> CLandscape::refineAll(<font class="keyword">const</font> CVector &amp;refineCenter)
+00744 {
+00745 <font class="comment">// -1. Update globals</font>
+00746 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (refineCenter);
+00747 <font class="comment">// NB: refineAll may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00748
+00749 <font class="comment">// Increment the update date.</font>
+00750 CLandscapeGlobals::CurrentDate++;
+00751
+00752 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00753 {
+00754 (*it).second-&gt;refineAll();
+00755 }
+00756
+00757 <font class="comment">// Must realase VB Buffers</font>
+00758 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00759
+00760 <font class="comment">// refineAll() may cause change in faces in visible patchs.</font>
+00761 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00762 }
+00763
+00764
+00765 <font class="comment">// ***************************************************************************</font>
+<a name="l00766"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_5">00766</a> <font class="keywordtype">void</font> CLandscape::excludePatchFromRefineAll(sint zoneId, uint patch, <font class="keywordtype">bool</font> exclude)
+00767 {
+00768 <a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId);
+00769 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+00770 {
+00771 it-&gt;second-&gt;excludePatchFromRefineAll(patch, exclude);
+00772 }
+00773
+00774 }
+00775
+00776
+00777 <font class="comment">// ***************************************************************************</font>
+<a name="l00778"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_6">00778</a> <font class="keywordtype">void</font> CLandscape::averageTesselationVertices()
+00779 {
+00780 <font class="comment">// -1. Update globals</font>
+00781 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (CVector::Null);
+00782 <font class="comment">// NB: averageTesselationVertices may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00783
+00784 <font class="comment">// Increment the update date.</font>
+00785 CLandscapeGlobals::CurrentDate++;
+00786
+00787 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+00788 {
+00789 (*it).second-&gt;averageTesselationVertices();
+00790 }
+00791
+00792 <font class="comment">// Must realase VB Buffers</font>
+00793 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+00794
+00795 <font class="comment">// averageTesselationVertices() should not cause change in faces in any patchs.</font>
+00796 <font class="comment">// It should not happens, but check for security.</font>
+00797 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z490_19">_TessBlockModificationRoot</a>.getNextToModify()==NULL);
+00798 <a class="code" href="classNL3D_1_1CLandscape.html#c10">updateTessBlocksFaceVector</a>();
+00799
+00800 }
+00801
+00802
+00803
+00804 <font class="comment">// ***************************************************************************</font>
+<a name="l00805"></a><a class="code" href="classNL3D_1_1CLandscape.html#c6">00805</a> <font class="keywordtype">void</font> CLandscape::updateGlobalsAndLockBuffers (<font class="keyword">const</font> CVector &amp;refineCenter)
+00806 {
+00807 <font class="comment">// Setup CLandscapeGlobals static members...</font>
+00808
+00809 <font class="comment">// Far limits.</font>
+00810 CLandscapeGlobals::FarTransition= <a class="code" href="classNL3D_1_1CLandscape.html#o4">_FarTransition</a>;
+00811
+00812 <font class="comment">// Tile subdivsion part.</font>
+00813 CLandscapeGlobals::TileMaxSubdivision= <a class="code" href="classNL3D_1_1CLandscape.html#o5">_TileMaxSubdivision</a>;
+00814 CLandscapeGlobals::TileDistNear = <a class="code" href="classNL3D_1_1CLandscape.html#o1">_TileDistNear</a>;
+00815 CLandscapeGlobals::TileDistFar = CLandscapeGlobals::TileDistNear+20;
+00816 CLandscapeGlobals::TileDistNearSqr = <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(CLandscapeGlobals::TileDistNear);
+00817 CLandscapeGlobals::TileDistFarSqr = <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(CLandscapeGlobals::TileDistFar);
+00818 CLandscapeGlobals::OOTileDistDeltaSqr = 1.0f / (CLandscapeGlobals::TileDistFarSqr - CLandscapeGlobals::TileDistNearSqr);
+00819
+00820 <font class="comment">// Tile Pixel size part.</font>
+00821 <font class="comment">// \todo yoyo: choose according to wanted tile pixel size.</font>
+00822 CLandscapeGlobals::TilePixelSize= 128.0f;
+00823 CLandscapeGlobals::TilePixelBias128= 0.5f/CLandscapeGlobals::TilePixelSize;
+00824 CLandscapeGlobals::TilePixelScale128= 1-1/CLandscapeGlobals::TilePixelSize;
+00825 CLandscapeGlobals::TilePixelBias256= 0.5f/(CLandscapeGlobals::TilePixelSize*2);
+00826 CLandscapeGlobals::TilePixelScale256= 1-1/(CLandscapeGlobals::TilePixelSize*2);
+00827
+00828 <font class="comment">// RefineThreshold.</font>
+00829 CLandscapeGlobals::RefineThreshold= <a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a>;
+00830
+00831 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a> == 0.0f)
+00832 CLandscapeGlobals::OORefineThreshold = FLT_MAX;
+00833 <font class="keywordflow">else</font>
+00834 CLandscapeGlobals::OORefineThreshold = 1.0f / CLandscapeGlobals::RefineThreshold;
+00835
+00836 <font class="comment">// Refine Center*.</font>
+00837 CLandscapeGlobals::RefineCenter= refineCenter;
+00838 CLandscapeGlobals::TileFarSphere.Center= CLandscapeGlobals::RefineCenter;
+00839 CLandscapeGlobals::TileFarSphere.Radius= CLandscapeGlobals::TileDistFar;
+00840 CLandscapeGlobals::TileNearSphere.Center= CLandscapeGlobals::RefineCenter;
+00841 CLandscapeGlobals::TileNearSphere.Radius= CLandscapeGlobals::TileDistNear;
+00842
+00843 <font class="comment">// PZBModelPosition</font>
+00844 CLandscapeGlobals::PZBModelPosition= <a class="code" href="classNL3D_1_1CLandscape.html#z497_0">_PZBModelPosition</a>;
+00845
+00846 <font class="comment">// VB Allocators.</font>
+00847 CLandscapeGlobals::CurrentFar0VBAllocator= &amp;<a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>;
+00848 CLandscapeGlobals::CurrentFar1VBAllocator= &amp;<a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>;
+00849 CLandscapeGlobals::CurrentTileVBAllocator= &amp;<a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>;
+00850
+00851 <font class="comment">// Must check driver, and create VB infos,locking buffers.</font>
+00852 <font class="keywordflow">if</font>(_Driver)
+00853 {
+00854 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.updateDriver(<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>);
+00855 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.updateDriver(<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>);
+00856 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.updateDriver(<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>);
+00857
+00858 <font class="comment">// must do the same for _VegetableManager.</font>
+00859 <font class="keywordflow">if</font>(_DriverOkForVegetable)
+00860 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;updateDriver(<a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>);
+00861
+00862 <a class="code" href="classNL3D_1_1CLandscape.html#c7">lockBuffers</a> ();
+00863 }
+00864 }
+00865
+00866
+00867 <font class="comment">// ***************************************************************************</font>
+<a name="l00868"></a><a class="code" href="classNL3D_1_1CLandscape.html#c7">00868</a> <font class="keywordtype">void</font> CLandscape::lockBuffers ()
+00869 {
+00870 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.lockBuffer(CLandscapeGlobals::CurrentFar0VBInfo);
+00871 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.lockBuffer(CLandscapeGlobals::CurrentFar1VBInfo);
+00872 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.lockBuffer(CLandscapeGlobals::CurrentTileVBInfo);
+00873
+00874 <font class="comment">// lock buffer of the vegetable manager.</font>
+00875 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;lockBuffers();
+00876
+00877 <font class="comment">// VertexProgrma mode???</font>
+00878 CLandscapeGlobals::VertexProgramEnabled= <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>;
+00879 }
+00880
+00881
+00882 <font class="comment">// ***************************************************************************</font>
+<a name="l00883"></a><a class="code" href="classNL3D_1_1CLandscape.html#c8">00883</a> <font class="keywordtype">void</font> CLandscape::unlockBuffers()
+00884 {
+00885 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.unlockBuffer();
+00886 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.unlockBuffer();
+00887 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.unlockBuffer();
+00888
+00889 <font class="comment">// unlock buffer of the vegetable manager.</font>
+00890 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;unlockBuffers();
+00891 }
+00892
+00893 <font class="comment">// ***************************************************************************</font>
+<a name="l00894"></a><a class="code" href="classNL3D_1_1CLandscape.html#c9">00894</a> <font class="keywordtype">void</font> CLandscape::synchronizeATIVBHards()
+00895 {
+00896 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.synchronizeATIVBHard();
+00897 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.synchronizeATIVBHard();
+00898 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.synchronizeATIVBHard();
+00899 }
+00900
+00901 <font class="comment">// ***************************************************************************</font>
+<a name="l00902"></a><a class="code" href="classNL3D_1_1CLandscape.html#c10">00902</a> <font class="keywordtype">void</font> CLandscape::updateTessBlocksFaceVector()
+00903 {
+00904 <font class="comment">// while some tessBlock to update remains.</font>
+00905 CTessBlock *tb;
+00906 <font class="keywordflow">while</font>( (tb=<a class="code" href="classNL3D_1_1CLandscape.html#z490_19">_TessBlockModificationRoot</a>.getNextToModify()) !=NULL )
+00907 {
+00908 <font class="comment">// Get the patch which owns this TessBlock.</font>
+00909 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *patch= tb-&gt;getPatch();
+00910
+00911 <font class="comment">// If this patch is visible, recreate faceVector for his tessBlock.</font>
+00912 patch-&gt;recreateTessBlockFaceVector(*tb);
+00913
+00914 <font class="comment">// remove from list.</font>
+00915 tb-&gt;removeFromModifyList();
+00916 }
+00917 }
+00918
+00919
+00920 <font class="comment">// ***************************************************************************</font>
+00921 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(CPatchRdrPass &amp;pass)
+00922 {
+00923 uint numIndices= pass.getMaxRenderedFaces()*3;
+00924 <font class="comment">// realloc if necessary</font>
+00925 <font class="keywordflow">if</font>( CLandscapeGlobals::PassTriArray.size() &lt; numIndices )
+00926 CLandscapeGlobals::PassTriArray.resize( numIndices );
+00927 <font class="comment">// reset ptr.</font>
+00928 <a class="code" href="namespaceNL3D.html#a71">NL3D_LandscapeGlobals_PassTriCurPtr</a>= &amp;CLandscapeGlobals::PassTriArray[0];
+00929 }
+00930
+00931
+00932 <font class="comment">// ***************************************************************************</font>
+00933 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(CMaterial &amp;mat)
+00934 {
+00935 <font class="keywordflow">if</font>(<a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>&gt;0)
+00936 {
+00937 CLandscapeGlobals::PatchCurrentDriver-&gt;setupMaterial(mat);
+00938 CLandscapeGlobals::PatchCurrentDriver-&gt;renderSimpleTriangles(&amp;CLandscapeGlobals::PassTriArray[0], <a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>);
+00939 <a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>= 0;
+00940 }
+00941 }
+00942
+00943
+00944 <font class="comment">// ***************************************************************************</font>
+<a name="l00945"></a><a class="code" href="classNL3D_1_1CLandscape.html#z479_3">00945</a> <font class="keywordtype">void</font> CLandscape::render(<font class="keyword">const</font> CVector &amp;refineCenter, <font class="keyword">const</font> CVector &amp;frontVector, <font class="keyword">const</font> CPlane pyramid[<a class="code" href="tess__block_8h.html#a0">NL3D_TESSBLOCK_NUM_CLIP_PLANE</a>], <font class="keywordtype">bool</font> doTileAddPass)
+00946 {
+00947 IDriver *driver= <a class="code" href="classNL3D_1_1CLandscape.html#z491_0">_Driver</a>;
+00948 <a class="code" href="debug_8h.html#a6">nlassert</a>(driver);
+00949
+00950 <font class="comment">// Increment the update date for preRender.</font>
+00951 CLandscapeGlobals::CurrentRenderDate++;
+00952
+00953
+00954 <a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it;
+00955 sint i;
+00956 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> itTile;
+00957 <a class="code" href="classNL3D_1_1CLandscape.html#u7">ItSPRenderPassSet</a> itFar;
+00958
+00959 <font class="comment">// Yoyo: profile.</font>
+00960 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a74">ProfNRdrFar0</a>, 0);
+00961 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a75">ProfNRdrFar1</a>, 0);
+00962 <font class="keywordflow">for</font>(i=0;i&lt;<a class="code" href="landscape__def_8h.html#a0">NL3D_MAX_TILE_PASS</a>;i++)
+00963 {
+00964 <a class="code" href="landscape__profile_8h.html#a1">NL3D_PROFILE_LAND_SET</a>(<a class="code" href="namespaceNL3D.html#a76">ProfNRdrTile</a>[i], 0);
+00965 }
+00966
+00967
+00968 <font class="comment">// -2. Update globals</font>
+00969 <font class="comment">//====================</font>
+00970 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (refineCenter);
+00971 <font class="comment">// NB: render may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+00972
+00973
+00974 <font class="comment">// -1. clear all PatchRenderPass renderList</font>
+00975 <font class="comment">//===================</font>
+00976
+00977 <font class="comment">// Fars.</font>
+00978 <font class="keywordflow">for</font>(itFar= <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.begin(); itFar!= <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.end(); itFar++)
+00979 {
+00980 CPatchRdrPass &amp;pass= **itFar;
+00981 <font class="comment">// clear list.</font>
+00982 pass.clearAllRenderList();
+00983 }
+00984
+00985 <font class="comment">// Tiles.</font>
+00986 <font class="keywordflow">for</font>(itTile= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.begin(); itTile!= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.end(); itTile++)
+00987 {
+00988 CPatchRdrPass &amp;pass= const_cast&lt;CPatchRdrPass&amp;&gt;(*itTile);
+00989 <font class="comment">// clear list.</font>
+00990 pass.clearAllRenderList();
+00991 }
+00992
+00993 <font class="comment">// Lightmaps.</font>
+00994 <font class="keywordflow">for</font>(sint lightRdrPass=0; lightRdrPass&lt;(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size(); lightRdrPass++)
+00995 {
+00996 CPatchRdrPass &amp;pass= *<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>[lightRdrPass];
+00997 <font class="comment">// clear list.</font>
+00998 pass.clearAllRenderList();
+00999 }
+01000
+01001 <font class="comment">// 0. preRender pass.</font>
+01002 <font class="comment">//===================</font>
+01003
+01004 <font class="comment">// change Far0 / Far1.</font>
+01005 <font class="comment">// Clip TessBlocks against pyramid and Far Limit.</font>
+01006 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="tess__block_8h.html#a0">NL3D_TESSBLOCK_NUM_CLIP_PLANE</a>; i++)
+01007 {
+01008 CTessBlock::CurrentPyramid[i]= pyramid[i];
+01009 }
+01010 <font class="comment">// Update VB with change of Far0 / Far1.</font>
+01011 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+01012 {
+01013 (*it).second-&gt;preRender();
+01014 }
+01015
+01016
+01017 <font class="comment">// Reallocation Mgt. If any of the VB is reallocated, we must refill it entirely.</font>
+01018 <font class="comment">// NB: all VBs are refilled entirely. It is not optimal (maybe 3* too slow), but reallocation are supposed</font>
+01019 <font class="comment">// to be very rare.</font>
+01020 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.reallocationOccurs() || <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.reallocationOccurs() || <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.reallocationOccurs() )
+01021 <a class="code" href="classNL3D_1_1CLandscape.html#z491_5">_RenderMustRefillVB</a>= <font class="keyword">true</font>;
+01022
+01023 <font class="comment">// VertexProgram dependency on RefineThreshold Management. If VertexShader, and if the refineThreshold has</font>
+01024 <font class="comment">// changed since the last time, we must refill All the VB, because data are out of date.</font>
+01025 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a> &amp;&amp; <a class="code" href="classNL3D_1_1CLandscape.html#o6">_VPThresholdChange</a> )
+01026 {
+01027 <a class="code" href="classNL3D_1_1CLandscape.html#o6">_VPThresholdChange</a>= <font class="keyword">false</font>;
+01028 <a class="code" href="classNL3D_1_1CLandscape.html#z491_5">_RenderMustRefillVB</a>= <font class="keyword">true</font>;
+01029 }
+01030
+01031 <font class="comment">// If we must refill the VB (for any reason).</font>
+01032 <font class="keywordflow">if</font>(_RenderMustRefillVB )
+01033 {
+01034 <font class="comment">// Ok, ok, we refill All the VB with good data.</font>
+01035 <a class="code" href="classNL3D_1_1CLandscape.html#z491_5">_RenderMustRefillVB</a>= <font class="keyword">false</font>;
+01036
+01037 <font class="comment">// First reset the flag, so fillVB() will effectively fill the VB.</font>
+01038 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.resetReallocation();
+01039 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.resetReallocation();
+01040 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.resetReallocation();
+01041
+01042 <font class="comment">// Then recompute good VBInfo (those in CurrentVBInfo are false!!).</font>
+01043 <font class="comment">// Do it by unlocking then re-locking Buffers.</font>
+01044 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+01045 <a class="code" href="classNL3D_1_1CLandscape.html#c7">lockBuffers</a>();
+01046
+01047 <font class="comment">// Finally, fill the VB for all patchs visible.</font>
+01048 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+01049 {
+01050 <font class="keywordflow">if</font>((*it).second-&gt;ClipResult==CZone::ClipOut)
+01051 <font class="keywordflow">continue</font>;
+01052 <font class="keywordflow">for</font>(sint i=0;i&lt;(*it).second-&gt;getNumPatchs(); i++)
+01053 {
+01054 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *patch= (*it).second-&gt;getPatch(i);
+01055 patch-&gt;fillVBIfVisible();
+01056 }
+01057 }
+01058 }
+01059
+01060
+01061 <font class="comment">// If software GeoMorph / Alpha Transition (no VertexShader), do it now.</font>
+01062 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>)
+01063 {
+01064 <font class="comment">// For all patch visible, compute geomoprh and alpha in software.</font>
+01065 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+01066 {
+01067 <font class="keywordflow">if</font>((*it).second-&gt;ClipResult==CZone::ClipOut)
+01068 <font class="keywordflow">continue</font>;
+01069 <font class="keywordflow">for</font>(sint i=0;i&lt;(*it).second-&gt;getNumPatchs(); i++)
+01070 {
+01071 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *patch= (*it).second-&gt;getPatch(i);
+01072 <font class="comment">// If visible, compute Geomorph And Alpha</font>
+01073 patch-&gt;computeSoftwareGeomorphAndAlpha();
+01074 }
+01075 }
+01076
+01077 <font class="comment">/*</font>
+01078 <font class="comment"> Optim note: here, lot of vertices are </font>
+01079 <font class="comment"> 1/ geomorphed twice (vertices on edges of patchs)</font>
+01080 <font class="comment"> 2/ vertices are geomorphed, but not used (because o the Tessblock clip), </font>
+01081 <font class="comment"> because lot of vertices used by faces in small TessBlocks are still in MasterBlock.</font>
+01082 <font class="comment"></font>
+01083 <font class="comment"> Some tries have been made to solve this, but result are even worse (2 times or more), because:</font>
+01084 <font class="comment"> 1/</font>
+01085 <font class="comment"> - does not really matter edges of patchs (and corner) because the majority is in interior of patch.</font>
+01086 <font class="comment"> - in this case, we need to reset all the flags which is very costly (reparse all zones...) .</font>
+01087 <font class="comment"> 2/ Except for the old CTessBlockEdge management which not solve all the thing, the other solution is</font>
+01088 <font class="comment"> to test all faces not clipped (on a per TessBlock basis), to compute only vertices needed.</font>
+01089 <font class="comment"> But in this cases, result are worse, maybe because there is 6 times more tests, and with bad BTB cache.</font>
+01090 <font class="comment"> */</font>
+01091 }
+01092
+01093
+01094 <font class="comment">// Must realase VB Buffers Now!! The VBuffers are now OK!</font>
+01095 <font class="comment">// NB: no parallelism is made between 3dCard and Fill of vertices.</font>
+01096 <font class="comment">// We Suppose Fill of vertices is rare, and so do not need to be parallelized.</font>
+01097 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+01098
+01099
+01100 <font class="comment">// Special for ATI: only copy all VBs to VBHard one time per frame</font>
+01101 <a class="code" href="classNL3D_1_1CLandscape.html#c9">synchronizeATIVBHards</a>();
+01102
+01103
+01104 <font class="comment">// If VertexShader enabled, setup VertexProgram Constants.</font>
+01105 <font class="keywordflow">if</font>(_VertexShaderOk)
+01106 {
+01107 <font class="comment">// c[0..3] take the ModelViewProjection Matrix.</font>
+01108 driver-&gt;setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
+01109 <font class="comment">// c[4] take usefull constants.</font>
+01110 driver-&gt;setConstant(4, 0, 1, 0.5f, 0);
+01111 <font class="comment">// c[5] take RefineCenter</font>
+01112 driver-&gt;setConstant(5, refineCenter);
+01113 <font class="comment">// c[6] take info for Geomorph trnasition to TileNear.</font>
+01114 driver-&gt;setConstant(6, CLandscapeGlobals::TileDistFarSqr, CLandscapeGlobals::OOTileDistDeltaSqr, 0, 0);
+01115 <font class="comment">// c[8..11] take the ModelView Matrix.</font>
+01116 driver-&gt;setConstantMatrix(8, IDriver::ModelView, IDriver::Identity);
+01117 <font class="comment">// c[12] take the current landscape Center / delta Pos to apply</font>
+01118 driver-&gt;setConstant(12, <a class="code" href="classNL3D_1_1CLandscape.html#z497_0">_PZBModelPosition</a>);
+01119 }
+01120
+01121
+01122 <font class="comment">// 1. TileRender pass.</font>
+01123 <font class="comment">//====================</font>
+01124
+01125
+01126 <font class="comment">// First, update Dynamic Lighting for Near, ie multiply Dynamic Lightmap with UserColor, and upload to texture.</font>
+01127 <font class="comment">// ==================</font>
+01128 CPatchDLMContext *dlmCtxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+01129 <font class="keywordflow">while</font>(dlmCtxPtr!=NULL)
+01130 {
+01131 <font class="comment">// do it only if the patch has some Near stuff to render, and if it is visible</font>
+01132 <font class="keywordflow">if</font>(dlmCtxPtr-&gt;getPatch()-&gt;getFar0() == 0
+01133 &amp;&amp; !dlmCtxPtr-&gt;getPatch()-&gt;isRenderClipped() )
+01134 {
+01135 <font class="comment">// upload lightmap into textureDLM, modulating before with patch TileColor.</font>
+01136 <font class="comment">// NB: no-op if both src and dst are already full black.</font>
+01137 dlmCtxPtr-&gt;compileLighting(CPatchDLMContext::ModulateTileColor);
+01138 }
+01139
+01140 <font class="comment">// next</font>
+01141 dlmCtxPtr= (CPatchDLMContext*)dlmCtxPtr-&gt;Next;
+01142 }
+01143
+01144
+01145 <font class="comment">// Active VB.</font>
+01146 <font class="comment">// ==================</font>
+01147
+01148 <font class="comment">// Active the good VB, and maybe activate the VertexProgram N°0.</font>
+01149 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.activate(0);
+01150
+01151
+01152 <font class="comment">// Render.</font>
+01153 <font class="comment">// ==================</font>
+01154 <font class="comment">// Before any render call. Set the global driver used to render.</font>
+01155 CLandscapeGlobals::PatchCurrentDriver= driver;
+01156
+01157
+01158 <font class="comment">// Render Order. Must "invert", since initial order is NOT the render order. This is done because the lightmap pass</font>
+01159 <font class="comment">// DO NOT have to do any renderTile(), since it is computed in RGB0 pass.</font>
+01160 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="landscape__def_8h.html#a0">NL3D_MAX_TILE_PASS</a>==5);
+01161 <font class="keyword">static</font> sint RenderOrder[<a class="code" href="landscape__def_8h.html#a0">NL3D_MAX_TILE_PASS</a>]= {<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>, <a class="code" href="landscape__def_8h.html#a3">NL3D_TILE_PASS_RGB1</a>, <a class="code" href="landscape__def_8h.html#a4">NL3D_TILE_PASS_RGB2</a>,
+01162 <a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>, <a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>};
+01163 <font class="comment">// For ALL pass..</font>
+01164 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="landscape__def_8h.html#a0">NL3D_MAX_TILE_PASS</a>; i++)
+01165 {
+01166 sint passOrder= RenderOrder[i];
+01167
+01168
+01169 <font class="comment">// If VertexShader enabled, and if lightmap or post Add pass, must setup good VertexProgram</font>
+01170 <font class="keywordflow">if</font>(_VertexShaderOk)
+01171 {
+01172 <font class="keywordflow">if</font>(passOrder == <a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>)
+01173 {
+01174 <font class="comment">// Must activate the vertexProgram to take TexCoord2 to stage0</font>
+01175 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.activate(1);
+01176 }
+01177 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(passOrder == <a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>)
+01178 {
+01179 <font class="comment">// Must re-activate the standard VertexProgram</font>
+01180 <a class="code" href="classNL3D_1_1CLandscape.html#z491_3">_TileVB</a>.activate(0);
+01181 }
+01182 }
+01183
+01184
+01185 <font class="comment">// Do add pass???</font>
+01186 <font class="keywordflow">if</font>((passOrder==<a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>) &amp;&amp; !doTileAddPass)
+01187 <font class="keywordflow">continue</font>;
+01188
+01189
+01190 <font class="comment">// Setup common material for this pass.</font>
+01191 <font class="comment">//=============================</font>
+01192 <font class="comment">// Default: Replace envmode.</font>
+01193 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpRGB(0, CMaterial::Replace);
+01194 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
+01195 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpAlpha(0, CMaterial::Replace);
+01196 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0Alpha(0, CMaterial::Texture, CMaterial::SrcAlpha);
+01197 <font class="comment">// NB: important to set Replace and not modulate, because in case of VerexProgram enabled, </font>
+01198 <font class="comment">// Diffuse o[COL0] is undefined.</font>
+01199
+01200 <font class="comment">// Copy from stage 0 to stage 1.</font>
+01201 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexEnvMode(1, <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.getTexEnvMode(0));
+01202
+01203 <font class="comment">// setup multitex / blending.</font>
+01204 <font class="keywordflow">if</font>(passOrder==<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>)
+01205 {
+01206 <font class="comment">// first pass, no blend.</font>
+01207 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setBlend(<font class="keyword">false</font>);
+01208 }
+01209 <font class="keywordflow">else</font>
+01210 {
+01211 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setBlend(<font class="keyword">true</font>);
+01212 <font class="keywordflow">switch</font>(passOrder)
+01213 {
+01214 <font class="keywordflow">case</font> <a class="code" href="landscape__def_8h.html#a3">NL3D_TILE_PASS_RGB1</a>:
+01215 <font class="keywordflow">case</font> <a class="code" href="landscape__def_8h.html#a4">NL3D_TILE_PASS_RGB2</a>:
+01216 <font class="comment">// alpha blending.</font>
+01217 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
+01218
+01219 <font class="comment">// Must use a special envmode for stage1: "separateAlpha"!!.</font>
+01220 <font class="comment">// keep the color from previous stage.</font>
+01221 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpRGB(1, CMaterial::Replace);
+01222 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0RGB(1, CMaterial::Previous, CMaterial::SrcColor);
+01223 <font class="comment">// take the alpha from current stage.</font>
+01224 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpAlpha(1, CMaterial::Replace);
+01225 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0Alpha(1, CMaterial::Texture, CMaterial::SrcAlpha);
+01226 <font class="keywordflow">break</font>;
+01227 <font class="keywordflow">case</font> <a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>:
+01228 <font class="comment">// modulate alpha blending.</font>
+01229 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setBlendFunc(CMaterial::zero, CMaterial::srccolor);
+01230
+01231 <font class="comment">// Setup the material envCombine so DynamicLightmap (stage 0) is added to static lightmap.</font>
+01232 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpRGB(1, CMaterial::Add);
+01233 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0RGB(1, CMaterial::Texture, CMaterial::SrcColor);
+01234 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg1RGB(1, CMaterial::Previous, CMaterial::SrcColor);
+01235
+01236 <font class="keywordflow">break</font>;
+01237 <font class="keywordflow">case</font> <a class="code" href="landscape__def_8h.html#a5">NL3D_TILE_PASS_ADD</a>:
+01238 <font class="comment">// Use srcalpha for src (and not ONE), since additive are blended with alpha Cte/AlphaTexture</font>
+01239 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setBlendFunc(CMaterial::srcalpha, CMaterial::one);
+01240
+01241 <font class="comment">// for MAYBE LATER smooth night transition, setup Alpha cte of stage0, and setup alpha stage.</font>
+01242 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpAlpha(0, CMaterial::Replace);
+01243 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
+01244 <font class="comment">// Temp, just setup alpha to 1.</font>
+01245 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texConstantColor(0, CRGBA(255, 255, 255, 255));
+01246
+01247 <font class="comment">// Must use a special envmode for stage1: "separateAlpha"!!.</font>
+01248 <font class="comment">// NB: it still works if The RdrPass has no texture.</font>
+01249 <font class="comment">// keep the color from previous stage.</font>
+01250 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpRGB(1, CMaterial::Replace);
+01251 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0RGB(1, CMaterial::Previous, CMaterial::SrcColor);
+01252 <font class="comment">// modulate the alpha of current stage with previous</font>
+01253 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvOpAlpha(1, CMaterial::Modulate);
+01254 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg0Alpha(1, CMaterial::Texture, CMaterial::SrcAlpha);
+01255 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.texEnvArg1Alpha(1, CMaterial::Previous, CMaterial::SrcAlpha);
+01256
+01257 <font class="keywordflow">break</font>;
+01258 <font class="keywordflow">default</font>:
+01259 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+01260 };
+01261 }
+01262 <font class="comment">// Reset the textures (so there is none in Addtive pass or in Lightmap).</font>
+01263 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(0, NULL);
+01264 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(1, NULL);
+01265 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(2, NULL);
+01266
+01267
+01268 <font class="comment">// Render All material RdrPass.</font>
+01269 <font class="comment">//=============================</font>
+01270 <font class="comment">// Special code for Lightmap and RGB0, for faster render.</font>
+01271 <font class="keywordflow">if</font>(passOrder==<a class="code" href="landscape__def_8h.html#a2">NL3D_TILE_PASS_RGB0</a>)
+01272 {
+01273 <font class="comment">// RGB0 pass.</font>
+01274 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> itTile;
+01275 <font class="keywordflow">for</font>(itTile= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.begin(); itTile!= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.end(); itTile++)
+01276 {
+01277 <font class="comment">// Get a ref on the render pass. Const cast work because we only modify attribut from CPatchRdrPass </font>
+01278 <font class="comment">// that don't affect the operator&lt; of this class</font>
+01279 CPatchRdrPass &amp;pass= const_cast&lt;CPatchRdrPass&amp;&gt;(*itTile);
+01280
+01281 <font class="comment">// Enlarge PassTriArray as needed</font>
+01282 <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(pass);
+01283
+01284 <font class="comment">// Setup Diffuse texture of the tile.</font>
+01285 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(0, pass.TextureDiffuse);
+01286
+01287 <font class="comment">// Add triangles to array</font>
+01288 CRdrTileId *tileToRdr= pass.getRdrTileRoot(passOrder);
+01289 <font class="keywordflow">while</font>(tileToRdr)
+01290 {
+01291 <font class="comment">// renderSimpleTriangles() with the material setuped.</font>
+01292 tileToRdr-&gt;TileMaterial-&gt;renderTilePassRGB0();
+01293 tileToRdr= (CRdrTileId*)tileToRdr-&gt;getNext();
+01294 }
+01295 <font class="comment">// Render triangles.</font>
+01296 <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>);
+01297 }
+01298 }
+01299 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(passOrder==<a class="code" href="landscape__def_8h.html#a6">NL3D_TILE_PASS_LIGHTMAP</a>)
+01300 {
+01301 <font class="comment">// Lightmap Pass.</font>
+01302 <font class="comment">/* \todo yoyo: TODO_CLOUD: setup stage2, and setup texcoord generation. COMPLEX because of interaction</font>
+01303 <font class="comment"> with Dynamic LightMap</font>
+01304 <font class="comment"> */</font>
+01305
+01306 <font class="comment">// Setup the Dynamic Lightmap into stage 0.</font>
+01307 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(0, <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>);
+01308
+01309 <font class="comment">// if vertex shader not used.</font>
+01310 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>)
+01311 {
+01312 <font class="comment">// special setup such that stage0 takes Uv2.</font>
+01313 driver-&gt;mapTextureStageToUV(0, 2);
+01314 }
+01315 <font class="comment">// else VertexProgram map itself the good vertex Attribute to UV0.</font>
+01316
+01317
+01318 <font class="comment">// Render All the lightmaps.</font>
+01319 <font class="keywordflow">for</font>(sint lightRdrPass=0; lightRdrPass&lt;(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size(); lightRdrPass++)
+01320 {
+01321 CPatchRdrPass &amp;pass= *<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>[lightRdrPass];
+01322
+01323 <font class="comment">// Enlarge PassTriArray as needed</font>
+01324 <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(pass);
+01325
+01326 <font class="comment">// Setup Lightmap into stage1. Because we share UV with pass RGB0. So we use UV1.</font>
+01327 <font class="comment">// Also, now stage0 is used for DynamicLightmap</font>
+01328 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(1, pass.TextureDiffuse);
+01329
+01330 <font class="comment">// Add triangles to array</font>
+01331 CRdrTileId *tileToRdr= pass.getRdrTileRoot(passOrder);
+01332 <font class="keywordflow">while</font>(tileToRdr)
+01333 {
+01334 <font class="comment">// renderSimpleTriangles() with the material setuped.</font>
+01335 tileToRdr-&gt;TileMaterial-&gt;renderTilePassLightmap();
+01336 tileToRdr= (CRdrTileId*)tileToRdr-&gt;getNext();
+01337 }
+01338 <font class="comment">// Render triangles.</font>
+01339 <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>);
+01340 }
+01341
+01342 <font class="comment">// if vertex shader not used.</font>
+01343 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>)
+01344 {
+01345 <font class="comment">// Reset special stage/UV setup to normal behavior</font>
+01346 driver-&gt;mapTextureStageToUV(0, 0);
+01347 }
+01348 }
+01349 <font class="keywordflow">else</font>
+01350 {
+01351 <font class="comment">// RGB1, RGB2, and ADD pass.</font>
+01352
+01353 <font class="comment">// Render Base, Transitions or Additives.</font>
+01354
+01355 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> itTile;
+01356 <font class="keywordflow">for</font>(itTile= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.begin(); itTile!= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.end(); itTile++)
+01357 {
+01358 <font class="comment">// Get a ref on the render pass. Const cast work because we only modify attribut from CPatchRdrPass </font>
+01359 <font class="comment">// that don't affect the operator&lt; of this class</font>
+01360 CPatchRdrPass &amp;pass= const_cast&lt;CPatchRdrPass&amp;&gt;(*itTile);
+01361
+01362 <font class="comment">// Enlarge PassTriArray as needed</font>
+01363 <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(pass);
+01364
+01365 <font class="comment">// Add triangles to array</font>
+01366 CRdrTileId *tileToRdr= pass.getRdrTileRoot(passOrder);
+01367 <font class="keywordflow">while</font>(tileToRdr)
+01368 {
+01369 <font class="comment">// renderSimpleTriangles() with the material setuped.</font>
+01370 tileToRdr-&gt;TileMaterial-&gt;renderTile(passOrder);
+01371 tileToRdr= (CRdrTileId*)tileToRdr-&gt;getNext();
+01372 }
+01373
+01374 <font class="comment">// Pass not empty ?</font>
+01375 <font class="keywordflow">if</font>(<a class="code" href="namespaceNL3D.html#a70">NL3D_LandscapeGlobals_PassNTri</a>&gt;0)
+01376 {
+01377 <font class="comment">// Setup material.</font>
+01378 <font class="comment">// Setup Diffuse texture of the tile.</font>
+01379 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(0, pass.TextureDiffuse);
+01380
+01381 <font class="comment">// If transition tile, must enable the alpha for this pass.</font>
+01382 <font class="comment">// NB: Additive pass may have pass.TextureAlpha==NULL</font>
+01383 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(1, pass.TextureAlpha);
+01384 }
+01385
+01386 <font class="comment">// Render triangles.</font>
+01387 <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>);
+01388 }
+01389 }
+01390 }
+01391
+01392
+01393 <font class="comment">// 2. Far0Render pass.</font>
+01394 <font class="comment">//====================</font>
+01395
+01396
+01397 <font class="comment">// First, update Dynamic Lighting for Far, ie multiply Dynamic Lightmap with TextureFar, and upload to texture.</font>
+01398 <font class="comment">// ==================</font>
+01399 dlmCtxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+01400 <font class="keywordflow">while</font>(dlmCtxPtr!=NULL)
+01401 {
+01402 <font class="comment">// do it only if the patch has some Far stuff to render, and if it is visible</font>
+01403 <font class="keywordflow">if</font>( (dlmCtxPtr-&gt;getPatch()-&gt;getFar0()&gt;0 || dlmCtxPtr-&gt;getPatch()-&gt;getFar1()&gt;0)
+01404 &amp;&amp; !dlmCtxPtr-&gt;getPatch()-&gt;isRenderClipped() )
+01405 {
+01406 <font class="comment">// upload lightmap into textureDLM, modulating before with patch TextureFar.</font>
+01407 <font class="comment">// NB: no-op if both src and dst are already full black.</font>
+01408 dlmCtxPtr-&gt;compileLighting(CPatchDLMContext::ModulateTextureFar);
+01409 }
+01410
+01411 <font class="comment">// next</font>
+01412 dlmCtxPtr= (CPatchDLMContext*)dlmCtxPtr-&gt;Next;
+01413 }
+01414
+01415
+01416 <font class="comment">// Active VB.</font>
+01417 <font class="comment">// ==================</font>
+01418
+01419 <font class="comment">// Active the good VB, and maybe activate the std VertexProgram.</font>
+01420 <a class="code" href="classNL3D_1_1CLandscape.html#z491_1">_Far0VB</a>.activate(0);
+01421
+01422
+01423 <font class="comment">// Render.</font>
+01424 <font class="comment">// ==================</font>
+01425
+01426 <font class="comment">// Setup common material.</font>
+01427 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setBlend(<font class="keyword">false</font>);
+01428 <font class="comment">// set the DLM texture.</font>
+01429 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(1, <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>);
+01430
+01431 <font class="comment">// Render All material RdrPass0.</font>
+01432 itFar=<a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.begin();
+01433 <font class="keywordflow">while</font> (itFar!=<a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.end())
+01434 {
+01435 CPatchRdrPass &amp;pass= **itFar;
+01436
+01437 <font class="comment">// Enlarge PassTriArray as needed</font>
+01438 <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(pass);
+01439
+01440 <font class="comment">// Setup the material.</font>
+01441 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(0, pass.TextureDiffuse);
+01442 <font class="comment">// If the texture need to be updated, do it now.</font>
+01443 <font class="keywordflow">if</font>(pass.TextureDiffuse &amp;&amp; pass.TextureDiffuse-&gt;touched())
+01444 driver-&gt;setupTexture(*pass.TextureDiffuse);
+01445
+01446 <font class="comment">// Add triangles to array</font>
+01447 CRdrPatchId *patchToRdr= pass.getRdrPatchFar0();
+01448 <font class="keywordflow">while</font>(patchToRdr)
+01449 {
+01450 <font class="comment">// renderSimpleTriangles() with the material setuped.</font>
+01451 patchToRdr-&gt;Patch-&gt;renderFar0();
+01452 patchToRdr= (CRdrPatchId*)patchToRdr-&gt;getNext();
+01453 }
+01454 <font class="comment">// Render triangles.</font>
+01455 <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>);
+01456
+01457 <font class="comment">// Next render pass</font>
+01458 itFar++;
+01459 }
+01460
+01461
+01462
+01463 <font class="comment">// 3. Far1Render pass.</font>
+01464 <font class="comment">//====================</font>
+01465
+01466 <font class="comment">// Active VB.</font>
+01467 <font class="comment">// ==================</font>
+01468
+01469 <font class="comment">// Active the good VB, and maybe activate the std VertexProgram.</font>
+01470 <a class="code" href="classNL3D_1_1CLandscape.html#z491_2">_Far1VB</a>.activate(0);
+01471
+01472
+01473 <font class="comment">// Render</font>
+01474 <font class="comment">// ==================</font>
+01475
+01476 <font class="comment">// Setup common material.</font>
+01477 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setBlend(<font class="keyword">true</font>);
+01478 <font class="comment">// set the DLM texture.</font>
+01479 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(1, <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>);
+01480
+01481
+01482 <font class="comment">// Render All material RdrPass1.</font>
+01483 itFar=<a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.begin();
+01484 <font class="keywordflow">while</font> (itFar!=<a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.end())
+01485 {
+01486 CPatchRdrPass &amp;pass= **itFar;
+01487
+01488 <font class="comment">// Enlarge PassTriArray as needed</font>
+01489 <a class="code" href="namespaceNL3D.html#a370">initPassTriArray</a>(pass);
+01490
+01491 <font class="comment">// Setup the material.</font>
+01492 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(0, pass.TextureDiffuse);
+01493 <font class="comment">// If the texture need to be updated, do it now.</font>
+01494 <font class="keywordflow">if</font>(pass.TextureDiffuse &amp;&amp; pass.TextureDiffuse-&gt;touched())
+01495 driver-&gt;setupTexture(*pass.TextureDiffuse);
+01496
+01497 <font class="comment">// Add triangles to array</font>
+01498 CRdrPatchId *patchToRdr= pass.getRdrPatchFar1();
+01499 <font class="keywordflow">while</font>(patchToRdr)
+01500 {
+01501 <font class="comment">// renderSimpleTriangles() with the material setuped.</font>
+01502 patchToRdr-&gt;Patch-&gt;renderFar1();
+01503 patchToRdr= (CRdrPatchId*)patchToRdr-&gt;getNext();
+01504 }
+01505 <font class="comment">// Render triangles.</font>
+01506 <a class="code" href="namespaceNL3D.html#a371">drawPassTriArray</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>);
+01507
+01508 <font class="comment">// Next render pass</font>
+01509 itFar++;
+01510 }
+01511
+01512
+01513 <font class="comment">// 4. "Release" texture materials.</font>
+01514 <font class="comment">//================================</font>
+01515 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(0, NULL);
+01516 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(1, NULL);
+01517 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(2, NULL);
+01518 <a class="code" href="classNL3D_1_1CLandscape.html#o13">FarMaterial</a>.setTexture(3, NULL);
+01519 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(0, NULL);
+01520 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(1, NULL);
+01521 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(2, NULL);
+01522 <a class="code" href="classNL3D_1_1CLandscape.html#o12">TileMaterial</a>.setTexture(3, NULL);
+01523
+01524 <font class="comment">// To ensure no use but in render()..</font>
+01525 CLandscapeGlobals::PatchCurrentDriver= NULL;
+01526
+01527 <font class="comment">// Desactive the vertex program (if anyone)</font>
+01528 <font class="keywordflow">if</font>(_VertexShaderOk)
+01529 driver-&gt;activeVertexProgram (NULL);
+01530
+01531
+01532 <font class="comment">// 5. Vegetable Management.</font>
+01533 <font class="comment">//================================</font>
+01534
+01535 <font class="comment">// First, update Dynamic Lighting for Vegetable, ie just copy.</font>
+01536 <font class="comment">// ==================</font>
+01537 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z485_4">isVegetableActive</a>())
+01538 {
+01539 <font class="comment">/* Actually we modulate the DLM with an arbitrary constant for this reason:</font>
+01540 <font class="comment"> Color of vegetable (ie their material) are NOT modulated with DLM.</font>
+01541 <font class="comment"> Doing this without using PixelShader / additional UVs seems to be impossible.</font>
+01542 <font class="comment"> And add new UVs (+700K in AGP) just for this is not worth the effort.</font>
+01543 <font class="comment"></font>
+01544 <font class="comment"> We prefer using a constant to simulate the "global vegetable color", which is a big trick.</font>
+01545 <font class="comment"></font>
+01546 <font class="comment"> Additionally, the vegetable take the diffuse lighting of landscape, which is</font>
+01547 <font class="comment"> false because it replaces the diffuse lighting it should have (ie with his own Normal and </font>
+01548 <font class="comment"> his own "global vegetable color")</font>
+01549 <font class="comment"></font>
+01550 <font class="comment"> We can't do anything for "correct normal vegetable", but it is possible to replace landscape</font>
+01551 <font class="comment"> material with vegetable material, by dividing _DLMGlobalVegetableColor by LandscapeDiffuseMaterial.</font>
+01552 <font class="comment"> This is a very approximate result because of CRGBA clamp, but it is acceptable.</font>
+01553 <font class="comment"> */</font>
+01554 CRGBA vegetDLMCte;
+01555 <font class="comment">// the constant is _DLMGlobalVegetableColor / PointLightDiffuseMaterial</font>
+01556 uint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+01557 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (<a class="code" href="classNL3D_1_1CLandscape.html#z499_5">_DLMGlobalVegetableColor</a>.R*256) / (<a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>.R+1);
+01558 vegetDLMCte.R= (uint8)<a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, 255U);
+01559 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (<a class="code" href="classNL3D_1_1CLandscape.html#z499_5">_DLMGlobalVegetableColor</a>.G*256) / (<a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>.G+1);
+01560 vegetDLMCte.G= (uint8)<a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, 255U);
+01561 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (<a class="code" href="classNL3D_1_1CLandscape.html#z499_5">_DLMGlobalVegetableColor</a>.B*256) / (<a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>.B+1);
+01562 vegetDLMCte.B= (uint8)<a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, 255U);
+01563
+01564 <font class="comment">// Parse all patch which have some vegetables</font>
+01565 dlmCtxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+01566 <font class="keywordflow">while</font>(dlmCtxPtr!=NULL)
+01567 {
+01568 <font class="comment">// do it only if the patch has some vegetable stuff to render, and if it is visible</font>
+01569 <font class="comment">// NB: we may have some vegetable stuff to render if the patch has some TileMaterial created.</font>
+01570 <font class="keywordflow">if</font>(dlmCtxPtr-&gt;getPatch()-&gt;getTileMaterialRefCount()&gt;0
+01571 &amp;&amp; !dlmCtxPtr-&gt;getPatch()-&gt;isRenderClipped() )
+01572 {
+01573 <font class="comment">// NB: no-op if both src and dst are already full black.</font>
+01574 dlmCtxPtr-&gt;compileLighting(CPatchDLMContext::ModulateConstant, vegetDLMCte);
+01575 }
+01576
+01577 <font class="comment">// next</font>
+01578 dlmCtxPtr= (CPatchDLMContext*)dlmCtxPtr-&gt;Next;
+01579 }
+01580 }
+01581
+01582
+01583 <font class="comment">// profile.</font>
+01584 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;resetNumVegetableFaceRendered();
+01585
+01586 <font class="comment">// render all vegetables, only if driver support VertexProgram.</font>
+01587 <font class="comment">// ==================</font>
+01588 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z485_4">isVegetableActive</a>())
+01589 {
+01590 <font class="comment">// Use same plane as TessBlock for faster clipping.</font>
+01591 vector&lt;CPlane&gt; vegetablePyramid;
+01592 vegetablePyramid.resize(<a class="code" href="tess__block_8h.html#a0">NL3D_TESSBLOCK_NUM_CLIP_PLANE</a>);
+01593 <font class="keywordflow">for</font>(i=0;i&lt;<a class="code" href="tess__block_8h.html#a0">NL3D_TESSBLOCK_NUM_CLIP_PLANE</a>;i++)
+01594 {
+01595 vegetablePyramid[i]= pyramid[i];
+01596 }
+01597 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;render(refineCenter, frontVector, vegetablePyramid, <a class="code" href="classNL3D_1_1CLandscape.html#z499_2">_TextureDLM</a>, driver);
+01598 }
+01599
+01600 }
+01601
+01602
+01603 <font class="comment">// ***************************************************************************</font>
+01604 <font class="comment">// ***************************************************************************</font>
+01605 <font class="comment">// Tile mgt.</font>
+01606 <font class="comment">// ***************************************************************************</font>
+01607 <font class="comment">// ***************************************************************************</font>
+01608
+01609
+01610 <font class="comment">// ***************************************************************************</font>
+<a name="l01611"></a><a class="code" href="classNL3D_1_1CLandscape.html#c17">01611</a> ITexture *CLandscape::findTileTexture(<font class="keyword">const</font> std::string &amp;textName)
+01612 {
+01613 ITexture *text;
+01614 text= <a class="code" href="classNL3D_1_1CLandscape.html#o7">TileTextureMap</a>[textName];
+01615 <font class="comment">// If just inserted, RefPtr is NULL!! :)</font>
+01616 <font class="comment">// This test too if the RefPtr is NULL... (tile released)</font>
+01617 <font class="comment">// The object is not owned by this map. It will be own by the multiple RdrPass via CSmartPtr.</font>
+01618 <font class="comment">// They will destroy it when no more points to them.</font>
+01619 <font class="keywordflow">if</font>(!text)
+01620 {
+01621 <a class="code" href="classNL3D_1_1CLandscape.html#o7">TileTextureMap</a>[textName]= text= <font class="keyword">new</font> CTextureFile(textName);
+01622 text-&gt;setWrapS(ITexture::Clamp);
+01623 text-&gt;setWrapT(ITexture::Clamp);
+01624 text-&gt;setUploadFormat(ITexture::DXTC5);
+01625 }
+01626 <font class="keywordflow">return</font> text;
+01627 }
+01628
+01629
+01630 <font class="comment">// ***************************************************************************</font>
+<a name="l01631"></a><a class="code" href="classNL3D_1_1CLandscape.html#c18">01631</a> CPatchRdrPass *CLandscape::findTileRdrPass(<font class="keyword">const</font> CPatchRdrPass &amp;pass)
+01632 {
+01633 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> it;
+01634 <font class="comment">// If already here, find it, else insert.</font>
+01635 it= (<a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.insert(pass)).first;
+01636
+01637 <font class="keywordflow">return</font> const_cast&lt;CPatchRdrPass*&gt;(&amp;(*it));
+01638 }
+01639
+01640
+01641 <font class="comment">// ***************************************************************************</font>
+<a name="l01642"></a><a class="code" href="classNL3D_1_1CLandscape.html#c15">01642</a> <font class="keywordtype">void</font> CLandscape::loadTile(uint16 tileId)
+01643 {
+01644 CTile *tile;
+01645 CTileInfo *tileInfo;
+01646 string textName;
+01647
+01648 <font class="comment">// Retrieve or create texture.</font>
+01649 <font class="comment">// ===========================</font>
+01650 <font class="comment">// Tile Must exist.</font>
+01651 <font class="comment">// nlassert(tileId==0xFFFF || tileId&lt;TileBank.getTileCount());</font>
+01652 <font class="keywordflow">if</font>(tileId&lt;<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileCount())
+01653 tile= <a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTile(tileId);
+01654 <font class="keywordflow">else</font>
+01655 tile= NULL;
+01656 <font class="comment">// TileInfo must not exist.</font>
+01657 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId]==NULL);
+01658 <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId]= tileInfo= <font class="keyword">new</font> CTileInfo;
+01659
+01660 <font class="comment">// Fill additive part.</font>
+01661 <font class="comment">// ===================</font>
+01662 <font class="keywordflow">if</font>(tile)
+01663 textName= tile-&gt;getRelativeFileName(CTile::additive);
+01664 <font class="keywordflow">else</font>
+01665 textName= <font class="stringliteral">""</font>;
+01666 <font class="comment">// If no additive for this tile, rdrpass is NULL.</font>
+01667 <font class="keywordflow">if</font>(textName==<font class="stringliteral">""</font>)
+01668 tileInfo-&gt;AdditiveRdrPass= NULL;
+01669 <font class="keywordflow">else</font>
+01670 {
+01671 <font class="comment">// Fill rdrpass.</font>
+01672 CPatchRdrPass pass;
+01673 pass.TextureDiffuse= <a class="code" href="classNL3D_1_1CLandscape.html#c17">findTileTexture</a>(<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getAbsPath()+textName);
+01674
+01675 <font class="comment">// We may have an alpha part for additive.</font>
+01676 textName= tile-&gt;getRelativeFileName (CTile::alpha);
+01677 <font class="keywordflow">if</font>(textName!=<font class="stringliteral">""</font>)
+01678 pass.TextureAlpha= <a class="code" href="classNL3D_1_1CLandscape.html#c17">findTileTexture</a>(<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getAbsPath()+textName);
+01679
+01680 <font class="comment">// Fill tileInfo.</font>
+01681 tileInfo-&gt;AdditiveRdrPass= <a class="code" href="classNL3D_1_1CLandscape.html#c18">findTileRdrPass</a>(pass);
+01682 <font class="comment">// Fill UV Info.</font>
+01683 <font class="comment">// NB: for now, One Tile== One Texture, so UVScaleBias is simple.</font>
+01684 tileInfo-&gt;AdditiveUvScaleBias.x= 0;
+01685 tileInfo-&gt;AdditiveUvScaleBias.y= 0;
+01686 tileInfo-&gt;AdditiveUvScaleBias.z= 1;
+01687 }
+01688
+01689
+01690 <font class="comment">// Fill diffuse part.</font>
+01691 <font class="comment">// =======================</font>
+01692 <font class="comment">// Fill rdrpass.</font>
+01693 CPatchRdrPass pass;
+01694 <font class="comment">// The diffuse part for a tile is inevitable.</font>
+01695 <font class="keywordflow">if</font>(tile)
+01696 {
+01697 textName= tile-&gt;getRelativeFileName(CTile::diffuse);
+01698 <font class="keywordflow">if</font>(textName!=<font class="stringliteral">""</font>)
+01699 pass.TextureDiffuse= <a class="code" href="classNL3D_1_1CLandscape.html#c17">findTileTexture</a>(<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getAbsPath()+textName);
+01700 <font class="keywordflow">else</font>
+01701 {
+01702 pass.TextureDiffuse= <font class="keyword">new</font> CTextureCross;
+01703 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"Missing Tile diffuse texname: %d"</font>, tileId);
+01704 }
+01705 }
+01706 <font class="keywordflow">else</font>
+01707 pass.TextureDiffuse= <font class="keyword">new</font> CTextureCross;
+01708 <font class="keywordflow">if</font>(tile)
+01709 {
+01710 textName= tile-&gt;getRelativeFileName (CTile::alpha);
+01711 <font class="keywordflow">if</font>(textName!=<font class="stringliteral">""</font>)
+01712 pass.TextureAlpha= <a class="code" href="classNL3D_1_1CLandscape.html#c17">findTileTexture</a>(<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getAbsPath()+textName);
+01713 }
+01714
+01715
+01716 <font class="comment">// Fill tileInfo.</font>
+01717 tileInfo-&gt;DiffuseRdrPass= <a class="code" href="classNL3D_1_1CLandscape.html#c18">findTileRdrPass</a>(pass);
+01718 <font class="comment">// Fill UV Info.</font>
+01719 <font class="comment">// NB: for now, One Tile== One Texture, so UVScaleBias is simple.</font>
+01720 tileInfo-&gt;DiffuseUvScaleBias.x= 0;
+01721 tileInfo-&gt;DiffuseUvScaleBias.y= 0;
+01722 tileInfo-&gt;DiffuseUvScaleBias.z= 1;
+01723 tileInfo-&gt;AlphaUvScaleBias.x= 0;
+01724 tileInfo-&gt;AlphaUvScaleBias.y= 0;
+01725 tileInfo-&gt;AlphaUvScaleBias.z= 1;
+01726 <font class="comment">// Retrieve the good rot alpha decal.</font>
+01727 <font class="keywordflow">if</font>(tile)
+01728 tileInfo-&gt;RotAlpha= tile-&gt;getRotAlpha();
+01729 <font class="keywordflow">else</font>
+01730 tileInfo-&gt;RotAlpha= 0;
+01731
+01732
+01733 <font class="comment">// Increment RefCount of RenderPart.</font>
+01734 <font class="comment">// =================================</font>
+01735 <font class="keywordflow">if</font>(tileInfo-&gt;AdditiveRdrPass)
+01736 tileInfo-&gt;AdditiveRdrPass-&gt;RefCount++;
+01737 <font class="keywordflow">if</font>(tileInfo-&gt;DiffuseRdrPass)
+01738 tileInfo-&gt;DiffuseRdrPass-&gt;RefCount++;
+01739
+01740 }
+01741
+01742
+01743 <font class="comment">// ***************************************************************************</font>
+<a name="l01744"></a><a class="code" href="classNL3D_1_1CLandscape.html#c16">01744</a> <font class="keywordtype">void</font> CLandscape::releaseTile(uint16 tileId)
+01745 {
+01746 CTileInfo *tileInfo;
+01747 tileInfo= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01748 <a class="code" href="debug_8h.html#a6">nlassert</a>(tileInfo!=NULL);
+01749
+01750 <font class="comment">// "Release" the rdr pass.</font>
+01751 <font class="keywordflow">if</font>(tileInfo-&gt;AdditiveRdrPass)
+01752 tileInfo-&gt;AdditiveRdrPass-&gt;RefCount--;
+01753 <font class="keywordflow">if</font>(tileInfo-&gt;DiffuseRdrPass)
+01754 tileInfo-&gt;DiffuseRdrPass-&gt;RefCount--;
+01755
+01756 <font class="keyword">delete</font> tileInfo;
+01757 <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId]= NULL;
+01758 }
+01759
+01760
+01761 <font class="comment">// ***************************************************************************</font>
+<a name="l01762"></a><a class="code" href="classNL3D_1_1CLandscape.html#c2">01762</a> CPatchRdrPass *CLandscape::getTileRenderPass(uint16 tileId, <font class="keywordtype">bool</font> additiveRdrPass)
+01763 {
+01764 CTileInfo *tile= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01765
+01766 <font class="comment">// If not here, create it.</font>
+01767 <font class="comment">//========================</font>
+01768 <font class="keywordflow">if</font>(tile==NULL)
+01769 {
+01770 <font class="comment">// Force loading of tile.</font>
+01771 <a class="code" href="classNL3D_1_1CLandscape.html#c15">loadTile</a>(tileId);
+01772
+01773 tile= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01774 <a class="code" href="debug_8h.html#a6">nlassert</a>(tile!=NULL);
+01775 }
+01776
+01777 <font class="comment">// Retrieve.</font>
+01778 <font class="comment">//========================</font>
+01779 <font class="keywordflow">if</font>(additiveRdrPass)
+01780 {
+01781 <font class="comment">// NB: additive pass is not lighted by the lightmap, so there is no lighted version of this rednerpass.</font>
+01782 <font class="keywordflow">return</font> tile-&gt;AdditiveRdrPass;
+01783 }
+01784 <font class="keywordflow">else</font>
+01785 {
+01786 <font class="keywordflow">return</font> tile-&gt;DiffuseRdrPass;
+01787 }
+01788 }
+01789
+01790
+01791 <font class="comment">// ***************************************************************************</font>
+<a name="l01792"></a><a class="code" href="classNL3D_1_1CLandscape.html#c3">01792</a> <font class="keywordtype">void</font> CLandscape::getTileUvScaleBiasRot(uint16 tileId, CTile::TBitmap bitmapType, CVector &amp;uvScaleBias, uint8 &amp;rotAlpha)
+01793 {
+01794 CTileInfo *tile= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01795 <font class="comment">// tile should not be NULL.</font>
+01796 <font class="comment">// Because load of tiles are always done in getTileRenderPass(), and this insertion always succeed.</font>
+01797 <a class="code" href="debug_8h.html#a6">nlassert</a>(tile);
+01798
+01799 rotAlpha= 0;
+01800 <font class="keywordflow">switch</font>(bitmapType)
+01801 {
+01802 <font class="keywordflow">case</font> CTile::diffuse:
+01803 uvScaleBias= tile-&gt;DiffuseUvScaleBias; <font class="keywordflow">break</font>;
+01804 <font class="keywordflow">case</font> CTile::additive:
+01805 uvScaleBias= tile-&gt;AdditiveUvScaleBias; <font class="keywordflow">break</font>;
+01806 <font class="keywordflow">case</font> CTile::alpha:
+01807 uvScaleBias= tile-&gt;AlphaUvScaleBias;
+01808 rotAlpha= tile-&gt;RotAlpha;
+01809 <font class="keywordflow">break</font>;
+01810 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
+01811 }
+01812 }
+01813
+01814
+01815 <font class="comment">// ***************************************************************************</font>
+<a name="l01816"></a><a class="code" href="classNL3D_1_1CLandscape.html#z482_2">01816</a> <a class="code" href="classNLMISC_1_1CSmartPtr.html">NLMISC::CSmartPtr&lt;ITexture&gt;</a> CLandscape::getTileTexture(uint16 tileId, CTile::TBitmap bitmapType, CVector &amp;uvScaleBias)
+01817 {
+01818 CPatchRdrPass *pass;
+01819 <font class="keywordflow">if</font>(bitmapType== CTile::additive)
+01820 pass= <a class="code" href="classNL3D_1_1CLandscape.html#c2">getTileRenderPass</a>(tileId, <font class="keyword">true</font>);
+01821 <font class="keywordflow">else</font>
+01822 pass= <a class="code" href="classNL3D_1_1CLandscape.html#c2">getTileRenderPass</a>(tileId, <font class="keyword">false</font>);
+01823 <font class="keywordflow">if</font>(!pass)
+01824 <font class="keywordflow">return</font> NULL;
+01825 uint8 dummy;
+01826 <a class="code" href="classNL3D_1_1CLandscape.html#c3">getTileUvScaleBiasRot</a>(tileId, bitmapType, uvScaleBias, dummy);
+01827
+01828 <font class="comment">// return the wanted texture.</font>
+01829 <font class="keywordflow">if</font>(bitmapType==CTile::diffuse || bitmapType==CTile::additive)
+01830 <font class="keywordflow">return</font> pass-&gt;TextureDiffuse;
+01831 <font class="keywordflow">else</font>
+01832 <font class="keywordflow">return</font> pass-&gt;TextureAlpha;
+01833 }
+01834
+01835
+01836 <font class="comment">// ***************************************************************************</font>
+<a name="l01837"></a><a class="code" href="classNL3D_1_1CLandscape.html#z482_3">01837</a> CTileElement *CLandscape::getTileElement(<font class="keyword">const</font> CPatchIdent &amp;patchId, <font class="keyword">const</font> CUV &amp;uv)
+01838 {
+01839 <font class="comment">// \todo yoyo: TODO_ZONEID: change ZoneId in 32 bits...</font>
+01840 std::map&lt;uint16, CZone*&gt;::const_iterator it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find((uint16)patchId.ZoneId);
+01841 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+01842 {
+01843 sint N= (*it).second-&gt;getNumPatchs();
+01844 <font class="comment">// patch must exist in the zone.</font>
+01845 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId.PatchId&lt;N);
+01846 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;CZone*&gt;((*it).second)-&gt;getPatch(patchId.PatchId);
+01847 <font class="keywordflow">return</font> pa-&gt;getTileElement (uv);
+01848 }
+01849 <font class="keywordflow">else</font>
+01850 <font class="comment">// Return not found</font>
+01851 <font class="keywordflow">return</font> NULL;
+01852 }
+01853
+01854
+01855 <font class="comment">// ***************************************************************************</font>
+<a name="l01856"></a><a class="code" href="classNL3D_1_1CLandscape.html#z482_0">01856</a> <font class="keywordtype">void</font> CLandscape::flushTiles(IDriver *drv, uint16 tileStart, uint16 nbTiles)
+01857 {
+01858 <font class="comment">// Load tile rdrpass, force setup the texture.</font>
+01859 <font class="keywordflow">for</font>(sint tileId= tileStart; tileId&lt;tileStart+nbTiles; tileId++)
+01860 {
+01861 CTileInfo *tile= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01862 <font class="keywordflow">if</font>(tile==NULL)
+01863 {
+01864 <a class="code" href="classNL3D_1_1CLandscape.html#c15">loadTile</a>(tileId);
+01865 }
+01866 }
+01867
+01868 <font class="comment">// For all rdrpass, force setup the texture.</font>
+01869 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> it;
+01870 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.begin(); it!=<a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.end(); it++)
+01871 {
+01872 <font class="keyword">const</font> CPatchRdrPass &amp;pass= *it;
+01873 <font class="comment">// If present and not already setuped...</font>
+01874 <font class="keywordflow">if</font>(pass.TextureDiffuse &amp;&amp; !pass.TextureDiffuse-&gt;setupedIntoDriver())
+01875 drv-&gt;setupTexture(*pass.TextureDiffuse);
+01876 <font class="comment">// If present and not already setuped...</font>
+01877 <font class="keywordflow">if</font>(pass.TextureAlpha &amp;&amp; !pass.TextureAlpha-&gt;setupedIntoDriver())
+01878 drv-&gt;setupTexture(*pass.TextureAlpha);
+01879 }
+01880 }
+01881
+01882
+01883 <font class="comment">// ***************************************************************************</font>
+<a name="l01884"></a><a class="code" href="classNL3D_1_1CLandscape.html#z482_1">01884</a> <font class="keywordtype">void</font> CLandscape::releaseTiles(uint16 tileStart, uint16 nbTiles)
+01885 {
+01886 <font class="comment">// release tiles.</font>
+01887 <font class="keywordflow">for</font>(sint tileId= tileStart; tileId&lt;tileStart+nbTiles; tileId++)
+01888 {
+01889 CTileInfo *tile= <a class="code" href="classNL3D_1_1CLandscape.html#o9">TileInfos</a>[tileId];
+01890 <font class="keywordflow">if</font>(tile!=NULL)
+01891 {
+01892 <a class="code" href="classNL3D_1_1CLandscape.html#c16">releaseTile</a>(tileId);
+01893 }
+01894 }
+01895
+01896 <font class="comment">// For all rdrpass, release one that are no more referenced.</font>
+01897 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> it;
+01898 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.begin(); it!=<a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.end();)
+01899 {
+01900 <font class="comment">// If no more tile access the rdrpass, delete it.</font>
+01901 <font class="keywordflow">if</font>((*it).RefCount==0)
+01902 {
+01903 <a class="code" href="classNL3D_1_1CLandscape.html#u4">ItTileRdrPassSet</a> itDel=it++;
+01904 <a class="code" href="classNL3D_1_1CLandscape.html#o8">TileRdrPassSet</a>.erase(itDel);
+01905 }
+01906 <font class="keywordflow">else</font>
+01907 it++;
+01908 }
+01909
+01910 <font class="comment">// Textures are automaticly deleted by smartptr, but not their entry int the map (TileTextureMap). </font>
+01911 <font class="comment">// =&gt; doesn't matter since findTileTexture() manages this case.</font>
+01912 <font class="comment">// And the memory overhead is not a problem (we talk about pointers).</font>
+01913 }
+01914
+01915
+01916 <font class="comment">// ***************************************************************************</font>
+<a name="l01917"></a><a class="code" href="classNL3D_1_1CLandscape.html#z492_0">01917</a> uint CLandscape::getTileLightMap(CRGBA map[<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>], CPatchRdrPass *&amp;lightmapRdrPass)
+01918 {
+01919 sint textNum;
+01920 uint lightMapId;
+01921 <font class="comment">/* </font>
+01922 <font class="comment"> NB: TextureNear are a grow only Array... TextureNear are never deleted. Why? :</font>
+01923 <font class="comment"> 2/ Unused near texture may be uncahced by opengl (and maybe by windows, to disk).</font>
+01924 <font class="comment"></font>
+01925 <font class="comment"> (old reason, no longer valid, since lightmaps are unlinked from tiles.</font>
+01926 <font class="comment"> 1/ There is an important issue with releasing texture nears: tiles may acces them (see getTileRenderPass())</font>
+01927 <font class="comment"> )</font>
+01928 <font class="comment"> */</font>
+01929 <font class="comment">// 0. Alloc Near Texture if necessary.</font>
+01930 <font class="comment">//====================================</font>
+01931 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#o11">_NFreeLightMaps</a>==0)
+01932 {
+01933 CTextureNear *text= <font class="keyword">new</font> CTextureNear(<a class="code" href="namespaceNL3D.html#a67">TextureNearSize</a>);
+01934 <a class="code" href="classNLMISC_1_1CSmartPtr.html">TSPRenderPass</a> newPass= <font class="keyword">new</font> CPatchRdrPass;
+01935
+01936 newPass-&gt;TextureDiffuse= text;
+01937
+01938 <a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.push_back(newPass);
+01939 <a class="code" href="classNL3D_1_1CLandscape.html#o11">_NFreeLightMaps</a>+= text-&gt;getNbAvailableTiles();
+01940 }
+01941
+01942 <font class="comment">// 1. Search the first texture which has a free tile.</font>
+01943 <font class="comment">//==================================================</font>
+01944 CTextureNear *nearText= NULL;
+01945 CPatchRdrPass *nearRdrPass= NULL;
+01946 <font class="keywordflow">for</font>(textNum=0;textNum&lt;(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size();textNum++)
+01947 {
+01948 nearRdrPass= <a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>[textNum];
+01949 nearText= (CTextureNear*)(ITexture*)nearRdrPass-&gt;TextureDiffuse;
+01950 <font class="keywordflow">if</font>(nearText-&gt;getNbAvailableTiles()!=0)
+01951 <font class="keywordflow">break</font>;
+01952 }
+01953 <a class="code" href="debug_8h.html#a6">nlassert</a>(textNum&lt;(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size());
+01954 <font class="comment">// A empty space has been found.</font>
+01955 <a class="code" href="classNL3D_1_1CLandscape.html#o11">_NFreeLightMaps</a>--;
+01956
+01957 <font class="comment">// 2. Fill the texture with the data, and updaterect.</font>
+01958 <font class="comment">//===================================================</font>
+01959 lightMapId= nearText-&gt;getTileAndFillRect(map);
+01960 <font class="comment">// Compute the Id.</font>
+01961 lightMapId= textNum*<a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a> + lightMapId;
+01962
+01963
+01964 <font class="comment">// 3. updateLighting</font>
+01965 <font class="comment">//===================================================</font>
+01966 <font class="comment">// Increment number of pixels to update for near.</font>
+01967 <a class="code" href="classNL3D_1_1CLandscape.html#z498_12">_ULTotalNearPixels</a>+= <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>;
+01968
+01969
+01970 <font class="comment">// Result:</font>
+01971 lightmapRdrPass= nearRdrPass;
+01972 <font class="keywordflow">return</font> lightMapId;
+01973 }
+01974 <font class="comment">// ***************************************************************************</font>
+<a name="l01975"></a><a class="code" href="classNL3D_1_1CLandscape.html#z492_1">01975</a> <font class="keywordtype">void</font> CLandscape::getTileLightMapUvInfo(uint tileLightMapId, CVector &amp;uvScaleBias)
+01976 {
+01977 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>;
+01978
+01979 <font class="comment">// Scale.</font>
+01980 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> scale10= (float)<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>/<a class="code" href="namespaceNL3D.html#a67">TextureNearSize</a>;
+01981 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> scale4= 4.f/<a class="code" href="namespaceNL3D.html#a67">TextureNearSize</a>;
+01982 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">float</font> scale1= 1.f/<a class="code" href="namespaceNL3D.html#a67">TextureNearSize</a>;
+01983 <font class="comment">// The size of a minilightmap, mapped onto the polygon, is still 4 pixels.</font>
+01984 uvScaleBias.z= scale4;
+01985
+01986 <font class="comment">// Get the id local in the texture.</font>
+01987 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= tileLightMapId%<a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a>;
+01988
+01989 <font class="comment">// Commpute UVBias.</font>
+01990 <font class="comment">// Get the coordinate of the tile, in tile number.</font>
+01991 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>%<a class="code" href="namespaceNL3D.html#a68">NbTileLightMapByLine</a>;
+01992 <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>/<a class="code" href="namespaceNL3D.html#a68">NbTileLightMapByLine</a>;
+01993 <font class="comment">// But the real size of a minilightmap is 10 pixels, and we must reach the pixel 1,1.</font>
+01994 uvScaleBias.x= <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>*scale10 + scale1;
+01995 uvScaleBias.y= <a class="code" href="driver__opengl__extension__def_8h.html#a384">t</a>*scale10 + scale1;
+01996 }
+01997 <font class="comment">// ***************************************************************************</font>
+<a name="l01998"></a><a class="code" href="classNL3D_1_1CLandscape.html#z492_2">01998</a> <font class="keywordtype">void</font> CLandscape::releaseTileLightMap(uint tileLightMapId)
+01999 {
+02000 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, textNum;
+02001
+02002 <font class="comment">// Get the id local in the texture.</font>
+02003 textNum= tileLightMapId / <a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a>;
+02004 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= tileLightMapId % <a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a>;
+02005 <a class="code" href="debug_8h.html#a6">nlassert</a>(textNum&gt;=0 &amp;&amp; textNum&lt;<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size());
+02006
+02007 <font class="comment">// Release the tile in this texture.</font>
+02008 CPatchRdrPass *nearRdrPass= <a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>[textNum];
+02009 CTextureNear *nearText= (CTextureNear*)(ITexture*)nearRdrPass-&gt;TextureDiffuse;
+02010 nearText-&gt;releaseTile(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
+02011 <a class="code" href="classNL3D_1_1CLandscape.html#o11">_NFreeLightMaps</a>++;
+02012
+02013 <font class="comment">// updateLighting</font>
+02014 <font class="comment">// Decrement number of pixels to update for near.</font>
+02015 <a class="code" href="classNL3D_1_1CLandscape.html#z498_12">_ULTotalNearPixels</a>-= <a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>;
+02016 }
+02017
+02018
+02019 <font class="comment">// ***************************************************************************</font>
+<a name="l02020"></a><a class="code" href="classNL3D_1_1CLandscape.html#z492_3">02020</a> <font class="keywordtype">void</font> CLandscape::refillTileLightMap(uint tileLightMapId, CRGBA map[<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>*<a class="code" href="texture__near_8h.html#a0">NL_TILE_LIGHTMAP_SIZE</a>])
+02021 {
+02022 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, textNum;
+02023
+02024 <font class="comment">// Get the id local in the texture.</font>
+02025 textNum= tileLightMapId / <a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a>;
+02026 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= tileLightMapId % <a class="code" href="namespaceNL3D.html#a69">NbTileLightMapByTexture</a>;
+02027 <a class="code" href="debug_8h.html#a6">nlassert</a>(textNum&gt;=0 &amp;&amp; textNum&lt;<a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>.size());
+02028
+02029 <font class="comment">// get a ptr on the texture.</font>
+02030 CPatchRdrPass *nearRdrPass= <a class="code" href="classNL3D_1_1CLandscape.html#o10">_TextureNears</a>[textNum];
+02031 CTextureNear *nearText= (CTextureNear*)(ITexture*)nearRdrPass-&gt;TextureDiffuse;
+02032
+02033 <font class="comment">// refill this tile</font>
+02034 nearText-&gt;refillRect(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, map);
+02035 }
+02036
+02037
+02038
+02039 <font class="comment">// ***************************************************************************</font>
+02040 <font class="comment">// ***************************************************************************</font>
+02041 <font class="comment">// Far.</font>
+02042 <font class="comment">// ***************************************************************************</font>
+02043 <font class="comment">// ***************************************************************************</font>
+02044
+02045
+02046 <font class="comment">// ***************************************************************************</font>
+<a name="l02047"></a><a class="code" href="classNL3D_1_1CLandscape.html#c0">02047</a> CPatchRdrPass* CLandscape::getFarRenderPass(CPatch* pPatch, uint farIndex, <font class="keywordtype">float</font>&amp; farUScale, <font class="keywordtype">float</font>&amp; farVScale, <font class="keywordtype">float</font>&amp; farUBias, <font class="keywordtype">float</font>&amp; farVBias, <font class="keywordtype">bool</font>&amp; bRot)
+02048 {
+02049 <font class="comment">// Check args</font>
+02050 <a class="code" href="debug_8h.html#a6">nlassert</a> (farIndex&gt;0);
+02051
+02052 <font class="comment">// Get size of the far texture</font>
+02053 uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>=(pPatch-&gt;getOrderS ()*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)&gt;&gt;(farIndex-1);
+02054 uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>=(pPatch-&gt;getOrderT ()*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)&gt;&gt;(farIndex-1);
+02055
+02056 <font class="comment">// For updateLighting: increment total of pixels to update.</font>
+02057 <a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>+= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
+02058
+02059 <font class="comment">// Render pass index</font>
+02060 uint passIndex=<a class="code" href="classNL3D_1_1CLandscape.html#f0">getRdrPassIndexWithSize</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
+02061
+02062 <font class="comment">// Look for a free render pass</font>
+02063 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].begin()==<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].end())
+02064 {
+02065 <font class="comment">// Empty, add a new render pass</font>
+02066 CPatchRdrPass *pass=<font class="keyword">new</font> CPatchRdrPass;
+02067
+02068 <font class="comment">// Fill the render pass</font>
+02069 CTextureFar *pTextureFar=<font class="keyword">new</font> CTextureFar;
+02070
+02071 <font class="comment">// Append this textureFar to the list of TextureFar to updateLighting.</font>
+02072 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>==NULL)
+02073 <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>= pTextureFar;
+02074 <font class="keywordflow">else</font>
+02075 pTextureFar-&gt;linkBeforeUL(<a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>);
+02076
+02077 <font class="comment">// Set the bank</font>
+02078 pTextureFar-&gt;_Bank=&amp;<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>;
+02079
+02080 <font class="comment">// Set as diffuse texture for this renderpass</font>
+02081 pass-&gt;TextureDiffuse=pTextureFar;
+02082
+02083 <font class="comment">// Set the size for this texture</font>
+02084 pTextureFar-&gt;setSizeOfFarPatch (std::max (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>), std::min (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>));
+02085
+02086 <font class="comment">// Add the render pass</font>
+02087 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].insert (pass);
+02088 <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.insert (pass);
+02089 }
+02090
+02091 <font class="comment">// Ok, add the patch to the first render pass in the free list</font>
+02092 <a class="code" href="classNLMISC_1_1CSmartPtr.html">TSPRenderPass</a> pass=*<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].begin();
+02093
+02094 <font class="comment">// Get a pointer on the diffuse far texture</font>
+02095 CTextureFar *pTextureFar=(CTextureFar*)(&amp;*(pass-&gt;TextureDiffuse));
+02096
+02097 <font class="comment">// Add the patch to the far texture</font>
+02098 <font class="keywordflow">if</font> (pTextureFar-&gt;addPatch (pPatch, farUScale, farVScale, farUBias, farVBias, bRot))
+02099 {
+02100 <font class="comment">// The render state is full, remove from the free list..</font>
+02101 _FarRdrPassSetVectorFree[passIndex].erase (pass);
+02102 }
+02103
+02104 <font class="comment">// Return the renderpass</font>
+02105 <font class="keywordflow">return</font> pass;
+02106 }
+02107
+02108
+02109 <font class="comment">// ***************************************************************************</font>
+<a name="l02110"></a><a class="code" href="classNL3D_1_1CLandscape.html#c1">02110</a> <font class="keywordtype">void</font> CLandscape::freeFarRenderPass (CPatch* pPatch, CPatchRdrPass* pass, uint farIndex)
+02111 {
+02112 <font class="comment">// Get size of the far texture</font>
+02113 uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>=(pPatch-&gt;getOrderS ()*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)&gt;&gt;(farIndex-1);
+02114 uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>=(pPatch-&gt;getOrderT ()*<a class="code" href="tile__far__bank_8h.html#a1">NL_NUM_PIXELS_ON_FAR_TILE_EDGE</a>)&gt;&gt;(farIndex-1);
+02115
+02116 <font class="comment">// For updateLighting: decrement total of pixels to update.</font>
+02117 <a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>-= <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>*<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>;
+02118 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>&gt;=0);
+02119
+02120 <font class="comment">// Render pass index</font>
+02121 uint passIndex=<a class="code" href="classNL3D_1_1CLandscape.html#f0">getRdrPassIndexWithSize</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
+02122
+02123 <font class="comment">// Get a pointer on the diffuse far texture</font>
+02124 CTextureFar *pTextureFar=(CTextureFar*)(&amp;*(pass-&gt;TextureDiffuse));
+02125
+02126 <font class="comment">// Remove from the patch from the texture if empty</font>
+02127 <font class="keywordflow">if</font> (pTextureFar-&gt;removePatch (pPatch))
+02128 {
+02129 <font class="comment">// Free list empty ?</font>
+02130 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].begin()==<a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].end())
+02131 {
+02132 <font class="comment">// Let this render pass in the free list</font>
+02133 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].insert (pass);
+02134 }
+02135 <font class="keywordflow">else</font>
+02136 {
+02137 <font class="comment">// Release for good</font>
+02138 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].erase (pass);
+02139
+02140 <font class="comment">// update UL links, and Remove from draw list</font>
+02141 <a class="code" href="classNL3D_1_1CLandscape.html#c11">eraseFarRenderPassFromSet</a> (pass);
+02142 }
+02143 }
+02144 <font class="keywordflow">else</font>
+02145 {
+02146 <font class="comment">// Insert in the free list</font>
+02147 <a class="code" href="classNL3D_1_1CLandscape.html#o15">_FarRdrPassSetVectorFree</a>[passIndex].insert (pass);
+02148 }
+02149 }
+02150
+02151
+02152 <font class="comment">// ***************************************************************************</font>
+<a name="l02153"></a><a class="code" href="classNL3D_1_1CLandscape.html#c11">02153</a> <font class="keywordtype">void</font> CLandscape::eraseFarRenderPassFromSet (CPatchRdrPass* pass)
+02154 {
+02155 <font class="comment">// Before deleting, must remove TextureFar from UpdateLighting list.</font>
+02156
+02157 <font class="comment">// Get a pointer on the diffuse far texture</font>
+02158 CTextureFar *pTextureFar=(CTextureFar*)(&amp;*(pass-&gt;TextureDiffuse));
+02159
+02160 <font class="comment">// If I delete the textureFar which is the current root</font>
+02161 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>==pTextureFar)
+02162 {
+02163 <font class="comment">// switch to next</font>
+02164 <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>= pTextureFar-&gt;getNextUL();
+02165 <font class="comment">// if still the same, it means that the circular list is now empty</font>
+02166 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>==pTextureFar)
+02167 <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>= NULL;
+02168 <font class="comment">// reset patch counter.</font>
+02169 <a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>= 0;
+02170 }
+02171
+02172 <font class="comment">// unlink the texture from list</font>
+02173 pTextureFar-&gt;unlinkUL();
+02174
+02175
+02176 <font class="comment">// Remove from draw list</font>
+02177 <a class="code" href="classNL3D_1_1CLandscape.html#o14">_FarRdrPassSet</a>.erase (pass);
+02178 }
+02179
+02180
+02181 <font class="comment">// ***************************************************************************</font>
+02182 <font class="comment">// ***************************************************************************</font>
+02183 <font class="comment">// Misc.</font>
+02184 <font class="comment">// ***************************************************************************</font>
+02185 <font class="comment">// ***************************************************************************</font>
+02186
+02187
+02188 <font class="comment">// ***************************************************************************</font>
+<a name="l02189"></a><a class="code" href="classNL3D_1_1CLandscape.html#z481_0">02189</a> CZone* CLandscape::getZone (sint zoneId)
+02190 {
+02191 TZoneMap::iterator it;
+02192 it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId);
+02193 <font class="keywordflow">if</font> (it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+02194 <font class="keywordflow">return</font> (*it).second;
+02195 <font class="keywordflow">else</font>
+02196 <font class="keywordflow">return</font> NULL;
+02197 }
+02198
+02199
+02200 <font class="comment">// ***************************************************************************</font>
+<a name="l02201"></a><a class="code" href="classNL3D_1_1CLandscape.html#z481_1">02201</a> <font class="keyword">const</font> CZone* CLandscape::getZone (sint zoneId)<font class="keyword"> const</font>
+02202 <font class="keyword"></font>{
+02203 TZoneMap::const_iterator it;
+02204
+02205 it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId);
+02206 <font class="keywordflow">if</font> (it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+02207 <font class="keywordflow">return</font> (*it).second;
+02208 <font class="keywordflow">else</font>
+02209 <font class="keywordflow">return</font> NULL;
+02210 }
+02211
+02212
+02213
+02214 <font class="comment">// ***************************************************************************</font>
+<a name="l02215"></a><a class="code" href="classNL3D_1_1CLandscape.html#c19">02215</a> <font class="keywordtype">void</font> CLandscape::checkZoneBinds(CZone &amp;curZone, EBadBind &amp;bindError)
+02216 {
+02217 <font class="keywordflow">for</font>(sint i=0;i&lt;curZone.getNumPatchs();i++)
+02218 {
+02219 <font class="keyword">const</font> CZone::CPatchConnect &amp;pa= *curZone.getPatchConnect(i);
+02220
+02221 <font class="comment">// Check the bindInfos.</font>
+02222 <font class="keywordflow">for</font>(sint j=0;j&lt;4;j++)
+02223 {
+02224 <font class="keyword">const</font> CPatchInfo::CBindInfo &amp;bd=pa.BindEdges[j];
+02225 <font class="comment">// Just 1/1 for now.</font>
+02226 <font class="keywordflow">if</font>(bd.NPatchs==1)
+02227 {
+02228 <a class="code" href="classNL3D_1_1CLandscape.html#l2">CZone</a> *oZone= <a class="code" href="classNL3D_1_1CLandscape.html#z481_0">getZone</a>(bd.ZoneId);
+02229 <font class="comment">// If loaded zone.</font>
+02230 <font class="keywordflow">if</font>(oZone)
+02231 {
+02232 <font class="keyword">const</font> CZone::CPatchConnect &amp;po= *(oZone-&gt;getPatchConnect(bd.Next[0]));
+02233 <font class="keyword">const</font> CPatchInfo::CBindInfo &amp;bo= po.BindEdges[bd.Edge[0]];
+02234 <font class="keywordflow">if</font>(bo.NPatchs!=1 || bo.Next[0]!=i || bo.Edge[0]!=j)
+02235 bindError.BindErrors.push_back( EBadBind::CBindError(curZone.getZoneId(), i));
+02236 }
+02237 }
+02238 }
+02239 }
+02240 }
+02241
+02242
+02243 <font class="comment">// ***************************************************************************</font>
+<a name="l02244"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_4">02244</a> <font class="keywordtype">void</font> CLandscape::checkBinds() <font class="keywordflow">throw</font>(EBadBind)
+02245 {
+02246 EBadBind bindError;
+02247
+02248 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= Zones.begin();it!=Zones.end();it++)
+02249 {
+02250 CZone &amp;curZone= *(*it).second;
+02251 checkZoneBinds(curZone, bindError);
+02252 }
+02253
+02254 <font class="keywordflow">if</font>(!bindError.BindErrors.empty())
+02255 <font class="keywordflow">throw</font> bindError;
+02256 }
+02257
+02258
+02259 <font class="comment">// ***************************************************************************</font>
+<a name="l02260"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_5">02260</a> <font class="keywordtype">void</font> CLandscape::checkBinds(uint16 zoneId) <font class="keywordflow">throw</font>(EBadBind)
+02261 {
+02262 EBadBind bindError;
+02263
+02264 <a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= Zones.find(zoneId);
+02265 <font class="keywordflow">if</font>(it!= Zones.end())
+02266 {
+02267 CZone &amp;curZone= *(*it).second;
+02268 checkZoneBinds(curZone, bindError);
+02269 <font class="keywordflow">if</font>(!bindError.BindErrors.empty())
+02270 <font class="keywordflow">throw</font> bindError;
+02271 }
+02272 }
+02273
+02274
+02275
+02276 <font class="comment">// ***************************************************************************</font>
+<a name="l02277"></a><a class="code" href="classNL3D_1_1CLandscape.html#z493_0">02277</a> <font class="keywordtype">void</font> CLandscape::addTrianglesInBBox(<font class="keyword">const</font> CPatchIdentEx &amp;paIdEx, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CTrianglePatch&gt; &amp;triangles, uint8 tileTessLevel)<font class="keyword"> const</font>
+02278 <font class="keyword"></font>{
+02279 <font class="comment">// No clear here, just add triangles to the array.</font>
+02280 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= paIdEx.Patch;
+02281
+02282 CPatchIdent paId;
+02283 paId.ZoneId= paIdEx.ZoneId;
+02284 paId.PatchId= paIdEx.PatchId;
+02285 pa-&gt;addTrianglesInBBox(paId, bbox, triangles, tileTessLevel);
+02286 }
+02287
+02288
+02289 <font class="comment">// ***************************************************************************</font>
+<a name="l02290"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_2">02290</a> <font class="keywordtype">void</font> CLandscape::buildTrianglesInBBox(<font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CTrianglePatch&gt; &amp;triangles, uint8 tileTessLevel)
+02291 {
+02292 <font class="comment">// clear selection.</font>
+02293 triangles.clear();
+02294
+02295 <font class="comment">// search path of interest.</font>
+02296 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.clearSelection();
+02297 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.select(bbox.getMin(), bbox.getMax());
+02298 CQuadGrid&lt;CPatchIdentEx&gt;::CIterator it;
+02299
+02300 <font class="comment">// for each patch, add triangles to the array.</font>
+02301 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.begin(); it!= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.end(); it++)
+02302 {
+02303 <a class="code" href="classNL3D_1_1CLandscape.html#z493_0">addTrianglesInBBox</a>((*it), bbox, triangles, tileTessLevel);
+02304 }
+02305 }
+02306
+02307
+02308
+02309 <font class="comment">// ***************************************************************************</font>
+<a name="l02310"></a><a class="code" href="classNL3D_1_1CLandscape.html#z493_1">02310</a> <font class="keywordtype">void</font> CLandscape::addPatchBlocksInBBox(<font class="keyword">const</font> CPatchIdentEx &amp;paIdEx, <font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CPatchBlockIdent&gt; &amp;paBlockIds)
+02311 {
+02312 <font class="comment">// No clear here, just add blocks to the array.</font>
+02313 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= paIdEx.Patch;
+02314
+02315 CPatchIdent paId;
+02316 paId.ZoneId= paIdEx.ZoneId;
+02317 paId.PatchId= paIdEx.PatchId;
+02318 pa-&gt;addPatchBlocksInBBox(paId, bbox, paBlockIds);
+02319 }
+02320
+02321
+02322 <font class="comment">// ***************************************************************************</font>
+<a name="l02323"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_3">02323</a> <font class="keywordtype">void</font> CLandscape::buildPatchBlocksInBBox(<font class="keyword">const</font> CAABBox &amp;bbox, std::vector&lt;CPatchBlockIdent&gt; &amp;paBlockIds)
+02324 {
+02325 <font class="comment">// clear selection.</font>
+02326 paBlockIds.clear();
+02327
+02328 <font class="comment">// search path of interest.</font>
+02329 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.clearSelection();
+02330 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.select(bbox.getMin(), bbox.getMax());
+02331 CQuadGrid&lt;CPatchIdentEx&gt;::CIterator it;
+02332
+02333 <font class="comment">// for each patch, add blocks to the array.</font>
+02334 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.begin(); it!= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.end(); it++)
+02335 {
+02336 <a class="code" href="classNL3D_1_1CLandscape.html#z493_1">addPatchBlocksInBBox</a>((*it), bbox, paBlockIds);
+02337 }
+02338 }
+02339
+02340
+02341 <font class="comment">// ***************************************************************************</font>
+<a name="l02342"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_4">02342</a> <font class="keywordtype">void</font> CLandscape::fillPatchQuadBlock(CPatchQuadBlock &amp;quadBlock)<font class="keyword"> const</font>
+02343 <font class="keyword"></font>{
+02344 sint zoneId= quadBlock.PatchBlockId.PatchId.ZoneId;
+02345 sint patchId= quadBlock.PatchBlockId.PatchId.PatchId;
+02346 std::map&lt;uint16, CZone*&gt;::const_iterator it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId);
+02347 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+02348 {
+02349 sint N= (*it).second-&gt;getNumPatchs();
+02350 <font class="comment">// patch must exist in the zone.</font>
+02351 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId&gt;=0);
+02352 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId&lt;N);
+02353
+02354 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(patchId);
+02355 pa-&gt;fillPatchQuadBlock(quadBlock);
+02356 }
+02357 }
+02358
+02359
+02360
+02361
+02362 <font class="comment">// ***************************************************************************</font>
+<a name="l02363"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_0">02363</a> <font class="keywordtype">void</font> CLandscape::buildCollideFaces(<font class="keyword">const</font> CAABBoxExt &amp;bbox, vector&lt;CTriangle&gt; &amp;faces, <font class="keywordtype">bool</font> faceClip)
+02364 {
+02365 CBSphere bsWanted(bbox.getCenter(), bbox.getRadius());
+02366
+02367 faces.clear();
+02368 <font class="comment">// For all zones.</font>
+02369 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+02370 {
+02371 <font class="keyword">const</font> CAABBoxExt &amp;bb= (*it).second-&gt;getZoneBB();
+02372 CBSphere bs(bb.getCenter(), bb.getRadius());
+02373 <font class="comment">// If zone intersect the wanted area.</font>
+02374 <font class="comment">//===================================</font>
+02375 <font class="keywordflow">if</font>(bs.intersect(bsWanted))
+02376 {
+02377 <font class="comment">// Then trace all patch.</font>
+02378 sint N= (*it).second-&gt;getNumPatchs();
+02379 <font class="keywordflow">for</font>(sint i=0;i&lt;N;i++)
+02380 {
+02381 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(i);
+02382
+02383 <font class="comment">// If patch in wanted area....</font>
+02384 <font class="comment">//============================</font>
+02385 <font class="keywordflow">if</font>(bsWanted.intersect(pa-&gt;getBSphere()))
+02386 {
+02387 <font class="comment">// 0. Build the faces.</font>
+02388 <font class="comment">//====================</font>
+02389 sint ordS= pa-&gt;getOrderS();
+02390 sint ordT= pa-&gt;getOrderT();
+02391 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>,j;
+02392 vector&lt;CTriangle&gt; tmpFaces;
+02393 tmpFaces.reserve(ordS*ordT);
+02394 <font class="keywordtype">float</font> OOS= 1.0f/ordS;
+02395 <font class="keywordtype">float</font> OOT= 1.0f/ordT;
+02396 <font class="keywordflow">for</font>(<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;ordT;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+02397 {
+02398 <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>&lt;ordS;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+02399 {
+02400 CTriangle f;
+02401 f.V0= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02402 f.V1= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02403 f.V2= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02404 tmpFaces.push_back(f);
+02405 f.V0= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02406 f.V1= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02407 f.V2= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02408 tmpFaces.push_back(f);
+02409 }
+02410 }
+02411
+02412 <font class="comment">// 1. Clip the faces.</font>
+02413 <font class="comment">//===================</font>
+02414 <font class="keywordflow">if</font>(faceClip)
+02415 {
+02416 <font class="comment">// Insert only faces which are In the area.</font>
+02417 <font class="keywordflow">for</font>(j=0;j&lt;(sint)tmpFaces.size();j++)
+02418 {
+02419 CTriangle &amp;f= tmpFaces[j];
+02420 <font class="keywordflow">if</font>(bbox.intersect(f.V0, f.V1, f.V2))
+02421 {
+02422 faces.push_back(f);
+02423 }
+02424 }
+02425 }
+02426 <font class="keywordflow">else</font>
+02427 {
+02428 <font class="comment">// Else insert ALL.</font>
+02429 faces.insert(faces.end(), tmpFaces.begin(), tmpFaces.end());
+02430 }
+02431 }
+02432 }
+02433 }
+02434 }
+02435 }
+02436
+02437
+02438 <font class="comment">// ***************************************************************************</font>
+<a name="l02439"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_1">02439</a> <font class="keywordtype">void</font> CLandscape::buildCollideFaces(sint zoneId, sint patch, std::vector&lt;CTriangle&gt; &amp;faces)
+02440 {
+02441 faces.clear();
+02442
+02443 <a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find(zoneId);
+02444 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+02445 {
+02446 <font class="comment">// Then trace all patch.</font>
+02447 sint N= (*it).second-&gt;getNumPatchs();
+02448 <a class="code" href="debug_8h.html#a6">nlassert</a>(patch&gt;=0);
+02449 <a class="code" href="debug_8h.html#a6">nlassert</a>(patch&lt;N);
+02450 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(patch);
+02451
+02452 <font class="comment">// Build the faces.</font>
+02453 <font class="comment">//=================</font>
+02454 sint ordS= pa-&gt;getOrderS();
+02455 sint ordT= pa-&gt;getOrderT();
+02456 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+02457 <font class="keywordtype">float</font> OOS= 1.0f/ordS;
+02458 <font class="keywordtype">float</font> OOT= 1.0f/ordT;
+02459 <font class="keywordflow">for</font>(<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;ordT;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+02460 {
+02461 <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>&lt;ordS;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++)
+02462 {
+02463 CTriangle f;
+02464 f.V0= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02465 f.V1= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02466 f.V2= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02467 faces.push_back(f);
+02468 f.V0= pa-&gt;computeVertex(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02469 f.V1= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, (<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1)*OOT);
+02470 f.V2= pa-&gt;computeVertex((<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1)*OOS, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*OOT);
+02471 faces.push_back(f);
+02472 }
+02473 }
+02474 }
+02475 }
+02476
+02477
+02478 <font class="comment">// ***************************************************************************</font>
+<a name="l02479"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_5">02479</a> CVector CLandscape::getTesselatedPos(<font class="keyword">const</font> CPatchIdent &amp;patchId, <font class="keyword">const</font> CUV &amp;uv)<font class="keyword"> const</font>
+02480 <font class="keyword"></font>{
+02481 <font class="comment">// First, must update globals, for CTessFace::computeTesselatedPos() to work properly.</font>
+02482
+02483 <font class="comment">// VertexProgrma mode???</font>
+02484 CLandscapeGlobals::VertexProgramEnabled= <a class="code" href="classNL3D_1_1CLandscape.html#z491_4">_VertexShaderOk</a>;
+02485
+02486 <font class="comment">// If VertexProgram enabled</font>
+02487 <font class="keywordflow">if</font>( CLandscapeGlobals::VertexProgramEnabled )
+02488 {
+02489 <font class="comment">/* because VertexProgram enabled, CTessVertex::Pos (geomorphed Pos) are not computed each frame</font>
+02490 <font class="comment"> Hence, CTessFace::computeTesselatedPos() will call CTessVertex::computeGeomPos() to have correct </font>
+02491 <font class="comment"> CTessVertex::Pos. ThereFore we must setup globals so CTessVertex::computeGeomPos() works properly.</font>
+02492 <font class="comment"> */</font>
+02493
+02494 <font class="comment">// see copy in updateGlobalsAndLockBuffers(). NB: Just copy what needed here!!!!</font>
+02495
+02496 <font class="comment">// Tile subdivsion part.</font>
+02497 CLandscapeGlobals::TileDistNear = <a class="code" href="classNL3D_1_1CLandscape.html#o1">_TileDistNear</a>;
+02498 CLandscapeGlobals::TileDistFar = CLandscapeGlobals::TileDistNear+20;
+02499 CLandscapeGlobals::TileDistNearSqr = <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(CLandscapeGlobals::TileDistNear);
+02500 CLandscapeGlobals::TileDistFarSqr = <a class="code" href="namespaceNLMISC.html#a214">sqr</a>(CLandscapeGlobals::TileDistFar);
+02501 CLandscapeGlobals::OOTileDistDeltaSqr = 1.0f / (CLandscapeGlobals::TileDistFarSqr - CLandscapeGlobals::TileDistNearSqr);
+02502
+02503 <font class="comment">// RefineThreshold.</font>
+02504 CLandscapeGlobals::RefineThreshold= <a class="code" href="classNL3D_1_1CLandscape.html#o2">_Threshold</a>;
+02505 CLandscapeGlobals::OORefineThreshold= 1.0f / CLandscapeGlobals::RefineThreshold;
+02506
+02507 <font class="comment">// Refine Center*.</font>
+02508 <font class="comment">// NB: setup the last setuped refineCenter.</font>
+02509 CLandscapeGlobals::RefineCenter= <a class="code" href="classNL3D_1_1CLandscape.html#z495_2">_OldRefineCenter</a>;
+02510 }
+02511
+02512
+02513 <font class="comment">// \todo yoyo: TODO_ZONEID: change ZoneId in 32 bits...</font>
+02514 std::map&lt;uint16, CZone*&gt;::const_iterator it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find((uint16)patchId.ZoneId);
+02515 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+02516 {
+02517 sint N= (*it).second-&gt;getNumPatchs();
+02518 <font class="comment">// patch must exist in the zone.</font>
+02519 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId.PatchId&lt;N);
+02520 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(patchId.PatchId);
+02521
+02522 <font class="keywordflow">return</font> pa-&gt;getTesselatedPos(uv);
+02523 }
+02524 <font class="keywordflow">else</font>
+02525 <font class="keywordflow">return</font> CVector::Null;
+02526 }
+02527
+02528
+02529 <font class="comment">// ***************************************************************************</font>
+<a name="l02530"></a><a class="code" href="classNL3D_1_1CLandscape.html#f0">02530</a> uint CLandscape::getRdrPassIndexWithSize (uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>)
+02531 {
+02532 <font class="comment">// Check no NULL size</font>
+02533 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>);
+02534 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>);
+02535
+02536 <font class="comment">// Find width order</font>
+02537 <font class="keywordtype">int</font> orderWidth=0;
+02538 <font class="keywordflow">while</font> (!(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>&amp;(1&lt;&lt;orderWidth)))
+02539 orderWidth++;
+02540
+02541 <font class="comment">// Find heightorder</font>
+02542 <font class="keywordtype">int</font> orderHeight=0;
+02543 <font class="keywordflow">while</font> (!(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>&amp;(1&lt;&lt;orderHeight)))
+02544 orderHeight++;
+02545
+02546 <font class="keywordflow">if</font> (orderWidth&gt;orderHeight)
+02547 {
+02548 <font class="keywordflow">return</font> <a class="code" href="landscape_8h.html#a0">NL_MAX_SIZE_OF_TEXTURE_EDGE_SHIFT</a>*orderHeight+orderWidth;
+02549 }
+02550 <font class="keywordflow">else</font>
+02551 {
+02552 <font class="keywordflow">return</font> <a class="code" href="landscape_8h.html#a0">NL_MAX_SIZE_OF_TEXTURE_EDGE_SHIFT</a>*orderWidth+orderHeight;
+02553 }
+02554 }
+02555
+<a name="l02556"></a><a class="code" href="landscape_8cpp.html#a6">02556</a> <font class="preprocessor">#define NL_TILE_FAR_SIZE_ORDER0 (NL_NUM_PIXELS_ON_FAR_TILE_EDGE*NL_NUM_PIXELS_ON_FAR_TILE_EDGE)</font>
+<a name="l02557"></a><a class="code" href="landscape_8cpp.html#a7">02557</a> <font class="preprocessor"></font><font class="preprocessor">#define NL_TILE_FAR_SIZE_ORDER1 ((NL_NUM_PIXELS_ON_FAR_TILE_EDGE&gt;&gt;1)*(NL_NUM_PIXELS_ON_FAR_TILE_EDGE&gt;&gt;1))</font>
+<a name="l02558"></a><a class="code" href="landscape_8cpp.html#a8">02558</a> <font class="preprocessor"></font><font class="preprocessor">#define NL_TILE_FAR_SIZE_ORDER2 ((NL_NUM_PIXELS_ON_FAR_TILE_EDGE&gt;&gt;2)*(NL_NUM_PIXELS_ON_FAR_TILE_EDGE&gt;&gt;2))</font>
+02559 <font class="preprocessor"></font>
+02560 <font class="comment">// ***************************************************************************</font>
+02561 <font class="comment">// internal use</font>
+<a name="l02562"></a><a class="code" href="classNL3D_1_1CLandscape.html#c12">02562</a> <font class="keywordtype">bool</font> CLandscape::eraseTileFarIfNotGood (uint tileNumber, uint sizeOrder0, uint sizeOrder1, uint sizeOrder2)
+02563 {
+02564 <font class="comment">// The same tiles ?</font>
+02565 <font class="keywordtype">bool</font> bSame=<font class="keyword">true</font>;
+02566
+02567 <font class="comment">// It is the same tile ?</font>
+02568 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;isFill (CTileFarBank::diffuse))
+02569 {
+02570 <font class="comment">// Good diffuse size ?</font>
+02571 <font class="keywordflow">if</font> (
+02572 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::diffuse, CTileFarBank::order0) != sizeOrder0) ||
+02573 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::diffuse, CTileFarBank::order1) != sizeOrder1) ||
+02574 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::diffuse, CTileFarBank::order2) != sizeOrder2)
+02575 )
+02576 {
+02577 <a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;erasePixels (CTileFarBank::diffuse);
+02578 bSame=<font class="keyword">false</font>;
+02579 }
+02580 }
+02581
+02582 <font class="comment">// It is the same tile ?</font>
+02583 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;isFill (CTileFarBank::additive))
+02584 {
+02585 <font class="comment">// Good additive size ?</font>
+02586 <font class="keywordflow">if</font> (
+02587 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::additive, CTileFarBank::order0) != sizeOrder0) ||
+02588 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::additive, CTileFarBank::order1) != sizeOrder1) ||
+02589 (<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;getSize (CTileFarBank::additive, CTileFarBank::order2) != sizeOrder2)
+02590 )
+02591 {
+02592 <a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getTile (tileNumber)-&gt;erasePixels (CTileFarBank::additive);
+02593 bSame=<font class="keyword">false</font>;
+02594 }
+02595 }
+02596
+02597 <font class="comment">// Return true if the tiles seem to be the sames</font>
+02598 <font class="keywordflow">return</font> bSame;
+02599 }
+02600
+02601 <font class="comment">// ***************************************************************************</font>
+<a name="l02602"></a><a class="code" href="classNL3D_1_1CLandscape.html#z477_6">02602</a> <font class="keywordtype">bool</font> CLandscape::initTileBanks ()
+02603 {
+02604 <font class="comment">// *** Check the two banks are OK</font>
+02605 <a class="code" href="classNL3D_1_1CLandscape.html#o16">_FarInitialized</a>=<font class="keyword">false</font>;
+02606
+02607 <font class="comment">// Compatibility check</font>
+02608 <font class="keywordtype">bool</font> bCompatibility=<font class="keyword">true</font>;
+02609
+02610 <font class="comment">// Same number of tiles</font>
+02611 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileCount()==<a class="code" href="classNL3D_1_1CLandscape.html#m1">TileFarBank</a>.getNumTile())
+02612 {
+02613 <font class="comment">// Same tileSet</font>
+02614 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> tileSet=0; tileSet&lt;<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSetCount(); tileSet++)
+02615 {
+02616 <font class="comment">// Same tile128</font>
+02617 <font class="keywordtype">int</font> tile;
+02618 <font class="keywordflow">for</font> (tile=0; tile&lt;<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSet(tileSet)-&gt;getNumTile128(); tile++)
+02619 {
+02620 <font class="comment">// tile number</font>
+02621 uint tileNumber=<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSet(tileSet)-&gt;getTile128(tile);
+02622
+02623 <font class="comment">// erase the tiles if not good</font>
+02624 bCompatibility&amp;=<a class="code" href="classNL3D_1_1CLandscape.html#c12">eraseTileFarIfNotGood</a> (tileNumber, <a class="code" href="landscape_8cpp.html#a6">NL_TILE_FAR_SIZE_ORDER0</a>, <a class="code" href="landscape_8cpp.html#a7">NL_TILE_FAR_SIZE_ORDER1</a>, <a class="code" href="landscape_8cpp.html#a8">NL_TILE_FAR_SIZE_ORDER2</a>);
+02625 }
+02626
+02627 <font class="comment">// Same tile256</font>
+02628 <font class="keywordflow">for</font> (tile=0; tile&lt;<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSet(tileSet)-&gt;getNumTile256(); tile++)
+02629 {
+02630 <font class="comment">// tile number</font>
+02631 uint tileNumber=<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSet(tileSet)-&gt;getTile256(tile);
+02632
+02633 <font class="comment">// erase the tiles if not good</font>
+02634 bCompatibility&amp;=<a class="code" href="classNL3D_1_1CLandscape.html#c12">eraseTileFarIfNotGood</a> (tileNumber, <a class="code" href="landscape_8cpp.html#a6">NL_TILE_FAR_SIZE_ORDER0</a>&lt;&lt;2, <a class="code" href="landscape_8cpp.html#a7">NL_TILE_FAR_SIZE_ORDER1</a>&lt;&lt;2, <a class="code" href="landscape_8cpp.html#a8">NL_TILE_FAR_SIZE_ORDER2</a>&lt;&lt;2);
+02635 }
+02636
+02637 <font class="comment">// Same transition</font>
+02638 <font class="keywordflow">for</font> (tile=0; tile&lt;CTileSet::count; tile++)
+02639 {
+02640 <font class="comment">// tile number</font>
+02641 uint tileNumber=<a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileSet(tileSet)-&gt;getTransition(tile)-&gt;getTile();
+02642
+02643 <font class="comment">// erase the tiles if not good</font>
+02644 bCompatibility&amp;=<a class="code" href="classNL3D_1_1CLandscape.html#c12">eraseTileFarIfNotGood</a> (tileNumber, <a class="code" href="landscape_8cpp.html#a6">NL_TILE_FAR_SIZE_ORDER0</a>, <a class="code" href="landscape_8cpp.html#a7">NL_TILE_FAR_SIZE_ORDER1</a>, <a class="code" href="landscape_8cpp.html#a8">NL_TILE_FAR_SIZE_ORDER2</a>);
+02645 }
+02646 }
+02647
+02648 <font class="comment">// Far actived!</font>
+02649 <a class="code" href="classNL3D_1_1CLandscape.html#o16">_FarInitialized</a>=<font class="keyword">true</font>;
+02650 }
+02651
+02652 <font class="comment">// Register / Load the vegetables.</font>
+02653 <a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.initTileVegetableDescs(<a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>);
+02654
+02655 <font class="keywordflow">return</font> bCompatibility;
+02656 }
+02657
+02658
+02659 <font class="comment">// ***************************************************************************</font>
+<a name="l02660"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_0">02660</a> <font class="keywordtype">void</font> CLandscape::setupStaticLight (<font class="keyword">const</font> CRGBA &amp;diffuse, <font class="keyword">const</font> CRGBA &amp;ambiant, <font class="keywordtype">float</font> multiply)
+02661 {
+02662 sint nMultiply=(sint)(256.f*multiply);
+02663 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i=0; i&lt;256; i++)
+02664 {
+02665 sint max=0;
+02666 sint <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>=(((nMultiply*diffuse.R*i)&gt;&gt;8)+ambiant.R*(256-i))&gt;&gt;8;
+02667 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>&gt;max)
+02668 max=<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>;
+02669 sint g=(((nMultiply*diffuse.G*i)&gt;&gt;8)+ambiant.G*(256-i))&gt;&gt;8;
+02670 <font class="keywordflow">if</font> (g&gt;max)
+02671 max=g;
+02672 sint b=(((nMultiply*diffuse.B*i)&gt;&gt;8)+ambiant.B*(256-i))&gt;&gt;8;
+02673 <font class="keywordflow">if</font> (b&gt;max)
+02674 max=b;
+02675 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>&lt;&lt;=8;
+02676 g&lt;&lt;=8;
+02677 b&lt;&lt;=8;
+02678 max=std::max(max, 256);
+02679 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>/=max;
+02680 g/=max;
+02681 b/=max;
+02682 <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>, 0, 255);
+02683 <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (g, 0, 255);
+02684 <a class="code" href="namespaceNLMISC.html#a215">clamp</a> (b, 0, 255);
+02685 <a class="code" href="classNL3D_1_1CLandscape.html#o17">_LightValue</a>[i].R=<a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>;
+02686 <a class="code" href="classNL3D_1_1CLandscape.html#o17">_LightValue</a>[i].G=g;
+02687 <a class="code" href="classNL3D_1_1CLandscape.html#o17">_LightValue</a>[i].B=b;
+02688 <a class="code" href="classNL3D_1_1CLandscape.html#o17">_LightValue</a>[i].A=255;
+02689 }
+02690 }
+02691
+02692 <font class="comment">// ***************************************************************************</font>
+<a name="l02693"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_4">02693</a> <font class="keywordtype">void</font> CLandscape::enableAutomaticLighting(<font class="keywordtype">bool</font> enable)
+02694 {
+02695 <a class="code" href="classNL3D_1_1CLandscape.html#o18">_AutomaticLighting</a>= enable;
+02696 }
+02697
+02698 <font class="comment">// ***************************************************************************</font>
+<a name="l02699"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_5">02699</a> <font class="keywordtype">void</font> CLandscape::setupAutomaticLightDir(<font class="keyword">const</font> CVector &amp;lightDir)
+02700 {
+02701 <a class="code" href="classNL3D_1_1CLandscape.html#o19">_AutomaticLightDir</a>= lightDir;
+02702 <a class="code" href="classNL3D_1_1CLandscape.html#o19">_AutomaticLightDir</a>.normalize();
+02703 }
+02704
+02705
+02706 <font class="comment">// ***************************************************************************</font>
+<a name="l02707"></a><a class="code" href="classNL3D_1_1CLandscape.html#z484_0">02707</a> CVector CLandscape::getHeightFieldDeltaZ(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>)<font class="keyword"> const</font>
+02708 <font class="keyword"></font>{
+02709 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>.size()==0)
+02710 <font class="keywordflow">return</font> CVector::Null;
+02711
+02712 <font class="comment">// map to _HeightField coordinates.</font>
+02713 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m1">OriginX</a>;
+02714 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m2">OriginY</a>;
+02715 <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>*= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m5">OOSizeX</a>;
+02716 <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>*= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m6">OOSizeY</a>;
+02717 <font class="comment">// get patch on the grid.</font>
+02718 sint ix, iy;
+02719 ix= (sint)floor(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>);
+02720 iy= (sint)floor(<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
+02721 <font class="comment">// out of the grid?</font>
+02722 <font class="keywordflow">if</font>( ix&lt;0 || ix&gt;=(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m7">Width</a> || iy&lt;0 || iy&gt;=(sint)<a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m8">Height</a>)
+02723 <font class="keywordflow">return</font> CVector::Null;
+02724
+02725 <font class="comment">// get patch.</font>
+02726 <font class="keyword">const</font> CBezierPatchZ &amp;paz= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>[iy*<a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m7">Width</a> + ix];
+02727
+02728 <font class="comment">// compute result.</font>
+02729 CVector ret=CVector::Null;
+02730 ret.x= 0;
+02731 ret.y= 0;
+02732 ret.z= paz.eval(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>-ix, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>-iy);
+02733
+02734 <font class="keywordflow">return</font> ret;
+02735 }
+02736
+02737
+02738
+02739 <font class="comment">// ***************************************************************************</font>
+<a name="l02740"></a><a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#a0">02740</a> <font class="keywordtype">void</font> CLandscape::CBezierPatchZ::makeInteriors()
+02741 {
+02742 <font class="keywordtype">float</font> &amp;a = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[0];
+02743 <font class="keywordtype">float</font> &amp;b = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[1];
+02744 <font class="keywordtype">float</font> &amp;c = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[2];
+02745 <font class="keywordtype">float</font> &amp;d = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[3];
+02746 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[0] = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[7] + <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[0] - a;
+02747 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[1] = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[1] + <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[2] - b;
+02748 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[2] = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[3] + <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[4] - c;
+02749 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[3] = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[5] + <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[6] - d;
+02750 }
+02751 <font class="comment">// ***************************************************************************</font>
+<a name="l02752"></a><a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#a1">02752</a> <font class="keywordtype">float</font> CLandscape::CBezierPatchZ::eval(<font class="keywordtype">float</font> ps, <font class="keywordtype">float</font> pt)<font class="keyword"> const</font>
+02753 <font class="keyword"></font>{
+02754 <font class="keywordtype">float</font> p;
+02755
+02756 <font class="keywordtype">float</font> ps2 = ps * ps;
+02757 <font class="keywordtype">float</font> ps1 = 1.0f - ps;
+02758 <font class="keywordtype">float</font> ps12 = ps1 * ps1;
+02759 <font class="keywordtype">float</font> s0 = ps12 * ps1;
+02760 <font class="keywordtype">float</font> s1 = 3.0f * ps * ps12;
+02761 <font class="keywordtype">float</font> s2 = 3.0f * ps2 * ps1;
+02762 <font class="keywordtype">float</font> s3 = ps2 * ps;
+02763 <font class="keywordtype">float</font> pt2 = pt * pt;
+02764 <font class="keywordtype">float</font> pt1 = 1.0f - pt;
+02765 <font class="keywordtype">float</font> pt12 = pt1 * pt1;
+02766 <font class="keywordtype">float</font> t0 = pt12 * pt1;
+02767 <font class="keywordtype">float</font> t1 = 3.0f * pt * pt12;
+02768 <font class="keywordtype">float</font> t2 = 3.0f * pt2 * pt1;
+02769 <font class="keywordtype">float</font> t3 = pt2 * pt;
+02770
+02771 p = <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[0] * s0 * t0 +
+02772 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[7] * s1 * t0 +
+02773 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[6] * s2 * t0 +
+02774 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[3] * s3 * t0;
+02775 p+= <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[0] * s0 * t1 +
+02776 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[0]* s1 * t1 +
+02777 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[3]* s2 * t1 +
+02778 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[5] * s3 * t1;
+02779 p+= <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[1] * s0 * t2 +
+02780 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[1]* s1 * t2 +
+02781 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m2">Interiors</a>[2]* s2 * t2 +
+02782 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[4] * s3 * t2;
+02783 p+= <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[1] * s0 * t3 +
+02784 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[2] * s1 * t3 +
+02785 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m1">Tangents</a>[3] * s2 * t3 +
+02786 <a class="code" href="structNL3D_1_1CLandscape_1_1CBezierPatchZ.html#m0">Vertices</a>[2] * s3 * t3;
+02787
+02788 <font class="keywordflow">return</font> p;
+02789 }
+02790
+02791
+02792 <font class="comment">// ***************************************************************************</font>
+<a name="l02793"></a><a class="code" href="classNL3D_1_1CLandscape.html#z484_1">02793</a> <font class="keywordtype">void</font> CLandscape::setHeightField(<font class="keyword">const</font> CHeightMap &amp;hf)
+02794 {
+02795 <font class="keywordflow">if</font>(hf.getWidth()&lt;2)
+02796 <font class="keywordflow">return</font>;
+02797 <font class="keywordflow">if</font>(hf.getHeight()&lt;2)
+02798 <font class="keywordflow">return</font>;
+02799
+02800 <font class="comment">// Fill basics.</font>
+02801 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m1">OriginX</a>= hf.OriginX;
+02802 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m2">OriginY</a>= hf.OriginY;
+02803 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m3">SizeX</a>= hf.SizeX;
+02804 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m4">SizeY</a>= hf.SizeY;
+02805 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m5">OOSizeX</a>= 1/hf.SizeX;
+02806 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m6">OOSizeY</a>= 1/hf.SizeY;
+02807 uint <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>= hf.getWidth()-1;
+02808 uint h= hf.getHeight()-1;
+02809 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m7">Width</a>= <a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a>;
+02810 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m8">Height</a>= h;
+02811 <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>.resize(<a class="code" href="driver__opengl__extension__def_8h.html#a367">w</a> * h);
+02812
+02813 <font class="comment">// compute patchs</font>
+02814 sint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>;
+02815
+02816 <font class="comment">// compute vertices / tangents on each patch</font>
+02817 <font class="keywordflow">for</font>(<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;(sint)h;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+02818 {
+02819 <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>&lt;(sint)<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>++)
+02820 {
+02821 CBezierPatchZ &amp;paz= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</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>];
+02822 <font class="comment">// vertices.</font>
+02823 paz.Vertices[0]= hf.getZ(<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>);
+02824 paz.Vertices[1]= hf.getZ(<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>+1);
+02825 paz.Vertices[2]= hf.getZ(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+1);
+02826 paz.Vertices[3]= hf.getZ(<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+1, <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>);
+02827 }
+02828 }
+02829
+02830 <font class="comment">// compute tangents</font>
+02831 <font class="keywordflow">for</font>(<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;(sint)h;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+02832 {
+02833 <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>&lt;(sint)<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>++)
+02834 {
+02835 CBezierPatchZ &amp;paz= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</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>];
+02836 sint tg;
+02837 <font class="comment">// For each tangent, what vertex (relative to x,y) we must take.</font>
+02838 <font class="keyword">struct </font>CDeltaPos
+02839 {
+02840 sint ox,oy;
+02841 sint dx1,dy1;
+02842 sint dx2,dy2;
+02843 };
+02844 <font class="keyword">static</font> CDeltaPos deltas[8]= {
+02845 {0,0, 0,1, 0,-1} ,
+02846 {0,1, 0,0, 0,2} ,
+02847 {0,1, 1,1, -1,1} ,
+02848 {1,1, 0,1, 2,1} ,
+02849 {1,1, 1,0, 1,2} ,
+02850 {1,0, 1,1, 1,-1} ,
+02851 {1,0, 0,0, 2,0} ,
+02852 {0,0, 1,0, -1,0} ,
+02853 };
+02854
+02855 <font class="comment">// compute each tangent of this patch.</font>
+02856 <font class="keywordflow">for</font>(tg=0; tg&lt;8;tg++)
+02857 {
+02858 sint x0,y0;
+02859 sint x1,y1;
+02860 sint x2,y2;
+02861 x0= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+deltas[tg].ox; y0= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+deltas[tg].oy;
+02862 x1= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+deltas[tg].dx1; y1= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+deltas[tg].dy1;
+02863 x2= <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>+deltas[tg].dx2; y2= <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>+deltas[tg].dy2;
+02864
+02865 <font class="comment">// borders case.</font>
+02866 <font class="keywordflow">if</font>(x2&lt;0 || x2&gt;=(sint)hf.getWidth() || y2&lt;0 || y2&gt;=(sint)hf.getHeight())
+02867 {
+02868 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>,dv;
+02869 <font class="comment">// base of tangents.</font>
+02870 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= hf.getZ(x0,y0);
+02871 <font class="comment">// target tangents.</font>
+02872 dv= hf.getZ(x1,y1) - <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+02873 <font class="comment">// result of tangent.</font>
+02874 paz.Tangents[tg]= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>+dv/3;
+02875 }
+02876 <font class="comment">// middle case.</font>
+02877 <font class="keywordflow">else</font>
+02878 {
+02879 <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>,dv;
+02880 <font class="comment">// base of tangents.</font>
+02881 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= hf.getZ(x0,y0);
+02882 <font class="comment">// target tangents.</font>
+02883 dv= hf.getZ(x1,y1) - <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+02884 <font class="comment">// add mirror target tangent.</font>
+02885 dv+= -(hf.getZ(x2,y2) - <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+02886 dv/=2;
+02887 <font class="comment">// result of tangent.</font>
+02888 paz.Tangents[tg]= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>+dv/3;
+02889 }
+02890 }
+02891 }
+02892 }
+02893
+02894 <font class="comment">// compute interiors.</font>
+02895 <font class="keywordflow">for</font>(<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;(sint)h;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++)
+02896 {
+02897 <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>&lt;(sint)<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>++)
+02898 {
+02899 CBezierPatchZ &amp;paz= <a class="code" href="classNL3D_1_1CLandscape.html#o21">_HeightField</a>.<a class="code" href="structNL3D_1_1CLandscape_1_1CHeightField.html#m0">ZPatchs</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</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>];
+02900 paz.makeInteriors();
+02901 }
+02902 }
+02903
+02904 }
+02905
+02906
+02907 <font class="comment">// ***************************************************************************</font>
+<a name="l02908"></a><a class="code" href="classNL3D_1_1CLandscape.html#z480_6">02908</a> <font class="keywordtype">void</font> CLandscape::getTessellationLeaves(std::vector&lt;const CTessFace*&gt; &amp;leaves)<font class="keyword"> const</font>
+02909 <font class="keyword"></font>{
+02910 leaves.clear();
+02911
+02912 std::map&lt;uint16, CZone*&gt;::const_iterator it;
+02913 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+02914 {
+02915 <font class="comment">// Then trace all patch.</font>
+02916 sint N= (*it).second-&gt;getNumPatchs();
+02917 <font class="keywordflow">for</font>(sint i=0;i&lt;N;i++)
+02918 {
+02919 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(i);
+02920
+02921 pa-&gt;appendTessellationLeaves(leaves);
+02922 }
+02923 }
+02924
+02925 }
+02926
+02927
+02928 <font class="comment">// ***************************************************************************</font>
+<a name="l02929"></a><a class="code" href="classNL3D_1_1CLandscape.html#z487_0">02929</a> <font class="keywordtype">void</font> CLandscape::setPZBModelPosition(<font class="keyword">const</font> CVector &amp;pos)
+02930 {
+02931 <a class="code" href="classNL3D_1_1CLandscape.html#z497_0">_PZBModelPosition</a>= pos;
+02932 }
+02933
+02934
+02935
+02936 <font class="comment">// ***************************************************************************</font>
+02937 <font class="comment">// ***************************************************************************</font>
+02938 <font class="comment">// Allocators.</font>
+02939 <font class="comment">// ***************************************************************************</font>
+02940 <font class="comment">// ***************************************************************************</font>
+02941
+02942
+02943 <font class="comment">// ***************************************************************************</font>
+<a name="l02944"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_0">02944</a> CTessFace *CLandscape::newTessFace()
+02945 {
+02946 <font class="comment">// allcoate the face.</font>
+02947 <a class="code" href="classNL3D_1_1CLandscape.html#l0">CTessFace</a> *face= <a class="code" href="classNL3D_1_1CLandscape.html#z490_12">TessFaceAllocator</a>.allocate();
+02948
+02949 <font class="comment">// for refine() mgt, append the face to the list of newLeaves, so they will be tested in refine()</font>
+02950 face-&gt;linkInPList(<a class="code" href="classNL3D_1_1CLandscape.html#z495_4">_RootNewLeaves</a>);
+02951
+02952 <font class="keywordflow">return</font> face;
+02953 }
+02954
+02955 <font class="comment">// ***************************************************************************</font>
+<a name="l02956"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_1">02956</a> CTessVertex *CLandscape::newTessVertex()
+02957 {
+02958 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z490_13">TessVertexAllocator</a>.allocate();
+02959 }
+02960
+02961 <font class="comment">// ***************************************************************************</font>
+<a name="l02962"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_2">02962</a> CTessNearVertex *CLandscape::newTessNearVertex()
+02963 {
+02964 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z490_14">TessNearVertexAllocator</a>.allocate();
+02965 }
+02966
+02967 <font class="comment">// ***************************************************************************</font>
+<a name="l02968"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_3">02968</a> CTessFarVertex *CLandscape::newTessFarVertex()
+02969 {
+02970 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z490_15">TessFarVertexAllocator</a>.allocate();
+02971 }
+02972
+02973 <font class="comment">// ***************************************************************************</font>
+<a name="l02974"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_4">02974</a> CTileMaterial *CLandscape::newTileMaterial()
+02975 {
+02976 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z490_16">TileMaterialAllocator</a>.allocate();
+02977 }
+02978
+02979 <font class="comment">// ***************************************************************************</font>
+<a name="l02980"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_5">02980</a> CTileFace *CLandscape::newTileFace()
+02981 {
+02982 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z490_17">TileFaceAllocator</a>.allocate();
+02983 }
+02984
+02985 <font class="comment">// ***************************************************************************</font>
+<a name="l02986"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_6">02986</a> <font class="keywordtype">void</font> CLandscape::deleteTessFace(CTessFace *f)
+02987 {
+02988 <font class="comment">// for refine() mgt, must remove from refine priority list, or from the temp rootTessFaceToUpdate list.</font>
+02989 f-&gt;unlinkInPList();
+02990
+02991 <a class="code" href="classNL3D_1_1CLandscape.html#z490_12">TessFaceAllocator</a>.free(f);
+02992 }
+02993
+02994 <font class="comment">// ***************************************************************************</font>
+<a name="l02995"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_7">02995</a> <font class="keywordtype">void</font> CLandscape::deleteTessVertex(CTessVertex *<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
+02996 {
+02997 <a class="code" href="classNL3D_1_1CLandscape.html#z490_13">TessVertexAllocator</a>.free(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+02998 }
+02999
+03000 <font class="comment">// ***************************************************************************</font>
+<a name="l03001"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_8">03001</a> <font class="keywordtype">void</font> CLandscape::deleteTessNearVertex(CTessNearVertex *<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
+03002 {
+03003 <a class="code" href="classNL3D_1_1CLandscape.html#z490_14">TessNearVertexAllocator</a>.free(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+03004 }
+03005
+03006 <font class="comment">// ***************************************************************************</font>
+<a name="l03007"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_9">03007</a> <font class="keywordtype">void</font> CLandscape::deleteTessFarVertex(CTessFarVertex *<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
+03008 {
+03009 <a class="code" href="classNL3D_1_1CLandscape.html#z490_15">TessFarVertexAllocator</a>.free(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+03010 }
+03011
+03012 <font class="comment">// ***************************************************************************</font>
+<a name="l03013"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_10">03013</a> <font class="keywordtype">void</font> CLandscape::deleteTileMaterial(CTileMaterial *tm)
+03014 {
+03015 <a class="code" href="classNL3D_1_1CLandscape.html#z490_16">TileMaterialAllocator</a>.free(tm);
+03016 }
+03017
+03018 <font class="comment">// ***************************************************************************</font>
+<a name="l03019"></a><a class="code" href="classNL3D_1_1CLandscape.html#z490_11">03019</a> <font class="keywordtype">void</font> CLandscape::deleteTileFace(CTileFace *tf)
+03020 {
+03021 <a class="code" href="classNL3D_1_1CLandscape.html#z490_17">TileFaceAllocator</a>.free(tf);
+03022 }
+03023
+03024
+03025
+03026 <font class="comment">// ***************************************************************************</font>
+03027 <font class="comment">// ***************************************************************************</font>
+03028 <font class="comment">// Noise</font>
+03029 <font class="comment">// ***************************************************************************</font>
+03030 <font class="comment">// ***************************************************************************</font>
+03031
+03032
+03033 <font class="comment">// ***************************************************************************</font>
+<a name="l03034"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_8">03034</a> <font class="keywordtype">void</font> CLandscape::setNoiseMode(<font class="keywordtype">bool</font> enable)
+03035 {
+03036 <a class="code" href="classNL3D_1_1CLandscape.html#z494_0">_NoiseEnabled</a>= enable;
+03037 }
+03038
+03039 <font class="comment">// ***************************************************************************</font>
+<a name="l03040"></a><a class="code" href="classNL3D_1_1CLandscape.html#z478_9">03040</a> <font class="keywordtype">bool</font> CLandscape::getNoiseMode()<font class="keyword"> const</font>
+03041 <font class="keyword"></font>{
+03042 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z494_0">_NoiseEnabled</a>;
+03043 }
+03044
+03045
+03046 <font class="comment">// ***************************************************************************</font>
+03047 <font class="comment">// ***************************************************************************</font>
+03048 <font class="comment">// Micro vegetation</font>
+03049 <font class="comment">// ***************************************************************************</font>
+03050 <font class="comment">// ***************************************************************************</font>
+03051
+03052
+03053 <font class="comment">// ***************************************************************************</font>
+<a name="l03054"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_3">03054</a> <font class="keywordtype">void</font> CLandscape::enableVegetable(<font class="keywordtype">bool</font> enable)
+03055 {
+03056 <a class="code" href="classNL3D_1_1CLandscape.html#z496_2">_VegetableManagerEnabled</a>= enable;
+03057
+03058 <font class="comment">// if false, delete all Vegetable IGs.</font>
+03059 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#z496_2">_VegetableManagerEnabled</a>)
+03060 {
+03061 <font class="comment">// Landscape always create ClipBlokcs, but IGs/addInstances() are created only if isVegetableActive().</font>
+03062 <font class="comment">// For all zones.</font>
+03063 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+03064 {
+03065 <font class="comment">// for all patch.</font>
+03066 sint N= (*it).second-&gt;getNumPatchs();
+03067 <font class="keywordflow">for</font>(sint i=0;i&lt;N;i++)
+03068 {
+03069 <font class="comment">// delete vegetable Igs of this patch</font>
+03070 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= ((*it).second)-&gt;getPatch(i);
+03071 pa-&gt;deleteAllVegetableIgs();
+03072 }
+03073
+03074 }
+03075 }
+03076 <font class="comment">// if true</font>
+03077 <font class="keywordflow">else</font>
+03078 {
+03079 <font class="comment">// reload all Shapes (actually load only new shapes)</font>
+03080 <a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.initTileVegetableDescs(<a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>);
+03081
+03082 <font class="comment">// And recreate vegetable igs.</font>
+03083 <font class="comment">// Landscape always create ClipBlokcs, but IGs/addInstances() are created only if isVegetableActive().</font>
+03084 <font class="comment">// For all zones.</font>
+03085 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+03086 {
+03087 <font class="comment">// for all patch.</font>
+03088 sint N= (*it).second-&gt;getNumPatchs();
+03089 <font class="keywordflow">for</font>(sint i=0;i&lt;N;i++)
+03090 {
+03091 <font class="comment">// recreate vegetable Igs of this patch</font>
+03092 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= ((*it).second)-&gt;getPatch(i);
+03093 pa-&gt;recreateAllVegetableIgs();
+03094 }
+03095
+03096 }
+03097 }
+03098
+03099 }
+03100
+03101 <font class="comment">// ***************************************************************************</font>
+<a name="l03102"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_4">03102</a> <font class="keywordtype">bool</font> CLandscape::isVegetableActive()<font class="keyword"> const</font>
+03103 <font class="keyword"></font>{
+03104 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z496_2">_VegetableManagerEnabled</a> &amp;&amp; <a class="code" href="classNL3D_1_1CLandscape.html#z496_3">_DriverOkForVegetable</a>;
+03105 }
+03106
+03107 <font class="comment">// ***************************************************************************</font>
+03108 <font class="keywordtype">void</font> CLandscape::loadVegetableTexture(<font class="keyword">const</font> string &amp;textureFileName)
+03109 {
+03110 <font class="comment">// load the texture in the manager</font>
+03111 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;loadTexture(textureFileName);
+03112 }
+03113
+03114 <font class="comment">// ***************************************************************************</font>
+<a name="l03115"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_6">03115</a> <font class="keywordtype">void</font> CLandscape::setupVegetableLighting(<font class="keyword">const</font> CRGBA &amp;ambient, <font class="keyword">const</font> CRGBA &amp;diffuse, <font class="keyword">const</font> CVector &amp;directionalLight)
+03116 {
+03117 <font class="comment">// set the directional light to the manager</font>
+03118 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;setDirectionalLight(ambient, diffuse, directionalLight);
+03119 }
+03120
+03121 <font class="comment">// ***************************************************************************</font>
+<a name="l03122"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_7">03122</a> <font class="keywordtype">void</font> CLandscape::setVegetableWind(<font class="keyword">const</font> CVector &amp;windDir, <font class="keywordtype">float</font> windFreq, <font class="keywordtype">float</font> windPower, <font class="keywordtype">float</font> windBendMin)
+03123 {
+03124 <font class="comment">// setup vegetable manager</font>
+03125 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;setWind(windDir, windFreq, windPower, windBendMin);
+03126 }
+03127
+03128
+03129 <font class="comment">// ***************************************************************************</font>
+<a name="l03130"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_1">03130</a> <font class="keywordtype">void</font> CLandscape::setVegetableTime(<font class="keywordtype">double</font> time)
+03131 {
+03132 <font class="comment">// setup vegetable manager</font>
+03133 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;setTime(time);
+03134 }
+03135
+03136 <font class="comment">// ***************************************************************************</font>
+<a name="l03137"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_2">03137</a> <font class="keywordtype">void</font> CLandscape::setVegetableUpdateLightingTime(<font class="keywordtype">double</font> time)
+03138 {
+03139 <font class="comment">// setup vegetable manager</font>
+03140 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;setUpdateLightingTime(time);
+03141 }
+03142
+03143
+03144 <font class="comment">// ***************************************************************************</font>
+<a name="l03145"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_8">03145</a> uint CLandscape::getNumVegetableFaceRendered()<font class="keyword"> const</font>
+03146 <font class="keyword"></font>{
+03147 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;getNumVegetableFaceRendered();
+03148 }
+03149
+03150
+03151 <font class="comment">// ***************************************************************************</font>
+<a name="l03152"></a><a class="code" href="classNL3D_1_1CLandscape.html#z496_0">03152</a> <font class="keyword">const</font> CTileVegetableDesc &amp;CLandscape::getTileVegetableDesc(uint16 tileId)
+03153 {
+03154 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLandscape.html#m0">TileBank</a>.getTileVegetableDesc(tileId);
+03155 }
+03156
+03157
+03158 <font class="comment">// ***************************************************************************</font>
+<a name="l03159"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_0">03159</a> <font class="keywordtype">void</font> CLandscape::createVegetableBlendLayersModels(CScene *scene)
+03160 {
+03161 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;createVegetableBlendLayersModels(scene);
+03162 }
+03163
+03164
+03165 <font class="comment">// ***************************************************************************</font>
+<a name="l03166"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_9">03166</a> <font class="keywordtype">void</font> CLandscape::setVegetableUpdateLightingFrequency(<font class="keywordtype">float</font> freq)
+03167 {
+03168 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;setUpdateLightingFrequency(freq);
+03169 }
+03170
+03171 <font class="comment">// ***************************************************************************</font>
+<a name="l03172"></a><a class="code" href="classNL3D_1_1CLandscape.html#z485_10">03172</a> <font class="keywordtype">void</font> CLandscape::setupColorsFromTileFlags(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> colors[4])
+03173 {
+03174 <font class="keywordflow">for</font> (TZoneMap::iterator it = <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin(); it != <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end(); ++it)
+03175 {
+03176 it-&gt;second-&gt;setupColorsFromTileFlags(colors);
+03177 }
+03178 }
+03179
+03180 <font class="comment">// ***************************************************************************</font>
+03181 <font class="comment">// ***************************************************************************</font>
+03182 <font class="comment">// Lightmap Get interface.</font>
+03183 <font class="comment">// ***************************************************************************</font>
+03184 <font class="comment">// ***************************************************************************</font>
+03185
+03186
+03187 <font class="comment">// ***************************************************************************</font>
+<a name="l03188"></a><a class="code" href="classNL3D_1_1CLandscape.html#z486_0">03188</a> uint8 CLandscape::getLumel(<font class="keyword">const</font> CPatchIdent &amp;patchId, <font class="keyword">const</font> CUV &amp;uv)<font class="keyword"> const</font>
+03189 <font class="keyword"></font>{
+03190 <font class="comment">// \todo yoyo: TODO_ZONEID: change ZoneId in 32 bits...</font>
+03191 std::map&lt;uint16, CZone*&gt;::const_iterator it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find((uint16)patchId.ZoneId);
+03192 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+03193 {
+03194 sint N= (*it).second-&gt;getNumPatchs();
+03195 <font class="comment">// patch must exist in the zone.</font>
+03196 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId.PatchId&lt;N);
+03197 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(patchId.PatchId);
+03198
+03199 <font class="keywordflow">return</font> pa-&gt;getLumel(uv);
+03200 }
+03201 <font class="keywordflow">else</font>
+03202 <font class="comment">// Return full sun contribution as default</font>
+03203 <font class="keywordflow">return</font> 255;
+03204 }
+03205
+03206 <font class="comment">// ***************************************************************************</font>
+<a name="l03207"></a><a class="code" href="classNL3D_1_1CLandscape.html#z486_1">03207</a> <font class="keywordtype">void</font> CLandscape::appendTileLightInfluences(<font class="keyword">const</font> CPatchIdent &amp;patchId, <font class="keyword">const</font> CUV &amp;uv,
+03208 std::vector&lt;CPointLightInfluence&gt; &amp;pointLightList)<font class="keyword"> const</font>
+03209 <font class="keyword"></font>{
+03210 <font class="comment">// \todo yoyo: TODO_ZONEID: change ZoneId in 32 bits...</font>
+03211 std::map&lt;uint16, CZone*&gt;::const_iterator it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.find((uint16)patchId.ZoneId);
+03212 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end())
+03213 {
+03214 sint N= (*it).second-&gt;getNumPatchs();
+03215 <font class="comment">// patch must exist in the zone.</font>
+03216 <a class="code" href="debug_8h.html#a6">nlassert</a>(patchId.PatchId&lt;N);
+03217 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= const_cast&lt;const CZone*&gt;((*it).second)-&gt;getPatch(patchId.PatchId);
+03218
+03219 pa-&gt;appendTileLightInfluences(uv, pointLightList);
+03220 }
+03221 }
+03222
+03223
+03224 <font class="comment">// ***************************************************************************</font>
+03225 <font class="comment">// ***************************************************************************</font>
+03226 <font class="comment">// Lighting</font>
+03227 <font class="comment">// ***************************************************************************</font>
+03228 <font class="comment">// ***************************************************************************</font>
+03229
+03230
+03231 <font class="comment">// ***************************************************************************</font>
+<a name="l03232"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_8">03232</a> <font class="keywordtype">void</font> CLandscape::removeAllPointLights()
+03233 {
+03234 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+03235 {
+03236 <font class="comment">// for all patch.</font>
+03237 sint N= (*it).second-&gt;getNumPatchs();
+03238 <font class="keywordflow">for</font>(sint i=0;i&lt;N;i++)
+03239 {
+03240 <font class="comment">// Clear TileLightInfluences</font>
+03241 <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= ((*it).second)-&gt;getPatch(i);
+03242 pa-&gt;resetTileLightInfluences();
+03243 }
+03244
+03245 <font class="comment">// Remove all PointLights.</font>
+03246 (*it).second-&gt;_PointLightArray.clear();
+03247 }
+03248
+03249 }
+03250
+03251
+03252 <font class="comment">// ***************************************************************************</font>
+<a name="l03253"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_9">03253</a> <font class="keywordtype">void</font> CLandscape::setPointLightFactor(<font class="keyword">const</font> std::string &amp;lightGroupName, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> nFactor)
+03254 {
+03255 <font class="comment">// Store the result in the map for addZone().</font>
+03256 <a class="code" href="classNL3D_1_1CLandscape.html#o20">_LightGroupColorMap</a>[lightGroupName]= nFactor;
+03257
+03258 <font class="comment">// Affect currently added zones.</font>
+03259 <font class="keywordflow">for</font>(<a class="code" href="namespaceNL3D.html#a313">ItZoneMap</a> it= <a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.begin();it!=<a class="code" href="classNL3D_1_1CLandscape.html#o0">Zones</a>.end();it++)
+03260 {
+03261 (*it).second-&gt;_PointLightArray.setPointLightFactor(lightGroupName, nFactor);
+03262 }
+03263 }
+03264
+03265
+03266 <font class="comment">// ***************************************************************************</font>
+<a name="l03267"></a><a class="code" href="classNL3D_1_1CLandscape.html#z488_0">03267</a> <font class="keywordtype">void</font> CLandscape::updateLighting(<font class="keywordtype">double</font> time)
+03268 {
+03269 <a class="code" href="classNL3D_1_1CLandscape.html#z498_6">_ULTime</a>= time;
+03270
+03271 <font class="comment">// first time in this method??</font>
+03272 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CLandscape.html#z498_5">_ULPrecTimeInit</a>)
+03273 {
+03274 <a class="code" href="classNL3D_1_1CLandscape.html#z498_5">_ULPrecTimeInit</a>= <font class="keyword">true</font>;
+03275 <a class="code" href="classNL3D_1_1CLandscape.html#z498_4">_ULPrecTime</a>= <a class="code" href="classNL3D_1_1CLandscape.html#z498_6">_ULTime</a>;
+03276 }
+03277 <font class="comment">// compute delta time from last update.</font>
+03278 <font class="keywordtype">float</font> dt= float(<a class="code" href="classNL3D_1_1CLandscape.html#z498_6">_ULTime</a> - <a class="code" href="classNL3D_1_1CLandscape.html#z498_4">_ULPrecTime</a>);
+03279 <a class="code" href="classNL3D_1_1CLandscape.html#z498_4">_ULPrecTime</a>= <a class="code" href="classNL3D_1_1CLandscape.html#z498_6">_ULTime</a>;
+03280
+03281
+03282 <font class="comment">// If not disabled</font>
+03283 <font class="keywordflow">if</font>(_ULFrequency)
+03284 {
+03285 <font class="comment">// Do it for near and far in 2 distinct ways.</font>
+03286 <a class="code" href="classNL3D_1_1CLandscape.html#z498_2">updateLightingTextureFar</a>(dt * <a class="code" href="classNL3D_1_1CLandscape.html#z498_7">_ULFrequency</a>);
+03287 <a class="code" href="classNL3D_1_1CLandscape.html#z498_3">updateLightingTextureNear</a>(dt * <a class="code" href="classNL3D_1_1CLandscape.html#z498_7">_ULFrequency</a>);
+03288 }
+03289
+03290 }
+03291
+03292
+03293 <font class="comment">// ***************************************************************************</font>
+<a name="l03294"></a><a class="code" href="classNL3D_1_1CLandscape.html#z488_2">03294</a> <font class="keywordtype">void</font> CLandscape::updateLightingAll()
+03295 {
+03296 <font class="comment">// Do it for near and far in 2 distinct ways.</font>
+03297 <font class="comment">//================</font>
+03298 <a class="code" href="classNL3D_1_1CLandscape.html#z498_2">updateLightingTextureFar</a>(1);
+03299 <a class="code" href="classNL3D_1_1CLandscape.html#z498_3">updateLightingTextureNear</a>(1);
+03300
+03301
+03302 <font class="comment">// update lighting for vegetables</font>
+03303 <font class="comment">//================</font>
+03304
+03305 <font class="comment">// Must lock buffers for update Lighting of vegetables.</font>
+03306 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (CVector::Null);
+03307
+03308 <font class="comment">// Because updateLighting() may use OptFastFloor..</font>
+03309 <a class="code" href="namespaceNL3D.html#a360">OptFastFloorBegin</a>();
+03310
+03311 <font class="comment">// update ALL lighting for vegetables</font>
+03312 <a class="code" href="classNL3D_1_1CLandscape.html#z496_1">_VegetableManager</a>-&gt;updateLightingAll();
+03313
+03314 <font class="comment">// Stop fastFloor optim.</font>
+03315 <a class="code" href="namespaceNL3D.html#a361">OptFastFloorEnd</a>();
+03316
+03317 <font class="comment">// Must realase VB Buffers</font>
+03318 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+03319 }
+03320
+03321
+03322 <font class="comment">// ***************************************************************************</font>
+<a name="l03323"></a><a class="code" href="classNL3D_1_1CLandscape.html#z488_1">03323</a> <font class="keywordtype">void</font> CLandscape::setUpdateLightingFrequency(<font class="keywordtype">float</font> freq)
+03324 {
+03325 freq= max(freq, 0.f);
+03326 <a class="code" href="classNL3D_1_1CLandscape.html#z498_7">_ULFrequency</a>= freq;
+03327 }
+03328
+03329
+03330 <font class="comment">// ***************************************************************************</font>
+<a name="l03331"></a><a class="code" href="classNL3D_1_1CLandscape.html#z498_0">03331</a> <font class="keywordtype">void</font> CLandscape::linkPatchToNearUL(CPatch *patch)
+03332 {
+03333 <font class="comment">// Append this patch to the list of patch to updateLighting.</font>
+03334 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>==NULL)
+03335 <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>= patch;
+03336 <font class="keywordflow">else</font>
+03337 patch-&gt;linkBeforeNearUL(<a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>);
+03338 }
+03339
+03340 <font class="comment">// ***************************************************************************</font>
+<a name="l03341"></a><a class="code" href="classNL3D_1_1CLandscape.html#z498_1">03341</a> <font class="keywordtype">void</font> CLandscape::unlinkPatchFromNearUL(CPatch *patch)
+03342 {
+03343 <font class="comment">// If I unlink the patch which is the current root</font>
+03344 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>==patch)
+03345 {
+03346 <font class="comment">// switch to next</font>
+03347 <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>= patch-&gt;getNextNearUL();
+03348 <font class="comment">// if still the same, it means that the circular list is now empty</font>
+03349 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>==patch)
+03350 <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>= NULL;
+03351 <font class="comment">// reset tessBlock counter.</font>
+03352 <a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>= 0;
+03353 }
+03354
+03355 <font class="comment">// unlink the patch from list</font>
+03356 patch-&gt;unlinkNearUL();
+03357 }
+03358
+03359
+03360 <font class="comment">// ***************************************************************************</font>
+<a name="l03361"></a><a class="code" href="classNL3D_1_1CLandscape.html#z498_2">03361</a> <font class="keywordtype">void</font> CLandscape::updateLightingTextureFar(<font class="keywordtype">float</font> ratio)
+03362 {
+03363 <font class="comment">// compute number of pixels to update.</font>
+03364 <a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a>+= ratio * <a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>;
+03365 <font class="comment">// maximize, so at max, it computes all patchs, just one time.</font>
+03366 <a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a>= <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CLandscape.html#z498_8">_ULTotalFarPixels</a>);
+03367
+03368 <font class="comment">// Test Profile Yoyo</font>
+03369 <font class="comment">/*extern bool YOYO_LandULTest;</font>
+03370 <font class="comment"> if(YOYO_LandULTest)</font>
+03371 <font class="comment"> {</font>
+03372 <font class="comment"> nlinfo("YOYO_UL Far: %dK, %dK", (sint)_ULFarPixelsToUpdate/1024, (sint)_ULTotalFarPixels/1024);</font>
+03373 <font class="comment"> }*/</font>
+03374
+03375 <font class="comment">// while there is still some pixels to update.</font>
+03376 <font class="keywordflow">while</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a> &gt; 0 &amp;&amp; <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>)
+03377 {
+03378 <font class="comment">// update patch (if not null) in the textureFar.</font>
+03379 <a class="code" href="classNL3D_1_1CLandscape.html#z498_9">_ULFarPixelsToUpdate</a>-= <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>-&gt;touchPatch(<a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>);
+03380 <font class="comment">// Next patch to process.</font>
+03381 <a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>++;
+03382
+03383 <font class="comment">// last patch in the texture??</font>
+03384 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>&gt;=<a class="code" href="texture__far_8h.html#a3">NL_NUM_FAR_PATCHES_BY_TEXTURE</a>)
+03385 {
+03386 <font class="comment">// yes, go to next texture.</font>
+03387 <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>= <a class="code" href="classNL3D_1_1CLandscape.html#z498_10">_ULRootTextureFar</a>-&gt;getNextUL();
+03388 <font class="comment">// reset to 0th patch.</font>
+03389 <a class="code" href="classNL3D_1_1CLandscape.html#z498_11">_ULFarCurrentPatchId</a>=0;
+03390 }
+03391 }
+03392
+03393 <font class="comment">// Now, _ULFarPixelsToUpdate should be &lt;=0. (most of the time &lt; 0)</font>
+03394 }
+03395
+03396
+03397 <font class="comment">// ***************************************************************************</font>
+<a name="l03398"></a><a class="code" href="classNL3D_1_1CLandscape.html#z498_3">03398</a> <font class="keywordtype">void</font> CLandscape::updateLightingTextureNear(<font class="keywordtype">float</font> ratio)
+03399 {
+03400 <font class="comment">// compute number of pixels to update.</font>
+03401 <a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a>+= ratio * <a class="code" href="classNL3D_1_1CLandscape.html#z498_12">_ULTotalNearPixels</a>;
+03402 <font class="comment">// maximize, so at max, it computes all patchs, just one time.</font>
+03403 <a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a>= <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a>, (<font class="keywordtype">float</font>)<a class="code" href="classNL3D_1_1CLandscape.html#z498_12">_ULTotalNearPixels</a>);
+03404
+03405
+03406 <font class="comment">// while there is still some pixels to update.</font>
+03407 <font class="keywordflow">while</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a> &gt; 0 &amp;&amp; <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>)
+03408 {
+03409 <font class="comment">// update tessBlock (if lightmap exist for this tessBlock) in the patch.</font>
+03410 <a class="code" href="classNL3D_1_1CLandscape.html#z498_13">_ULNearPixelsToUpdate</a>-= <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>-&gt;updateTessBlockLighting(<a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>);
+03411 <font class="comment">// Next tessBlock to process.</font>
+03412 <a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>++;
+03413
+03414 <font class="comment">// last tessBlock in the patch??</font>
+03415 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>&gt;=<a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>-&gt;getNumNearTessBlocks())
+03416 {
+03417 <font class="comment">// yes, go to next patch.</font>
+03418 <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>= <a class="code" href="classNL3D_1_1CLandscape.html#z498_14">_ULRootNearPatch</a>-&gt;getNextNearUL();
+03419 <font class="comment">// reset to 0th tessBlock.</font>
+03420 <a class="code" href="classNL3D_1_1CLandscape.html#z498_15">_ULNearCurrentTessBlockId</a>=0;
+03421 }
+03422 }
+03423
+03424 }
+03425
+03426
+03427 <font class="comment">// ***************************************************************************</font>
+<a name="l03428"></a><a class="code" href="classNL3D_1_1CLandscape.html#z489_0">03428</a> <font class="keywordtype">void</font> CLandscape::computeDynamicLighting(<font class="keyword">const</font> std::vector&lt;CPointLight*&gt; &amp;pls)
+03429 {
+03430 uint i;
+03431
+03432 <font class="comment">// Update globals, and lock buffers</font>
+03433 <font class="comment">//====================</font>
+03434 <a class="code" href="classNL3D_1_1CLandscape.html#c6">updateGlobalsAndLockBuffers</a> (CVector::Null);
+03435 <font class="comment">// NB: averageTesselationVertices may change vertices in VB in visible patchs =&gt; buffers are locked.</font>
+03436
+03437
+03438 <font class="comment">// Run all DLM Context create, to init Lighting process.</font>
+03439 <font class="comment">//===============</font>
+03440 CPatchDLMContext *ctxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+03441 <font class="keywordflow">while</font>(ctxPtr!=NULL)
+03442 {
+03443 <font class="comment">// init lighting process, do differential from last computeDynamicLighting()</font>
+03444 ctxPtr-&gt;getPatch()-&gt;beginDLMLighting();
+03445
+03446 <font class="comment">// next</font>
+03447 ctxPtr= (CPatchDLMContext*)ctxPtr-&gt;Next;
+03448 }
+03449
+03450
+03451 <font class="comment">// compile all pointLights</font>
+03452 <font class="comment">//===============</font>
+03453 <font class="keyword">static</font> vector&lt;CPatchDLMPointLight&gt; dlmPls;
+03454 dlmPls.resize(pls.size());
+03455 <font class="keywordflow">for</font>(i=0;i&lt;dlmPls.size();i++)
+03456 {
+03457 <font class="comment">// compile the pl.</font>
+03458 dlmPls[i].compile(*pls[i], <a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>, <a class="code" href="classNL3D_1_1CLandscape.html#z499_4">_DLMMaxAttEnd</a>);
+03459 }
+03460
+03461
+03462 <font class="comment">// For all pointLight, intersect patch.</font>
+03463 <font class="comment">//===============</font>
+03464 <font class="keywordflow">for</font>(i=0;i&lt;dlmPls.size();i++)
+03465 {
+03466 CPatchDLMPointLight &amp;pl= dlmPls[i];
+03467
+03468 <font class="comment">// search patchs of interest: those which interssect the pointLight</font>
+03469 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.clearSelection();
+03470 <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.select(pl.BBox.getMin(), pl.BBox.getMax());
+03471 CQuadGrid&lt;CPatchIdentEx&gt;::CIterator it;
+03472
+03473 <font class="comment">// for each patch, light it with the light.</font>
+03474 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.begin(); it!= <a class="code" href="classNL3D_1_1CLandscape.html#z493_2">_PatchQuadGrid</a>.end(); it++)
+03475 {
+03476 <font class="comment">// get the patch</font>
+03477 <font class="keyword">const</font> <a class="code" href="classNL3D_1_1CLandscape.html#l1">CPatch</a> *pa= (*it).Patch;
+03478
+03479 <font class="comment">// More precise clipping: </font>
+03480 <font class="keywordflow">if</font>( pa-&gt;getBSphere().intersect( pl.BSphere ) )
+03481 {
+03482 <font class="comment">// Ok, light the patch with this spotLight</font>
+03483 const_cast&lt;CPatch*&gt;(pa)-&gt;processDLMLight(pl);
+03484 }
+03485 }
+03486
+03487 }
+03488
+03489
+03490 <font class="comment">// Run all DLM Context create, to end Lighting process.</font>
+03491 <font class="comment">//===============</font>
+03492 ctxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+03493 <font class="keywordflow">while</font>(ctxPtr!=NULL)
+03494 {
+03495 <font class="comment">// get enxt now, because the DLM itself may be deleted in endDLMLighting()</font>
+03496 CPatchDLMContext *next= (CPatchDLMContext*)ctxPtr-&gt;Next;
+03497
+03498 <font class="comment">// delete the DLM if no more needed (near don't use nor pointLights)</font>
+03499 ctxPtr-&gt;getPatch()-&gt;endDLMLighting();
+03500
+03501 <font class="comment">// next</font>
+03502 ctxPtr= next;
+03503 }
+03504
+03505
+03506 <font class="comment">// Must realase VB Buffers</font>
+03507 <font class="comment">//====================</font>
+03508 <a class="code" href="classNL3D_1_1CLandscape.html#c8">unlockBuffers</a>();
+03509
+03510 }
+03511
+03512
+03513 <font class="comment">// ***************************************************************************</font>
+<a name="l03514"></a><a class="code" href="classNL3D_1_1CLandscape.html#z489_2">03514</a> <font class="keywordtype">void</font> CLandscape::setDynamicLightingMaxAttEnd(<font class="keywordtype">float</font> maxAttEnd)
+03515 {
+03516 maxAttEnd= max(maxAttEnd, 1.f);
+03517 <a class="code" href="classNL3D_1_1CLandscape.html#z499_4">_DLMMaxAttEnd</a>= maxAttEnd;
+03518 }
+03519
+03520
+03521 <font class="comment">// ***************************************************************************</font>
+<a name="l03522"></a><a class="code" href="classNL3D_1_1CLandscape.html#z489_1">03522</a> uint CLandscape::getDynamicLightingMemoryLoad()<font class="keyword"> const</font>
+03523 <font class="keyword"></font>{
+03524 uint mem= 0;
+03525 <font class="comment">// First, set size of global texture overhead.</font>
+03526 mem= <a class="code" href="landscape__def_8h.html#a13">NL3D_LANDSCAPE_DLM_WIDTH</a> * <a class="code" href="landscape__def_8h.html#a14">NL3D_LANDSCAPE_DLM_HEIGHT</a> * <font class="keyword">sizeof</font>(CRGBA);
+03527
+03528 <font class="comment">// Then, for each patchContext created</font>
+03529 CPatchDLMContext *ctxPtr= <a class="code" href="classNL3D_1_1CLandscape.html#z499_3">_PatchDLMContextList</a>-&gt;begin();
+03530 <font class="keywordflow">while</font>(ctxPtr!=NULL)
+03531 {
+03532 <font class="comment">// add its memory load.</font>
+03533 mem+= ctxPtr-&gt;getMemorySize();
+03534
+03535 <font class="comment">// next</font>
+03536 ctxPtr= (CPatchDLMContext*)ctxPtr-&gt;Next;
+03537 }
+03538
+03539 <font class="keywordflow">return</font> mem;
+03540 }
+03541
+03542
+03543 <font class="comment">// ***************************************************************************</font>
+<a name="l03544"></a><a class="code" href="classNL3D_1_1CLandscape.html#z489_4">03544</a> <font class="keywordtype">void</font> CLandscape::setDLMGlobalVegetableColor(CRGBA gvc)
+03545 {
+03546 <a class="code" href="classNL3D_1_1CLandscape.html#z499_5">_DLMGlobalVegetableColor</a>= gvc;
+03547 }
+03548
+03549
+03550 <font class="comment">// ***************************************************************************</font>
+<a name="l03551"></a><a class="code" href="classNL3D_1_1CLandscape.html#z483_2">03551</a> <font class="keywordtype">void</font> CLandscape::setPointLightDiffuseMaterial(CRGBA diffuse)
+03552 {
+03553 <a class="code" href="classNL3D_1_1CLandscape.html#z499_6">_PointLightDiffuseMaterial</a>= diffuse;
+03554 }
+03555
+03556
+03557 } <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>