diff options
Diffstat (limited to 'docs/doxygen/nel/ps__face__look__at_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/ps__face__look__at_8cpp-source.html | 649 |
1 files changed, 649 insertions, 0 deletions
diff --git a/docs/doxygen/nel/ps__face__look__at_8cpp-source.html b/docs/doxygen/nel/ps__face__look__at_8cpp-source.html new file mode 100644 index 00000000..77430ae5 --- /dev/null +++ b/docs/doxygen/nel/ps__face__look__at_8cpp-source.html @@ -0,0 +1,649 @@ +<!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>ps_face_look_at.cpp</h1><a href="ps__face__look__at_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="ps__face__look__at_8h.html">3d/ps_face_look_at.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="ps__macro_8h.html">3d/ps_macro.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="ps__iterator_8h.html">3d/ps_iterator.h</a>"</font> +00033 +00034 +00035 <font class="keyword">namespace </font>NL3D +00036 { +00037 +00038 +00039 +00041 <font class="comment">// CPSFaceLookAt implementation //</font> +00043 <font class="comment"></font> +00044 +<a name="l00050"></a><a class="code" href="classNL3D_1_1CPSFaceLookAtHelper.html">00050</a> <font class="keyword">class </font>CPSFaceLookAtHelper +00051 { +00052 <font class="keyword">public</font>: +00053 <font class="keyword">template</font> <<font class="keyword">class</font> T> +<a name="l00054"></a><a class="code" href="classNL3D_1_1CPSFaceLookAtHelper.html#d0">00054</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classNL3D_1_1CPSFaceLookAtHelper.html#d0">drawLookAt</a>(T it, T speedIt, CPSFaceLookAt &la, uint size, uint32 srcStep) +00055 { +00056 PARTICLES_CHECK_MEM; +00057 <a class="code" href="debug_8h.html#a6">nlassert</a>(la._Owner); +00058 IDriver *driver = la.getDriver(); +00059 +00060 la.updateMatBeforeRendering(driver); +00061 +00062 CVertexBuffer &vb = la.getNeededVB(); +00063 la._Owner->incrementNbDrawnParticles(size); <font class="comment">// for benchmark purpose </font> +00064 la.setupDriverModelMatrix(); +00065 driver->activeVertexBuffer(vb); +00066 <font class="keyword">const</font> CVector I = la.computeI(); +00067 <font class="keyword">const</font> CVector J = la.computeJ(); +00068 <font class="keyword">const</font> CVector K = la.computeK(); +00069 <font class="keyword">const</font> <font class="keywordtype">float</font> *rotTable = CPSRotated2DParticle::getRotTable(); +00070 <font class="comment">// for each the particle can be constantly rotated or have an independant rotation for each particle</font> +00071 <font class="comment">// number of face left, and number of face to process at once</font> +00072 uint32 leftToDo = size, toProcess; +00073 <font class="keywordtype">float</font> pSizes[CPSQuad::quadBufSize]; <font class="comment">// the sizes to use </font> +00074 <font class="keywordtype">float</font> pSecondSizes[CPSQuad::quadBufSize]; <font class="comment">// the second sizes to use</font> +00075 <font class="keywordtype">float</font> *currentSize; +00076 uint32 currentSizeStep = la._SizeScheme ? 1 : 0; +00077 <font class="comment">// point the vector part in the current vertex</font> +00078 uint8 *ptPos; +00079 <font class="comment">// strides to go from one vertex to another one</font> +00080 <font class="keyword">const</font> uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> = vb.getVertexSize(), stride2 = <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> << 1, stride3 = <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> + stride2, stride4 = <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> << 2; +00081 <font class="keywordflow">if</font> (!la._Angle2DScheme) +00082 { +00083 <font class="comment">// constant rotation case</font> +00084 <font class="keywordflow">do</font> +00085 { +00086 <font class="comment">// restart at the beginning of the vertex buffer</font> +00087 ptPos = (uint8 *) vb.getVertexCoordPointer(); +00088 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00089 +00090 <font class="keywordflow">if</font> (la._SizeScheme) +00091 { +00092 currentSize = (<font class="keywordtype">float</font> *) la._SizeScheme->make(la._Owner, size- leftToDo, pSizes, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00093 } +00094 <font class="keywordflow">else</font> +00095 { +00096 currentSize = &la._ParticleSize; +00097 } +00098 +00099 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00100 T endIt = it + toProcess; +00101 <font class="keywordflow">if</font> (la._MotionBlurCoeff == 0.f) +00102 { +00103 <font class="keywordflow">if</font> (!la._IndependantSizes) +00104 { +00105 <font class="keyword">const</font> uint32 tabIndex = (((uint32) la._Angle2D) & 0xff) << 2; +00106 <font class="keyword">const</font> CVector v1 = rotTable[tabIndex] * I + rotTable[tabIndex + 1] * K; +00107 <font class="keyword">const</font> CVector v2 = rotTable[tabIndex + 2] * I + rotTable[tabIndex + 3] * K; +00108 <font class="keywordflow">if</font> (currentSizeStep) +00109 { +00110 <font class="keywordflow">while</font> (it != endIt) +00111 { +00112 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00113 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x; +00114 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y; +00115 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z; +00116 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00117 +00118 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00119 ((CVector *) ptPos)->x = (*it).x + *currentSize * v2.x; +00120 ((CVector *) ptPos)->y = (*it).y + *currentSize * v2.y; +00121 ((CVector *) ptPos)->z = (*it).z + *currentSize * v2.z; +00122 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00123 +00124 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00125 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x; +00126 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y; +00127 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z; +00128 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00129 +00130 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00131 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00132 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00133 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00134 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00135 +00136 ++it; +00137 currentSize += currentSizeStep; +00138 } +00139 } +00140 <font class="keywordflow">else</font> +00141 { +00142 <font class="comment">// constant size</font> +00143 <font class="keyword">const</font> CVector myV1 = *currentSize * v1; +00144 <font class="keyword">const</font> CVector myV2 = *currentSize * v2; +00145 +00146 <font class="keywordflow">while</font> (it != endIt) +00147 { +00148 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00149 ((CVector *) ptPos)->x = (*it).x + myV1.x; +00150 ((CVector *) ptPos)->y = (*it).y + myV1.y; +00151 ((CVector *) ptPos)->z = (*it).z + myV1.z; +00152 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00153 +00154 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00155 ((CVector *) ptPos)->x = (*it).x + myV2.x; +00156 ((CVector *) ptPos)->y = (*it).y + myV2.y; +00157 ((CVector *) ptPos)->z = (*it).z + myV2.z; +00158 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00159 +00160 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00161 ((CVector *) ptPos)->x = (*it).x - myV1.x; +00162 ((CVector *) ptPos)->y = (*it).y - myV1.y; +00163 ((CVector *) ptPos)->z = (*it).z - myV1.z; +00164 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00165 +00166 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00167 ((CVector *) ptPos)->x = (*it).x - myV2.x; +00168 ((CVector *) ptPos)->y = (*it).y - myV2.y; +00169 ((CVector *) ptPos)->z = (*it).z - myV2.z; +00170 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00171 ++it; +00172 } +00173 } +00174 } +00175 <font class="keywordflow">else</font> <font class="comment">// independant sizes</font> +00176 { +00177 <font class="keyword">const</font> CVector v1 = CPSUtil::getCos((sint32) la._Angle2D) * I + CPSUtil::getSin((sint32) la._Angle2D) * K; +00178 <font class="keyword">const</font> CVector v2 = - CPSUtil::getSin((sint32) la._Angle2D) * I + CPSUtil::getCos((sint32) la._Angle2D) * K; +00179 +00180 <font class="keywordtype">float</font> *currentSize2; +00181 <font class="keywordtype">float</font> secondSize; +00182 uint32 currentSizeStep2; +00183 <font class="keywordflow">if</font> (la._SecondSize.getSizeScheme()) +00184 { +00185 currentSize2 = (<font class="keywordtype">float</font> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00186 currentSizeStep2 = 1; +00187 } +00188 <font class="keywordflow">else</font> +00189 { +00190 secondSize = la._SecondSize.getSize(); +00191 currentSize2 = &secondSize; +00192 currentSizeStep2 = 0; +00193 } +00194 +00195 +00196 <font class="keywordflow">while</font> (it != endIt) +00197 { +00198 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00199 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00200 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00201 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00202 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00203 +00204 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00205 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00206 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00207 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00208 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00209 +00210 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00211 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00212 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00213 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00214 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00215 +00216 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00217 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00218 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00219 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00220 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00221 ++it; +00222 currentSize += currentSizeStep; +00223 currentSize2 += currentSizeStep2; +00224 } +00225 } +00226 } +00227 <font class="keywordflow">else</font> +00228 { +00229 <font class="comment">// perform motion, blur, we need an iterator on speed</font> +00230 <font class="comment">// independant sizes and rotation not supported for now with motion blur </font> +00231 <font class="keyword">const</font> CVector v1 = I + K; +00232 <font class="keyword">const</font> CVector v2 = K - I; +00233 CVector startV, endV, mbv1, mbv1n, mbv12, mbv2; +00234 <font class="comment">// norme of the v1 vect</font> +00235 <font class="keywordtype">float</font> n; +00236 <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 10E-5f; +00237 <font class="keyword">const</font> <font class="keywordtype">float</font> normEpsilon = 10E-6f; +00238 +00239 CMatrix tMat = la._Owner->isInSystemBasis() ? la.getViewMat() * la.getSysMat() +00240 : la.getViewMat(); +00241 +00242 <font class="keywordflow">while</font> (it != endIt) +00243 { +00244 <font class="comment">// project the speed in the projection plane</font> +00245 <font class="comment">// this give us the v1 vect</font> +00246 startV = tMat * *it ; +00247 endV = tMat * (*it + *speedIt); +00248 <font class="keywordflow">if</font> (startV.y > epsilon || endV.y > epsilon) +00249 { +00250 <font class="keywordflow">if</font> (startV.y < epsilon) +00251 { +00252 <font class="keywordflow">if</font> (fabsf(endV.y - startV.y) > normEpsilon) +00253 { +00254 startV = endV + (endV.y - epsilon) / (endV.y - startV.y) * (startV - endV); +00255 } +00256 startV.y = epsilon; +00257 } +00258 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (endV.y < epsilon) +00259 { +00260 <font class="keywordflow">if</font> (fabsf(endV.y - startV.y) > normEpsilon) +00261 { +00262 endV = startV + (startV.y - epsilon) / (startV.y - endV.y) * (endV - startV); +00263 } +00264 endV.y = epsilon; +00265 } +00266 +00267 mbv1 = (startV.x / startV.y - endV.x / endV.y) * I +00268 + (startV.z / startV.y - endV.z / endV.y) * K ; +00269 +00270 n = mbv1.norm(); +00271 <font class="keywordflow">if</font> (n > la._Threshold) +00272 { +00273 mbv1 *= la._Threshold / n; +00274 n = la._Threshold; +00275 } +00276 <font class="keywordflow">if</font> (n > normEpsilon) +00277 { +00278 mbv1n = mbv1 / n; +00279 mbv2 = *currentSize * (J ^ mbv1n); +00280 mbv12 = -*currentSize * mbv1n; +00281 mbv1 *= *currentSize * (1 + la._MotionBlurCoeff * n * n) / n; +00282 +00283 *(CVector *) ptPos = *it - mbv2; +00284 *(CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>) = *it + mbv1; +00285 *(CVector *) (ptPos + stride2) = *it + mbv2; +00286 *(CVector *) (ptPos + stride3) = *it + mbv12; +00287 +00288 +00289 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00290 ((CVector *) ptPos)->x = (*it).x - mbv2.x; +00291 ((CVector *) ptPos)->y = (*it).y - mbv2.y; +00292 ((CVector *) ptPos)->z = (*it).z - mbv2.z; +00293 +00294 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>); +00295 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->x = (*it).x + mbv1.x; +00296 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->y = (*it).y + mbv1.y; +00297 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->z = (*it).z + mbv1.z; +00298 +00299 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00300 ((CVector *) (ptPos + stride2))->x = (*it).x + mbv2.x; +00301 ((CVector *) (ptPos + stride2))->y = (*it).y + mbv2.y; +00302 ((CVector *) (ptPos + stride2))->z = (*it).z + mbv2.z; +00303 +00304 +00305 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00306 ((CVector *) (ptPos + stride3))->x = (*it).x + mbv12.x; +00307 ((CVector *) (ptPos + stride3))->y = (*it).y + mbv12.y; +00308 ((CVector *) (ptPos + stride3))->z = (*it).z + mbv12.z; +00309 +00310 } +00311 <font class="keywordflow">else</font> <font class="comment">// speed too small, we must avoid imprecision</font> +00312 { +00313 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00314 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00315 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00316 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00317 +00318 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>); +00319 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->x = (*it).x + *currentSize * v1.x; +00320 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->y = (*it).y + *currentSize * v1.y; +00321 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->z = (*it).z + *currentSize * v1.z; +00322 +00323 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00324 ((CVector *) (ptPos + stride2))->x = (*it).x + *currentSize * v2.x; +00325 ((CVector *) (ptPos + stride2))->y = (*it).y + *currentSize * v2.y; +00326 ((CVector *) (ptPos + stride2))->z = (*it).z + *currentSize * v2.z; +00327 +00328 +00329 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00330 ((CVector *) (ptPos + stride3))->x = (*it).x - *currentSize * v1.x; +00331 ((CVector *) (ptPos + stride3))->y = (*it).y - *currentSize * v1.y; +00332 ((CVector *) (ptPos + stride3))->z = (*it).z - *currentSize * v1.z; +00333 } +00334 } +00335 <font class="keywordflow">else</font> +00336 { +00337 +00338 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00339 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00340 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00341 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00342 +00343 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>); +00344 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->x = (*it).x + *currentSize * v1.x; +00345 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->y = (*it).y + *currentSize * v1.y; +00346 ((CVector *) (ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>))->z = (*it).z + *currentSize * v1.z; +00347 +00348 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00349 ((CVector *) (ptPos + stride2))->x = (*it).x + *currentSize * v2.x; +00350 ((CVector *) (ptPos + stride2))->y = (*it).y + *currentSize * v2.y; +00351 ((CVector *) (ptPos + stride2))->z = (*it).z + *currentSize * v2.z; +00352 +00353 +00354 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00355 ((CVector *) (ptPos + stride3))->x = (*it).x - *currentSize * v1.x; +00356 ((CVector *) (ptPos + stride3))->y = (*it).y - *currentSize * v1.y; +00357 ((CVector *) (ptPos + stride3))->z = (*it).z - *currentSize * v1.z; +00358 } +00359 +00360 ptPos += stride4; +00361 ++it; +00362 ++speedIt; +00363 currentSize += currentSizeStep; +00364 } +00365 +00366 } +00367 driver->renderQuads(la._Mat, 0, toProcess); +00368 leftToDo -= toProcess; +00369 } +00370 <font class="keywordflow">while</font> (leftToDo); +00371 } +00372 <font class="keywordflow">else</font> +00373 { +00374 <font class="keywordtype">float</font> pAngles[CPSQuad::quadBufSize]; <font class="comment">// the angles to use</font> +00375 <font class="keywordtype">float</font> *currentAngle; +00376 <font class="keywordflow">do</font> +00377 { +00378 <font class="comment">// restart at the beginning of the vertex buffer</font> +00379 ptPos = (uint8 *) vb.getVertexCoordPointer(); +00380 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00381 <font class="keywordflow">if</font> (la._SizeScheme) +00382 { +00383 currentSize = (<font class="keywordtype">float</font> *) la._SizeScheme->make(la._Owner, size - leftToDo, pSizes, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00384 } +00385 <font class="keywordflow">else</font> +00386 { +00387 currentSize = &la._ParticleSize; +00388 } +00389 currentAngle = (<font class="keywordtype">float</font> *) la._Angle2DScheme->make(la._Owner, size - leftToDo, pAngles, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00390 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00391 T endIt = it + toProcess; +00392 CVector v1, v2; +00393 <a class="code" href="namespaceNL3D.html#a360">OptFastFloorBegin</a>(); +00394 <font class="keywordflow">if</font> (!la._IndependantSizes) +00395 { +00396 <font class="keywordflow">while</font> (it != endIt) +00397 { +00398 <font class="keyword">const</font> uint32 tabIndex = ((<a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(*currentAngle)) & 0xff) << 2; +00399 <font class="comment">// lets avoid some ctor calls</font> +00400 v1.x = *currentSize * (rotTable[tabIndex] * I.x + rotTable[tabIndex + 1] * K.x); +00401 v1.y = *currentSize * (rotTable[tabIndex] * I.y + rotTable[tabIndex + 1] * K.y); +00402 v1.z = *currentSize * (rotTable[tabIndex] * I.z + rotTable[tabIndex + 1] * K.z); +00403 +00404 v2.x = *currentSize * (rotTable[tabIndex + 2] * I.x + rotTable[tabIndex + 3] * K.x); +00405 v2.y = *currentSize * (rotTable[tabIndex + 2] * I.y + rotTable[tabIndex + 3] * K.y); +00406 v2.z = *currentSize * (rotTable[tabIndex + 2] * I.z + rotTable[tabIndex + 3] * K.z); +00407 +00408 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00409 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>); +00410 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00411 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00412 +00413 ((CVector *) ptPos)->x = (*it).x + v1.x; +00414 ((CVector *) ptPos)->y = (*it).y + v1.y; +00415 ((CVector *) ptPos)->z = (*it).z + v1.z; +00416 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00417 +00418 ((CVector *) ptPos)->x = (*it).x + v2.x; +00419 ((CVector *) ptPos)->y = (*it).y + v2.y; +00420 ((CVector *) ptPos)->z = (*it).z + v2.z; +00421 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00422 +00423 ((CVector *) ptPos)->x = (*it).x - v1.x; +00424 ((CVector *) ptPos)->y = (*it).y - v1.y; +00425 ((CVector *) ptPos)->z = (*it).z - v1.z; +00426 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00427 +00428 ((CVector *) ptPos)->x = (*it).x - v2.x; +00429 ((CVector *) ptPos)->y = (*it).y - v2.y; +00430 ((CVector *) ptPos)->z = (*it).z - v2.z; +00431 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00432 +00433 ++it; +00434 currentSize += currentSizeStep; +00435 ++currentAngle; +00436 } +00437 } +00438 <font class="keywordflow">else</font> <font class="comment">// independant size, and non-constant rotation</font> +00439 { +00440 +00441 <font class="keywordtype">float</font> *currentSize2; +00442 <font class="keywordtype">float</font> secondSize; +00443 uint32 currentSizeStep2; +00444 <font class="keywordflow">if</font> (la._SecondSize.getSizeScheme()) +00445 { +00446 currentSize2 = (<font class="keywordtype">float</font> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep); +00447 currentSizeStep2 = 1; +00448 } +00449 <font class="keywordflow">else</font> +00450 { +00451 secondSize = la._SecondSize.getSize(); +00452 currentSize2 = &secondSize; +00453 currentSizeStep2 = 0; +00454 } +00455 +00456 <font class="keywordtype">float</font> cosAngle, sinAngle; +00457 <font class="keywordflow">while</font> (it != endIt) +00458 { +00459 cosAngle = CPSUtil::getCos((sint32) *currentAngle); +00460 sinAngle = CPSUtil::getSin((sint32) *currentAngle); +00461 v1 = cosAngle * I + sinAngle * K; +00462 v2 = - sinAngle * I + cosAngle * K; +00463 +00464 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00465 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00466 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00467 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00468 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00469 +00470 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00471 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00472 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00473 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00474 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00475 +00476 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00477 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00478 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00479 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00480 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00481 +00482 <a class="code" href="ps__macro_8h.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00483 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00484 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00485 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00486 ptPos += <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>; +00487 ++it; +00488 ++currentAngle; +00489 currentSize += currentSizeStep; +00490 currentSize2 += currentSizeStep2; +00491 } +00492 } +00493 <a class="code" href="namespaceNL3D.html#a361">OptFastFloorEnd</a>(); +00494 driver->renderQuads(la._Mat, 0, toProcess); +00495 leftToDo -= toProcess; +00496 } +00497 <font class="keywordflow">while</font> (leftToDo); +00498 } +00499 PARTICLES_CHECK_MEM; +00500 } +00501 }; +00502 +<a name="l00504"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#b0">00504</a> <font class="keywordtype">void</font> CPSFaceLookAt::draw(<font class="keywordtype">bool</font> opaque) +00505 { +00506 PARTICLES_CHECK_MEM; +00507 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize()) <font class="keywordflow">return</font>; +00508 +00509 uint32 <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a>; +00510 uint numToProcess; +00511 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a>, numToProcess); +00512 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>; +00513 +00514 +00515 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> == (1 << 16)) +00516 { +00517 CPSFaceLookAtHelper::drawLookAt(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), +00518 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed().begin(), +00519 *<font class="keyword">this</font>, +00520 numToProcess, +00521 <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> +00522 ); +00523 } +00524 <font class="keywordflow">else</font> +00525 { +00526 CPSFaceLookAtHelper::drawLookAt(<a class="code" href="namespaceNL3D.html#a199">TIteratorVectStep1616</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), 0, <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a>), +00527 <a class="code" href="namespaceNL3D.html#a199">TIteratorVectStep1616</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed().begin(), 0, <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a>), +00528 *<font class="keyword">this</font>, +00529 numToProcess, +00530 <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> +00531 ); +00532 } +00533 +00534 PARTICLES_CHECK_MEM; +00535 } +00536 +<a name="l00538"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#a0">00538</a> CPSFaceLookAt::CPSFaceLookAt(CSmartPtr<ITexture> tex) : CPSQuad(tex), _MotionBlurCoeff(0.f) +00539 , _Threshold(0.5f), _IndependantSizes(false) +00540 { +00541 <a class="code" href="classNL3D_1_1CPSFaceLookAt.html#n2">_SecondSize</a>.<a class="code" href="structNL3D_1_1CPSFaceLookAt_1_1CSecondSize.html#m0">Owner</a> = <font class="keyword">this</font>; +00542 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"LookAt"</font>); +00543 } +00544 +<a name="l00546"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#b1">00546</a> <font class="keywordtype">void</font> CPSFaceLookAt::newElement(CPSLocated *emitterLocated, uint32 emitterIndex) +00547 { +00548 CPSQuad::newElement(emitterLocated, emitterIndex); +00549 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b1">newAngle2DElement</a>(emitterLocated, emitterIndex); +00550 } +00551 +<a name="l00553"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#b2">00553</a> <font class="keywordtype">void</font> CPSFaceLookAt::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) +00554 { +00555 CPSQuad::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00556 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b2">deleteAngle2DElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00557 } +00558 +<a name="l00560"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#b3">00560</a> <font class="keywordtype">void</font> CPSFaceLookAt::resize(uint32 capacity) +00561 { +00562 <a class="code" href="debug_8h.html#a6">nlassert</a>(capacity < (1 << 16)); +00563 CPSQuad::resize(capacity); +00564 <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b3">resizeAngle2D</a>(capacity); +00565 } +00566 +00567 +<a name="l00569"></a><a class="code" href="classNL3D_1_1CPSFaceLookAt.html#a1">00569</a> <font class="keywordtype">void</font> CPSFaceLookAt::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream) +00570 { +00571 sint ver = f.serialVersion(2); +00572 CPSQuad::serial(f); +00573 CPSRotated2DParticle::serialAngle2DScheme(f); +00574 f.serial(_MotionBlurCoeff); +00575 <font class="keywordflow">if</font> (_MotionBlurCoeff != 0) +00576 { +00577 f.serial(_Threshold); +00578 } +00579 <font class="keywordflow">if</font> (ver > 1) +00580 { +00581 f.serial(_IndependantSizes); +00582 <font class="keywordflow">if</font> (_IndependantSizes) +00583 { +00584 _SecondSize.serialSizeScheme(f); +00585 } +00586 } +00587 <font class="keywordflow">if</font> (f.isReading()) +00588 { +00589 init(); +00590 } +00591 } +00592 +00593 } <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> |