aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/3d_zone_cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/3d_zone_cpp-source.html')
-rw-r--r--docs/doxygen/nel/3d_zone_cpp-source.html1184
1 files changed, 1184 insertions, 0 deletions
diff --git a/docs/doxygen/nel/3d_zone_cpp-source.html b/docs/doxygen/nel/3d_zone_cpp-source.html
new file mode 100644
index 00000000..b1afd882
--- /dev/null
+++ b/docs/doxygen/nel/3d_zone_cpp-source.html
@@ -0,0 +1,1184 @@
+<!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.2 on Thu May 31 22:01:28 2001 -->
+<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>zone.cpp</h1><a href="3d_zone_cpp.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="3d_zone_h.html">nel/3d/zone.h</a>"</font>
+00027 <font class="preprocessor">#include "<a class="code" href="landscape_h.html">nel/3d/landscape.h</a>"</font>
+00028 <font class="preprocessor">#include "<a class="code" href="common_h.html">nel/misc/common.h</a>"</font>
+00029
+00030
+00031 <font class="keyword">using</font> <font class="keyword">namespace</font> NLMISC;
+00032 <font class="keyword">using</font> <font class="keyword">namespace</font> std;
+00033
+00034
+00035 <font class="comment">// define it only for debug bind.</font>
+00036 <font class="comment">//#define NL3D_DEBUG_DONT_BIND_PATCH</font>
+00037
+00038
+00039 <font class="keyword">namespace</font> NL3D {
+00040
+00041
+<a name="l00042"></a><a class="code" href="namespace_NL3D.html#a190">00042</a> <font class="keyword">const</font> sint ClipIn= 0;
+<a name="l00043"></a><a class="code" href="namespace_NL3D.html#a191">00043</a> <font class="keyword">const</font> sint ClipOut= 1;
+<a name="l00044"></a><a class="code" href="namespace_NL3D.html#a192">00044</a> <font class="keyword">const</font> sint ClipSide= 2;
+00045
+00046
+00047 <font class="comment">// ***************************************************************************</font>
+<a name="l00048"></a><a class="code" href="class_NL3D__CZone.html#a0">00048</a> CZone::CZone()<font class="keyword">
+</font>00049 <font class="keyword"></font>{
+00050 ComputeTileErrorMetric= <font class="keyword">false</font>;
+00051 ZoneId= 0;
+00052 Compiled= <font class="keyword">false</font>;
+00053 Landscape= NULL;
+00054 }
+00055 <font class="comment">// ***************************************************************************</font>
+<a name="l00056"></a><a class="code" href="class_NL3D__CZone.html#a1">00056</a> CZone::~CZone()<font class="keyword">
+</font>00057 <font class="keyword"></font>{
+00058 <font class="comment">// release() must have been called.</font>
+00059 <a class="code" href="debug_h.html#a6">nlassert</a>(!Compiled);
+00060 }
+00061
+00062
+00063 <font class="comment">// ***************************************************************************</font>
+<a name="l00064"></a><a class="code" href="class_NL3D__CZone.html#c4">00064</a> <font class="keywordtype">void</font> CZone::computeBBScaleBias(<font class="keyword">const</font> CAABBox &amp;bb)<font class="keyword">
+</font>00065 <font class="keyword"></font>{
+00066 ZoneBB= bb;
+00067 <font class="comment">// Take a security for noise. (usefull for zone clipping).</font>
+00068 ZoneBB.setHalfSize(ZoneBB.getHalfSize()+CVector(NL3D_NOISE_MAX, NL3D_NOISE_MAX, NL3D_NOISE_MAX));
+00069 CVector hs= ZoneBB.getHalfSize();
+00070 <font class="keywordtype">float</font> rmax= maxof(hs.x, hs.y, hs.z);
+00071 PatchScale= rmax / 32760; <font class="comment">// Prevent from float imprecision by taking 32760 and not 32767.</font>
+00072 PatchBias= ZoneBB.getCenter();
+00073 }
+00074
+00075
+00076 <font class="comment">// ***************************************************************************</font>
+<a name="l00077"></a><a class="code" href="class_NL3D__CZone.html#a2">00077</a> <font class="keywordtype">void</font> CZone::build(uint16 zoneId, <font class="keyword">const</font> std::vector&lt;CPatchInfo&gt; &amp;patchs, <font class="keyword">const</font> std::vector&lt;CBorderVertex&gt; &amp;borderVertices)<font class="keyword">
+</font>00078 <font class="keyword"></font>{
+00079 sint i,j;
+00080 <a class="code" href="debug_h.html#a6">nlassert</a>(!Compiled);
+00081
+00082 ZoneId= zoneId;
+00083 BorderVertices= borderVertices;
+00084
+00085 <font class="comment">// Compute the bbox and the bias/scale.</font>
+00086 <font class="comment">//=====================================</font>
+00087 CAABBox bb;
+00088 <font class="keywordflow">if</font>(patchs.size())
+00089 bb.setCenter(patchs[0].Patch.Vertices[0]);
+00090 bb.setHalfSize(CVector::Null);
+00091 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+00092 {
+00093 <font class="keyword">const</font> CBezierPatch &amp;p= patchs[j].Patch;
+00094 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00095 bb.extend(p.Vertices[i]);
+00096 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+00097 bb.extend(p.Tangents[i]);
+00098 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00099 bb.extend(p.Interiors[i]);
+00100 }
+00101 <font class="comment">// Compute BBox, and Patch Scale Bias, according to Noise.</font>
+00102 computeBBScaleBias(bb);
+00103
+00104
+00105 <font class="comment">// Compute/compress Patchs.</font>
+00106 <font class="comment">//=========================</font>
+00107 Patchs.resize(patchs.size());
+00108 PatchConnects.resize(patchs.size());
+00109 sint maxVertex=-1;
+00110 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+00111 {
+00112 <font class="keyword">const</font> CPatchInfo &amp;pi= patchs[j];
+00113 <font class="keyword">const</font> CBezierPatch &amp;p= pi.Patch;
+00114 CPatch &amp;pa= Patchs[j];
+00115 CPatchConnect &amp;pc= PatchConnects[j];
+00116
+00117 <font class="comment">// Smoothing flags</font>
+00118 pa.Flags&amp;=~NL_PATCH_SMOOTH_FLAG_MASK;
+00119 pa.Flags|=NL_PATCH_SMOOTH_FLAG_MASK&amp;(pi.Flags&lt;&lt;NL_PATCH_SMOOTH_FLAG_SHIFT);
+00120
+00121 <font class="comment">// Build the patch.</font>
+00122 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00123 pa.Vertices[i].pack(p.Vertices[i], PatchBias, PatchScale);
+00124 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+00125 pa.Tangents[i].pack(p.Tangents[i], PatchBias, PatchScale);
+00126 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00127 pa.Interiors[i].pack(p.Interiors[i], PatchBias, PatchScale);
+00128 pa.Tiles= pi.Tiles;
+00129 pa.TileColors= pi.TileColors;
+00130
+00131 <font class="comment">// Copy order of the patch</font>
+00132 pa.OrderS= pi.OrderS;
+00133 pa.OrderT= pi.OrderT;
+00134
+00135 <font class="comment">// Number of lumels in this patch</font>
+00136 uint lumelCount=(pi.OrderS*NL_LUMEL_BY_TILE+1)*(pi.OrderT*NL_LUMEL_BY_TILE+1);
+00137
+00138 <font class="comment">// Lumel empty ?</font>
+00139 <font class="keywordflow">if</font> (pi.Lumels.<a class="code" href="lexlang_cpp.html#a56">size</a> ()==lumelCount)
+00140 {
+00141 <font class="comment">// Pack the lumel map</font>
+00142 pa.packShadowMap (&amp;pi.Lumels[0]);
+00143 }
+00144 <font class="keywordflow">else</font>
+00145 {
+00146 <font class="comment">// Reset lightmap</font>
+00147 pa.resetCompressedLumels ();
+00148 }
+00149
+00150 <a class="code" href="debug_h.html#a6">nlassert</a>(pa.Tiles.size()== (uint)pi.OrderS*pi.OrderT);
+00151 <a class="code" href="debug_h.html#a6">nlassert</a>(pa.TileColors.size()== (uint)(pi.OrderS+1)*(pi.OrderT+1));
+00152
+00153 <font class="comment">// Build the patchConnect.</font>
+00154 pc.ErrorSize= pi.ErrorSize;
+00155 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00156 {
+00157 pc.BaseVertices[i]= pi.BaseVertices[i];
+00158 maxVertex= <a class="code" href="nel_patch_mesh_cpp.html#a0">max</a>((sint)pc.BaseVertices[i], maxVertex);
+00159 }
+00160 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00161 pc.BindEdges[i]= pi.BindEdges[i];
+00162 }
+00163
+00164 NumVertices= maxVertex+1;
+00165 }
+00166
+00167
+00168 <font class="comment">// ***************************************************************************</font>
+<a name="l00169"></a><a class="code" href="class_NL3D__CZone.html#a4">00169</a> <font class="keywordtype">void</font> CZone::retrieve(std::vector&lt;CPatchInfo&gt; &amp;patchs, std::vector&lt;CBorderVertex&gt; &amp;borderVertices)<font class="keyword">
+</font>00170 <font class="keyword"></font>{
+00171 sint i,j;
+00172
+00173 <font class="comment">// uncompress Patchs.</font>
+00174 <font class="comment">//=========================</font>
+00175 patchs.resize(Patchs.size());
+00176 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+00177 {
+00178 CPatchInfo &amp;pi= patchs[j];
+00179 CBezierPatch &amp;p= pi.Patch;
+00180 CPatch &amp;pa= Patchs[j];
+00181 CPatchConnect &amp;pc= PatchConnects[j];
+00182
+00183 <font class="comment">// re-Build the uncompressed bezier patch.</font>
+00184 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00185 pa.Vertices[i].unpack(p.Vertices[i], PatchBias, PatchScale);
+00186 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+00187 pa.Tangents[i].unpack(p.Tangents[i], PatchBias, PatchScale);
+00188 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00189 pa.Interiors[i].unpack(p.Interiors[i], PatchBias, PatchScale);
+00190 pi.Tiles= pa.Tiles;
+00191 pi.TileColors= pa.TileColors;
+00192 pi.Lumels.resize ((pa.OrderS*4+1)*(pa.OrderT*4+1));
+00193
+00194 <font class="comment">// Unpack the lumel map</font>
+00195 pa.unpackShadowMap (&amp;pi.Lumels[0]);
+00196
+00197 <font class="comment">// from the patchConnect.</font>
+00198 pi.OrderS= pa.OrderS;
+00199 pi.OrderT= pa.OrderT;
+00200 pi.ErrorSize= pc.ErrorSize;
+00201 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00202 {
+00203 pi.BaseVertices[i]= pc.BaseVertices[i];
+00204 }
+00205 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00206 pi.BindEdges[i]= pc.BindEdges[i];
+00207 }
+00208
+00209 <font class="comment">// retrieve bordervertices.</font>
+00210 <font class="comment">//=========================</font>
+00211 borderVertices= BorderVertices;
+00212 }
+00213
+00214
+00215 <font class="comment">// ***************************************************************************</font>
+<a name="l00216"></a><a class="code" href="class_NL3D__CZone.html#a3">00216</a> <font class="keywordtype">void</font> CZone::build(<font class="keyword">const</font> CZone &amp;zone)<font class="keyword">
+</font>00217 <font class="keyword"></font>{
+00218 <a class="code" href="debug_h.html#a6">nlassert</a>(!Compiled);
+00219
+00220 ZoneId= zone.ZoneId;
+00221 BorderVertices= zone.BorderVertices;
+00222
+00223 <font class="comment">// Compute the bbox and the bias/scale.</font>
+00224 <font class="comment">//=====================================</font>
+00225 ZoneBB= zone.ZoneBB;
+00226 PatchScale= zone.PatchScale;
+00227 PatchBias= zone.PatchBias;
+00228
+00229
+00230 <font class="comment">// Compute/compress Patchs.</font>
+00231 <font class="comment">//=========================</font>
+00232 Patchs= zone.Patchs;
+00233 PatchConnects= zone.PatchConnects;
+00234
+00235
+00236 NumVertices= zone.NumVertices;
+00237 }
+00238
+00239
+00240
+00241 <font class="comment">// ***************************************************************************</font>
+<a name="l00242"></a><a class="code" href="class_NL3D__CBorderVertex.html#a0">00242</a> <font class="keywordtype">void</font> CBorderVertex::serial(<a class="code" href="class_NLMISC__IStream.html">NLMISC::IStream</a> &amp;f)<font class="keyword">
+</font>00243 <font class="keyword"></font>{
+00244 uint ver= f.<a class="code" href="class_NLMISC__IStream.html#a51">serialVersion</a>(0);
+00245 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(CurrentVertex, NeighborZoneId, NeighborVertex);
+00246 }
+<a name="l00247"></a><a class="code" href="class_NL3D__CZone__CPatchConnect.html#a0">00247</a> <font class="keywordtype">void</font> CZone::CPatchConnect::serial(<a class="code" href="class_NLMISC__IStream.html">NLMISC::IStream</a> &amp;f)<font class="keyword">
+</font>00248 <font class="keyword"></font>{
+00249 uint ver= f.<a class="code" href="class_NLMISC__IStream.html#a51">serialVersion</a>(1);
+00250
+00251 <font class="keywordflow">if</font> (ver&lt;1)
+00252 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(OldOrderS, OldOrderT, ErrorSize);
+00253 <font class="keywordflow">else</font>
+00254 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(ErrorSize);
+00255 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(BaseVertices[0], BaseVertices[1], BaseVertices[2], BaseVertices[3]);
+00256 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(BindEdges[0], BindEdges[1], BindEdges[2], BindEdges[3]);
+00257 }
+<a name="l00258"></a><a class="code" href="class_NL3D__CPatchInfo__CBindInfo.html#a0">00258</a> <font class="keywordtype">void</font> CPatchInfo::CBindInfo::serial(<a class="code" href="class_NLMISC__IStream.html">NLMISC::IStream</a> &amp;f)<font class="keyword">
+</font>00259 <font class="keyword"></font>{
+00260 <font class="keywordtype">int</font> i;
+00261 uint ver= f.<a class="code" href="class_NLMISC__IStream.html#a51">serialVersion</a>(0);
+00262 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(NPatchs);
+00263 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(ZoneId);
+00264 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00265 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(Next[i]);
+00266 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+00267 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(Edge[i]);
+00268 }
+00269
+00270 <font class="comment">// ***************************************************************************</font>
+<a name="l00271"></a><a class="code" href="class_NL3D__CZone.html#a8">00271</a> <font class="keywordtype">void</font> CZone::serial(<a class="code" href="class_NLMISC__IStream.html">NLMISC::IStream</a> &amp;f)<font class="keyword">
+</font>00272 <font class="keyword"></font>{
+00273 <font class="comment">/*
+</font>00274 <font class="comment"> Version 2:
+</font>00275 <font class="comment"> - Lumels.
+</font>00276 <font class="comment"> Version 1:
+</font>00277 <font class="comment"> - Tile color.
+</font>00278 <font class="comment"> Version 0:
+</font>00279 <font class="comment"> - base verison.
+</font>00280 <font class="comment"> */</font>
+00281 uint ver= f.<a class="code" href="class_NLMISC__IStream.html#a51">serialVersion</a>(2);
+00282
+00283 f.<a class="code" href="class_NLMISC__IStream.html#a52">serialCheck</a>((uint32)'ENOZ');
+00284 f.<a class="code" href="class_NLMISC__IStream.html#a5">serial</a>(ZoneId, ZoneBB, PatchBias, PatchScale, NumVertices);
+00285 f.<a class="code" href="class_NLMISC__IStream.html#a29">serialCont</a>(BorderVertices);
+00286 f.<a class="code" href="class_NLMISC__IStream.html#a29">serialCont</a>(Patchs);
+00287 f.<a class="code" href="class_NLMISC__IStream.html#a29">serialCont</a>(PatchConnects);
+00288
+00289 <font class="comment">// If read and version 0, must init default TileColors of patchs.</font>
+00290 <font class="comment">//===============================================================</font>
+00291 <font class="keywordflow">if</font>(f.<a class="code" href="class_NLMISC__IStream.html#a4">isReading</a>() &amp;&amp; ver&lt;2)
+00292 {
+00293 <font class="keywordflow">for</font>(sint j=0;j&lt;(sint)Patchs.size();j++)
+00294 {
+00295 CPatch &amp;pa= Patchs[j];
+00296 CPatchConnect &amp;pc= PatchConnects[j];
+00297
+00298 <font class="comment">// Force Order of the patch</font>
+00299 pa.OrderS=pc.OldOrderS;
+00300 pa.OrderT=pc.OldOrderT;
+00301
+00302 <font class="comment">// Tile colors exist ?</font>
+00303 <font class="keywordflow">if</font> (ver&lt;1)
+00304 {
+00305 <font class="comment">// Leave it as default behavior: Must init the color as pure white...</font>
+00306 <font class="comment">// We must fo it with help of patchconnects OrderS and OrderT.</font>
+00307 pa.TileColors.resize( (pc.OldOrderS+1)*(pc.OldOrderT+1) );
+00308 <font class="keywordflow">for</font>(sint i=0;i&lt;(sint)pa.TileColors.<a class="code" href="lexlang_cpp.html#a56">size</a>();i++)
+00309 {
+00310 pa.TileColors[i].Color565= 0xFFFF;
+00311 pa.TileColors[i].Shade= 0xFF;
+00312 pa.TileColors[i].LightX= 0xFF;
+00313 pa.TileColors[i].LightY= 0x00;
+00314 pa.TileColors[i].LightZ= 0x00;
+00315 }
+00316 }
+00317
+00318 <font class="comment">// Lumels exist ?</font>
+00319 <font class="keywordflow">if</font> (ver&lt;2)
+00320 {
+00321 <font class="comment">// Reset shadows</font>
+00322 pa.resetCompressedLumels ();
+00323 }
+00324 }
+00325 }
+00326 }
+00327
+00328
+00329 <font class="comment">// ***************************************************************************</font>
+<a name="l00330"></a><a class="code" href="class_NL3D__CZone.html#a6">00330</a> <font class="keywordtype">void</font> CZone::compile(CLandscape *landscape, TZoneMap &amp;loadedZones)<font class="keyword">
+</font>00331 <font class="keyword"></font>{
+00332 sint i,j;
+00333 TZoneMap neighborZones;
+00334
+00335 <font class="comment">// Can't compile if compiled.</font>
+00336 <a class="code" href="debug_h.html#a6">nlassert</a>(!Compiled);
+00337 Landscape= landscape;
+00338
+00339 <font class="comment">// Attach this to loadedZones.</font>
+00340 <font class="comment">//============================</font>
+00341 <a class="code" href="debug_h.html#a6">nlassert</a>(loadedZones.find(ZoneId)==loadedZones.end());
+00342 loadedZones[ZoneId]= <font class="keyword">this</font>;
+00343
+00344 <font class="comment">// Create/link the base vertices according to present neigbor zones.</font>
+00345 <font class="comment">//============================</font>
+00346 BaseVertices.clear();
+00347 BaseVertices.resize(NumVertices);
+00348 <font class="comment">// First try to link vertices to other.</font>
+00349 <font class="keywordflow">for</font>(i=0;i&lt;(sint)BorderVertices.size();i++)
+00350 {
+00351 sint cur= BorderVertices[i].CurrentVertex;
+00352 sint vertto= BorderVertices[i].NeighborVertex;
+00353 sint zoneto= BorderVertices[i].NeighborZoneId;
+00354 <a class="code" href="debug_h.html#a6">nlassert</a>(cur&lt;NumVertices);
+00355
+00356 <font class="keywordflow">if</font>(loadedZones.find(zoneto)!=loadedZones.end())
+00357 {
+00358 CZone *zone;
+00359 zone= (*loadedZones.find(zoneto)).second;
+00360 <a class="code" href="debug_h.html#a6">nlassert</a>(zone!=<font class="keyword">this</font>);
+00361 <font class="comment">// insert the zone in the neigborood (if not done...).</font>
+00362 neighborZones[zoneto]= zone;
+00363 <font class="comment">// Doesn't matter if BaseVertices is already linked to an other zone... </font>
+00364 <font class="comment">// This should be the same pointer in this case...</font>
+00365 BaseVertices[cur]= zone-&gt;getBaseVertex(vertto);
+00366 }
+00367 }
+00368 <font class="comment">// Else, create unbounded vertices.</font>
+00369 <font class="keywordflow">for</font>(i=0;i&lt;(sint)BaseVertices.size();i++)
+00370 {
+00371 <font class="keywordflow">if</font>(BaseVertices[i]==NULL)
+00372 {
+00373 BaseVertices[i]= <font class="keyword">new</font> CTessBaseVertex;
+00374 }
+00375 }
+00376
+00377
+00378 <font class="comment">// compile() the patchs.</font>
+00379 <font class="comment">//======================</font>
+00380 <font class="keywordflow">for</font>(j=0;j&lt;(sint)Patchs.size();j++)
+00381 {
+00382 CPatch &amp;pa= Patchs[j];
+00383 CPatchConnect &amp;pc= PatchConnects[j];
+00384 CTessVertex *baseVertices[4];
+00385
+00386 baseVertices[0]= &amp;(BaseVertices[pc.BaseVertices[0]]-&gt;Vert);
+00387 baseVertices[1]= &amp;(BaseVertices[pc.BaseVertices[1]]-&gt;Vert);
+00388 baseVertices[2]= &amp;(BaseVertices[pc.BaseVertices[2]]-&gt;Vert);
+00389 baseVertices[3]= &amp;(BaseVertices[pc.BaseVertices[3]]-&gt;Vert);
+00390 pa.compile(<font class="keyword">this</font>, pa.OrderS, pa.OrderT, baseVertices, pc.ErrorSize);
+00391 };
+00392
+00393 <font class="comment">// bind() the patchs. (after all compiled).</font>
+00394 <font class="comment">//===================</font>
+00395 <font class="keywordflow">for</font>(j=0;j&lt;(sint)Patchs.size();j++)
+00396 {
+00397 CPatch &amp;pa= Patchs[j];
+00398 CPatchConnect &amp;pc= PatchConnects[j];
+00399
+00400 bindPatch(loadedZones, pa, pc);
+00401 }
+00402
+00403
+00404 <font class="comment">// rebindBorder() on neighbor zones.</font>
+00405 <font class="comment">//==================================</font>
+00406 ItZoneMap zoneIt;
+00407 <font class="comment">// Traverse the neighborood.</font>
+00408 <font class="keywordflow">for</font>(zoneIt= neighborZones.begin(); zoneIt!=neighborZones.end(); zoneIt++)
+00409 {
+00410 (*zoneIt).second-&gt;rebindBorder(loadedZones);
+00411 }
+00412
+00413 <font class="comment">// End!!</font>
+00414 Compiled= <font class="keyword">true</font>;
+00415 }
+00416
+00417 <font class="comment">// ***************************************************************************</font>
+<a name="l00418"></a><a class="code" href="class_NL3D__CZone.html#a7">00418</a> <font class="keywordtype">void</font> CZone::release(TZoneMap &amp;loadedZones)<font class="keyword">
+</font>00419 <font class="keyword"></font>{
+00420 sint i,j;
+00421
+00422 <font class="keywordflow">if</font>(!Compiled)
+00423 <font class="keywordflow">return</font>;
+00424
+00425 <font class="comment">// detach this zone to loadedZones.</font>
+00426 <font class="comment">//=================================</font>
+00427 <a class="code" href="debug_h.html#a6">nlassert</a>(loadedZones.find(ZoneId)!=loadedZones.end());
+00428 loadedZones.erase(ZoneId);
+00429 <font class="comment">// It doesn't server to unbindPatch(), since patch is not binded to neigbors.</font>
+00430
+00431
+00432 <font class="comment">// unbind() the patchs.</font>
+00433 <font class="comment">//=====================</font>
+00434 <font class="keywordflow">for</font>(j=0;j&lt;(sint)Patchs.size();j++)
+00435 {
+00436 CPatch &amp;pa= Patchs[j];
+00437 CPatchConnect &amp;pc= PatchConnects[j];
+00438 unbindPatch(loadedZones, pa, pc);
+00439 <font class="comment">/*
+</font>00440 <font class="comment"> This patch may be unbinded with exceptions (multiple patch case), but there is no problem, since in this case,
+</font>00441 <font class="comment"> his neighbor will (or have precedently) unbind.
+</font>00442 <font class="comment"> Since only Bind 1/1 are permitted on zone neighborood, there should be no problem:
+</font>00443 <font class="comment"> patch are unbinded with no exceptions.
+</font>00444 <font class="comment"> */</font>
+00445 }
+00446
+00447
+00448 <font class="comment">// rebindBorder() on neighbor zones.</font>
+00449 <font class="comment">//==================================</font>
+00450 <font class="comment">// Build the nieghborood.</font>
+00451 TZoneMap neighborZones;
+00452 <font class="keywordflow">for</font>(i=0;i&lt;(sint)BorderVertices.size();i++)
+00453 {
+00454 sint cur= BorderVertices[i].CurrentVertex;
+00455 sint zoneto= BorderVertices[i].NeighborZoneId;
+00456 <a class="code" href="debug_h.html#a6">nlassert</a>(cur&lt;NumVertices);
+00457
+00458 <font class="keywordflow">if</font>(loadedZones.find(zoneto)!=loadedZones.end())
+00459 {
+00460 CZone *zone;
+00461 zone= (*loadedZones.find(zoneto)).second;
+00462 <a class="code" href="debug_h.html#a6">nlassert</a>(zone!=<font class="keyword">this</font>);
+00463 <font class="comment">// insert the zone in the neigborood (if not done...).</font>
+00464 neighborZones[zoneto]= zone;
+00465 }
+00466 }
+00467 <font class="comment">// rebind borders.</font>
+00468 ItZoneMap zoneIt;
+00469 <font class="comment">// Traverse the neighborood.</font>
+00470 <font class="keywordflow">for</font>(zoneIt= neighborZones.begin(); zoneIt!=neighborZones.end(); zoneIt++)
+00471 {
+00472 <font class="comment">// Since </font>
+00473 (*zoneIt).second-&gt;rebindBorder(loadedZones);
+00474 }
+00475
+00476
+00477 <font class="comment">// release() the patchs.</font>
+00478 <font class="comment">//======================</font>
+00479 <font class="comment">// unbind() need compiled neigbor patchs, so do the release after all unbind (so after rebindBorder() too...).</font>
+00480 <font class="keywordflow">for</font>(j=0;j&lt;(sint)Patchs.size();j++)
+00481 {
+00482 CPatch &amp;pa= Patchs[j];
+00483 pa.release();
+00484 }
+00485
+00486
+00487 <font class="comment">// destroy/unlink the base vertices (internal..), according to present neigbor zones.</font>
+00488 <font class="comment">//=================================</font>
+00489 <font class="comment">// Just release the smartptrs (easy!!). Do it after patchs released...</font>
+00490 BaseVertices.clear();
+00491
+00492
+00493 <font class="comment">// End!!</font>
+00494 Compiled= <font class="keyword">false</font>;
+00495 Landscape= NULL;
+00496 }
+00497
+00498
+00499 <font class="comment">// ***************************************************************************</font>
+00500 <font class="comment">// ***************************************************************************</font>
+00501 <font class="comment">// Private part.</font>
+00502 <font class="comment">// ***************************************************************************</font>
+00503 <font class="comment">// ***************************************************************************</font>
+00504
+00505
+00506 <font class="comment">// ***************************************************************************</font>
+<a name="l00507"></a><a class="code" href="class_NL3D__CZone.html#c0">00507</a> <font class="keywordtype">void</font> CZone::rebindBorder(TZoneMap &amp;loadedZones)<font class="keyword">
+</font>00508 <font class="keyword"></font>{
+00509 sint j;
+00510
+00511 <font class="comment">// rebind patchs which are on border.</font>
+00512 <font class="keywordflow">for</font>(j=0;j&lt;(sint)Patchs.size();j++)
+00513 {
+00514 CPatch &amp;pa= Patchs[j];
+00515 CPatchConnect &amp;pc= PatchConnects[j];
+00516
+00517 <font class="keywordflow">if</font>(patchOnBorder(pc))
+00518 bindPatch(loadedZones, pa, pc);
+00519 }
+00520 }
+00521
+00522 <font class="comment">// ***************************************************************************</font>
+<a name="l00523"></a><a class="code" href="class_NL3D__CZone.html#f0">00523</a> CPatch *CZone::getZonePatch(TZoneMap &amp;loadedZones, sint zoneId, sint patch)<font class="keyword">
+</font>00524 <font class="keyword"></font>{
+00525 <font class="preprocessor">#ifdef NL3D_DEBUG_DONT_BIND_PATCH
+</font>00526 <font class="preprocessor"></font> <font class="keywordflow">return</font> NULL;
+00527 <font class="preprocessor">#endif
+</font>00528 <font class="preprocessor"></font> <font class="keywordflow">if</font>(loadedZones.find(zoneId)==loadedZones.end())
+00529 <font class="keywordflow">return</font> NULL;
+00530 <font class="keywordflow">else</font>
+00531 <font class="keywordflow">return</font> (loadedZones[zoneId])-&gt;getPatch(patch);
+00532 }
+00533
+00534
+00535 <font class="comment">// ***************************************************************************</font>
+<a name="l00536"></a><a class="code" href="class_NL3D__CZone.html#f1">00536</a> <font class="keywordtype">void</font> CZone::unbindAndMakeBindInfo(TZoneMap &amp;loadedZones, CPatch &amp;pa, CPatchConnect &amp;pc, CPatch::CBindInfo edges[4])<font class="keyword">
+</font>00537 <font class="keyword"></font>{
+00538 CPatch *exceptions[4]= {NULL, NULL, NULL, NULL};
+00539
+00540 <font class="comment">/*
+</font>00541 <font class="comment"> Remind: the old version with CPatch::unbindFrom*() doesn't work because of CZone::release(). This function
+</font>00542 <font class="comment"> first erase the zone from loadedZones...
+</font>00543 <font class="comment"> Not matter here. We use CPatch::unbind() which should do all the good job correctly (unbind pa from ohters
+</font>00544 <font class="comment"> , and unbind others from pa at same time).
+</font>00545 <font class="comment"> */</font>
+00546
+00547 <font class="comment">// Fill all edges.</font>
+00548 <font class="keywordflow">for</font>(sint i=0;i&lt;4;i++)
+00549 {
+00550 CPatchInfo::CBindInfo &amp;pcBind= pc.BindEdges[i];
+00551 CPatch::CBindInfo &amp;paBind= edges[i];
+00552
+00553 <a class="code" href="debug_h.html#a6">nlassert</a>(pcBind.NPatchs==0 || pcBind.NPatchs==1 || pcBind.NPatchs==2 || pcBind.NPatchs==4 || pcBind.NPatchs==5);
+00554 paBind.NPatchs= pcBind.NPatchs;
+00555
+00556 <font class="comment">// Special case of a small patch connected to a bigger.</font>
+00557 <font class="keywordflow">if</font>(paBind.NPatchs==5)
+00558 {
+00559 <font class="comment">// In this case, neither the unbind must not be done, nor the bind.</font>
+00560 exceptions[i]= CZone::getZonePatch(loadedZones, pcBind.ZoneId, pcBind.Next[0]);
+00561 <font class="comment">// This code prevent the bind in CPatch::bind() to be done!!</font>
+00562 <font class="comment">// The bind must not be done, since exceptions[] prevent the unbind!</font>
+00563 paBind.NPatchs=0;
+00564 <font class="keywordflow">continue</font>;
+00565 }
+00566
+00567
+00568 <font class="keywordflow">if</font>(paBind.NPatchs&gt;=1)
+00569 {
+00570 paBind.Edge[0]= pcBind.Edge[0];
+00571 paBind.Next[0]= CZone::getZonePatch(loadedZones, pcBind.ZoneId, pcBind.Next[0]);
+00572 <font class="comment">// If not loaded, don't bind to this edge.</font>
+00573 <font class="keywordflow">if</font>(!paBind.Next[0])
+00574 paBind.NPatchs=0;
+00575 }
+00576 <font class="keywordflow">if</font>(paBind.NPatchs&gt;=2)
+00577 {
+00578 paBind.Edge[1]= pcBind.Edge[1];
+00579 paBind.Next[1]= CZone::getZonePatch(loadedZones, pcBind.ZoneId, pcBind.Next[1]);
+00580 <font class="comment">// If not loaded, don't bind to this edge.</font>
+00581 <font class="keywordflow">if</font>(!paBind.Next[1])
+00582 paBind.NPatchs=0;
+00583 }
+00584 <font class="keywordflow">if</font>(paBind.NPatchs&gt;=4)
+00585 {
+00586 paBind.Edge[2]= pcBind.Edge[2];
+00587 paBind.Edge[3]= pcBind.Edge[3];
+00588 paBind.Next[2]= CZone::getZonePatch(loadedZones, pcBind.ZoneId, pcBind.Next[2]);
+00589 paBind.Next[3]= CZone::getZonePatch(loadedZones, pcBind.ZoneId, pcBind.Next[3]);
+00590 <font class="comment">// If not loaded, don't bind to this edge.</font>
+00591 <font class="keywordflow">if</font>(!paBind.Next[2] || !paBind.Next[3])
+00592 paBind.NPatchs=0;
+00593 }
+00594 }
+00595
+00596 pa.unbind(exceptions);
+00597 }
+00598
+00599 <font class="comment">// ***************************************************************************</font>
+<a name="l00600"></a><a class="code" href="class_NL3D__CZone.html#f3">00600</a> <font class="keywordtype">void</font> CZone::bindPatch(TZoneMap &amp;loadedZones, CPatch &amp;pa, CPatchConnect &amp;pc)<font class="keyword">
+</font>00601 <font class="keyword"></font>{
+00602 CPatch::CBindInfo edges[4];
+00603
+00604 unbindAndMakeBindInfo(loadedZones, pa, pc, edges);
+00605
+00606 pa.bind(edges);
+00607 }
+00608
+00609
+00610 <font class="comment">// ***************************************************************************</font>
+<a name="l00611"></a><a class="code" href="class_NL3D__CZone.html#f2">00611</a> <font class="keywordtype">void</font> CZone::unbindPatch(TZoneMap &amp;loadedZones, CPatch &amp;pa, CPatchConnect &amp;pc)<font class="keyword">
+</font>00612 <font class="keyword"></font>{
+00613 CPatch::CBindInfo edges[4];
+00614
+00615 unbindAndMakeBindInfo(loadedZones, pa, pc, edges);
+00616
+00617 <font class="comment">// Don't rebind.</font>
+00618 }
+00619
+00620
+00621 <font class="comment">// ***************************************************************************</font>
+<a name="l00622"></a><a class="code" href="class_NL3D__CZone.html#c3">00622</a> <font class="keywordtype">bool</font> CZone::patchOnBorder(<font class="keyword">const</font> CPatchConnect &amp;pc)<font class="keyword"> const
+</font>00623 <font class="keyword"></font>{
+00624 <font class="comment">// If only one of neighbor patch is not of this zone, we are on a border.</font>
+00625
+00626 <font class="comment">// Test all edges.</font>
+00627 <font class="keywordflow">for</font>(sint i=0;i&lt;4;i++)
+00628 {
+00629 <font class="keyword">const</font> CPatchInfo::CBindInfo &amp;pcBind= pc.BindEdges[i];
+00630
+00631 <a class="code" href="debug_h.html#a6">nlassert</a>(pcBind.NPatchs==0 || pcBind.NPatchs==1 || pcBind.NPatchs==2 || pcBind.NPatchs==4 || pcBind.NPatchs==5);
+00632 <font class="keywordflow">if</font>(pcBind.NPatchs&gt;=1)
+00633 {
+00634 <font class="keywordflow">if</font>(pcBind.ZoneId != ZoneId)
+00635 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00636 }
+00637 }
+00638
+00639 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00640 }
+00641
+00642
+00643 <font class="comment">// ***************************************************************************</font>
+00644 <font class="comment">// ***************************************************************************</font>
+00645 <font class="comment">// Render part.</font>
+00646 <font class="comment">// ***************************************************************************</font>
+00647 <font class="comment">// ***************************************************************************</font>
+00648
+00649
+00650 <font class="comment">// ***************************************************************************</font>
+<a name="l00651"></a><a class="code" href="class_NL3D__CZone.html#a13">00651</a> <font class="keywordtype">void</font> CZone::clip(<font class="keyword">const</font> std::vector&lt;CPlane&gt; &amp;pyramid)<font class="keyword">
+</font>00652 <font class="keyword"></font>{
+00653 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00654
+00655 <font class="comment">// Store current pyramid.</font>
+00656 CurrentPyramid= pyramid;
+00657
+00658 <font class="comment">// Fill ClipResult.</font>
+00659 ClipResult= ClipIn;
+00660 <font class="keywordflow">for</font>(sint i=0;i&lt;(sint)pyramid.size();i++)
+00661 {
+00662 <font class="comment">// If entirely out.</font>
+00663 <font class="keywordflow">if</font>(!ZoneBB.clipBack(pyramid[i]))
+00664 {
+00665 ClipResult= ClipOut;
+00666 <font class="comment">// If out of only one plane, out of all.</font>
+00667 <font class="keywordflow">break</font>;
+00668 }
+00669 <font class="comment">// If partially IN (ie not entirely out, and not entirely IN)</font>
+00670 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(ZoneBB.clipFront(pyramid[i]))
+00671 {
+00672 <font class="comment">// Force ClipResult to be ClipSide, and not ClipIn.</font>
+00673 ClipResult=ClipSide;
+00674 }
+00675 }
+00676
+00677 <font class="comment">// Fill computeTileErrorMetric.</font>
+00678 CBSphere zonesphere(ZoneBB.getCenter(), ZoneBB.getRadius());
+00679 <font class="keywordflow">if</font>(zonesphere.intersect(CTessFace::TileFarSphere))
+00680 ComputeTileErrorMetric= <font class="keyword">true</font>;
+00681 <font class="keywordflow">else</font>
+00682 ComputeTileErrorMetric= <font class="keyword">false</font>;
+00683
+00684 <font class="comment">// Easy Clip :)</font>
+00685 <font class="keywordflow">if</font>(Patchs.size()==0)
+00686 {
+00687 ClipResult= ClipOut;
+00688 }
+00689
+00690
+00691 <font class="comment">// Clip By Patch Pass.</font>
+00692 <font class="comment">//--------------------</font>
+00693 <font class="keywordflow">if</font>(ClipResult==ClipOut)
+00694 {
+00695 CPatch *pPatch= &amp;(*Patchs.begin());
+00696 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00697 {
+00698 pPatch-&gt;forceClip();
+00699 }
+00700 }
+00701 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(ClipResult==ClipIn)
+00702 {
+00703 CPatch *pPatch= &amp;(*Patchs.begin());
+00704 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00705 {
+00706 pPatch-&gt;forceNoClip();
+00707 }
+00708 }
+00709 <font class="keywordflow">else</font>
+00710 {
+00711 CPatch *pPatch= &amp;(*Patchs.begin());
+00712 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00713 {
+00714 pPatch-&gt;clip(CurrentPyramid);
+00715 }
+00716 }
+00717
+00718 }
+00719
+00720
+00721 <font class="comment">// ***************************************************************************</font>
+00722 <font class="comment">// DebugYoyo.</font>
+00723 <font class="comment">// Code for Debug test Only.. Do not erase it, may be used later :)</font>
+00724 <font class="comment">/*
+</font>00725 <font class="comment">static void cleanTess(CTessFace *face)
+</font>00726 <font class="comment">{
+</font>00727 <font class="comment"> if(!face-&gt;isLeaf())
+</font>00728 <font class="comment"> {
+</font>00729 <font class="comment"> cleanTess(face-&gt;SonLeft);
+</font>00730 <font class="comment"> cleanTess(face-&gt;SonRight);
+</font>00731 <font class="comment"> }
+</font>00732 <font class="comment"> // If has father, clean it.
+</font>00733 <font class="comment"> if(face-&gt;Father)
+</font>00734 <font class="comment"> {
+</font>00735 <font class="comment"> CTessFace *face1=face-&gt;Father;
+</font>00736 <font class="comment"> CTessFace *face2=face-&gt;Father-&gt;FBase;
+</font>00737 <font class="comment"> face1-&gt;FLeft= face1-&gt;SonLeft-&gt;FBase;
+</font>00738 <font class="comment"> face1-&gt;FRight= face1-&gt;SonRight-&gt;FBase;
+</font>00739 <font class="comment"> if(face2!=NULL)
+</font>00740 <font class="comment"> {
+</font>00741 <font class="comment"> face2-&gt;FLeft= face2-&gt;SonLeft-&gt;FBase;
+</font>00742 <font class="comment"> face2-&gt;FRight= face2-&gt;SonRight-&gt;FBase;
+</font>00743 <font class="comment"> }
+</font>00744 <font class="comment"> }
+</font>00745 <font class="comment">}
+</font>00746 <font class="comment">static void testTess(CTessFace *face)
+</font>00747 <font class="comment">{
+</font>00748 <font class="comment"> if(!face-&gt;isLeaf())
+</font>00749 <font class="comment"> {
+</font>00750 <font class="comment"> testTess(face-&gt;SonLeft);
+</font>00751 <font class="comment"> testTess(face-&gt;SonRight);
+</font>00752 <font class="comment"> }
+</font>00753 <font class="comment"> // Test validity.
+</font>00754 <font class="comment"> nlassert(!face-&gt;FBase || face-&gt;FBase-&gt;Patch!=(CPatch*)0xdddddddd);
+</font>00755 <font class="comment"> nlassert(!face-&gt;FLeft || face-&gt;FLeft-&gt;Patch!=(CPatch*)0xdddddddd);
+</font>00756 <font class="comment"> nlassert(!face-&gt;FRight || face-&gt;FRight-&gt;Patch!=(CPatch*)0xdddddddd);
+</font>00757 <font class="comment">}
+</font>00758 <font class="comment">static void checkTess()
+</font>00759 <font class="comment">{
+</font>00760 <font class="comment"> // This test should be inserted at begin of CZone::refine().
+</font>00761 <font class="comment"> // And it needs hacking public/private.
+</font>00762 <font class="comment"> CPatch *pPatch;
+</font>00763 <font class="comment"> sint n;
+</font>00764 <font class="comment"> pPatch= &amp;(*Patchs.begin());
+</font>00765 <font class="comment"> for(n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+</font>00766 <font class="comment"> {
+</font>00767 <font class="comment"> cleanTess(pPatch-&gt;Son0);
+</font>00768 <font class="comment"> cleanTess(pPatch-&gt;Son1);
+</font>00769 <font class="comment"> }
+</font>00770 <font class="comment"> pPatch= &amp;(*Patchs.begin());
+</font>00771 <font class="comment"> for(n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+</font>00772 <font class="comment"> {
+</font>00773 <font class="comment"> testTess(pPatch-&gt;Son0);
+</font>00774 <font class="comment"> testTess(pPatch-&gt;Son1);
+</font>00775 <font class="comment"> }
+</font>00776 <font class="comment">}
+</font>00777 <font class="comment">*/</font>
+00778
+00779
+00780 <font class="comment">// ***************************************************************************</font>
+00781 <font class="comment">// DebugYoyo.</font>
+00782 <font class="comment">//volatile sint pipo1;</font>
+00783 <font class="comment">//volatile sint pipo2;</font>
+<a name="l00784"></a><a class="code" href="class_NL3D__CZone.html#a14">00784</a> <font class="keywordtype">void</font> CZone::refine()<font class="keyword">
+</font>00785 <font class="keyword"></font>{
+00786 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00787 <font class="comment">// Must be 2^X-1.</font>
+00788 <font class="keyword">static</font> <font class="keyword">const</font> sint hideRefineFreq= 15;
+00789
+00790 <font class="comment">// DebugYoyo.</font>
+00791 <font class="comment">// For the monkey bind test.</font>
+00792 <font class="comment">/*extern sint numFrames;
+</font>00793 <font class="comment"> pipo1=(rand()&gt;&gt;12)&amp;1;
+</font>00794 <font class="comment"> pipo2=(rand()&gt;&gt;12)&amp;1;
+</font>00795 <font class="comment"> //if(pipo1 &amp;&amp; numFrames&gt;1360)
+</font>00796 <font class="comment"> if(true)
+</font>00797 <font class="comment"> {
+</font>00798 <font class="comment"> TZoneMap pipoMap;
+</font>00799 <font class="comment"> pipoMap[ZoneId]= this;
+</font>00800 <font class="comment"> bindPatch(pipoMap, Patchs[0], PatchConnects[0]);
+</font>00801 <font class="comment"> }*/</font>
+00802
+00803
+00804 <font class="comment">// Force refine of invisible zones only every 8 times.</font>
+00805 <font class="keywordflow">if</font>(ClipResult==ClipOut &amp;&amp; (CTessFace::CurrentDate &amp; hideRefineFreq)!=(ZoneId &amp; hideRefineFreq))
+00806 <font class="keywordflow">return</font>;
+00807 <font class="comment">// Fuck stlport....</font>
+00808 <font class="keywordflow">if</font>(Patchs.size()==0)
+00809 <font class="keywordflow">return</font>;
+00810
+00811 CPatch *pPatch= &amp;(*Patchs.begin());
+00812 <font class="keywordflow">if</font>(ClipResult==ClipSide)
+00813 {
+00814 <font class="comment">// Force refine of invisible patchs only every 16 times.</font>
+00815 <font class="comment">// NB: do this only if zone is clipSide</font>
+00816 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00817 {
+00818 <font class="comment">// "ZoneId+n", because there is only 70 approx patchs per zone. doing this may stabilize framerate.</font>
+00819 <font class="keywordflow">if</font>(pPatch-&gt;isClipped() &amp;&amp; (CTessFace::CurrentDate &amp; hideRefineFreq)!=((ZoneId+n) &amp; hideRefineFreq))
+00820 <font class="keywordflow">continue</font>;
+00821 pPatch-&gt;refine();
+00822 }
+00823 }
+00824 <font class="keywordflow">else</font>
+00825 {
+00826 <font class="comment">// Else refine ALL patchs (even those which may be invisible).</font>
+00827 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00828 {
+00829 pPatch-&gt;refine();
+00830 }
+00831 }
+00832
+00833 }
+00834 <font class="comment">// ***************************************************************************</font>
+<a name="l00835"></a><a class="code" href="class_NL3D__CZone.html#a21">00835</a> <font class="keywordtype">void</font> CZone::refineAll()<font class="keyword">
+</font>00836 <font class="keyword"></font>{
+00837 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00838
+00839 <font class="comment">// Fuck stlport....</font>
+00840 <font class="keywordflow">if</font>(Patchs.size()==0)
+00841 <font class="keywordflow">return</font>;
+00842
+00843 <font class="comment">// Do a dummy clip.</font>
+00844 ComputeTileErrorMetric= <font class="keyword">true</font>;
+00845 ClipResult= ClipIn;
+00846 CPatch *pPatch= &amp;(*Patchs.begin());
+00847 sint n;
+00848 <font class="keywordflow">for</font>(n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00849 {
+00850 pPatch-&gt;forceNoClip();
+00851 }
+00852
+00853
+00854 <font class="comment">// refine ALL patchs (even those which may be invisible).</font>
+00855 pPatch= &amp;(*Patchs.begin());
+00856 <font class="keywordflow">for</font>(n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00857 {
+00858 pPatch-&gt;refine();
+00859 }
+00860
+00861 }
+00862
+00863 <font class="comment">// ***************************************************************************</font>
+<a name="l00864"></a><a class="code" href="class_NL3D__CZone.html#a15">00864</a> <font class="keywordtype">void</font> CZone::preRender(<font class="keyword">const</font> std::vector&lt;CPlane&gt; &amp;pyramid)<font class="keyword">
+</font>00865 <font class="keyword"></font>{
+00866 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00867 <font class="keywordflow">if</font>(ClipResult==ClipOut)
+00868 <font class="keywordflow">return</font>;
+00869
+00870 <font class="comment">// PreRender Pass.</font>
+00871 CPatch *pPatch= &amp;(*Patchs.begin());
+00872 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00873 {
+00874 pPatch-&gt;preRender(pyramid);
+00875 }
+00876 }
+00877 <font class="comment">// ***************************************************************************</font>
+<a name="l00878"></a><a class="code" href="class_NL3D__CZone.html#a16">00878</a> <font class="keywordtype">void</font> CZone::renderFar0()<font class="keyword">
+</font>00879 <font class="keyword"></font>{
+00880 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00881 <font class="keywordflow">if</font>(ClipResult==ClipOut)
+00882 <font class="keywordflow">return</font>;
+00883
+00884 <font class="comment">// RenderFar0.</font>
+00885 CPatch *pPatch= &amp;(*Patchs.begin());
+00886 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00887 {
+00888 pPatch-&gt;renderFar0();
+00889 }
+00890 }
+00891 <font class="comment">// ***************************************************************************</font>
+<a name="l00892"></a><a class="code" href="class_NL3D__CZone.html#a17">00892</a> <font class="keywordtype">void</font> CZone::renderFar1()<font class="keyword">
+</font>00893 <font class="keyword"></font>{
+00894 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00895 <font class="keywordflow">if</font>(ClipResult==ClipOut)
+00896 <font class="keywordflow">return</font>;
+00897
+00898 <font class="comment">// RenderFar1.</font>
+00899 CPatch *pPatch= &amp;(*Patchs.begin());
+00900 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00901 {
+00902 pPatch-&gt;renderFar1();
+00903 }
+00904 }
+00905 <font class="comment">// ***************************************************************************</font>
+<a name="l00906"></a><a class="code" href="class_NL3D__CZone.html#a18">00906</a> <font class="keywordtype">void</font> CZone::renderTile(sint pass)<font class="keyword">
+</font>00907 <font class="keyword"></font>{
+00908 <a class="code" href="debug_h.html#a6">nlassert</a>(Compiled);
+00909 <font class="keywordflow">if</font>(ClipResult==ClipOut)
+00910 <font class="keywordflow">return</font>;
+00911
+00912 <font class="comment">// RenderTile.</font>
+00913 CPatch *pPatch= &amp;(*Patchs.begin());
+00914 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00915 {
+00916 pPatch-&gt;renderTile(pass);
+00917 }
+00918 }
+00919
+00920
+00921 <font class="comment">// ***************************************************************************</font>
+<a name="l00922"></a><a class="code" href="class_NL3D__CZone.html#a19">00922</a> <font class="keywordtype">void</font> CZone::resetRenderFar()<font class="keyword">
+</font>00923 <font class="keyword"></font>{
+00924 CPatch *pPatch= &amp;(*Patchs.begin());
+00925 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00926 {
+00927 pPatch-&gt;resetRenderFar();
+00928 }
+00929 }
+00930
+00931
+00932 <font class="comment">// ***************************************************************************</font>
+<a name="l00933"></a><a class="code" href="class_NL3D__CZone.html#a20">00933</a> <font class="keywordtype">void</font> CZone::forceMergeAtTileLevel()<font class="keyword">
+</font>00934 <font class="keyword"></font>{
+00935 CPatch *pPatch= &amp;(*Patchs.begin());
+00936 <font class="keywordflow">for</font>(sint n=(sint)Patchs.size();n&gt;0;n--, pPatch++)
+00937 {
+00938 pPatch-&gt;forceMergeAtTileLevel();
+00939 }
+00940 }
+00941
+00942
+00943 <font class="comment">// ***************************************************************************</font>
+00944 <font class="comment">// ***************************************************************************</font>
+00945 <font class="comment">// Misc part.</font>
+00946 <font class="comment">// ***************************************************************************</font>
+00947 <font class="comment">// ***************************************************************************</font>
+00948
+00949
+00950 <font class="comment">// ***************************************************************************</font>
+<a name="l00951"></a><a class="code" href="class_NL3D__CZone.html#a9">00951</a> <font class="keywordtype">void</font> CZone::changePatchTextureAndColor (sint numPatch, <font class="keyword">const</font> std::vector&lt;CTileElement&gt; *tiles, <font class="keyword">const</font> std::vector&lt;CTileColor&gt; *colors)<font class="keyword">
+</font>00952 <font class="keyword"></font>{
+00953 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&gt;=0);
+00954 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&lt;getNumPatchs());
+00955
+00956
+00957 <font class="comment">// Update the patch texture.</font>
+00958 <font class="keywordflow">if</font> (tiles)
+00959 {
+00960 <a class="code" href="debug_h.html#a6">nlassert</a>( Patchs[numPatch].Tiles.size() == tiles-&gt;size() );
+00961 Patchs[numPatch].Tiles = *tiles;
+00962 }
+00963
+00964 <font class="comment">// Update the patch colors.</font>
+00965 <font class="keywordflow">if</font> (colors)
+00966 {
+00967 <a class="code" href="debug_h.html#a6">nlassert</a>( Patchs[numPatch].TileColors.size() == colors-&gt;size() );
+00968 Patchs[numPatch].TileColors = *colors;
+00969 }
+00970
+00971 <font class="keywordflow">if</font> (Compiled&amp;&amp;(tiles||colors))
+00972 {
+00973 Patchs[numPatch].deleteTileUvs();
+00974 Patchs[numPatch].recreateTileUvs();
+00975 }
+00976 }
+00977
+00978
+00979 <font class="comment">// ***************************************************************************</font>
+<a name="l00980"></a><a class="code" href="class_NL3D__CZone.html#a10">00980</a> <font class="keyword">const</font> std::vector&lt;CTileElement&gt; &amp;CZone::getPatchTexture(sint numPatch)<font class="keyword"> const
+</font>00981 <font class="keyword"></font>{
+00982 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&gt;=0);
+00983 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&lt;getNumPatchs());
+00984
+00985 <font class="comment">// Update the patch texture.</font>
+00986 <font class="keywordflow">return</font> Patchs[numPatch].Tiles;
+00987 }
+00988
+00989
+00990 <font class="comment">// ***************************************************************************</font>
+<a name="l00991"></a><a class="code" href="class_NL3D__CZone.html#a11">00991</a> <font class="keyword">const</font> std::vector&lt;CTileColor&gt; &amp;CZone::getPatchColor(sint numPatch)<font class="keyword"> const
+</font>00992 <font class="keyword"></font>{
+00993 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&gt;=0);
+00994 <a class="code" href="debug_h.html#a6">nlassert</a>(numPatch&lt;getNumPatchs());
+00995
+00996 <font class="comment">// Update the patch texture.</font>
+00997 <font class="keywordflow">return</font> Patchs[numPatch].TileColors;
+00998 }
+00999
+01000
+01001 <font class="comment">// ***************************************************************************</font>
+<a name="l01002"></a><a class="code" href="class_NL3D__CZone.html#a5">01002</a> <font class="keywordtype">void</font> CZone::debugBinds(FILE *f)<font class="keyword">
+</font>01003 <font class="keyword"></font>{
+01004 fprintf(f, <font class="stringliteral">"*****************************\n"</font>);
+01005 fprintf(f, <font class="stringliteral">"ZoneId: %d. NPatchs:%d\n"</font>, ZoneId, PatchConnects.size());
+01006 sint i;
+01007 <font class="keywordflow">for</font>(i=0;i&lt;(sint)PatchConnects.size();i++)
+01008 {
+01009 CPatchConnect &amp;pc= PatchConnects[i];
+01010 fprintf(f, <font class="stringliteral">"patch%d:\n"</font>, i);
+01011 <font class="keywordflow">for</font>(sint j=0;j&lt;4;j++)
+01012 {
+01013 CPatchInfo::CBindInfo &amp;bd= pc.BindEdges[j];
+01014 fprintf(f, <font class="stringliteral">" edge%d: Zone:%d. NPatchs:%d. "</font>, j, bd.ZoneId, bd.NPatchs);
+01015 <font class="keywordflow">for</font>(sint k=0;k&lt;bd.NPatchs;k++)
+01016 {
+01017 fprintf(f, <font class="stringliteral">"p%de%d - "</font>, bd.Next[k], bd.Edge[k]);
+01018 }
+01019 fprintf(f, <font class="stringliteral">"\n"</font>);
+01020 }
+01021 }
+01022
+01023 fprintf(f,<font class="stringliteral">"Vertices :\n"</font>);
+01024 <font class="keywordflow">for</font>(i=0;i&lt;(sint)BorderVertices.size();i++)
+01025 {
+01026 fprintf(f,<font class="stringliteral">"current : %d -&gt; (zone %d) vertex %d\n"</font>,BorderVertices[i].CurrentVertex,
+01027 BorderVertices[i].NeighborZoneId,
+01028 BorderVertices[i].NeighborVertex);
+01029 }
+01030 }
+01031
+01032
+01033 <font class="comment">// ***************************************************************************</font>
+<a name="l01034"></a><a class="code" href="class_NL3D__CZone.html#a30">01034</a> <font class="keywordtype">void</font> CZone::applyHeightField(<font class="keyword">const</font> CLandscape &amp;landScape)<font class="keyword">
+</font>01035 <font class="keyword"></font>{
+01036 sint i,j;
+01037 vector&lt;CBezierPatch&gt; patchs;
+01038
+01039 <font class="comment">// no patch, do nothing.</font>
+01040 <font class="keywordflow">if</font>(Patchs.size()==0)
+01041 <font class="keywordflow">return</font>;
+01042
+01043 <font class="comment">// 0. Unpack patchs to Bezier Patchs.</font>
+01044 <font class="comment">//===================================</font>
+01045 patchs.resize(Patchs.size());
+01046 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+01047 {
+01048 CBezierPatch &amp;p= patchs[j];
+01049 CPatch &amp;pa= Patchs[j];
+01050
+01051 <font class="comment">// re-Build the uncompressed bezier patch.</font>
+01052 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01053 pa.Vertices[i].unpack(p.Vertices[i], PatchBias, PatchScale);
+01054 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+01055 pa.Tangents[i].unpack(p.Tangents[i], PatchBias, PatchScale);
+01056 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01057 pa.Interiors[i].unpack(p.Interiors[i], PatchBias, PatchScale);
+01058 }
+01059
+01060 <font class="comment">// 1. apply heightfield on bezier patchs.</font>
+01061 <font class="comment">//===================================</font>
+01062 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+01063 {
+01064 CBezierPatch &amp;p= patchs[j];
+01065
+01066 <font class="comment">// apply delta.</font>
+01067 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01068 p.Vertices[i]+= landScape.getHeightFieldDeltaZ(p.Vertices[i].x, p.Vertices[i].y);
+01069 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+01070 p.Tangents[i]+= landScape.getHeightFieldDeltaZ(p.Tangents[i].x, p.Tangents[i].y);
+01071 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01072 p.Interiors[i]+= landScape.getHeightFieldDeltaZ(p.Interiors[i].x, p.Interiors[i].y);
+01073 }
+01074
+01075
+01076 <font class="comment">// 2. Re-compute Patch Scale/Bias, and Zone BBox.</font>
+01077 <font class="comment">//===================================</font>
+01078 CAABBox bb;
+01079 bb.setCenter(patchs[0].Vertices[0]);
+01080 bb.setHalfSize(CVector::Null);
+01081 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+01082 {
+01083 <font class="comment">// extend bbox.</font>
+01084 <font class="keyword">const</font> CBezierPatch &amp;p= patchs[j];
+01085 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01086 bb.extend(p.Vertices[i]);
+01087 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+01088 bb.extend(p.Tangents[i]);
+01089 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01090 bb.extend(p.Interiors[i]);
+01091 }
+01092 <font class="comment">// Compute BBox, and Patch Scale Bias, according to Noise.</font>
+01093 computeBBScaleBias(bb);
+01094
+01095
+01096 <font class="comment">// 3. Re-pack patchs.</font>
+01097 <font class="comment">//===================================</font>
+01098 <font class="keywordflow">for</font>(j=0;j&lt;(sint)patchs.size();j++)
+01099 {
+01100 CBezierPatch &amp;p= patchs[j];
+01101 CPatch &amp;pa= Patchs[j];
+01102
+01103 <font class="comment">// Build the packed patch.</font>
+01104 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01105 pa.Vertices[i].pack(p.Vertices[i], PatchBias, PatchScale);
+01106 <font class="keywordflow">for</font>(i=0;i&lt;8;i++)
+01107 pa.Tangents[i].pack(p.Tangents[i], PatchBias, PatchScale);
+01108 <font class="keywordflow">for</font>(i=0;i&lt;4;i++)
+01109 pa.Interiors[i].pack(p.Interiors[i], PatchBias, PatchScale);
+01110 }
+01111 }
+01112
+01113
+01114
+01115 } <font class="comment">// NL3D</font>
+</div></pre>
+
+<!-- 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>