diff options
Diffstat (limited to 'docs/doxygen/nel/a06275.html')
-rw-r--r-- | docs/doxygen/nel/a06275.html | 623 |
1 files changed, 623 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a06275.html b/docs/doxygen/nel/a06275.html new file mode 100644 index 00000000..c777afd6 --- /dev/null +++ b/docs/doxygen/nel/a06275.html @@ -0,0 +1,623 @@ +<!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: ps_ribbon_base.cpp Source File</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>ps_ribbon_base.cpp</h1><a href="a04852.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <span class="comment">/* Copyright, 2001 Nevrax Ltd.</span> +00008 <span class="comment"> *</span> +00009 <span class="comment"> * This file is part of NEVRAX NEL.</span> +00010 <span class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</span> +00011 <span class="comment"> * it under the terms of the GNU General Public License as published by</span> +00012 <span class="comment"> * the Free Software Foundation; either version 2, or (at your option)</span> +00013 <span class="comment"> * any later version.</span> +00014 <span class="comment"></span> +00015 <span class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</span> +00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span> +00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> +00018 <span class="comment"> * General Public License for more details.</span> +00019 <span class="comment"></span> +00020 <span class="comment"> * You should have received a copy of the GNU General Public License</span> +00021 <span class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</span> +00022 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</span> +00023 <span class="comment"> * MA 02111-1307, USA.</span> +00024 <span class="comment"> */</span> +00025 +00026 <span class="preprocessor">#include "<a class="code" href="a05015.html">std3d.h</a>"</span> +00027 +00028 <span class="preprocessor">#include "<a class="code" href="a04853.html">3d/ps_ribbon_base.h</a>"</span> +00029 <span class="preprocessor">#include "<a class="code" href="a04720.html">3d/particle_system.h</a>"</span> +00030 +00031 <span class="keyword">namespace </span>NL3D +00032 { +00033 +00035 <span class="comment">// CPSRibbonBase implementation //</span> +00037 <span class="comment"></span> +00038 +<a name="l00040"></a><a class="code" href="a05363.html#a514">00040</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a05363.html#a514">BuildHermiteVector</a>(<span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &P0, +00041 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &P1, +00042 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &T0, +00043 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &T1, +00044 <a class="code" href="a03128.html">NLMISC::CVector</a> &dest, +00045 <span class="keywordtype">float</span> lambda +00046 ) +00047 { +00048 <span class="keyword">const</span> <span class="keywordtype">float</span> lambda2 = lambda * lambda; +00049 <span class="keyword">const</span> <span class="keywordtype">float</span> lambda3 = lambda2 * lambda; +00050 <span class="keyword">const</span> <span class="keywordtype">float</span> h1 = 2 * lambda3 - 3 * lambda2 + 1; +00051 <span class="keyword">const</span> <span class="keywordtype">float</span> h2 = - 2 * lambda3 + 3 * lambda2; +00052 <span class="keyword">const</span> <span class="keywordtype">float</span> h3 = lambda3 - 2 * lambda2 + lambda; +00053 <span class="keyword">const</span> <span class="keywordtype">float</span> h4 = lambda3 - lambda2; +00055 dest.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2051_8">set</a> (h1 * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> + h2 * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> + h3 * T0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> + h4 * T1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, +00056 h1 * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a> + h2 * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a> + h3 * T0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a> + h4 * T1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a>, +00057 h1 * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a> + h2 * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a> + h3 * T0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a> + h4 * T1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>); +00058 +00059 } +00060 +<a name="l00062"></a><a class="code" href="a05363.html#a515">00062</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="a05363.html#a515">BuildLinearVector</a>(<span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &P0, +00063 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &P1, +00064 <a class="code" href="a03128.html">NLMISC::CVector</a> &dest, +00065 <span class="keywordtype">float</span> lambda, +00066 <span class="keywordtype">float</span> oneMinusLambda +00067 ) +00068 { +00069 dest.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2051_8">set</a> (lambda * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> + oneMinusLambda * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, +00070 lambda * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a> + oneMinusLambda * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro1">y</a>, +00071 lambda * P1.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a> + oneMinusLambda * P0.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>); +00072 } +00073 +00074 +<a name="l00075"></a><a class="code" href="a05363.html#a267">00075</a> <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a05363.html#a267">EndRibbonStorage</a> = 1; +00076 +00077 +00078 <span class="comment">//=======================================================</span> +<a name="l00079"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBasez753_0">00079</a> CPSRibbonBase::CPSRibbonBase() : _NbSegs(8), +00080 _SegDuration(0.02f), +00081 _Parametric(false), +00082 _RibbonIndex(0), +00083 _LastUpdateDate(0), +00084 _RibbonMode(VariableSize), +00085 _InterpolationMode(Hermitte), +00086 _RibbonLength(1), +00087 _SegLength(_RibbonLength / _NbSegs), +00088 _LODDegradation(1) +00089 +00090 { +00091 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotb10">initDateVect</a>(); +00092 } +00093 +00094 <span class="comment">//=======================================================</span> +<a name="l00095"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotz755_3">00095</a> <span class="keywordtype">void</span> CPSRibbonBase::setRibbonLength(<span class="keywordtype">float</span> length) +00096 { +00097 <a class="code" href="a04199.html#a6">nlassert</a>(length > 0.f); +00098 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser4">_RibbonLength</a> = length; +00099 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser8">_SegLength</a> = length / <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a>; +00100 } +00101 +00102 <span class="comment">//=======================================================</span> +<a name="l00103"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotz754_3">00103</a> <span class="keywordtype">void</span> CPSRibbonBase::setRibbonMode(TRibbonMode mode) +00104 { +00105 <a class="code" href="a04199.html#a6">nlassert</a>(mode < <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw11NL3D_1_1CPSTailDotw8">RibbonModeLast</a>); +00106 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser5">_RibbonMode</a> = mode; +00107 } +00108 +00109 +00110 <span class="comment">//=======================================================</span> +<a name="l00111"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotz754_2">00111</a> <span class="keywordtype">void</span> CPSRibbonBase::setInterpolationMode(TInterpolationMode mode) +00112 { +00113 <a class="code" href="a04199.html#a6">nlassert</a>(mode < <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw10NL3D_1_1CPSTailDotw5">InterpModeLast</a>); +00114 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser0">_InterpolationMode</a> = mode; +00115 } +00116 +00117 <span class="comment">//=======================================================</span> +<a name="l00118"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotz755_5">00118</a> <span class="keywordtype">void</span> CPSRibbonBase::setTailNbSeg(<a class="code" href="a04558.html#a11">uint32</a> nbSegs) +00119 { +00120 <a class="code" href="a04199.html#a6">nlassert</a>(nbSegs >= 1); +00121 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> = nbSegs; +00122 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a> = 0; +00123 <span class="keywordflow">if</span> (_Owner) +00124 { +00125 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaseb12">resize</a>(_Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda34">getMaxSize</a>()); +00126 } +00127 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotb10">initDateVect</a>(); +00128 } +00129 +00130 +00131 <span class="comment">//======================================================= </span> +<a name="l00132"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotz755_4">00132</a> <span class="keywordtype">void</span> CPSRibbonBase::setSegDuration(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime) +00133 { +00134 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp10">_SegDuration</a> = ellapsedTime; +00135 +00136 } +00137 +00138 <span class="comment">//======================================================= </span> +<a name="l00139"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb19">00139</a> <span class="keywordtype">void</span> CPSRibbonBase::updateGlobals(<span class="keywordtype">float</span> realET) +00140 { +00141 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00142 <a class="code" href="a04199.html#a6">nlassert</a>(_Owner); +00143 <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda44">getSize</a>(); +00144 <span class="keywordflow">if</span> (!<a class="code" href="a04223.html#a587">size</a>) <span class="keywordflow">return</span>; +00145 <span class="keyword">const</span> <a class="code" href="a05363.html#a366">TAnimationTime</a> currDate = _Owner-><a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-><a class="code" href="a03041.html#NL3D_1_1CParticleSystemz584_1">getSystemDate</a>() + realET; +00146 <span class="keywordflow">if</span> (currDate - _LastUpdateDate >= <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp10">_SegDuration</a>) +00147 { +00148 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a> == 0) <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a> = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>; +00149 <span class="keywordflow">else</span> --<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>; +00150 +00152 ::memmove(&<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>[1], &_SamplingDate[0], <span class="keyword">sizeof</span>(<span class="keywordtype">float</span>) * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>)); +00153 _LastUpdateDate = currDate; +00154 } +00155 +00157 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>[0] = currDate; +00158 +00160 TPSAttribVector::iterator posIt = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); +00161 <a class="code" href="a03128.html">NLMISC::CVector</a> *currIt = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>]; +00162 <a class="code" href="a04558.html#a15">uint</a> k = <a class="code" href="a04223.html#a587">size</a>; +00163 <span class="keywordflow">for</span> (;;) +00164 { +00165 *currIt = *posIt; +00166 --k; +00167 <span class="keywordflow">if</span> (!k) <span class="keywordflow">break</span>; +00168 ++posIt; +00169 currIt += (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00170 } +00171 } +00172 +00173 +00174 <span class="comment">//======================================================= </span> +<a name="l00175"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased1">00175</a> <span class="keywordtype">void</span> CPSRibbonBase::computeHermitteRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">NLMISC::CVector</a> *dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a582">stride</a> <span class="comment">/* = sizeof(NLMISC::CVector)*/</span>) +00176 { +00177 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00178 <a class="code" href="a03128.html">NLMISC::CVector</a> *startIt = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[(<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>) * <a class="code" href="a04223.html#a566">index</a>]; +00179 <a class="code" href="a03128.html">NLMISC::CVector</a> *endIt = startIt + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00180 <a class="code" href="a03128.html">NLMISC::CVector</a> *currIt = startIt + <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>; +00181 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> *firstIt = currIt; +00182 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextIt = currIt + 1; +00183 <span class="keywordflow">if</span> (nextIt == endIt) nextIt = startIt; +00184 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextNextIt = nextIt + 1; +00185 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00186 <span class="keywordtype">float</span> *date = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>[0]; +00187 +00188 <a class="code" href="a03128.html">NLMISC::CVector</a> t0 = (*nextIt - *currIt); +00189 <a class="code" href="a03128.html">NLMISC::CVector</a> t1 = 0.5f * (*nextNextIt - *currIt); +00190 +00191 <a class="code" href="a04558.html#a15">uint</a> leftToDo = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a> + 1; +00192 +00193 <span class="keywordtype">float</span> lambda = 0.f; +00194 <span class="keywordtype">float</span> lambdaStep = 1.f; +00195 +00196 +00197 <span class="keywordflow">for</span> (;;) +00198 { +00199 <span class="keywordtype">float</span> dt = date[0] - date[1]; +00200 +00201 <span class="keywordflow">if</span> (dt < 10E-6f) <span class="comment">// we reached the start of ribbon</span> +00202 { +00203 +00204 <span class="keywordflow">do</span> +00205 { +00206 *dest = *currIt; +00207 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00208 } +00209 <span class="keywordflow">while</span> (--leftToDo); +00210 <span class="keywordflow">return</span>; +00211 } +00212 +00213 <span class="keywordtype">float</span> newLambdaStep = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp12">_UsedSegDuration</a> / dt; +00214 <span class="comment">// readapt lambda</span> +00215 lambda *= newLambdaStep / lambdaStep; +00216 lambdaStep = newLambdaStep; +00217 <span class="keywordflow">for</span>(;;) +00218 { +00219 <span class="keywordflow">if</span> (lambda >= 1.f) <span class="keywordflow">break</span>; +00221 <a class="code" href="a05363.html#a514">BuildHermiteVector</a>(*currIt, *nextIt, t0, t1, *dest, lambda); +00222 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00223 -- leftToDo; +00224 <span class="keywordflow">if</span> (!leftToDo) <span class="keywordflow">return</span>; +00225 lambda += lambdaStep; +00226 } +00227 +00228 ++date; +00229 lambda -= 1.f; +00230 +00231 <span class="comment">// Start new segment and compute new tangents</span> +00232 t0 = t1; +00233 currIt = nextIt; +00234 nextIt = nextNextIt; +00235 ++nextNextIt; +00236 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00237 <span class="keywordflow">if</span> (nextNextIt == firstIt) +00238 { +00239 t1 = *nextIt - *currIt; +00240 } +00241 <span class="keywordflow">else</span> +00242 { +00243 t1 = 0.5f * (*nextNextIt - *currIt); +00244 } +00245 } +00246 } +00247 +00248 <span class="comment">//======================================================= </span> +<a name="l00249"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased3">00249</a> <span class="keywordtype">void</span> CPSRibbonBase::computeLinearRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">NLMISC::CVector</a> *dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a582">stride</a> <span class="comment">/* = sizeof(NLMISC::CVector)*/</span>) +00250 { +00252 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00253 <a class="code" href="a03128.html">NLMISC::CVector</a> *startIt = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[(<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>) * <a class="code" href="a04223.html#a566">index</a>]; +00254 <a class="code" href="a03128.html">NLMISC::CVector</a> *endIt = startIt + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00255 <a class="code" href="a03128.html">NLMISC::CVector</a> *currIt = startIt + <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>; +00256 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextIt = currIt + 1; +00257 <span class="keywordflow">if</span> (nextIt == endIt) nextIt = startIt; +00258 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextNextIt = nextIt + 1; +00259 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00260 <span class="keywordtype">float</span> *date = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>[0]; +00261 +00262 <a class="code" href="a04558.html#a15">uint</a> leftToDo = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a> + 1; +00263 +00264 <span class="keywordtype">float</span> lambda = 0.f; +00265 <span class="keywordtype">float</span> lambdaStep = 1.f; +00266 +00267 <span class="keywordflow">for</span> (;;) +00268 { +00269 <span class="keywordtype">float</span> dt = date[0] - date[1]; +00270 +00271 <span class="keywordflow">if</span> (dt < 10E-6f) <span class="comment">// we reached the start of ribbon</span> +00272 { +00273 <span class="keywordflow">do</span> +00274 { +00275 *dest = *currIt; +00276 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00277 } +00278 <span class="keywordflow">while</span> (--leftToDo); +00279 <span class="keywordflow">return</span>; +00280 } +00281 +00282 +00283 <span class="keywordtype">float</span> newLambdaStep = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp12">_UsedSegDuration</a> / dt; +00284 <span class="comment">// readapt lambda</span> +00285 lambda *= newLambdaStep / lambdaStep; +00286 lambdaStep = newLambdaStep; +00287 +00288 <span class="keywordtype">float</span> oneMinusLambda = 1.f - lambda; +00289 <span class="keywordflow">for</span>(;;) +00290 { +00291 <span class="keywordflow">if</span> (lambda >= 1.f) <span class="keywordflow">break</span>; +00293 <a class="code" href="a05363.html#a515">BuildLinearVector</a>(*currIt, *nextIt, *dest, lambda, oneMinusLambda); +00294 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00295 -- leftToDo; +00296 <span class="keywordflow">if</span> (!leftToDo) <span class="keywordflow">return</span>; +00297 lambda += lambdaStep; +00298 oneMinusLambda -= lambdaStep; +00299 } +00300 +00301 ++date; +00302 lambda -= 1.f; +00303 +00304 currIt = nextIt; +00305 nextIt = nextNextIt; +00306 ++nextNextIt; +00307 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00308 +00309 } +00310 } +00311 +00312 +00313 +00314 <span class="comment">//======================================================= </span> +<a name="l00315"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased2">00315</a> <span class="keywordtype">void</span> CPSRibbonBase::computeLinearCstSizeRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">NLMISC::CVector</a> *dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a582">stride</a> <span class="comment">/* = sizeof(NLMISC::CVector)*/</span>) +00316 { +00317 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00318 <a class="code" href="a03128.html">CVector</a> *startIt = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[(<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>) * <a class="code" href="a04223.html#a566">index</a>]; +00319 <a class="code" href="a03128.html">NLMISC::CVector</a> *endIt = startIt + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00320 <a class="code" href="a03128.html">NLMISC::CVector</a> *currIt = startIt + <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>; +00321 <a class="code" href="a03128.html">NLMISC::CVector</a> *firstIt = currIt; +00322 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextIt = currIt + 1; +00323 <span class="keywordflow">if</span> (nextIt == endIt) nextIt = startIt; +00324 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextNextIt = nextIt + 1; +00325 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00326 +00327 <a class="code" href="a04558.html#a15">uint</a> leftToDo = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a> + 1; +00328 +00329 <span class="keywordtype">float</span> lambda = 0.f; +00330 <span class="keywordtype">float</span> lambdaStep = 1.f; +00331 +00332 +00334 <span class="keywordflow">for</span> (;;) +00335 { +00337 <span class="keyword">const</span> <span class="keywordtype">float</span> sampleLength = (*nextIt - *currIt).norm(); +00338 <span class="keywordflow">if</span> (sampleLength > 10E-6f) +00339 { +00341 <span class="keywordtype">float</span> newLambdaStep = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp13">_UsedSegLength</a> / sampleLength; +00342 <span class="comment">// readapt lambda</span> +00343 lambda *= newLambdaStep / lambdaStep; +00344 lambdaStep = newLambdaStep; +00345 +00346 <span class="keywordtype">float</span> oneMinusLambda = 1.f - lambda; +00347 <span class="keywordflow">for</span>(;;) +00348 { +00349 <span class="keywordflow">if</span> (lambda >= 1.f) <span class="keywordflow">break</span>; +00351 <a class="code" href="a05363.html#a515">BuildLinearVector</a>(*currIt, *nextIt, *dest, lambda, oneMinusLambda); +00352 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00353 -- leftToDo; +00354 <span class="keywordflow">if</span> (!leftToDo) <span class="keywordflow">return</span>; +00355 lambda += lambdaStep; +00356 oneMinusLambda -= lambdaStep; +00357 } +00358 lambda -= 1.f; +00359 } +00360 +00362 currIt = nextIt; +00363 nextIt = nextNextIt; +00364 ++nextNextIt; +00365 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00366 <span class="keywordflow">if</span> (nextNextIt == firstIt) +00367 { +00368 <span class="comment">// The length of the sampling curve is too short</span> +00369 <span class="comment">// must truncate the ribbon.</span> +00370 <a class="code" href="a03128.html">NLMISC::CVector</a> &toDup = *nextIt; +00371 <span class="keywordflow">while</span> (leftToDo --) +00372 { +00373 *dest = toDup; +00374 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00375 } +00376 <span class="keywordflow">return</span>; +00377 } +00378 } +00379 } +00380 +00381 <span class="comment">//======================================================= </span> +<a name="l00382"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased0">00382</a> <span class="keywordtype">void</span> CPSRibbonBase::computeHermitteCstSizeRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">NLMISC::CVector</a> *dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a582">stride</a> <span class="comment">/* = sizeof(NLMISC::CVector)*/</span>) +00383 { +00384 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00385 <a class="code" href="a03128.html">NLMISC::CVector</a> *startIt = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[(<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>) * <a class="code" href="a04223.html#a566">index</a>]; +00386 <a class="code" href="a03128.html">NLMISC::CVector</a> *endIt = startIt + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00387 <a class="code" href="a03128.html">NLMISC::CVector</a> *currIt = startIt + <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser3">_RibbonIndex</a>; +00388 <a class="code" href="a03128.html">NLMISC::CVector</a> *firstIt = currIt; +00389 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextIt = currIt + 1; +00390 <span class="keywordflow">if</span> (nextIt == endIt) nextIt = startIt; +00391 <a class="code" href="a03128.html">NLMISC::CVector</a> *nextNextIt = nextIt + 1; +00392 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00393 +00394 <a class="code" href="a03128.html">NLMISC::CVector</a> t0 = (*nextIt - *currIt); +00395 <a class="code" href="a03128.html">NLMISC::CVector</a> t1 = 0.5f * (*nextNextIt - *currIt); +00396 +00397 <a class="code" href="a04558.html#a15">uint</a> leftToDo = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a> + 1; +00398 +00399 <span class="keywordtype">float</span> lambda = 0.f; +00400 <span class="keywordtype">float</span> lambdaStep = 1.f; +00401 +00402 +00405 <span class="keywordflow">for</span> (;;) +00406 { +00408 <span class="keyword">const</span> <span class="keywordtype">float</span> sampleLength = (*nextIt - *currIt).norm(); +00409 <span class="keywordflow">if</span> (sampleLength > 10E-6f) +00410 { +00412 <span class="keywordtype">float</span> newLambdaStep = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp13">_UsedSegLength</a> / sampleLength; +00413 <span class="comment">// readapt lambda</span> +00414 lambda *= newLambdaStep / lambdaStep; +00415 lambdaStep = newLambdaStep; +00416 +00417 <span class="keywordflow">for</span>(;;) +00418 { +00419 <span class="keywordflow">if</span> (lambda >= 1.f) <span class="keywordflow">break</span>; +00421 <a class="code" href="a05363.html#a514">BuildHermiteVector</a>(*currIt, *nextIt, t0, t1, *dest, lambda); +00422 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00423 -- leftToDo; +00424 <span class="keywordflow">if</span> (!leftToDo) <span class="keywordflow">return</span>; +00425 lambda += lambdaStep; +00426 } +00427 lambda -= 1.f; +00428 } +00429 +00431 currIt = nextIt; +00432 nextIt = nextNextIt; +00433 ++nextNextIt; +00434 <span class="keywordflow">if</span> (nextNextIt == endIt) nextNextIt = startIt; +00435 <span class="keywordflow">if</span> (nextNextIt == firstIt) +00436 { +00437 <span class="comment">// The length of the sampling curve is too short</span> +00438 <span class="comment">// must truncate the ribbon.</span> +00439 <a class="code" href="a03128.html">NLMISC::CVector</a> &toDup = *nextIt; +00440 <span class="keywordflow">while</span> (leftToDo --) +00441 { +00442 *dest = toDup; +00443 dest = (<a class="code" href="a03128.html">NLMISC::CVector</a> *) ((<a class="code" href="a04558.html#a7">uint8</a> *) dest + <a class="code" href="a04223.html#a582">stride</a>); +00444 } +00445 <span class="keywordflow">return</span>; +00446 } +00448 t0 = t1; +00449 t1 = 0.5f * (*nextNextIt - *currIt); +00450 } +00451 } +00452 +00453 +00454 <span class="comment">//======================================================= </span> +<a name="l00455"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb1">00455</a> <span class="keywordtype">void</span> CPSRibbonBase::computeRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">NLMISC::CVector</a> *dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a582">stride</a> <span class="comment">/* = sizeof(NLMISC::CVector)*/</span>) +00456 { +00457 <span class="keywordflow">switch</span> (<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser0">_InterpolationMode</a>) +00458 { +00459 <span class="keywordflow">case</span> <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw10NL3D_1_1CPSTailDotw6">Linear</a>: +00460 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser5">_RibbonMode</a> == <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw11NL3D_1_1CPSTailDotw12">VariableSize</a>) +00461 { +00462 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased3">computeLinearRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, dest, <a class="code" href="a04223.html#a582">stride</a>); +00463 } +00464 <span class="keywordflow">else</span> +00465 { +00466 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased2">computeLinearCstSizeRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, dest, <a class="code" href="a04223.html#a582">stride</a>); +00467 } +00468 <span class="keywordflow">break</span>; +00469 <span class="keywordflow">case</span> <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw10NL3D_1_1CPSTailDotw4">Hermitte</a>: +00470 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser5">_RibbonMode</a> == <a class="code" href="a03227.html#NL3D_1_1CPSTailDotw11NL3D_1_1CPSTailDotw12">VariableSize</a>) +00471 { +00472 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased1">computeHermitteRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, dest, <a class="code" href="a04223.html#a582">stride</a>); +00473 +00474 } +00475 <span class="keywordflow">else</span> +00476 { +00477 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased0">computeHermitteCstSizeRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, dest, <a class="code" href="a04223.html#a582">stride</a>); +00478 } +00479 <span class="keywordflow">break</span>; +00480 <span class="keywordflow">default</span>: +00481 <a class="code" href="a04199.html#a6">nlassert</a>(0); +00482 <span class="keywordflow">break</span>; +00483 } +00484 +00485 } +00486 +00487 +00488 <span class="comment">//======================================================= </span> +<a name="l00489"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased4">00489</a> <span class="keywordtype">void</span> CPSRibbonBase::dupRibbon(<a class="code" href="a04558.html#a15">uint</a> dest, <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a652">src</a>) +00490 { +00491 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00492 <a class="code" href="a04199.html#a6">nlassert</a>(_Owner); +00493 <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda44">getSize</a>(); +00494 <a class="code" href="a04199.html#a6">nlassert</a>(dest < <a class="code" href="a04223.html#a587">size</a> && <a class="code" href="a04223.html#a652">src</a> < <a class="code" href="a04223.html#a587">size</a>); +00495 ::memcpy(&<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[dest * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + <a class="code" href="a05363.html#a267">EndRibbonStorage</a> + 1)], &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[<a class="code" href="a04223.html#a652">src</a> * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + <a class="code" href="a05363.html#a267">EndRibbonStorage</a> + 1)], <span class="keyword">sizeof</span>(<a class="code" href="a03128.html">NLMISC::CVector</a>) * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>)); +00496 } +00497 +00498 <span class="comment">//======================================================= </span> +<a name="l00499"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaseb9">00499</a> <span class="keywordtype">void</span> CPSRibbonBase::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex) +00500 { +00501 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>) <span class="keywordflow">return</span>; +00503 <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda37">getNewElementIndex</a>(); +00504 <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &pos = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]; <span class="comment">// get the pos of the new element;</span> +00505 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased5">resetSingleRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, pos); +00506 } +00507 +00508 <span class="comment">//======================================================= </span> +<a name="l00509"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaseb3">00509</a> <span class="keywordtype">void</span> CPSRibbonBase::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>) +00510 { +00511 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>) <span class="keywordflow">return</span>; +00512 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a> = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda44">getSize</a>(); +00513 <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a566">index</a> == (<a class="code" href="a04223.html#a587">size</a> - 1)) <span class="keywordflow">return</span>; <span class="comment">// was the last element, no permutation needed.</span> +00514 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased4">dupRibbon</a>(<a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a04223.html#a587">size</a> - 1); +00515 } +00516 +00517 <span class="comment">//======================================================= </span> +<a name="l00518"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaseb12">00518</a> <span class="keywordtype">void</span> CPSRibbonBase::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>) +00519 { +00520 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> < (1 << 16)); +00521 <span class="keywordflow">if</span> (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>) <span class="keywordflow">return</span>; +00522 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>.resize(<a class="code" href="a04223.html#a587">size</a> * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>)); +00523 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotb15">resetFromOwner</a>(); +00524 } +00525 +00526 +00527 <span class="comment">//======================================================= </span> +<a name="l00528"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased5">00528</a> <span class="keywordtype">void</span> CPSRibbonBase::resetSingleRibbon(<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a03128.html">NLMISC::CVector</a> &pos) +00529 { +00530 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00531 <a class="code" href="a03128.html">NLMISC::CVector</a> *it = &<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>[(<a class="code" href="a04223.html#a566">index</a> * (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>))]; +00532 std::fill(it, it + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>), pos); +00533 } +00534 +00535 +00536 +00537 <span class="comment">//======================================================= </span> +<a name="l00538"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb15">00538</a> <span class="keywordtype">void</span> CPSRibbonBase::resetFromOwner() +00539 { +00540 <a class="code" href="a04199.html#a6">nlassert</a>(!<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a>); +00541 TPSAttribVector::iterator posIt = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); +00542 TPSAttribVector::iterator endPosIt = _Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>(); +00543 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; posIt != endPosIt; ++posIt, ++k) +00544 { +00545 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased5">resetSingleRibbon</a>(k, *posIt); +00546 } +00547 } +00548 +00549 <span class="comment">//======================================================= </span> +<a name="l00550"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb11">00550</a> <span class="keywordtype">void</span> CPSRibbonBase::motionTypeChanged(<span class="keywordtype">bool</span> parametric) +00551 { +00552 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp9">_Parametric</a> = parametric; +00553 <span class="keywordflow">if</span> (parametric) +00554 { +00555 <a class="code" href="a05378.html#a381">NLMISC::contReset</a>(<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser6">_Ribbons</a>); <span class="comment">// kill the vector </span> +00556 } +00557 <span class="keywordflow">else</span> +00558 { +00559 <a class="code" href="a04199.html#a6">nlassert</a>(_Owner); +00560 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaseb12">resize</a>(_Owner-><a class="code" href="a03214.html#NL3D_1_1CPSLocateda34">getMaxSize</a>()); +00561 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotb10">initDateVect</a>(); +00562 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotb15">resetFromOwner</a>(); +00563 } +00564 } +00565 +00566 +00567 <span class="comment">//======================================================= </span> +<a name="l00568"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb10">00568</a> <span class="keywordtype">void</span> CPSRibbonBase::initDateVect() +00569 { +00570 <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>.resize( <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>); +00571 std::fill(<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>.begin(), <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>.begin() + (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> + 1 + <a class="code" href="a05363.html#a267">EndRibbonStorage</a>), 0.f); +00572 } +00573 +00574 +00575 <span class="comment">//======================================================= </span> +<a name="l00576"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBasez753_1">00576</a> <span class="keywordtype">void</span> CPSRibbonBase::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>) +00577 { +00578 CPSParticle::serial(f); +00579 <a class="code" href="a04558.html#a14">sint</a> ver = f.serialVersion(1); +00580 f.serialEnum(_RibbonMode); +00581 f.serialEnum(_InterpolationMode); +00582 f.serial(_NbSegs, _SegDuration); +00583 <span class="keywordflow">if</span> (_RibbonMode == FixedSize) +00584 { +00585 f.serial(_RibbonLength); +00586 <span class="keywordflow">if</span> (f.isReading()) +00587 { +00588 _SegLength = _RibbonLength / _NbSegs; +00589 } +00590 } +00591 +00592 <span class="keywordflow">if</span> (f.isReading()) +00593 { +00594 <span class="keywordflow">if</span> (_Owner) +00595 { +00596 resize(_Owner->getMaxSize()); +00597 initDateVect(); +00598 resetFromOwner(); +00599 } +00600 } +00601 +00602 <span class="keywordflow">if</span> (ver >= 1) +00603 { +00604 f.serial(_LODDegradation); +00605 } +00606 } +00607 +00608 +00609 <span class="comment">//======================================================= </span> +<a name="l00610"></a><a class="code" href="a03227.html#NL3D_1_1CPSTailDotb20">00610</a> <span class="keywordtype">void</span> CPSRibbonBase::updateLOD() +00611 { +00612 <a class="code" href="a04199.html#a6">nlassert</a>(_Owner); +00613 <span class="keywordtype">float</span> ratio = _Owner-><a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-><a class="code" href="a03041.html#NL3D_1_1CParticleSystemz596_15">getOneMinusCurrentLODRatio</a>(); +00614 <span class="keywordtype">float</span> squaredRatio = ratio * ratio; +00615 <span class="keywordtype">float</span> lodRatio = _LODDegradation + (1.f - _LODDegradation ) * squaredRatio * squaredRatio * squaredRatio; +00616 +00617 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a> = (<a class="code" href="a04558.html#a15">uint</a>) (<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a> * lodRatio); +00618 <a class="code" href="a05378.html#a374">NLMISC::clamp</a>(<a class="code" href="a03227.html#NL3D_1_1CPSTailDotp11">_UsedNbSegs</a>, 0u, <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp7">_NbSegs</a>); +00619 <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 10E-4f; +00620 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp12">_UsedSegDuration</a> = <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp10">_SegDuration</a> / std::max(epsilon, lodRatio); +00621 <a class="code" href="a03227.html#NL3D_1_1CPSTailDotp13">_UsedSegLength</a> = <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser8">_SegLength</a> / std::max(epsilon, lodRatio); +00622 +00623 } +00624 +00625 <span class="comment">//======================================================= </span> +<a name="l00626"></a><a class="code" href="a03227.html#NL3D_1_1CPSRibbonBased6">00626</a> <span class="keywordtype">void</span> CPSRibbonBase::systemDateChanged() +00627 { +00628 <a class="code" href="a04199.html#a6">nlassert</a>(_Owner-><a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()); +00629 _Owner-><a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-><a class="code" href="a03041.html#NL3D_1_1CParticleSystemz584_1">getSystemDate</a>(); +00630 <span class="keywordtype">float</span> date = _Owner-><a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-><a class="code" href="a03041.html#NL3D_1_1CParticleSystemz584_1">getSystemDate</a>(); +00631 std::fill(<a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>.begin(), <a class="code" href="a03227.html#NL3D_1_1CPSRibbonBaser7">_SamplingDate</a>.end(), date); +00632 _LastUpdateDate = date; +00633 } +00634 +00635 +00636 +00637 } <span class="comment">// NL3D</span> +00638 +</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:34:40 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> |