diff options
Diffstat (limited to 'docs/doxygen/nel/lod__character__manager_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/lod__character__manager_8cpp-source.html | 926 |
1 files changed, 926 insertions, 0 deletions
diff --git a/docs/doxygen/nel/lod__character__manager_8cpp-source.html b/docs/doxygen/nel/lod__character__manager_8cpp-source.html new file mode 100644 index 00000000..65ac3401 --- /dev/null +++ b/docs/doxygen/nel/lod__character__manager_8cpp-source.html @@ -0,0 +1,926 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>lod_character_manager.cpp</h1><a href="lod__character__manager_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="lod__character__manager_8h.html">3d/lod_character_manager.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="lod__character__shape_8h.html">3d/lod_character_shape.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="lod__character__shape__bank_8h.html">3d/lod_character_shape_bank.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="lod__character__instance_8h.html">3d/lod_character_instance.h</a>"</font> +00033 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font> +00035 <font class="preprocessor">#include "<a class="code" href="lod__character__texture_8h.html">3d/lod_character_texture.h</a>"</font> +00036 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font> +00037 +00038 +00039 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00040 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00041 +00042 <font class="keyword">namespace </font>NL3D +00043 { +00044 +00045 +00046 <a class="code" href="hierarchical__timer_8h.html#a6">H_AUTO_DECL</a> ( NL3D_CharacterLod_Render ) +00047 +00048 +00049 <font class="comment">// ***************************************************************************</font> +00050 <font class="comment">// Dest is without Normal because precomputed</font> +<a name="l00051"></a><a class="code" href="lod__character__manager_8cpp.html#a0">00051</a> <font class="preprocessor">#define NL3D_CLOD_VERTEX_FORMAT (CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::PrimaryColorFlag)</font> +<a name="l00052"></a><a class="code" href="lod__character__manager_8cpp.html#a1">00052</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_VERTEX_SIZE 24</font> +<a name="l00053"></a><a class="code" href="lod__character__manager_8cpp.html#a2">00053</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_UV_OFF 12</font> +<a name="l00054"></a><a class="code" href="lod__character__manager_8cpp.html#a3">00054</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_COLOR_OFF 20</font> +00055 <font class="preprocessor"></font> +00056 <font class="comment">// size (in block) of the big texture.</font> +<a name="l00057"></a><a class="code" href="lod__character__manager_8cpp.html#a4">00057</a> <font class="preprocessor">#define NL3D_CLOD_TEXT_NLOD_WIDTH 16</font> +<a name="l00058"></a><a class="code" href="lod__character__manager_8cpp.html#a5">00058</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_TEXT_NLOD_HEIGHT 16</font> +<a name="l00059"></a><a class="code" href="lod__character__manager_8cpp.html#a6">00059</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_TEXT_NUM_IDS NL3D_CLOD_TEXT_NLOD_WIDTH*NL3D_CLOD_TEXT_NLOD_HEIGHT</font> +<a name="l00060"></a><a class="code" href="lod__character__manager_8cpp.html#a7">00060</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_BIGTEXT_WIDTH NL3D_CLOD_TEXT_NLOD_WIDTH*NL3D_CLOD_TEXT_WIDTH</font> +<a name="l00061"></a><a class="code" href="lod__character__manager_8cpp.html#a8">00061</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_CLOD_BIGTEXT_HEIGHT NL3D_CLOD_TEXT_NLOD_HEIGHT*NL3D_CLOD_TEXT_HEIGHT</font> +00062 <font class="preprocessor"></font> +00063 <font class="comment">// Default texture color. Alpha must be 255</font> +<a name="l00064"></a><a class="code" href="lod__character__manager_8cpp.html#a9">00064</a> <font class="preprocessor">#define NL3D_CLOD_DEFAULT_TEXCOLOR CRGBA(255,255,255,255)</font> +00065 <font class="preprocessor"></font> +00066 +00067 <font class="comment">// ***************************************************************************</font> +<a name="l00068"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#a0">00068</a> CLodCharacterManager::CLodCharacterManager() +00069 { +00070 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>= NULL; +00071 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>= 3000; +00072 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_11">_Rendering</a>= <font class="keyword">false</font>; +00073 +00074 <font class="comment">// Setup the format of render</font> +00075 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.setVertexFormat(<a class="code" href="lod__character__manager_8cpp.html#a0">NL3D_CLOD_VERTEX_FORMAT</a>); +00076 +00077 <font class="comment">// NB: addRenderCharacterKey() loop hardCoded for Vertex+UV+Normal+Color only.</font> +00078 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="lod__character__manager_8cpp.html#a2">NL3D_CLOD_UV_OFF</a> == <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getTexCoordOff()); +00079 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="lod__character__manager_8cpp.html#a3">NL3D_CLOD_COLOR_OFF</a> == <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getColorOff()); +00080 +00081 <font class="comment">// setup the texture.</font> +00082 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>= <font class="keyword">new</font> CTextureBlank; +00083 <font class="comment">// The texture always reside in memory... This take 1Mo of RAM. (16*32*16*32 * 4)</font> +00084 <font class="comment">// NB: this is simplier like that, and this is not a problem, since only 1 or 2 Mo are allocated :o)</font> +00085 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->setReleasable(<font class="keyword">false</font>); +00086 <font class="comment">// create the bitmap.</font> +00087 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->resize(<a class="code" href="lod__character__manager_8cpp.html#a7">NL3D_CLOD_BIGTEXT_WIDTH</a>, <a class="code" href="lod__character__manager_8cpp.html#a8">NL3D_CLOD_BIGTEXT_HEIGHT</a>, CBitmap::RGBA); +00088 <font class="comment">// Format of texture, 16 bits and no mipmaps.</font> +00089 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->setUploadFormat(ITexture::RGB565); +00090 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->setFilterMode(ITexture::Linear, ITexture::LinearMipMapOff); +00091 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->setWrapS(ITexture::Clamp); +00092 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->setWrapT(ITexture::Clamp); +00093 +00094 <font class="comment">// Alloc free Ids</font> +00095 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.resize(<a class="code" href="lod__character__manager_8cpp.html#a6">NL3D_CLOD_TEXT_NUM_IDS</a>); +00096 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.size();i++) +00097 { +00098 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>[i]= i; +00099 } +00100 +00101 <font class="comment">// setup the material</font> +00102 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_2">_Material</a>.initUnlit(); +00103 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_2">_Material</a>.setAlphaTest(<font class="keyword">true</font>); +00104 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_2">_Material</a>.setDoubleSided(<font class="keyword">true</font>); +00105 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_2">_Material</a>.setTexture(0, <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>); +00106 +00107 <font class="comment">// setup for lighting, Default for Ryzom setup</font> +00108 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>.rotateZ((<font class="keywordtype">float</font>)<a class="code" href="namespaceNLMISC.html#a7">Pi</a>/2); +00109 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>.invert(); +00110 } +00111 +00112 +00113 <font class="comment">// ***************************************************************************</font> +<a name="l00114"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#a1">00114</a> CLodCharacterManager::~CLodCharacterManager() +00115 { +00116 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_0">reset</a>(); +00117 } +00118 +00119 <font class="comment">// ***************************************************************************</font> +<a name="l00120"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_0">00120</a> <font class="keywordtype">void</font> CLodCharacterManager::reset() +00121 { +00122 <font class="comment">// delete shapeBanks.</font> +00123 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size();i++) +00124 { +00125 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]) +00126 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]; +00127 } +00128 +00129 <font class="comment">// clears containers</font> +00130 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>); +00131 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>); +00132 +00133 <font class="comment">// reset render part.</font> +00134 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_0">deleteVertexBuffer</a>(); +00135 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>= NULL; +00136 } +00137 +00138 <font class="comment">// ***************************************************************************</font> +<a name="l00139"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_1">00139</a> uint32 CLodCharacterManager::createShapeBank() +00140 { +00141 <font class="comment">// search a free entry</font> +00142 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size();i++) +00143 { +00144 <font class="comment">// if ree, use it.</font> +00145 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]==NULL) +00146 { +00147 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]= <font class="keyword">new</font> CLodCharacterShapeBank; +00148 <font class="keywordflow">return</font> i; +00149 } +00150 } +00151 +00152 <font class="comment">// no free entrey, resize array.</font> +00153 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.push_back(<font class="keyword">new</font> CLodCharacterShapeBank); +00154 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size()-1; +00155 } +00156 +00157 <font class="comment">// ***************************************************************************</font> +<a name="l00158"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_2">00158</a> <font class="keyword">const</font> CLodCharacterShapeBank *CLodCharacterManager::getShapeBank(uint32 bankId)<font class="keyword"> const</font> +00159 <font class="keyword"></font>{ +00160 <font class="keywordflow">if</font>(bankId>=<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size()) +00161 <font class="keywordflow">return</font> NULL; +00162 <font class="keywordflow">else</font> +00163 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[bankId]; +00164 } +00165 +00166 <font class="comment">// ***************************************************************************</font> +<a name="l00167"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_3">00167</a> CLodCharacterShapeBank *CLodCharacterManager::getShapeBank(uint32 bankId) +00168 { +00169 <font class="keywordflow">if</font>(bankId>=<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size()) +00170 <font class="keywordflow">return</font> NULL; +00171 <font class="keywordflow">else</font> +00172 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[bankId]; +00173 } +00174 +00175 <font class="comment">// ***************************************************************************</font> +<a name="l00176"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_4">00176</a> <font class="keywordtype">void</font> CLodCharacterManager::deleteShapeBank(uint32 bankId) +00177 { +00178 <font class="keywordflow">if</font>(bankId>=<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size()) +00179 { +00180 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[bankId]) +00181 { +00182 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[bankId]; +00183 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[bankId]= NULL; +00184 } +00185 } +00186 } +00187 +00188 <font class="comment">// ***************************************************************************</font> +<a name="l00189"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_5">00189</a> sint32 CLodCharacterManager::getShapeIdByName(<font class="keyword">const</font> std::string &name)<font class="keyword"> const</font> +00190 <font class="keyword"></font>{ +00191 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#u2">CstItStrIdMap</a> it= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>.find(name); +00192 <font class="keywordflow">if</font>(it==<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>.end()) +00193 <font class="keywordflow">return</font> -1; +00194 <font class="keywordflow">else</font> +00195 <font class="keywordflow">return</font> it->second; +00196 } +00197 +00198 <font class="comment">// ***************************************************************************</font> +<a name="l00199"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_6">00199</a> <font class="keyword">const</font> CLodCharacterShape *CLodCharacterManager::getShape(uint32 shapeId)<font class="keyword"> const</font> +00200 <font class="keyword"></font>{ +00201 <font class="comment">// split the id</font> +00202 uint bankId= shapeId >> 16; +00203 uint shapeInBankId= shapeId &0xFFFF; +00204 +00205 <font class="comment">// if valid bankId</font> +00206 <font class="keyword">const</font> CLodCharacterShapeBank *shapeBank= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_2">getShapeBank</a>(bankId); +00207 <font class="keywordflow">if</font>(shapeBank) +00208 { +00209 <font class="comment">// return the shape from the bank</font> +00210 <font class="keywordflow">return</font> shapeBank->getShape(shapeInBankId); +00211 } +00212 <font class="keywordflow">else</font> +00213 <font class="keywordflow">return</font> NULL; +00214 } +00215 +00216 <font class="comment">// ***************************************************************************</font> +<a name="l00217"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_7">00217</a> <font class="keywordtype">bool</font> CLodCharacterManager::compile() +00218 { +00219 <font class="keywordtype">bool</font> error= <font class="keyword">false</font>; +00220 +00221 <font class="comment">// clear the map</font> +00222 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>); +00223 +00224 <font class="comment">// build the map</font> +00225 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>.size(); i++) +00226 { +00227 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]) +00228 { +00229 <font class="comment">// Parse all Shapes</font> +00230 <font class="keywordflow">for</font>(uint j=0; j<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]->getNumShapes(); j++) +00231 { +00232 <font class="comment">// build the shape Id</font> +00233 uint shapeId= (i<<16) + j; +00234 +00235 <font class="comment">// get the shape</font> +00236 <font class="keyword">const</font> CLodCharacterShape *shape= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o0">_ShapeBankArray</a>[i]->getShape(j); +00237 <font class="keywordflow">if</font>(shape) +00238 { +00239 <font class="keyword">const</font> string &name= shape->getName(); +00240 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#u1">ItStrIdMap</a> it= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>.find(name); +00241 <font class="keywordflow">if</font>(it == <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>.end()) +00242 <font class="comment">// insert the id in the map</font> +00243 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#o1">_ShapeMap</a>.insert(make_pair(name, shapeId)); +00244 <font class="keywordflow">else</font> +00245 { +00246 error= <font class="keyword">true</font>; +00247 <a class="code" href="debug_8h.html#a2">nlwarning</a>(<font class="stringliteral">"Found a Character Lod with same name in the manager: %s"</font>, name.c_str()); +00248 } +00249 } +00250 } +00251 } +00252 } +00253 +00254 <font class="keywordflow">return</font> error; +00255 } +00256 +00257 <font class="comment">// ***************************************************************************</font> +00258 <font class="comment">// ***************************************************************************</font> +00259 <font class="comment">// Render</font> +00260 <font class="comment">// ***************************************************************************</font> +00261 <font class="comment">// ***************************************************************************</font> +00262 +00263 +00264 <font class="comment">// ***************************************************************************</font> +<a name="l00265"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_0">00265</a> <font class="keywordtype">void</font> CLodCharacterManager::setMaxVertex(uint32 maxVertex) +00266 { +00267 <font class="comment">// we must not be beewteen beginRender() and endRender()</font> +00268 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_5">isRendering</a>()); +00269 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>= maxVertex; +00270 } +00271 +00272 <font class="comment">// ***************************************************************************</font> +<a name="l00273"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_0">00273</a> <font class="keywordtype">void</font> CLodCharacterManager::deleteVertexBuffer() +00274 { +00275 <font class="comment">// test (refptr) if the object still exist in memory.</font> +00276 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>!=NULL) +00277 { +00278 <font class="comment">// A vbufferhard should still exist only if driver still exist.</font> +00279 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>!=NULL); +00280 +00281 <font class="comment">// must unlock VBhard before. ATI: No need to update any vertices.</font> +00282 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>->unlock(0,0); +00283 +00284 <font class="comment">// delete it from driver.</font> +00285 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->deleteVertexBufferHard(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>); +00286 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>= NULL; +00287 } +00288 +00289 <font class="comment">// delete the soft one.</font> +00290 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.deleteAllVertices(); +00291 } +00292 +00293 +00294 <font class="comment">// ***************************************************************************</font> +<a name="l00295"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_2">00295</a> <font class="keywordtype">void</font> CLodCharacterManager::beginRender(IDriver *driver, <font class="keyword">const</font> CVector &managerPos) +00296 { +00297 <a class="code" href="hierarchical__timer_8h.html#a7">H_AUTO_USE</a> ( NL3D_CharacterLod_Render ) +00298 +00299 <font class="comment">// we must not be beewteen beginRender() and endRender()</font> +00300 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_5">isRendering</a>()); +00301 +00302 <font class="comment">// Reset render</font> +00303 <font class="comment">//=================</font> +00304 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a>=0; +00305 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>= 0; +00306 +00307 <font class="comment">// update Driver.</font> +00308 <font class="comment">//=================</font> +00309 <a class="code" href="debug_8h.html#a6">nlassert</a>(driver); +00310 +00311 <font class="comment">// test change of driver.</font> +00312 <a class="code" href="debug_8h.html#a6">nlassert</a>(driver); +00313 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>==NULL || driver!=<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a> ) +00314 { +00315 <font class="comment">// must restart build of VB.</font> +00316 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_0">deleteVertexBuffer</a>(); +00317 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>= driver; +00318 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_8">_VBHardOk</a>= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->supportVertexBufferHard(); +00319 } +00320 +00321 <font class="comment">// If the vbhard exist, but size is different from cur max size, reset.</font> +00322 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a> && <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>->getNumVertices()!=<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>) +00323 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_0">deleteVertexBuffer</a>(); +00324 +00325 <font class="comment">// If VBHard is possible, and if not already allocated, try to create it.</font> +00326 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_8">_VBHardOk</a> && <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>==NULL) +00327 { +00328 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>= driver->createVertexBufferHard(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getVertexFormat(), <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getValueTypePointer(), +00329 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>, IDriver::VBHardAGP); +00330 } +00331 +00332 <font class="comment">// Last try to create a std VertexBuffer if the VBHard does not exist.</font> +00333 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>==NULL) +00334 { +00335 <font class="comment">// just resize the std VB.</font> +00336 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.setNumVertices(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>); +00337 } +00338 +00339 <font class="comment">// prepare for render.</font> +00340 <font class="comment">//=================</font> +00341 +00342 <font class="comment">// Lock Buffer.</font> +00343 <font class="keywordflow">if</font>(_VBHard) +00344 { +00345 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_9">_VertexData</a>= (uint8*)<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>->lock(); +00346 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_10">_VertexSize</a>= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>->getVertexSize(); +00347 } +00348 <font class="keywordflow">else</font> +00349 { +00350 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_9">_VertexData</a>= (uint8*)<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getVertexCoordPointer(); +00351 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_10">_VertexSize</a>= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>.getVertexSize(); +00352 } +00353 <font class="comment">// NB: addRenderCharacterKey() loop hardCoded for Vertex+UV+Normal+Color only.</font> +00354 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_10">_VertexSize</a> == <a class="code" href="lod__character__manager_8cpp.html#a1">NL3D_CLOD_VERTEX_SIZE</a> ); <font class="comment">// Vector + Normal + UV + RGBA</font> +00355 +00356 +00357 <font class="comment">// Alloc a minimum of primitives (2*vertices), to avoid as possible reallocation in addRenderCharacterKey</font> +00358 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>.size()<<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a> * 2) +00359 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>.resize(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a> * 2); +00360 +00361 <font class="comment">// Local manager matrix</font> +00362 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_1">_ManagerMatrixPos</a>= managerPos; +00363 +00364 <font class="comment">// Ok, start rendering</font> +00365 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_11">_Rendering</a>= <font class="keyword">true</font>; +00366 } +00367 +00368 +00369 <font class="comment">// ***************************************************************************</font> +00370 <font class="keyword">static</font> <font class="keyword">inline</font> CRGBA <a class="code" href="namespaceNL3D.html#a375">computeLodLighting</a>(<font class="keyword">const</font> CVector &lightObjectSpace, <font class="keyword">const</font> CVector &normalPtr, CRGBA ambient, CRGBA diffuse) +00371 { +00372 <font class="comment">// \todo yoyo: TODO_OPTIMIZE</font> +00373 <font class="keywordtype">float</font> f= lightObjectSpace * normalPtr; +00374 f= max(0.f,f); +00375 sint f8= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(f*255); +00376 CRGBA lightRes; +00377 lightRes.modulateFromuiRGBOnly(diffuse, f8); +00378 lightRes.addRGBOnly(lightRes, ambient); +00379 <font class="keywordflow">return</font> lightRes; +00380 } +00381 +00382 +00383 <font class="comment">// ***************************************************************************</font> +<a name="l00384"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_3">00384</a> <font class="keywordtype">bool</font> CLodCharacterManager::addRenderCharacterKey(CLodCharacterInstance &instance, <font class="keyword">const</font> CMatrix &worldMatrix, +00385 CRGBA ambient, CRGBA diffuse, <font class="keyword">const</font> CVector &lightDir) +00386 { +00387 <a class="code" href="hierarchical__timer_8h.html#a7">H_AUTO_USE</a> ( NL3D_CharacterLod_Render ) +00388 +00389 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>); +00390 <font class="comment">// we must be beewteen beginRender() and endRender()</font> +00391 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_5">isRendering</a>()); +00392 +00393 CVector unPackScaleFactor; +00394 uint numVertices; +00395 +00396 <font class="comment">// Get the Shape and current key.</font> +00397 <font class="comment">//=============</font> +00398 +00399 <font class="comment">// get the shape</font> +00400 <font class="keyword">const</font> CLodCharacterShape *clod= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_6">getShape</a>(instance.ShapeId); +00401 <font class="comment">// if not found quit, return true</font> +00402 <font class="keywordflow">if</font>(!clod) +00403 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00404 +00405 <font class="comment">// get UV/Normal array. NULL => error</font> +00406 <font class="keyword">const</font> CVector *normalPtr= clod->getNormals(); +00407 <font class="comment">// get UV of the instance</font> +00408 <font class="keyword">const</font> CUV *uvPtr= instance.getUVs(); +00409 <font class="comment">// uvPtr is NULL means that initInstance() has not been called!!</font> +00410 <a class="code" href="debug_8h.html#a6">nlassert</a>(normalPtr && uvPtr); +00411 +00412 <font class="comment">// get the anim key</font> +00413 <font class="keyword">const</font> CLodCharacterShape::CVector3s *vertPtr; +00414 vertPtr= clod->getAnimKey(instance.AnimId, instance.AnimTime, instance.WrapMode, unPackScaleFactor); +00415 <font class="comment">// if not found quit, return true</font> +00416 <font class="keywordflow">if</font>(!vertPtr) +00417 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00418 <font class="comment">// get num verts</font> +00419 numVertices= clod->getNumVertices(); +00420 +00421 <font class="comment">// empty shape??</font> +00422 <font class="keywordflow">if</font>(numVertices==0) +00423 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00424 +00425 <font class="comment">// If too many vertices, quit, returning false.</font> +00426 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a>+numVertices > <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_4">_MaxNumVertices</a>) +00427 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00428 +00429 <font class="comment">// verify colors.</font> +00430 <font class="keywordtype">bool</font> vertexColor= instance.VertexColors.size() == numVertices; +00431 <font class="comment">// if error, take white as global color.</font> +00432 +00433 +00434 <font class="comment">// Transform and Add vertices.</font> +00435 <font class="comment">//=============</font> +00436 +00437 <font class="comment">// Get matrix pos.</font> +00438 CVector matPos= worldMatrix.getPos(); +00439 <font class="comment">// compute in manager space.</font> +00440 matPos -= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_1">_ManagerMatrixPos</a>; +00441 <font class="comment">// Get rotation line vectors</font> +00442 <font class="keywordtype">float</font> <a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>= worldMatrix.get()[0]; <font class="keywordtype">float</font> <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a>= worldMatrix.get()[4]; <font class="keywordtype">float</font> <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>= worldMatrix.get()[8]; +00443 <font class="keywordtype">float</font> <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a>= worldMatrix.get()[1]; <font class="keywordtype">float</font> a11= worldMatrix.get()[5]; <font class="keywordtype">float</font> a12= worldMatrix.get()[9]; +00444 <font class="keywordtype">float</font> <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a>= worldMatrix.get()[2]; <font class="keywordtype">float</font> a21= worldMatrix.get()[6]; <font class="keywordtype">float</font> a22= worldMatrix.get()[10]; +00445 +00446 <font class="comment">// get the light in object space.</font> +00447 CVector lightObjectSpace; +00448 <font class="comment">// Multiply light dir with transpose of worldMatrix. This may be not exact (not uniform scale) but sufficient.</font> +00449 lightObjectSpace.x= <a class="code" href="patch__lightmap_8cpp.html#a0">a00</a> * lightDir.x + <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a> * lightDir.y + <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a> * lightDir.z; +00450 lightObjectSpace.y= <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a> * lightDir.x + a11 * lightDir.y + a21 * lightDir.z; +00451 lightObjectSpace.z= <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a> * lightDir.x + a12 * lightDir.y + a22 * lightDir.z; +00452 <font class="comment">// animation User correction</font> +00453 lightObjectSpace= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>.mulVector(lightObjectSpace); +00454 <font class="comment">// normalize, and neg for Dot Product.</font> +00455 lightObjectSpace.normalize(); +00456 lightObjectSpace= -lightObjectSpace; +00457 +00458 <font class="comment">// multiply matrix with scale factor for Pos.</font> +00459 <a class="code" href="patch__lightmap_8cpp.html#a0">a00</a>*= unPackScaleFactor.x; <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a>*= unPackScaleFactor.y; <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a>*= unPackScaleFactor.z; +00460 <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a>*= unPackScaleFactor.x; a11*= unPackScaleFactor.y; a12*= unPackScaleFactor.z; +00461 <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a>*= unPackScaleFactor.x; a21*= unPackScaleFactor.y; a22*= unPackScaleFactor.z; +00462 +00463 +00464 <font class="comment">// get dst Array.</font> +00465 uint8 *dstPtr; +00466 dstPtr= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_9">_VertexData</a> + <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a> * <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_10">_VertexSize</a>; +00467 +00468 <font class="comment">// 2 modes, with or without per vertexColor</font> +00469 <font class="keywordflow">if</font>(vertexColor) +00470 { +00471 <font class="comment">// get color array</font> +00472 <font class="keyword">const</font> CRGBA *colorPtr= &instance.VertexColors[0]; +00473 <font class="keywordflow">for</font>(;numVertices>0;numVertices--) +00474 { +00475 <font class="comment">// NB: order is important for AGP filling optimisation</font> +00476 <font class="comment">// transform vertex, and store.</font> +00477 CVector *dstVector= (CVector*)dstPtr; +00478 dstVector->x= <a class="code" href="patch__lightmap_8cpp.html#a0">a00</a> * vertPtr->x + <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a> * vertPtr->y + <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a> * vertPtr->z + matPos.x; +00479 dstVector->y= <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a> * vertPtr->x + a11 * vertPtr->y + a12 * vertPtr->z + matPos.y; +00480 dstVector->z= <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a> * vertPtr->x + a21 * vertPtr->y + a22 * vertPtr->z + matPos.z; +00481 <font class="comment">// Copy UV</font> +00482 *(CUV*)(dstPtr + <a class="code" href="lod__character__manager_8cpp.html#a2">NL3D_CLOD_UV_OFF</a>)= *uvPtr; +00483 +00484 <font class="comment">// Compute Lighting.</font> +00485 CRGBA lightRes= <a class="code" href="namespaceNL3D.html#a375">computeLodLighting</a>(lightObjectSpace, *normalPtr, ambient, diffuse); +00486 <font class="comment">// modulate color and store.</font> +00487 ((CRGBA*)(dstPtr + <a class="code" href="lod__character__manager_8cpp.html#a3">NL3D_CLOD_COLOR_OFF</a>))->modulateFromColorRGBOnly(*colorPtr, lightRes); +00488 <font class="comment">// Copy Alpha.</font> +00489 ((CRGBA*)(dstPtr + <a class="code" href="lod__character__manager_8cpp.html#a3">NL3D_CLOD_COLOR_OFF</a>))->A= colorPtr->A; +00490 +00491 <font class="comment">// next</font> +00492 vertPtr++; +00493 uvPtr++; +00494 normalPtr++; +00495 colorPtr++; +00496 dstPtr+= <a class="code" href="lod__character__manager_8cpp.html#a1">NL3D_CLOD_VERTEX_SIZE</a>; +00497 } +00498 } +00499 <font class="keywordflow">else</font> +00500 { +00501 <font class="keywordflow">for</font>(;numVertices>0;numVertices--) +00502 { +00503 <font class="comment">// NB: order is important for AGP filling optimisation</font> +00504 <font class="comment">// transform vertex, and store.</font> +00505 CVector *dstVector= (CVector*)dstPtr; +00506 dstVector->x= <a class="code" href="patch__lightmap_8cpp.html#a0">a00</a> * vertPtr->x + <a class="code" href="patch__lightmap_8cpp.html#a5">a01</a> * vertPtr->y + <a class="code" href="patch__lightmap_8cpp.html#a10">a02</a> * vertPtr->z + matPos.x; +00507 dstVector->y= <a class="code" href="patch__lightmap_8cpp.html#a1">a10</a> * vertPtr->x + a11 * vertPtr->y + a12 * vertPtr->z + matPos.y; +00508 dstVector->z= <a class="code" href="patch__lightmap_8cpp.html#a2">a20</a> * vertPtr->x + a21 * vertPtr->y + a22 * vertPtr->z + matPos.z; +00509 <font class="comment">// Copy UV</font> +00510 *(CUV*)(dstPtr + <a class="code" href="lod__character__manager_8cpp.html#a2">NL3D_CLOD_UV_OFF</a>)= *uvPtr; +00511 +00512 <font class="comment">// Compute Lighting.</font> +00513 CRGBA lightRes= <a class="code" href="namespaceNL3D.html#a375">computeLodLighting</a>(lightObjectSpace, *normalPtr, ambient, diffuse); +00514 lightRes.A= 255; +00515 <font class="comment">// store global color</font> +00516 *(CRGBA*)(dstPtr + <a class="code" href="lod__character__manager_8cpp.html#a3">NL3D_CLOD_COLOR_OFF</a>)= lightRes; +00517 +00518 <font class="comment">// next</font> +00519 vertPtr++; +00520 uvPtr++; +00521 normalPtr++; +00522 dstPtr+= <a class="code" href="lod__character__manager_8cpp.html#a1">NL3D_CLOD_VERTEX_SIZE</a>; +00523 } +00524 } +00525 +00526 +00527 <font class="comment">// Add Primitives.</font> +00528 <font class="comment">//=============</font> +00529 +00530 <font class="comment">// get number of tri indexes</font> +00531 uint numTriIdxs= clod->getNumTriangles() * 3; +00532 +00533 <font class="comment">// realloc tris if needed.</font> +00534 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>+numTriIdxs > <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>.size()) +00535 { +00536 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>.resize(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>+numTriIdxs); +00537 } +00538 +00539 <font class="comment">// reindex and copy tris</font> +00540 <font class="keyword">const</font> uint32 *srcIdx= clod->getTriangleArray(); +00541 uint32 *dstIdx= &<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>[<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>]; +00542 <font class="keywordflow">for</font>(;numTriIdxs>0;numTriIdxs--, srcIdx++, dstIdx++) +00543 { +00544 *dstIdx= *srcIdx + <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a>; +00545 } +00546 +00547 +00548 <font class="comment">// Next</font> +00549 <font class="comment">//=============</font> +00550 +00551 <font class="comment">// Inc Vertex count.</font> +00552 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a>+= clod->getNumVertices(); +00553 <font class="comment">// Inc Prim count.</font> +00554 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>+= clod->getNumTriangles() * 3; +00555 +00556 +00557 <font class="comment">// key added</font> +00558 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00559 } +00560 +00561 <font class="comment">// ***************************************************************************</font> +<a name="l00562"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_4">00562</a> <font class="keywordtype">void</font> CLodCharacterManager::endRender() +00563 { +00564 <a class="code" href="hierarchical__timer_8h.html#a7">H_AUTO_USE</a> ( NL3D_CharacterLod_Render ) +00565 +00566 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>); +00567 <font class="comment">// we must be beewteen beginRender() and endRender()</font> +00568 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_5">isRendering</a>()); +00569 +00570 <font class="comment">// UnLock Buffer.</font> +00571 <font class="keywordflow">if</font>(_VBHard) +00572 { +00573 <font class="comment">// ATI: copy only used vertices.</font> +00574 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>->unlock(0, <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_3">_CurrentVertexId</a>); +00575 } +00576 +00577 <font class="comment">// Render the VBuffer and the primitives.</font> +00578 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>>0) +00579 { +00580 <font class="comment">// setup matrix.</font> +00581 CMatrix managerMatrix; +00582 managerMatrix.setPos(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_1">_ManagerMatrixPos</a>); +00583 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->setupModelMatrix(managerMatrix); +00584 +00585 <font class="comment">// active VB</font> +00586 <font class="keywordflow">if</font>(_VBHard) +00587 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->activeVertexBufferHard(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_7">_VBHard</a>); +00588 <font class="keywordflow">else</font> +00589 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->activeVertexBuffer(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_5">_VBuffer</a>); +00590 +00591 <font class="comment">// render triangles</font> +00592 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_6">_Driver</a>->renderTriangles(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_2">_Material</a>, &<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_13">_Triangles</a>[0], <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_12">_CurrentTriId</a>/3); +00593 } +00594 +00595 <font class="comment">// Ok, end rendering</font> +00596 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_11">_Rendering</a>= <font class="keyword">false</font>; +00597 } +00598 +00599 <font class="comment">// ***************************************************************************</font> +<a name="l00600"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z532_6">00600</a> <font class="keywordtype">void</font> CLodCharacterManager::setupNormalCorrectionMatrix(<font class="keyword">const</font> CMatrix &normalMatrix) +00601 { +00602 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>= normalMatrix; +00603 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>.setPos(CVector::Null); +00604 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z534_14">_LightCorrectionMatrix</a>.invert(); +00605 } +00606 +00607 +00608 <font class="comment">// ***************************************************************************</font> +00609 <font class="comment">// ***************************************************************************</font> +00610 <font class="comment">// Texturing.</font> +00611 <font class="comment">// ***************************************************************************</font> +00612 <font class="comment">// ***************************************************************************</font> +00613 +00614 +00615 <font class="comment">// ***************************************************************************</font> +<a name="l00616"></a><a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a0">00616</a> CLodCharacterTmpBitmap::CLodCharacterTmpBitmap() +00617 { +00618 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a1">reset</a>(); +00619 } +00620 +00621 <font class="comment">// ***************************************************************************</font> +<a name="l00622"></a><a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a1">00622</a> <font class="keywordtype">void</font> CLodCharacterTmpBitmap::reset() +00623 { +00624 <font class="comment">// setup a 1*1 bitmap</font> +00625 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o0">_Bitmap</a>.<a class="code" href="classNLMISC_1_1CObjectVector.html#z301_1">resize</a>(1); +00626 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o0">_Bitmap</a>[0]= CRGBA::Black; +00627 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o1">_WidthPower</a>=0; +00628 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o2">_UShift</a>= 8; +00629 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o3">_VShift</a>= 8; +00630 } +00631 +00632 <font class="comment">// ***************************************************************************</font> +<a name="l00633"></a><a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a2">00633</a> <font class="keywordtype">void</font> CLodCharacterTmpBitmap::build(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CBitmap.html">NLMISC::CBitmap</a> &bmpIn) +00634 { +00635 uint <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>= bmpIn.<a class="code" href="classNLMISC_1_1CBitmap.html#a6">getWidth</a>(); +00636 uint <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>= bmpIn.<a class="code" href="classNLMISC_1_1CBitmap.html#a7">getHeight</a>(); +00637 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>>0 && <a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a><=256); +00638 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>>0 && <a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a><=256); +00639 +00640 <font class="comment">// resize bitmap.</font> +00641 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o0">_Bitmap</a>.<a class="code" href="classNLMISC_1_1CObjectVector.html#z301_1">resize</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>); +00642 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o1">_WidthPower</a>= <a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>); +00643 <font class="comment">// compute shift</font> +00644 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o2">_UShift</a>= 8-<a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a389">width</a>); +00645 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o3">_VShift</a>= 8-<a class="code" href="namespaceNLMISC.html#a224">getPowerOf2</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a390">height</a>); +00646 +00647 <font class="comment">// convert the bitmap.</font> +00648 CBitmap bmp= bmpIn; +00649 bmp.<a class="code" href="classNLMISC_1_1CBitmap.html#a4">convertToType</a>(CBitmap::RGBA); +00650 CRGBA *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>= (CRGBA*)&bmp.getPixels()[0]; +00651 CRGBA *dst= <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o0">_Bitmap</a>.<a class="code" href="classNLMISC_1_1CObjectVector.html#z302_2">getPtr</a>(); +00652 <font class="keywordflow">for</font>(sint nPix= <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>;nPix>0;nPix--, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>++, dst++) +00653 { +00654 *dst= *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00655 } +00656 } +00657 +00658 <font class="comment">// ***************************************************************************</font> +<a name="l00659"></a><a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a3">00659</a> <font class="keywordtype">void</font> CLodCharacterTmpBitmap::build(CRGBA col) +00660 { +00661 <font class="comment">// setup a 1*1 bitmap and set it with col</font> +00662 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#a1">reset</a>(); +00663 <a class="code" href="classNL3D_1_1CLodCharacterTmpBitmap.html#o0">_Bitmap</a>[0]= col; +00664 } +00665 +00666 +00667 <font class="comment">// ***************************************************************************</font> +<a name="l00668"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z533_0">00668</a> <font class="keywordtype">void</font> CLodCharacterManager::initInstance(CLodCharacterInstance &instance) +00669 { +00670 <font class="comment">// first release in (maybe) other manager.</font> +00671 <font class="keywordflow">if</font>(instance._Owner) +00672 instance._Owner->releaseInstance(instance); +00673 +00674 <font class="comment">// get the shape</font> +00675 <font class="keyword">const</font> CLodCharacterShape *clod= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z531_6">getShape</a>(instance.ShapeId); +00676 <font class="comment">// if not found quit</font> +00677 <font class="keywordflow">if</font>(!clod) +00678 <font class="keywordflow">return</font>; +00679 <font class="comment">// get Uvs.</font> +00680 <font class="keyword">const</font> CUV *uvSrc= clod->getUVs(); +00681 <a class="code" href="debug_8h.html#a6">nlassert</a>(uvSrc); +00682 +00683 +00684 <font class="comment">// Ok, init header</font> +00685 instance._Owner= <font class="keyword">this</font>; +00686 instance._UVs.resize(clod->getNumVertices()); +00687 +00688 <font class="comment">// allocate an id. If cannot, then fill Uvs with 0 => filled with Black. (see endTextureCompute() why).</font> +00689 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.empty()) +00690 { +00691 <font class="comment">// set a "Not enough memory" id</font> +00692 instance._TextureId= <a class="code" href="lod__character__manager_8cpp.html#a6">NL3D_CLOD_TEXT_NUM_IDS</a>; +00693 CUV uv(0,0); +00694 fill(instance._UVs.begin(), instance._UVs.end(), uv); +00695 } +00696 <font class="comment">// else OK, can instanciate the Uvs.</font> +00697 <font class="keywordflow">else</font> +00698 { +00699 <font class="comment">// get the id.</font> +00700 instance._TextureId= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.back(); +00701 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.pop_back(); +00702 <font class="comment">// get the x/y.</font> +00703 uint xId= instance._TextureId % <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00704 uint yId= instance._TextureId / <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00705 <font class="comment">// compute the scale/bias to apply to Uvs.</font> +00706 <font class="keywordtype">float</font> scaleU= 1.0f / <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00707 <font class="keywordtype">float</font> scaleV= 1.0f / <a class="code" href="lod__character__manager_8cpp.html#a5">NL3D_CLOD_TEXT_NLOD_HEIGHT</a>; +00708 <font class="keywordtype">float</font> biasU= (float)xId / <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00709 <font class="keywordtype">float</font> biasV= (float)yId / <a class="code" href="lod__character__manager_8cpp.html#a5">NL3D_CLOD_TEXT_NLOD_HEIGHT</a>; +00710 <font class="comment">// apply it to each UVs.</font> +00711 CUV *uvDst= &instance._UVs[0]; +00712 <font class="keywordflow">for</font>(uint i=0; i<instance._UVs.size();i++) +00713 { +00714 uvDst[i].U= biasU + uvSrc[i].U*scaleU; +00715 uvDst[i].V= biasV + uvSrc[i].V*scaleV; +00716 } +00717 } +00718 } +00719 +00720 <font class="comment">// ***************************************************************************</font> +<a name="l00721"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z533_1">00721</a> <font class="keywordtype">void</font> CLodCharacterManager::releaseInstance(CLodCharacterInstance &instance) +00722 { +00723 <font class="keywordflow">if</font>(instance._Owner==NULL) +00724 <font class="keywordflow">return</font>; +00725 <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">this</font>==instance._Owner); +00726 +00727 <font class="comment">// if the id is not a "Not enough memory" id, release it.</font> +00728 <font class="keywordflow">if</font>(instance._TextureId>=0 && instance._TextureId<<a class="code" href="lod__character__manager_8cpp.html#a6">NL3D_CLOD_TEXT_NUM_IDS</a>) +00729 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_2">_FreeIds</a>.push_back(instance._TextureId); +00730 +00731 <font class="comment">// reset the instance</font> +00732 instance._Owner= NULL; +00733 instance._TextureId= -1; +00734 <a class="code" href="namespaceNLMISC.html#a222">contReset</a>(instance._UVs); +00735 } +00736 +00737 +00738 <font class="comment">// ***************************************************************************</font> +<a name="l00739"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_0">00739</a> CRGBA *CLodCharacterManager::getTextureInstance(CLodCharacterInstance &instance) +00740 { +00741 <a class="code" href="debug_8h.html#a6">nlassert</a>(instance._Owner==<font class="keyword">this</font>); +00742 <a class="code" href="debug_8h.html#a6">nlassert</a>(instance._TextureId!=-1); +00743 <font class="comment">// if the texture id is a "not enough memory", quit.</font> +00744 <font class="keywordflow">if</font>(instance._TextureId==<a class="code" href="lod__character__manager_8cpp.html#a6">NL3D_CLOD_TEXT_NUM_IDS</a>) +00745 <font class="keywordflow">return</font> NULL; +00746 +00747 <font class="comment">// get the x/y.</font> +00748 uint xId= instance._TextureId % <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00749 uint yId= instance._TextureId / <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00750 +00751 <font class="comment">// get the ptr on the correct pixel.</font> +00752 CRGBA *pix= (CRGBA*)&<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->getPixels(0)[0]; +00753 <font class="keywordflow">return</font> pix + yId*<a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>*<a class="code" href="lod__character__manager_8cpp.html#a7">NL3D_CLOD_BIGTEXT_WIDTH</a> + xId*<a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>; +00754 } +00755 +00756 +00757 <font class="comment">// ***************************************************************************</font> +<a name="l00758"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z533_2">00758</a> <font class="keywordtype">bool</font> CLodCharacterManager::startTextureCompute(CLodCharacterInstance &instance) +00759 { +00760 CRGBA *dst= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_0">getTextureInstance</a>(instance); +00761 <font class="keywordflow">if</font>(!dst) +00762 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00763 +00764 <font class="comment">// erase the texture with 0,0,0,255. Alpha is actually the min "Quality" part of the CTUVQ.</font> +00765 CRGBA col= <a class="code" href="lod__character__manager_8cpp.html#a9">NL3D_CLOD_DEFAULT_TEXCOLOR</a>; +00766 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +00767 { +00768 <font class="comment">// erase the line</font> +00769 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +00770 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= col; +00771 <font class="comment">// Next line</font> +00772 dst+= <a class="code" href="lod__character__manager_8cpp.html#a7">NL3D_CLOD_BIGTEXT_WIDTH</a>; +00773 } +00774 +00775 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00776 } +00777 +00778 <font class="comment">// ***************************************************************************</font> +<a name="l00779"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z533_4">00779</a> <font class="keywordtype">void</font> CLodCharacterManager::addTextureCompute(CLodCharacterInstance &instance, <font class="keyword">const</font> CLodCharacterTexture &lodTexture) +00780 { +00781 CRGBA *dst= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_0">getTextureInstance</a>(instance); +00782 <font class="keywordflow">if</font>(!dst) +00783 <font class="keywordflow">return</font>; +00784 +00785 <font class="comment">// get lookup ptr.</font> +00786 <a class="code" href="debug_8h.html#a6">nlassert</a>(lodTexture.Texture.size()==<a class="code" href="lod__character__texture_8h.html#a2">NL3D_CLOD_TEXT_SIZE</a>); +00787 <font class="keyword">const</font> CLodCharacterTexture::CTUVQ *lookUpPtr= &lodTexture.Texture[0]; +00788 +00789 <font class="comment">// apply the lodTexture, taking only better quality (ie nearer 0)</font> +00790 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +00791 { +00792 <font class="comment">// erase the line</font> +00793 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +00794 { +00795 CLodCharacterTexture::CTUVQ lut= *lookUpPtr; +00796 <font class="comment">// if this quality is better than the one stored</font> +00797 <font class="keywordflow">if</font>(lut.Q<dst[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>].A) +00798 { +00799 <font class="comment">// get what texture to read, and read the pixel.</font> +00800 CRGBA col= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_3">_TmpBitmaps</a>[lut.T].getPixel(lut.U, lut.V); +00801 <font class="comment">// set quality.</font> +00802 col.A= lut.Q; +00803 <font class="comment">// set in dest</font> +00804 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>]= col; +00805 } +00806 +00807 <font class="comment">// next lookup</font> +00808 lookUpPtr++; +00809 } +00810 <font class="comment">// Next line</font> +00811 dst+= <a class="code" href="lod__character__manager_8cpp.html#a7">NL3D_CLOD_BIGTEXT_WIDTH</a>; +00812 } +00813 } +00814 +00815 <font class="comment">// ***************************************************************************</font> +<a name="l00816"></a><a class="code" href="classNL3D_1_1CLodCharacterManager.html#z533_5">00816</a> <font class="keywordtype">void</font> CLodCharacterManager::endTextureCompute(CLodCharacterInstance &instance, uint numBmpToReset) +00817 { +00818 CRGBA *dst= <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_0">getTextureInstance</a>(instance); +00819 <font class="keywordflow">if</font>(!dst) +00820 <font class="keywordflow">return</font>; +00821 +00822 <font class="comment">// reset All Alpha values to 255 => no AlphaTest problems</font> +00823 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a><<a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a365">y</a>++) +00824 { +00825 <font class="comment">// erase the line</font> +00826 <font class="keywordflow">for</font>(uint <a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a><<a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>++) +00827 { +00828 dst[<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a>].A= 255; +00829 } +00830 <font class="comment">// Next line</font> +00831 dst+= <a class="code" href="lod__character__manager_8cpp.html#a7">NL3D_CLOD_BIGTEXT_WIDTH</a>; +00832 } +00833 +00834 <font class="comment">// If the id == 0 then must reset the 0,0 Pixel to black. for the "Not Enough memory" case in initInstance().</font> +00835 <font class="keywordflow">if</font>(instance._TextureId==0) +00836 *(CRGBA*)&<a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->getPixels(0)[0]= <a class="code" href="lod__character__manager_8cpp.html#a9">NL3D_CLOD_DEFAULT_TEXCOLOR</a>; +00837 +00838 <font class="comment">// get the x/y.</font> +00839 uint xId= instance._TextureId % <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00840 uint yId= instance._TextureId / <a class="code" href="lod__character__manager_8cpp.html#a4">NL3D_CLOD_TEXT_NLOD_WIDTH</a>; +00841 <font class="comment">// touch the texture for Driver update.</font> +00842 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_1">_BigTexture</a>->touchRect( +00843 CRect(xId*<a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>, yId*<a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>, <a class="code" href="lod__character__texture_8h.html#a0">NL3D_CLOD_TEXT_WIDTH</a>, <a class="code" href="lod__character__texture_8h.html#a1">NL3D_CLOD_TEXT_HEIGHT</a>) ); +00844 +00845 <font class="comment">// reset tmpBitmaps / free memory.</font> +00846 <font class="keywordflow">for</font>(uint i=0; i<numBmpToReset; i++) +00847 { +00848 <a class="code" href="classNL3D_1_1CLodCharacterManager.html#z535_3">_TmpBitmaps</a>[i].reset(); +00849 } +00850 +00851 <font class="comment">// TestYoyo</font> +00852 <font class="comment">/*NLMISC::COFile f("tam.tga");</font> +00853 <font class="comment"> _BigTexture->writeTGA(f,32);*/</font> +00854 } +00855 +00856 +00857 } <font class="comment">// NL3D</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |