diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a03193.html | 988 |
1 files changed, 988 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a03193.html b/docs/doxygen/nel/a03193.html new file mode 100644 index 00000000..bba5dbed --- /dev/null +++ b/docs/doxygen/nel/a03193.html @@ -0,0 +1,988 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NL3D::CPSFaceLookAtHelper class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.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">Data Structures</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">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NL3D::CPSFaceLookAtHelper Class Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2> +Well, we could have put a method template in <a class="el" href="a03191.html">CPSFaceLookAt</a>, but some compilers want the definition of the methods in the header, and some compilers don't want friend with function template, so we use a static method template of a friend class instead, which gives us the same result :) +<p> + +<p> +Definition at line <a class="el" href="a06233.html#l00062">62</a> of file <a class="el" href="a06233.html">ps_face_look_at.cpp</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a03193.html#NL3D_1_1CPSFaceLookAtHelpere0">computeOrientationVectors</a> (T speedIt, const <a class="el" href="a03128.html">CVector</a> &I, const <a class="el" href="a03128.html">CVector</a> &K, <a class="el" href="a02829.html">CLookAtAlign</a> *dest, <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a587">size</a>)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a03193.html#NL3D_1_1CPSFaceLookAtHelpere1">drawLookAt</a> (T it, T speedIt, <a class="el" href="a03191.html">CPSFaceLookAt</a> &la, <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a587">size</a>, <a class="el" href="a04558.html#a11">uint32</a> srcStep)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>template<class T> void </td><td class="memItemRight" valign=bottom><a class="el" href="a03193.html#NL3D_1_1CPSFaceLookAtHelpere2">drawLookAtAlignOnMotion</a> (T it, T speedIt, <a class="el" href="a03191.html">CPSFaceLookAt</a> &la, <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a587">size</a>, <a class="el" href="a04558.html#a11">uint32</a> srcStep)</td></tr> + +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NL3D_1_1CPSFaceLookAtHelpere0" doxytag="NL3D::CPSFaceLookAtHelper::computeOrientationVectors" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" colspan="4"> +template<class T> </td> + </tr> + <tr> + <td class="md" nowrap valign="top"> void NL3D::CPSFaceLookAtHelper::computeOrientationVectors </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">T </td> + <td class="mdname" nowrap> <em>speedIt</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03128.html">CVector</a> & </td> + <td class="mdname" nowrap> <em>I</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03128.html">CVector</a> & </td> + <td class="mdname" nowrap> <em>K</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a02829.html">CLookAtAlign</a> * </td> + <td class="mdname" nowrap> <em>dest</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>size</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +compute orientation vectors depending on speed +<p> +Definition at line <a class="el" href="a06233.html#l00068">68</a> of file <a class="el" href="a06233.html">ps_face_look_at.cpp</a>. +<p> +References <a class="el" href="a06233.html#l00044">NL3D::CLookAtAlign::I</a>, <a class="el" href="a06233.html#l00045">NL3D::CLookAtAlign::K</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06682.html#l00125">NLMISC::CVector::normed()</a>, <a class="el" href="a05646.html#l00645">size</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06233.html#l00089">drawLookAtAlignOnMotion()</a>. +<p> +<div class="fragment"><pre>00069 { +00070 <a class="code" href="a04199.html#a6">nlassert</a>(size > 0); +00071 <span class="keyword">const</span> CLookAtAlign *endDest = dest + <a class="code" href="a04223.html#a587">size</a>; +00072 <span class="keywordflow">do</span> +00073 { +00074 <span class="comment">// tmp unoptimized slow version</span> +00075 CVector normedSpeed = (*speedIt).normed(); +00076 <span class="keywordtype">float</span> iProj = normedSpeed * I; +00077 <span class="keywordtype">float</span> kProj = normedSpeed * K; +00078 dest->I = iProj * I + kProj * K; +00079 dest->K = (- kProj * I + iProj * K).normed(); +00080 ++ speedIt; +00081 ++ dest; +00082 } +00083 <span class="keywordflow">while</span>(dest != endDest); +00084 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NL3D_1_1CPSFaceLookAtHelpere1" doxytag="NL3D::CPSFaceLookAtHelper::drawLookAt" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" colspan="4"> +template<class T> </td> + </tr> + <tr> + <td class="md" nowrap valign="top"> void NL3D::CPSFaceLookAtHelper::drawLookAt </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">T </td> + <td class="mdname" nowrap> <em>it</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>T </td> + <td class="mdname" nowrap> <em>speedIt</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03191.html">CPSFaceLookAt</a> & </td> + <td class="mdname" nowrap> <em>la</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>size</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>srcStep</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +render look at, but dont align on motion +<p> +Definition at line <a class="el" href="a06233.html#l00379">379</a> of file <a class="el" href="a06233.html">ps_face_look_at.cpp</a>. +<p> +References <a class="el" href="a06258.html#l00367">NL3D::CPSRotated2DParticle::_Angle2D</a>, <a class="el" href="a06258.html#l00368">NL3D::CPSRotated2DParticle::_Angle2DScheme</a>, <a class="el" href="a06234.html#l00124">NL3D::CPSFaceLookAt::_IndependantSizes</a>, <a class="el" href="a06258.html#l00844">NL3D::CPSMaterial::_Mat</a>, <a class="el" href="a06234.html#l00116">NL3D::CPSFaceLookAt::_MotionBlurCoeff</a>, <a class="el" href="a06247.html#l01026">NL3D::CPSLocatedBindable::_Owner</a>, <a class="el" href="a06258.html#l00289">NL3D::CPSSizedParticle::_ParticleSize</a>, <a class="el" href="a03191.html#NL3D_1_1CPSFaceLookAtp19">NL3D::CPSFaceLookAt::_SecondSize</a>, <a class="el" href="a06258.html#l00290">NL3D::CPSSizedParticle::_SizeScheme</a>, <a class="el" href="a06234.html#l00117">NL3D::CPSFaceLookAt::_Threshold</a>, <a class="el" href="a02434.html#NL3D_1_1IDrivera2">NL3D::IDriver::activeVertexBuffer()</a>, <a class="el" href="a06249.html#l00039">CHECK_VERTEX_BUFFER</a>, <a class="el" href="a06247.html#l00931">NL3D::CPSLocatedBindable::computeI()</a>, <a class="el" href="a06247.html#l00936">NL3D::CPSLocatedBindable::computeJ()</a>, <a class="el" href="a06247.html#l00940">NL3D::CPSLocatedBindable::computeK()</a>, <a class="el" href="a06247.html#l00890">NL3D::CPSLocatedBindable::getDriver()</a>, <a class="el" href="a06246.html#l00092">NL3D::CPSLocated::getLocalToWorldMatrix()</a>, <a class="el" href="a06262.html#l00146">NL3D::CPSQuad::getNeededVB()</a>, <a class="el" href="a06258.html#l00274">NL3D::CPSSizedParticle::getSize()</a>, <a class="el" href="a06258.html#l00265">NL3D::CPSSizedParticle::getSizeScheme()</a>, <a class="el" href="a06710.html#l00438">NL3D::CVertexBuffer::getVertexCoordPointer()</a>, <a class="el" href="a06711.html#l00473">NL3D::CVertexBuffer::getVertexSize()</a>, <a class="el" href="a06246.html#l02125">NL3D::CPSLocatedBindable::getViewMat()</a>, <a class="el" href="a06246.html#l00500">NL3D::CPSLocated::incrementNbDrawnParticles()</a>, <a class="el" href="a03136.html#NL3D_1_1CPSAttribMakerz714_2">NL3D::CPSAttribMaker< float >::make()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06682.html#l00115">NLMISC::CVector::norm()</a>, <a class="el" href="a05701.html#l00125">NLMISC::OptFastFloor()</a>, <a class="el" href="a05701.html#l00123">NLMISC::OptFastFloorBegin()</a>, <a class="el" href="a05701.html#l00124">NLMISC::OptFastFloorEnd()</a>, <a class="el" href="a06152.html#l00060">PARTICLES_CHECK_MEM</a>, <a class="el" href="a02434.html#NL3D_1_1IDrivera52">NL3D::IDriver::renderOrientedQuads()</a>, <a class="el" href="a02434.html#NL3D_1_1IDrivera54">NL3D::IDriver::renderQuads()</a>, <a class="el" href="a06246.html#l02142">NL3D::CPSLocatedBindable::setupDriverModelMatrix()</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a05646.html#l00244">stride</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, <a class="el" href="a05981.html#l00096">uint8</a>, <a class="el" href="a06262.html#l00520">NL3D::CPSQuad::updateMatBeforeRendering()</a>, <a class="el" href="a06262.html#l00386">NL3D::CPSQuad::updateVbColNUVForRender()</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::x</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::y</a>, and <a class="el" href="a06673.html#l00051">NLMISC::CVector::z</a>. +<p> +<div class="fragment"><pre>00380 { +00381 <span class="comment">//uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00382 <a class="code" href="a04729.html#a0">PARTICLES_CHECK_MEM</a>; +00383 <a class="code" href="a04199.html#a6">nlassert</a>(la._Owner); +00384 IDriver *driver = la.getDriver(); +00385 +00386 la.updateMatBeforeRendering(driver); +00387 +00388 CVertexBuffer &vb = la.getNeededVB(); +00389 la._Owner->incrementNbDrawnParticles(size); <span class="comment">// for benchmark purpose </span> +00390 la.setupDriverModelMatrix(); +00391 driver->activeVertexBuffer(vb); +00392 <span class="keyword">const</span> CVector I = la.computeI(); +00393 <span class="keyword">const</span> CVector J = la.computeJ(); +00394 <span class="keyword">const</span> CVector K = la.computeK(); +00395 <span class="keyword">const</span> <span class="keywordtype">float</span> *rotTable = CPSRotated2DParticle::getRotTable(); +00396 <span class="comment">// for each the particle can be constantly rotated or have an independant rotation for each particle</span> +00397 <span class="comment">// number of face left, and number of face to process at once</span> +00398 <a class="code" href="a04558.html#a11">uint32</a> leftToDo = <a class="code" href="a04223.html#a587">size</a>, toProcess; +00399 <span class="keywordtype">float</span> pSizes[CPSQuad::quadBufSize]; <span class="comment">// the sizes to use </span> +00400 <span class="keywordtype">float</span> pSecondSizes[CPSQuad::quadBufSize]; <span class="comment">// the second sizes to use</span> +00401 <span class="keywordtype">float</span> *currentSize; +00402 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep = la._SizeScheme ? 1 : 0; +00403 <span class="comment">// point the vector part in the current vertex</span> +00404 <a class="code" href="a04558.html#a7">uint8</a> *ptPos; +00405 <span class="comment">// strides to go from one vertex to another one</span> +00406 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a582">stride</a> = vb.getVertexSize(), stride2 = <a class="code" href="a04223.html#a582">stride</a> << 1, stride3 = <a class="code" href="a04223.html#a582">stride</a> + stride2, stride4 = <a class="code" href="a04223.html#a582">stride</a> << 2; +00407 <span class="comment">//PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick; </span> +00408 <span class="keywordflow">if</span> (!la._Angle2DScheme) +00409 { +00410 <span class="comment">// constant rotation case</span> +00411 <span class="keywordflow">do</span> +00412 { +00413 <span class="comment">// restart at the beginning of the vertex buffer</span> +00414 ptPos = (<a class="code" href="a04558.html#a7">uint8</a> *) vb.getVertexCoordPointer(); +00415 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00416 +00417 <span class="keywordflow">if</span> (la._SizeScheme) +00418 { +00419 currentSize = (<span class="keywordtype">float</span> *) la._SizeScheme->make(la._Owner, size- leftToDo, pSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00420 } +00421 <span class="keywordflow">else</span> +00422 { +00423 currentSize = &la._ParticleSize; +00424 } +00425 +00426 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00427 T endIt = it + toProcess; +00428 <span class="keywordflow">if</span> (la._MotionBlurCoeff == 0.f) +00429 { +00430 <span class="keywordflow">if</span> (!la._IndependantSizes) +00431 { +00432 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> tabIndex = (((<a class="code" href="a04558.html#a11">uint32</a>) la._Angle2D) & 0xff) << 2; +00433 <span class="keyword">const</span> CVector v1 = rotTable[tabIndex] * I + rotTable[tabIndex + 1] * K; +00434 <span class="keyword">const</span> CVector v2 = rotTable[tabIndex + 2] * I + rotTable[tabIndex + 3] * K; +00435 <span class="keywordflow">if</span> (currentSizeStep) +00436 { +00437 <span class="keywordflow">while</span> (it != endIt) +00438 { +00439 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00440 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x; +00441 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y; +00442 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z; +00443 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00444 +00445 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00446 ((CVector *) ptPos)->x = (*it).x + *currentSize * v2.x; +00447 ((CVector *) ptPos)->y = (*it).y + *currentSize * v2.y; +00448 ((CVector *) ptPos)->z = (*it).z + *currentSize * v2.z; +00449 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00450 +00451 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00452 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x; +00453 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y; +00454 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z; +00455 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00456 +00457 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00458 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00459 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00460 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00461 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00462 +00463 ++it; +00464 currentSize += currentSizeStep; +00465 } +00466 } +00467 <span class="keywordflow">else</span> +00468 { +00469 <span class="comment">// constant size</span> +00470 <span class="keyword">const</span> CVector myV1 = *currentSize * v1; +00471 <span class="keyword">const</span> CVector myV2 = *currentSize * v2; +00472 +00473 <span class="keywordflow">while</span> (it != endIt) +00474 { +00475 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00476 ((CVector *) ptPos)->x = (*it).x + myV1.x; +00477 ((CVector *) ptPos)->y = (*it).y + myV1.y; +00478 ((CVector *) ptPos)->z = (*it).z + myV1.z; +00479 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00480 +00481 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00482 ((CVector *) ptPos)->x = (*it).x + myV2.x; +00483 ((CVector *) ptPos)->y = (*it).y + myV2.y; +00484 ((CVector *) ptPos)->z = (*it).z + myV2.z; +00485 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00486 +00487 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00488 ((CVector *) ptPos)->x = (*it).x - myV1.x; +00489 ((CVector *) ptPos)->y = (*it).y - myV1.y; +00490 ((CVector *) ptPos)->z = (*it).z - myV1.z; +00491 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00492 +00493 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00494 ((CVector *) ptPos)->x = (*it).x - myV2.x; +00495 ((CVector *) ptPos)->y = (*it).y - myV2.y; +00496 ((CVector *) ptPos)->z = (*it).z - myV2.z; +00497 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00498 ++it; +00499 } +00500 } +00501 } +00502 <span class="keywordflow">else</span> <span class="comment">// independant sizes</span> +00503 { +00504 <span class="keyword">const</span> CVector v1 = CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * I + CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * K; +00505 <span class="keyword">const</span> CVector v2 = - CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * I + CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * K; +00506 +00507 <span class="keywordtype">float</span> *currentSize2; +00508 <span class="keywordtype">float</span> secondSize; +00509 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep2; +00510 <span class="keywordflow">if</span> (la._SecondSize.getSizeScheme()) +00511 { +00512 currentSize2 = (<span class="keywordtype">float</span> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00513 currentSizeStep2 = 1; +00514 } +00515 <span class="keywordflow">else</span> +00516 { +00517 secondSize = la._SecondSize.getSize(); +00518 currentSize2 = &secondSize; +00519 currentSizeStep2 = 0; +00520 } +00521 +00522 +00523 <span class="keywordflow">while</span> (it != endIt) +00524 { +00525 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00526 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00527 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00528 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00529 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00530 +00531 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00532 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00533 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00534 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00535 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00536 +00537 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00538 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00539 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00540 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00541 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00542 +00543 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00544 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00545 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00546 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00547 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00548 ++it; +00549 currentSize += currentSizeStep; +00550 currentSize2 += currentSizeStep2; +00551 } +00552 } +00553 <span class="comment">//tmp</span> +00554 <span class="comment">//uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00555 driver->renderQuads(la._Mat, 0, toProcess); +00556 <span class="comment">//PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick;</span> +00557 } +00558 <span class="keywordflow">else</span> +00559 { +00560 <span class="comment">// perform motion, blur, we need an iterator on speed</span> +00561 <span class="comment">// independant sizes and rotation not supported for now with motion blur </span> +00562 <span class="keyword">const</span> CVector v1 = I + K; +00563 <span class="keyword">const</span> CVector v2 = K - I; +00564 CVector startV, endV, mbv1, mbv1n, mbv12, mbv2; +00565 <span class="comment">// norme of the v1 vect</span> +00566 <span class="keywordtype">float</span> n; +00567 <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 10E-5f; +00568 <span class="keyword">const</span> <span class="keywordtype">float</span> normEpsilon = 10E-6f; +00569 +00570 CMatrix tMat = la.getViewMat() * la._Owner->getLocalToWorldMatrix(); +00571 +00572 <span class="keywordflow">while</span> (it != endIt) +00573 { +00574 <span class="comment">// project the speed in the projection plane</span> +00575 <span class="comment">// this give us the v1 vect</span> +00576 startV = tMat * *it ; +00577 endV = tMat * (*it + *speedIt); +00578 <span class="keywordflow">if</span> (startV.y > epsilon || endV.y > epsilon) +00579 { +00580 <span class="keywordflow">if</span> (startV.y < epsilon) +00581 { +00582 <span class="keywordflow">if</span> (fabsf(endV.y - startV.y) > normEpsilon) +00583 { +00584 startV = endV + (endV.y - epsilon) / (endV.y - startV.y) * (startV - endV); +00585 } +00586 startV.y = epsilon; +00587 } +00588 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (endV.y < epsilon) +00589 { +00590 <span class="keywordflow">if</span> (fabsf(endV.y - startV.y) > normEpsilon) +00591 { +00592 endV = startV + (startV.y - epsilon) / (startV.y - endV.y) * (endV - startV); +00593 } +00594 endV.y = epsilon; +00595 } +00596 +00597 mbv1 = (startV.x / startV.y - endV.x / endV.y) * I +00598 + (startV.z / startV.y - endV.z / endV.y) * K ; +00599 +00600 n = mbv1.norm(); +00601 <span class="keywordflow">if</span> (n > la._Threshold) +00602 { +00603 mbv1 *= la._Threshold / n; +00604 n = la._Threshold; +00605 } +00606 <span class="keywordflow">if</span> (n > normEpsilon) +00607 { +00608 mbv1n = mbv1 / n; +00609 mbv2 = *currentSize * (J ^ mbv1n); +00610 mbv12 = -*currentSize * mbv1n; +00611 mbv1 *= *currentSize * (1 + la._MotionBlurCoeff * n * n) / n; +00612 +00613 *(CVector *) ptPos = *it - mbv2; +00614 *(CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>) = *it + mbv1; +00615 *(CVector *) (ptPos + stride2) = *it + mbv2; +00616 *(CVector *) (ptPos + stride3) = *it + mbv12; +00617 +00618 +00619 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00620 ((CVector *) ptPos)->x = (*it).x - mbv2.x; +00621 ((CVector *) ptPos)->y = (*it).y - mbv2.y; +00622 ((CVector *) ptPos)->z = (*it).z - mbv2.z; +00623 +00624 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride); +00625 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->x = (*it).x + mbv1.x; +00626 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->y = (*it).y + mbv1.y; +00627 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->z = (*it).z + mbv1.z; +00628 +00629 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00630 ((CVector *) (ptPos + stride2))->x = (*it).x + mbv2.x; +00631 ((CVector *) (ptPos + stride2))->y = (*it).y + mbv2.y; +00632 ((CVector *) (ptPos + stride2))->z = (*it).z + mbv2.z; +00633 +00634 +00635 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00636 ((CVector *) (ptPos + stride3))->x = (*it).x + mbv12.x; +00637 ((CVector *) (ptPos + stride3))->y = (*it).y + mbv12.y; +00638 ((CVector *) (ptPos + stride3))->z = (*it).z + mbv12.z; +00639 +00640 } +00641 <span class="keywordflow">else</span> <span class="comment">// speed too small, we must avoid imprecision</span> +00642 { +00643 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00644 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00645 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00646 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00647 +00648 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride); +00649 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->x = (*it).x + *currentSize * v1.x; +00650 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->y = (*it).y + *currentSize * v1.y; +00651 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->z = (*it).z + *currentSize * v1.z; +00652 +00653 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00654 ((CVector *) (ptPos + stride2))->x = (*it).x + *currentSize * v2.x; +00655 ((CVector *) (ptPos + stride2))->y = (*it).y + *currentSize * v2.y; +00656 ((CVector *) (ptPos + stride2))->z = (*it).z + *currentSize * v2.z; +00657 +00658 +00659 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00660 ((CVector *) (ptPos + stride3))->x = (*it).x - *currentSize * v1.x; +00661 ((CVector *) (ptPos + stride3))->y = (*it).y - *currentSize * v1.y; +00662 ((CVector *) (ptPos + stride3))->z = (*it).z - *currentSize * v1.z; +00663 } +00664 } +00665 <span class="keywordflow">else</span> +00666 { +00667 +00668 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00669 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00670 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00671 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00672 +00673 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride); +00674 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->x = (*it).x + *currentSize * v1.x; +00675 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->y = (*it).y + *currentSize * v1.y; +00676 ((CVector *) (ptPos + <a class="code" href="a04223.html#a582">stride</a>))->z = (*it).z + *currentSize * v1.z; +00677 +00678 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00679 ((CVector *) (ptPos + stride2))->x = (*it).x + *currentSize * v2.x; +00680 ((CVector *) (ptPos + stride2))->y = (*it).y + *currentSize * v2.y; +00681 ((CVector *) (ptPos + stride2))->z = (*it).z + *currentSize * v2.z; +00682 +00683 +00684 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00685 ((CVector *) (ptPos + stride3))->x = (*it).x - *currentSize * v1.x; +00686 ((CVector *) (ptPos + stride3))->y = (*it).y - *currentSize * v1.y; +00687 ((CVector *) (ptPos + stride3))->z = (*it).z - *currentSize * v1.z; +00688 } +00689 +00690 ptPos += stride4; +00691 ++it; +00692 ++speedIt; +00693 currentSize += currentSizeStep; +00694 } +00695 <span class="comment">//uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00696 driver->renderOrientedQuads(la._Mat, 0, toProcess); +00697 <span class="comment">//PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick;</span> +00698 } +00699 leftToDo -= toProcess; +00700 } +00701 <span class="keywordflow">while</span> (leftToDo); +00702 } +00703 <span class="keywordflow">else</span> +00704 { +00705 <span class="keywordtype">float</span> pAngles[CPSQuad::quadBufSize]; <span class="comment">// the angles to use</span> +00706 <span class="keywordtype">float</span> *currentAngle; +00707 <span class="keywordflow">do</span> +00708 { +00709 <span class="comment">// restart at the beginning of the vertex buffer</span> +00710 ptPos = (<a class="code" href="a04558.html#a7">uint8</a> *) vb.getVertexCoordPointer(); +00711 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00712 <span class="keywordflow">if</span> (la._SizeScheme) +00713 { +00714 currentSize = (<span class="keywordtype">float</span> *) la._SizeScheme->make(la._Owner, size - leftToDo, pSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00715 } +00716 <span class="keywordflow">else</span> +00717 { +00718 currentSize = &la._ParticleSize; +00719 } +00720 currentAngle = (<span class="keywordtype">float</span> *) la._Angle2DScheme->make(la._Owner, size - leftToDo, pAngles, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00721 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00722 T endIt = it + toProcess; +00723 CVector v1, v2; +00724 <a class="code" href="a05378.html#a395">NLMISC::OptFastFloorBegin</a>(); +00725 <span class="keywordflow">if</span> (!la._IndependantSizes) +00726 { +00727 <span class="keywordflow">while</span> (it != endIt) +00728 { +00729 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> tabIndex = ((<a class="code" href="a05378.html#a397">NLMISC::OptFastFloor</a>(*currentAngle)) & 0xff) << 2; +00730 <span class="comment">// lets avoid some ctor calls</span> +00731 v1.x = *currentSize * (rotTable[tabIndex] * I.x + rotTable[tabIndex + 1] * K.x); +00732 v1.y = *currentSize * (rotTable[tabIndex] * I.y + rotTable[tabIndex + 1] * K.y); +00733 v1.z = *currentSize * (rotTable[tabIndex] * I.z + rotTable[tabIndex + 1] * K.z); +00734 +00735 v2.x = *currentSize * (rotTable[tabIndex + 2] * I.x + rotTable[tabIndex + 3] * K.x); +00736 v2.y = *currentSize * (rotTable[tabIndex + 2] * I.y + rotTable[tabIndex + 3] * K.y); +00737 v2.z = *currentSize * (rotTable[tabIndex + 2] * I.z + rotTable[tabIndex + 3] * K.z); +00738 +00739 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00740 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride); +00741 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00742 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00743 +00744 ((CVector *) ptPos)->x = (*it).x + v1.x; +00745 ((CVector *) ptPos)->y = (*it).y + v1.y; +00746 ((CVector *) ptPos)->z = (*it).z + v1.z; +00747 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00748 +00749 ((CVector *) ptPos)->x = (*it).x + v2.x; +00750 ((CVector *) ptPos)->y = (*it).y + v2.y; +00751 ((CVector *) ptPos)->z = (*it).z + v2.z; +00752 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00753 +00754 ((CVector *) ptPos)->x = (*it).x - v1.x; +00755 ((CVector *) ptPos)->y = (*it).y - v1.y; +00756 ((CVector *) ptPos)->z = (*it).z - v1.z; +00757 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00758 +00759 ((CVector *) ptPos)->x = (*it).x - v2.x; +00760 ((CVector *) ptPos)->y = (*it).y - v2.y; +00761 ((CVector *) ptPos)->z = (*it).z - v2.z; +00762 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00763 +00764 ++it; +00765 currentSize += currentSizeStep; +00766 ++currentAngle; +00767 } +00768 } +00769 <span class="keywordflow">else</span> <span class="comment">// independant size, and non-constant rotation</span> +00770 { +00771 +00772 <span class="keywordtype">float</span> *currentSize2; +00773 <span class="keywordtype">float</span> secondSize; +00774 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep2; +00775 <span class="keywordflow">if</span> (la._SecondSize.getSizeScheme()) +00776 { +00777 currentSize2 = (<span class="keywordtype">float</span> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00778 currentSizeStep2 = 1; +00779 } +00780 <span class="keywordflow">else</span> +00781 { +00782 secondSize = la._SecondSize.getSize(); +00783 currentSize2 = &secondSize; +00784 currentSizeStep2 = 0; +00785 } +00786 +00787 <span class="keywordtype">float</span> cosAngle, sinAngle; +00788 <span class="keywordflow">while</span> (it != endIt) +00789 { +00790 cosAngle = CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) *currentAngle); +00791 sinAngle = CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) *currentAngle); +00792 v1 = cosAngle * I + sinAngle * K; +00793 v2 = - sinAngle * I + cosAngle * K; +00794 +00795 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00796 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00797 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00798 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00799 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00800 +00801 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00802 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00803 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00804 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00805 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00806 +00807 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00808 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00809 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00810 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00811 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00812 +00813 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00814 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00815 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00816 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00817 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00818 ++it; +00819 ++currentAngle; +00820 currentSize += currentSizeStep; +00821 currentSize2 += currentSizeStep2; +00822 } +00823 } +00824 <a class="code" href="a05378.html#a396">NLMISC::OptFastFloorEnd</a>(); +00825 <span class="comment">//tmp</span> +00826 <span class="comment">// uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00827 driver->renderQuads(la._Mat, 0, toProcess); +00828 <span class="comment">//PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick;*/</span> +00829 leftToDo -= toProcess; +00830 } +00831 <span class="keywordflow">while</span> (leftToDo); +00832 } +00833 <a class="code" href="a04729.html#a0">PARTICLES_CHECK_MEM</a>; +00834 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NL3D_1_1CPSFaceLookAtHelpere2" doxytag="NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" colspan="4"> +template<class T> </td> + </tr> + <tr> + <td class="md" nowrap valign="top"> void NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">T </td> + <td class="mdname" nowrap> <em>it</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>T </td> + <td class="mdname" nowrap> <em>speedIt</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03191.html">CPSFaceLookAt</a> & </td> + <td class="mdname" nowrap> <em>la</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>size</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname" nowrap> <em>srcStep</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Draw look at and align them on motion +<p> +Definition at line <a class="el" href="a06233.html#l00089">89</a> of file <a class="el" href="a06233.html">ps_face_look_at.cpp</a>. +<p> +References <a class="el" href="a06258.html#l00367">NL3D::CPSRotated2DParticle::_Angle2D</a>, <a class="el" href="a06258.html#l00368">NL3D::CPSRotated2DParticle::_Angle2DScheme</a>, <a class="el" href="a06234.html#l00124">NL3D::CPSFaceLookAt::_IndependantSizes</a>, <a class="el" href="a06258.html#l00844">NL3D::CPSMaterial::_Mat</a>, <a class="el" href="a06247.html#l01026">NL3D::CPSLocatedBindable::_Owner</a>, <a class="el" href="a06258.html#l00289">NL3D::CPSSizedParticle::_ParticleSize</a>, <a class="el" href="a03191.html#NL3D_1_1CPSFaceLookAtp19">NL3D::CPSFaceLookAt::_SecondSize</a>, <a class="el" href="a06258.html#l00290">NL3D::CPSSizedParticle::_SizeScheme</a>, <a class="el" href="a02434.html#NL3D_1_1IDrivera2">NL3D::IDriver::activeVertexBuffer()</a>, <a class="el" href="a06249.html#l00039">CHECK_VERTEX_BUFFER</a>, <a class="el" href="a06247.html#l00931">NL3D::CPSLocatedBindable::computeI()</a>, <a class="el" href="a06247.html#l00940">NL3D::CPSLocatedBindable::computeK()</a>, <a class="el" href="a06233.html#l00068">computeOrientationVectors()</a>, <a class="el" href="a06247.html#l00890">NL3D::CPSLocatedBindable::getDriver()</a>, <a class="el" href="a06262.html#l00146">NL3D::CPSQuad::getNeededVB()</a>, <a class="el" href="a06258.html#l00274">NL3D::CPSSizedParticle::getSize()</a>, <a class="el" href="a06258.html#l00265">NL3D::CPSSizedParticle::getSizeScheme()</a>, <a class="el" href="a06710.html#l00438">NL3D::CVertexBuffer::getVertexCoordPointer()</a>, <a class="el" href="a06711.html#l00473">NL3D::CVertexBuffer::getVertexSize()</a>, <a class="el" href="a06233.html#l00044">NL3D::CLookAtAlign::I</a>, <a class="el" href="a06246.html#l00500">NL3D::CPSLocated::incrementNbDrawnParticles()</a>, <a class="el" href="a06233.html#l00045">NL3D::CLookAtAlign::K</a>, <a class="el" href="a03136.html#NL3D_1_1CPSAttribMakerz714_2">NL3D::CPSAttribMaker< float >::make()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05701.html#l00125">NLMISC::OptFastFloor()</a>, <a class="el" href="a05701.html#l00123">NLMISC::OptFastFloorBegin()</a>, <a class="el" href="a05701.html#l00124">NLMISC::OptFastFloorEnd()</a>, <a class="el" href="a06152.html#l00060">PARTICLES_CHECK_MEM</a>, <a class="el" href="a02434.html#NL3D_1_1IDrivera54">NL3D::IDriver::renderQuads()</a>, <a class="el" href="a06246.html#l02142">NL3D::CPSLocatedBindable::setupDriverModelMatrix()</a>, <a class="el" href="a05981.html#l00099">sint32</a>, <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a05646.html#l00244">stride</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, <a class="el" href="a05981.html#l00096">uint8</a>, <a class="el" href="a06262.html#l00520">NL3D::CPSQuad::updateMatBeforeRendering()</a>, <a class="el" href="a06262.html#l00386">NL3D::CPSQuad::updateVbColNUVForRender()</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::x</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::y</a>, and <a class="el" href="a06673.html#l00051">NLMISC::CVector::z</a>. +<p> +<div class="fragment"><pre>00090 { +00091 <a class="code" href="a04729.html#a0">PARTICLES_CHECK_MEM</a>; +00092 <a class="code" href="a04199.html#a6">nlassert</a>(la._Owner); +00093 IDriver *driver = la.getDriver(); +00094 +00095 la.updateMatBeforeRendering(driver); +00096 +00097 CVertexBuffer &vb = la.getNeededVB(); +00098 la._Owner->incrementNbDrawnParticles(size); <span class="comment">// for benchmark purpose </span> +00099 la.setupDriverModelMatrix(); +00100 driver->activeVertexBuffer(vb); +00101 <span class="keyword">const</span> CVector I = la.computeI(); +00102 <span class="keyword">const</span> CVector K = la.computeK(); +00103 <span class="keyword">const</span> <span class="keywordtype">float</span> *rotTable = CPSRotated2DParticle::getRotTable(); +00104 <span class="comment">// for each the particle can be constantly rotated or have an independant rotation for each particle</span> +00105 <span class="comment">// number of face left, and number of face to process at once</span> +00106 <a class="code" href="a04558.html#a11">uint32</a> leftToDo = <a class="code" href="a04223.html#a587">size</a>, toProcess; +00107 <span class="keywordtype">float</span> pSizes[CPSQuad::quadBufSize]; <span class="comment">// the sizes to use </span> +00108 <span class="keywordtype">float</span> pSecondSizes[CPSQuad::quadBufSize]; <span class="comment">// the second sizes to use</span> +00109 <a class="code" href="a04558.html#a7">uint8</a> laAlignRaw[<span class="keyword">sizeof</span>(CLookAtAlign) * CPSQuad::quadBufSize]; <span class="comment">// orientation computed from motion for each particle</span> +00110 CLookAtAlign *laAlign = (CLookAtAlign *) laAlignRaw; <span class="comment">// cast to avoid unilined ctor calls</span> +00111 <span class="keywordtype">float</span> *currentSize; +00112 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep = la._SizeScheme ? 1 : 0; +00113 <span class="comment">// point the vector part in the current vertex</span> +00114 <a class="code" href="a04558.html#a7">uint8</a> *ptPos; +00115 <span class="comment">// strides to go from one vertex to another one</span> +00116 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a582">stride</a> = vb.getVertexSize(), stride2 = <a class="code" href="a04223.html#a582">stride</a> << 1, stride3 = <a class="code" href="a04223.html#a582">stride</a> + stride2, stride4 = <a class="code" href="a04223.html#a582">stride</a> << 2; +00117 <span class="keywordflow">if</span> (!la._Angle2DScheme) +00118 { +00119 <span class="comment">// constant rotation case</span> +00120 <span class="keywordflow">do</span> +00121 { +00122 <span class="comment">// restart at the beginning of the vertex buffer</span> +00123 ptPos = (<a class="code" href="a04558.html#a7">uint8</a> *) vb.getVertexCoordPointer(); +00124 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00125 +00126 <span class="keywordflow">if</span> (la._SizeScheme) +00127 { +00128 currentSize = (<span class="keywordtype">float</span> *) la._SizeScheme->make(la._Owner, size- leftToDo, pSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00129 } +00130 <span class="keywordflow">else</span> +00131 { +00132 currentSize = &la._ParticleSize; +00133 } +00134 <a class="code" href="a03193.html#NL3D_1_1CPSFaceLookAtHelpere0">computeOrientationVectors</a>(speedIt, I, K, laAlign, toProcess); +00135 speedIt = speedIt + toProcess; +00136 <span class="keyword">const</span> CLookAtAlign *currAlign = laAlign; +00137 +00138 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00139 T endIt = it + toProcess; +00140 <span class="keywordflow">if</span> (!la._IndependantSizes) +00141 { +00142 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> tabIndex = (((<a class="code" href="a04558.html#a11">uint32</a>) la._Angle2D) & 0xff) << 2; +00143 CVector v1; +00144 CVector v2; +00145 <span class="comment">// TODO : optimize if necessary</span> +00146 <span class="keywordflow">while</span> (it != endIt) +00147 { +00148 v1 = rotTable[tabIndex] * currAlign->I + rotTable[tabIndex + 1] * currAlign->K; +00149 v2 = rotTable[tabIndex + 2] * currAlign->I + rotTable[tabIndex + 3] * currAlign->K; +00150 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00151 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x; +00152 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y; +00153 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z; +00154 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00155 +00156 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00157 ((CVector *) ptPos)->x = (*it).x + *currentSize * v2.x; +00158 ((CVector *) ptPos)->y = (*it).y + *currentSize * v2.y; +00159 ((CVector *) ptPos)->z = (*it).z + *currentSize * v2.z; +00160 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00161 +00162 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00163 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x; +00164 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y; +00165 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z; +00166 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00167 +00168 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00169 ((CVector *) ptPos)->x = (*it).x - *currentSize * v2.x; +00170 ((CVector *) ptPos)->y = (*it).y - *currentSize * v2.y; +00171 ((CVector *) ptPos)->z = (*it).z - *currentSize * v2.z; +00172 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00173 +00174 ++it; +00175 ++currAlign; +00176 currentSize += currentSizeStep; +00177 } +00178 } +00179 <span class="keywordflow">else</span> <span class="comment">// independant sizes</span> +00180 { +00181 <span class="keywordtype">float</span> *currentSize2; +00182 <span class="keywordtype">float</span> secondSize; +00183 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep2; +00184 <span class="keywordflow">if</span> (la._SecondSize.getSizeScheme()) +00185 { +00186 currentSize2 = (<span class="keywordtype">float</span> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00187 currentSizeStep2 = 1; +00188 } +00189 <span class="keywordflow">else</span> +00190 { +00191 secondSize = la._SecondSize.getSize(); +00192 currentSize2 = &secondSize; +00193 currentSizeStep2 = 0; +00194 } +00195 CVector v1; +00196 CVector v2; +00197 <span class="comment">// TODO : optimize if necessary</span> +00198 <span class="keywordflow">while</span> (it != endIt) +00199 { +00200 v1 = CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * currAlign->I + CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * currAlign->K; +00201 v2 = - CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * currAlign->I + CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) la._Angle2D) * currAlign->K; +00202 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00203 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00204 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00205 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00206 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00207 +00208 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00209 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00210 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00211 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00212 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00213 +00214 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00215 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00216 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00217 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00218 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00219 +00220 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00221 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00222 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00223 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00224 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00225 ++it; +00226 ++currAlign; +00227 currentSize += currentSizeStep; +00228 currentSize2 += currentSizeStep2; +00229 } +00230 } +00231 <span class="comment">// uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00232 driver->renderQuads(la._Mat, 0, toProcess); +00233 <span class="comment">// PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick;</span> +00234 leftToDo -= toProcess; +00235 } +00236 <span class="keywordflow">while</span> (leftToDo); +00237 } +00238 <span class="keywordflow">else</span> +00239 { +00240 <span class="keywordtype">float</span> pAngles[CPSQuad::quadBufSize]; <span class="comment">// the angles to use</span> +00241 <span class="keywordtype">float</span> *currentAngle; +00242 <span class="keywordflow">do</span> +00243 { +00244 <span class="comment">// restart at the beginning of the vertex buffer</span> +00245 ptPos = (<a class="code" href="a04558.html#a7">uint8</a> *) vb.getVertexCoordPointer(); +00246 toProcess = leftToDo <= CPSQuad::quadBufSize ? leftToDo : CPSQuad::quadBufSize; +00247 <span class="keywordflow">if</span> (la._SizeScheme) +00248 { +00249 currentSize = (<span class="keywordtype">float</span> *) la._SizeScheme->make(la._Owner, size - leftToDo, pSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00250 } +00251 <span class="keywordflow">else</span> +00252 { +00253 currentSize = &la._ParticleSize; +00254 } +00255 <a class="code" href="a03193.html#NL3D_1_1CPSFaceLookAtHelpere0">computeOrientationVectors</a>(speedIt, I, K, laAlign, toProcess); +00256 speedIt = speedIt + toProcess; +00257 <span class="keyword">const</span> CLookAtAlign *currAlign = laAlign; +00258 currentAngle = (<span class="keywordtype">float</span> *) la._Angle2DScheme->make(la._Owner, size - leftToDo, pAngles, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00259 la.updateVbColNUVForRender(vb, size - leftToDo, toProcess, srcStep); +00260 T endIt = it + toProcess; +00261 CVector v1, v2; +00262 <a class="code" href="a05378.html#a395">NLMISC::OptFastFloorBegin</a>(); +00263 <span class="keywordflow">if</span> (!la._IndependantSizes) +00264 { +00265 <span class="keywordflow">while</span> (it != endIt) +00266 { +00267 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> tabIndex = ((<a class="code" href="a05378.html#a397">NLMISC::OptFastFloor</a>(*currentAngle)) & 0xff) << 2; +00268 <span class="comment">// lets avoid some ctor calls</span> +00269 v1.x = *currentSize * (rotTable[tabIndex] * currAlign->I.x + rotTable[tabIndex + 1] * currAlign->K.x); +00270 v1.y = *currentSize * (rotTable[tabIndex] * currAlign->I.y + rotTable[tabIndex + 1] * currAlign->K.y); +00271 v1.z = *currentSize * (rotTable[tabIndex] * currAlign->I.z + rotTable[tabIndex + 1] * currAlign->K.z); +00272 +00273 v2.x = *currentSize * (rotTable[tabIndex + 2] * currAlign->I.x + rotTable[tabIndex + 3] * currAlign->K.x); +00274 v2.y = *currentSize * (rotTable[tabIndex + 2] * currAlign->I.y + rotTable[tabIndex + 3] * currAlign->K.y); +00275 v2.z = *currentSize * (rotTable[tabIndex + 2] * currAlign->I.z + rotTable[tabIndex + 3] * currAlign->K.z); +00276 +00277 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00278 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride); +00279 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride2); +00280 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos + stride3); +00281 +00282 ((CVector *) ptPos)->x = (*it).x + v1.x; +00283 ((CVector *) ptPos)->y = (*it).y + v1.y; +00284 ((CVector *) ptPos)->z = (*it).z + v1.z; +00285 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00286 +00287 ((CVector *) ptPos)->x = (*it).x + v2.x; +00288 ((CVector *) ptPos)->y = (*it).y + v2.y; +00289 ((CVector *) ptPos)->z = (*it).z + v2.z; +00290 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00291 +00292 ((CVector *) ptPos)->x = (*it).x - v1.x; +00293 ((CVector *) ptPos)->y = (*it).y - v1.y; +00294 ((CVector *) ptPos)->z = (*it).z - v1.z; +00295 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00296 +00297 ((CVector *) ptPos)->x = (*it).x - v2.x; +00298 ((CVector *) ptPos)->y = (*it).y - v2.y; +00299 ((CVector *) ptPos)->z = (*it).z - v2.z; +00300 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00301 +00302 ++it; +00303 ++ currAlign; +00304 currentSize += currentSizeStep; +00305 ++currentAngle; +00306 } +00307 } +00308 <span class="keywordflow">else</span> <span class="comment">// independant size, and non-constant rotation</span> +00309 { +00310 +00311 <span class="keywordtype">float</span> *currentSize2; +00312 <span class="keywordtype">float</span> secondSize; +00313 <a class="code" href="a04558.html#a11">uint32</a> currentSizeStep2; +00314 <span class="keywordflow">if</span> (la._SecondSize.getSizeScheme()) +00315 { +00316 currentSize2 = (<span class="keywordtype">float</span> *) la._SecondSize.getSizeScheme()->make(la._Owner, size- leftToDo, pSecondSizes, <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>), toProcess, <span class="keyword">true</span>, srcStep); +00317 currentSizeStep2 = 1; +00318 } +00319 <span class="keywordflow">else</span> +00320 { +00321 secondSize = la._SecondSize.getSize(); +00322 currentSize2 = &secondSize; +00323 currentSizeStep2 = 0; +00324 } +00325 +00326 <span class="keywordtype">float</span> cosAngle, sinAngle; +00327 <span class="keywordflow">while</span> (it != endIt) +00328 { +00329 cosAngle = CPSUtil::getCos((<a class="code" href="a04558.html#a10">sint32</a>) *currentAngle); +00330 sinAngle = CPSUtil::getSin((<a class="code" href="a04558.html#a10">sint32</a>) *currentAngle); +00331 v1 = cosAngle * currAlign->I + sinAngle * currAlign->K; +00332 v2 = - sinAngle * currAlign->I + cosAngle * currAlign->K; +00333 +00334 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00335 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x + *currentSize2 * v2.x; +00336 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y + *currentSize2 * v2.y; +00337 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z + *currentSize2 * v2.z; +00338 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00339 +00340 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00341 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x + *currentSize2 * v2.x; +00342 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y + *currentSize2 * v2.y; +00343 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z + *currentSize2 * v2.z; +00344 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00345 +00346 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00347 ((CVector *) ptPos)->x = (*it).x + *currentSize * v1.x - *currentSize2 * v2.x; +00348 ((CVector *) ptPos)->y = (*it).y + *currentSize * v1.y - *currentSize2 * v2.y; +00349 ((CVector *) ptPos)->z = (*it).z + *currentSize * v1.z - *currentSize2 * v2.z; +00350 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00351 +00352 <a class="code" href="a04826.html#a0">CHECK_VERTEX_BUFFER</a>(vb, ptPos); +00353 ((CVector *) ptPos)->x = (*it).x - *currentSize * v1.x - *currentSize2 * v2.x; +00354 ((CVector *) ptPos)->y = (*it).y - *currentSize * v1.y - *currentSize2 * v2.y; +00355 ((CVector *) ptPos)->z = (*it).z - *currentSize * v1.z - *currentSize2 * v2.z; +00356 ptPos += <a class="code" href="a04223.html#a582">stride</a>; +00357 ++it; +00358 ++currentAngle; +00359 ++ currAlign; +00360 currentSize += currentSizeStep; +00361 currentSize2 += currentSizeStep2; +00362 } +00363 } +00364 <a class="code" href="a05378.html#a396">NLMISC::OptFastFloorEnd</a>(); +00365 <span class="comment">//tmp</span> +00366 <span class="comment">// uint64 startTick = NLMISC::CTime::getPerformanceTime(); </span> +00367 driver->renderQuads(la._Mat, 0, toProcess); +00368 <span class="comment">// PSLookAtRenderTime += NLMISC::CTime::getPerformanceTime() - startTick;</span> +00369 leftToDo -= toProcess; +00370 } +00371 <span class="keywordflow">while</span> (leftToDo); +00372 } +00373 <a class="code" href="a04729.html#a0">PARTICLES_CHECK_MEM</a>; +00374 } +</pre></div> </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following file:<ul> +<li><a class="el" href="a06233.html">ps_face_look_at.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 07:12:22 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |