diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html | 419 |
1 files changed, 419 insertions, 0 deletions
diff --git a/docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html b/docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html new file mode 100644 index 00000000..7f6d4552 --- /dev/null +++ b/docs/doxygen/nel/meshvp__wind__tree_8cpp-source.html @@ -0,0 +1,419 @@ +<!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>meshvp_wind_tree.cpp</h1><a href="meshvp__wind__tree_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="meshvp__wind__tree_8h.html">3d/meshvp_wind_tree.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="mesh__base__instance_8h.html">3d/mesh_base_instance.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00032 <font class="preprocessor">#include <math.h></font> +00033 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font> +00034 <font class="preprocessor">#include "<a class="code" href="render__trav_8h.html">3d/render_trav.h</a>"</font> +00035 +00036 +00037 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00038 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00039 +00040 +00041 <font class="keyword">namespace </font>NL3D +00042 { +00043 +00044 +00045 <font class="comment">// ***************************************************************************</font> +00046 <font class="comment">// Light VP fragment constants start at 24</font> +00047 <font class="keyword">static</font> <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a145">VPLightConstantStart</a>= 24; +00048 +00049 +00050 <font class="comment">// ***************************************************************************</font> +<a name="l00051"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#r0">00051</a> std::auto_ptr<CVertexProgram> CMeshVPWindTree::_VertexProgram[CMeshVPWindTree::NumVp]; +00052 +00053 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>* <a class="code" href="namespaceNL3D.html#a155">WindTreeVPCodeWave</a>= +00054 <font class="stringliteral">"!!VP1.0 \n\</font> +00055 <font class="stringliteral"> # extract from color.R the 3 factors into R0.xyz \n\</font> +00056 <font class="stringliteral"> MAD R0, v[3].x, c[9].x, c[9].yzww; # col.R*3 \n\</font> +00057 <font class="stringliteral"> MIN R0, R0, c[8].yyyy; # clamp each to 0,1 \n\</font> +00058 <font class="stringliteral"> MAX R0, R0, c[8].xxxx; \n\</font> +00059 <font class="stringliteral"> \n\</font> +00060 <font class="stringliteral"> # Add influence of Bone Level1 \n\</font> +00061 <font class="stringliteral"> MAD R5, c[15], R0.x, v[0]; \n\</font> +00062 <font class="stringliteral"> \n\</font> +00063 <font class="stringliteral"> # Sample LevelPhase into R7.yz: 0 to 3. \n\</font> +00064 <font class="stringliteral"> MUL R7, v[3].xyzw, c[10].x; \n\</font> +00065 <font class="stringliteral"> \n\</font> +00066 <font class="stringliteral"> # Add influence of Bone Level2 \n\</font> +00067 <font class="stringliteral"> ARL A0.x, R7.y; \n\</font> +00068 <font class="stringliteral"> MAD R5, c[A0.x+16], R0.y, R5; \n\</font> +00069 <font class="stringliteral"> \n\</font> +00070 <font class="stringliteral"> # Add influence of Bone Level3 \n\</font> +00071 <font class="stringliteral"> ARL A0.x, R7.z; \n\</font> +00072 <font class="stringliteral"> MAD R5, c[A0.x+20], R0.z, R5; \n\</font> +00073 <font class="stringliteral"> \n\</font> +00074 <font class="stringliteral"> # Get normal in R6 for lighting. \n\</font> +00075 <font class="stringliteral"> MOV R6, v[2]; \n\</font> +00076 <font class="stringliteral">"</font>; +00077 +00078 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>* <a class="code" href="namespaceNL3D.html#a156">WindTreeVPCodeEnd</a>= +00079 <font class="stringliteral">" # compute in Projection space \n\</font> +00080 <font class="stringliteral"> DP4 o[HPOS].x, c[0], R5; \n\</font> +00081 <font class="stringliteral"> DP4 o[HPOS].y, c[1], R5; \n\</font> +00082 <font class="stringliteral"> DP4 o[HPOS].z, c[2], R5; \n\</font> +00083 <font class="stringliteral"> DP4 o[HPOS].w, c[3], R5; \n\</font> +00084 <font class="stringliteral"> MOV o[TEX0].xy, v[8]; \n\</font> +00085 <font class="stringliteral"> MOV o[TEX1].xy, v[9]; \n\</font> +00086 <font class="stringliteral"> DP4 o[FOGC].x, c[6], -R5; # fogc>0 => fogc= - (ModelView*R1).z \n\</font> +00087 <font class="stringliteral"> END \n\</font> +00088 <font class="stringliteral">"</font>; +00089 +00090 +00091 <font class="comment">// ***************************************************************************</font> +<a name="l00092"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">00092</a> <font class="keywordtype">float</font> CMeshVPWindTree::speedCos(<font class="keywordtype">float</font> angle) +00093 { +00094 <font class="comment">// \todo yoyo TODO_OPTIM</font> +00095 <font class="keywordflow">return</font> cosf(angle * 2*(<font class="keywordtype">float</font>)<a class="code" href="namespaceNLMISC.html#a7">Pi</a>); +00096 } +00097 +00098 +00099 <font class="comment">// ***************************************************************************</font> +<a name="l00100"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#a0">00100</a> CMeshVPWindTree::CMeshVPWindTree() +00101 { +00102 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>; i++) +00103 { +00104 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_0">Frequency</a>[i]= 1; +00105 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_1">FrequencyWindFactor</a>[i]= 0; +00106 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_2">PowerXY</a>[i]= 0; +00107 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_3">PowerZ</a>[i]= 0; +00108 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[i]= 0; +00109 <font class="comment">// Init currentTime.</font> +00110 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[i]= 0; +00111 } +00112 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_5">SpecularLighting</a>= <font class="keyword">false</font>; +00113 +00114 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o1">_LastSceneTime</a>= 0; +00115 } +00116 +00117 +00118 <font class="comment">// ***************************************************************************</font> +<a name="l00119"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#a1">00119</a> CMeshVPWindTree::~CMeshVPWindTree() +00120 { +00121 } +00122 +00123 +00124 <font class="comment">// ***************************************************************************</font> +<a name="l00125"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_5">00125</a> <font class="keywordtype">void</font> CMeshVPWindTree::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00126 { +00127 (void)f.serialVersion(0); +00128 +00129 <a class="code" href="debug_8h.html#a6">nlassert</a>(HrcDepth==3); +00130 <font class="keywordflow">for</font>(uint i=0; i<HrcDepth; i++) +00131 { +00132 f.serial(Frequency[i]); +00133 f.serial(FrequencyWindFactor[i]); +00134 f.serial(PowerXY[i]); +00135 f.serial(PowerZ[i]); +00136 f.serial(Bias[i]); +00137 } +00138 f.serial(SpecularLighting); +00139 } +00140 +00141 +00142 <font class="comment">// ***************************************************************************</font> +<a name="l00143"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_0">00143</a> <font class="keywordtype">void</font> CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi) +00144 { +00145 <font class="comment">// init the vertexProgram code.</font> +00146 <font class="keyword">static</font> <font class="keywordtype">bool</font> vpCreated= <font class="keyword">false</font>; +00147 <font class="keywordflow">if</font>(!vpCreated) +00148 { +00149 vpCreated= <font class="keyword">true</font>; +00150 <font class="comment">// All vpcode and begin() written for HrcDepth==3</font> +00151 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>==3); +00152 +00153 <font class="comment">// combine fragments.</font> +00154 string vpCode; +00155 +00156 <font class="comment">// For all possible VP.</font> +00157 <font class="keywordflow">for</font>(uint i=0;i<<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#u1u0">NumVp</a>;i++) +00158 { +00159 <font class="comment">// setup of the VPLight fragment</font> +00160 uint numPls= i/4; +00161 <font class="keywordtype">bool</font> normalize= (i&1)!=0; +00162 <font class="keywordtype">bool</font> specular= (i&2)!=0; +00163 +00164 <font class="comment">// combine fragments</font> +00165 vpCode= string(<a class="code" href="namespaceNL3D.html#a155">WindTreeVPCodeWave</a>) +00166 + CRenderTrav::getLightVPFragment(numPls, <a class="code" href="namespaceNL3D.html#a145">VPLightConstantStart</a>, specular, normalize) +00167 + <a class="code" href="namespaceNL3D.html#a156">WindTreeVPCodeEnd</a>; +00168 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#r0">_VertexProgram</a>[i]= std::auto_ptr<CVertexProgram>(<font class="keyword">new</font> CVertexProgram(vpCode.c_str())); +00169 } +00170 } +00171 +00172 <font class="comment">// init a random phase.</font> +00173 mbi->_VPWindTreePhase= <a class="code" href="namespaceNLMISC.html#a212">frand</a>(1); +00174 } +00175 <font class="comment">// ***************************************************************************</font> +<a name="l00176"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_1">00176</a> <font class="keywordtype">bool</font> CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &invertedModelMat, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> & <font class="comment">/*viewerPos*/</font>) +00177 { +00178 <font class="keywordflow">if</font> (!(driver->isVertexProgramSupported() && !driver->isVertexProgramEmulated())) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00179 +00180 +00181 <font class="comment">// precompute mesh/instance.</font> +00182 <font class="comment">//===============</font> +00183 +00184 +00185 <font class="comment">// Get info from scene/instance</font> +00186 <font class="keywordtype">float</font> windPower= scene->getGlobalWindPower(); +00187 <font class="keywordtype">float</font> instancePhase= mbi->_VPWindTreePhase; +00188 +00189 +00190 <font class="comment">// process current times and current power. Only one time per render() and per CMeshVPWindTree.</font> +00191 <font class="keywordflow">if</font>(scene->getCurrentTime() != <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o1">_LastSceneTime</a>) +00192 { +00193 <font class="keywordtype">float</font> dt= (float)(scene->getCurrentTime() - <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o1">_LastSceneTime</a>); +00194 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o1">_LastSceneTime</a>= scene->getCurrentTime(); +00195 +00196 <font class="comment">// Update each boneLevel time according to frequency.</font> +00197 uint i; +00198 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>; i++) +00199 { +00200 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[i]+= dt*(<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_0">Frequency</a>[i] + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_1">FrequencyWindFactor</a>[i]*windPower); +00201 <font class="comment">// get it between 0 and 1. Important for float precision problems.</font> +00202 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[i]= (float)fmod(<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[i], 1); +00203 } +00204 +00205 <font class="comment">// Update each boneLevel maximum amplitude vector.</font> +00206 <font class="keywordflow">for</font>(i=0; i<<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>; i++) +00207 { +00208 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o2">_MaxDeltaPos</a>[i]= scene->getGlobalWindDirection() * <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_2">PowerXY</a>[i] * windPower; +00209 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o2">_MaxDeltaPos</a>[i].z= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_3">PowerZ</a>[i] * windPower; +00210 } +00211 } +00212 +00213 +00214 <font class="comment">// maxDeltaPos in ObjectSpace. So same world Wind direction is applied to all objects</font> +00215 <font class="keyword">static</font> CMatrix invWorldMatrix; +00216 <font class="comment">// Keep only rotation part. (just need it and faster invert)</font> +00217 invWorldMatrix.setRot(mbi->getWorldMatrix()); +00218 invWorldMatrix.invert(); +00219 <font class="keyword">static</font> CVector maxDeltaPosOS[<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>]; +00220 <font class="keywordflow">for</font>(uint i=0; i<<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#s1s0">HrcDepth</a>; i++) +00221 { +00222 maxDeltaPosOS[i]= invWorldMatrix.mulVector(<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o2">_MaxDeltaPos</a>[i]); +00223 } +00224 +00225 +00226 <font class="comment">// Setup constants</font> +00227 <font class="comment">//===============</font> +00228 +00229 <font class="comment">// Setup lighting and lighting constants</font> +00230 <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#c0">setupLighting</a>(scene, mbi, invertedModelMat); +00231 +00232 <font class="comment">// c[0..3] take the ModelViewProjection Matrix. After setupModelMatrix();</font> +00233 driver->setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity); +00234 <font class="comment">// c[4..7] take the ModelView Matrix. After setupModelMatrix();</font> +00235 driver->setConstantMatrix(4, IDriver::ModelView, IDriver::Identity); +00236 <font class="comment">// c[8] take usefull constants.</font> +00237 <font class="keyword">static</font> <font class="keywordtype">float</font> ct8[4]= {0, 1, 0.5f, 2}; +00238 driver->setConstant(8, 1, ct8); +00239 <font class="comment">// c[9] take other usefull constants.</font> +00240 <font class="keyword">static</font> <font class="keywordtype">float</font> ct9[4]= {3.f, 0.f, -1.f, -2.f}; +00241 driver->setConstant(9, 1, ct9); +00242 <font class="comment">// c[10] take Number of phase (4) for level2 and 3. -0.01 to avoid int value == 4.</font> +00243 <font class="keyword">static</font> <font class="keywordtype">float</font> ct10[4]= {4-0.01f, 0, 0, 0}; +00244 driver->setConstant(10, 1, ct10); +00245 +00246 +00247 <font class="comment">// c[15] take Wind of level 0.</font> +00248 <font class="keywordtype">float</font> f; +00249 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[0] + instancePhase; +00250 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>(f) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[0]; +00251 driver->setConstant(15, maxDeltaPosOS[0]*f ); +00252 +00253 +00254 <font class="comment">// c[16-19] take Wind of level 1.</font> +00255 <font class="comment">// Unrolled. </font> +00256 <font class="keywordtype">float</font> instTime1= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[1] + instancePhase; +00257 <font class="comment">// phase 0.</font> +00258 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime1+0 ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[1]; +00259 driver->setConstant(16+0, maxDeltaPosOS[1]*f); +00260 <font class="comment">// phase 1.</font> +00261 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime1+0.25f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[1]; +00262 driver->setConstant(16+1, maxDeltaPosOS[1]*f); +00263 <font class="comment">// phase 2.</font> +00264 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime1+0.50f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[1]; +00265 driver->setConstant(16+2, maxDeltaPosOS[1]*f); +00266 <font class="comment">// phase 3.</font> +00267 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime1+0.75f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[1]; +00268 driver->setConstant(16+3, maxDeltaPosOS[1]*f); +00269 +00270 +00271 <font class="comment">// c[20, 23] take Wind of level 2.</font> +00272 <font class="comment">// Unrolled. </font> +00273 <font class="keywordtype">float</font> instTime2= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#o0">_CurrentTime</a>[2] + instancePhase; +00274 <font class="comment">// phase 0.</font> +00275 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime2+0 ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[2]; +00276 driver->setConstant(20+0, maxDeltaPosOS[2]*f); +00277 <font class="comment">// phase 1.</font> +00278 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime2+0.25f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[2]; +00279 driver->setConstant(20+1, maxDeltaPosOS[2]*f); +00280 <font class="comment">// phase 2.</font> +00281 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime2+0.50f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[2]; +00282 driver->setConstant(20+2, maxDeltaPosOS[2]*f); +00283 <font class="comment">// phase 3.</font> +00284 f= <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#f0">speedCos</a>( instTime2+0.75f ) + <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_4">Bias</a>[2]; +00285 driver->setConstant(20+3, maxDeltaPosOS[2]*f); +00286 +00287 +00288 <font class="comment">// Activate the good VertexProgram</font> +00289 <font class="comment">//===============</font> +00290 +00291 <font class="comment">// Get how many pointLights are setuped now.</font> +00292 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene != NULL); +00293 CRenderTrav *renderTrav= scene->getRenderTrav(); +00294 sint numPls= renderTrav->getNumVPLights()-1; +00295 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(numPls, 0, CRenderTrav::MaxVPLight-1); +00296 +00297 <font class="comment">// Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting"</font> +00298 uint idVP= (<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_5">SpecularLighting</a>?2:0) + (driver->isForceNormalize()?1:0) ; +00299 <font class="comment">// correct VP id for correct unmber of pls.</font> +00300 idVP= numPls*4 + idVP; +00301 +00302 <font class="comment">// activate VP.</font> +00303 driver->activeVertexProgram(<a class="code" href="classNL3D_1_1CMeshVPWindTree.html#r0">_VertexProgram</a>[idVP].get()); +00304 +00305 +00306 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00307 } +00308 <font class="comment">// ***************************************************************************</font> +<a name="l00309"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_2">00309</a> <font class="keywordtype">void</font> CMeshVPWindTree::end(IDriver *driver) +00310 { +00311 <font class="comment">// Disable the VertexProgram</font> +00312 driver->activeVertexProgram(NULL); +00313 } +00314 +00315 <font class="comment">// ***************************************************************************</font> +00316 <font class="comment">// tool fct</font> +00317 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a382">SetupForMaterial</a>(<font class="keyword">const</font> CMaterial &mat, CScene *scene) +00318 { +00319 CRenderTrav *renderTrav= scene->getRenderTrav(); +00320 renderTrav->changeVPLightSetupMaterial(mat, <font class="keyword">false</font> <font class="comment">/* don't exclude strongest */</font>); +00321 } +00322 +00323 <font class="comment">// ***************************************************************************</font> +<a name="l00324"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_3">00324</a> <font class="keywordtype">void</font> CMeshVPWindTree::setupForMaterial(<font class="keyword">const</font> CMaterial &mat, +00325 IDriver *drv, +00326 CScene *scene, +00327 CVertexBuffer *) +00328 { +00329 <a class="code" href="namespaceNL3D.html#a382">SetupForMaterial</a>(mat, scene); +00330 } +00331 +00332 <font class="comment">// ***************************************************************************</font> +<a name="l00333"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z611_4">00333</a> <font class="keywordtype">void</font> CMeshVPWindTree::setupForMaterial(<font class="keyword">const</font> CMaterial &mat, +00334 IDriver *drv, +00335 CScene *scene, +00336 IVertexBufferHard *vb) +00337 { +00338 <a class="code" href="namespaceNL3D.html#a382">SetupForMaterial</a>(mat, scene); +00339 } +00340 +00341 <font class="comment">// ***************************************************************************</font> +<a name="l00342"></a><a class="code" href="classNL3D_1_1CMeshVPWindTree.html#c0">00342</a> <font class="keywordtype">void</font> CMeshVPWindTree::setupLighting(CScene *scene, CMeshBaseInstance *mbi, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &invertedModelMat) +00343 { +00344 <a class="code" href="debug_8h.html#a6">nlassert</a>(scene != NULL); +00345 CRenderTrav *renderTrav= scene->getRenderTrav(); +00346 <font class="comment">// setup cte for lighting</font> +00347 renderTrav->beginVPLightSetup(<a class="code" href="namespaceNL3D.html#a145">VPLightConstantStart</a>, <a class="code" href="classNL3D_1_1CMeshVPWindTree.html#z610_5">SpecularLighting</a>, invertedModelMat); +00348 } +00349 +00350 } <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> |