aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/track_tcb_h-source.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/track_tcb_h-source.html628
1 files changed, 628 insertions, 0 deletions
diff --git a/docs/doxygen/nel/track_tcb_h-source.html b/docs/doxygen/nel/track_tcb_h-source.html
new file mode 100644
index 00000000..b113a2ef
--- /dev/null
+++ b/docs/doxygen/nel/track_tcb_h-source.html
@@ -0,0 +1,628 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.2 on Tue May 29 22:01:22 2001 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>track_tcb.h</h1><a href="track_tcb_h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.
+</font>00008 <font class="comment"> *
+</font>00009 <font class="comment"> * This file is part of NEVRAX NEL.
+</font>00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify
+</font>00011 <font class="comment"> * it under the terms of the GNU General Public License as published by
+</font>00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)
+</font>00013 <font class="comment"> * any later version.
+</font>00014 <font class="comment">
+</font>00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but
+</font>00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of
+</font>00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+</font>00018 <font class="comment"> * General Public License for more details.
+</font>00019 <font class="comment">
+</font>00020 <font class="comment"> * You should have received a copy of the GNU General Public License
+</font>00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the
+</font>00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+</font>00023 <font class="comment"> * MA 02111-1307, USA.
+</font>00024 <font class="comment"> */</font>
+00025
+00026
+00027 <font class="preprocessor">#ifndef NL_TRACK_H
+</font>00028 <font class="preprocessor"></font><font class="preprocessor">#error "internal file included from track.h"
+</font>00029 <font class="preprocessor"></font><font class="preprocessor">#endif
+</font>00030 <font class="preprocessor"></font>
+00031 <font class="comment">// ***************************************************************************</font>
+00032 <font class="comment">// ***************************************************************************</font>
+00033 <font class="comment">// TCB Keyframes.</font>
+00034 <font class="comment">// ***************************************************************************</font>
+00035 <font class="comment">// ***************************************************************************</font>
+00036
+00037
+00038 <font class="comment">// ***************************************************************************
+</font>00046 <font class="comment"></font>template&lt;class CKeyT, class T, class TMapTimeCKey&gt;
+<a name="l00047"></a><a class="code" href="class_CTCBTools.html">00047</a> <font class="keyword">class </font><a class="code" href="class_CTCBTools.html">CTCBTools</a>
+00048 {
+00049 <font class="keyword">protected</font>:
+<a name="l00050"></a><a class="code" href="class_CTCBTools.html#t0">00050</a> <font class="keyword">typedef</font> <font class="keyword">typename</font> TMapTimeCKey::iterator TMapTimeCKeyIterator;
+00051
+00052
+00053
+<a name="l00055"></a><a class="code" href="class_CTCBTools.html#b0">00055</a> <font class="keywordtype">void</font> <a class="code" href="class_CTCBTools.html#b0">compileTCBEase</a>(TMapTimeCKey &amp;mapKey, <font class="keywordtype">bool</font> loopMode)<font class="keyword">
+</font>00056 <font class="keyword"> </font>{
+00057 TMapTimeCKeyIterator it= mapKey.begin();
+00058 <font class="keywordflow">for</font>(;it!=mapKey.end();it++)
+00059 {
+00060 TMapTimeCKeyIterator next= it;
+00061 next++;
+00062
+00063 <font class="comment">// loop mgt. must compute ease from last to first (usefull if _RangeLock is false).</font>
+00064 <font class="keywordflow">if</font>(next==mapKey.end() &amp;&amp; loopMode &amp;&amp; mapKey.size()&gt;1)
+00065 next= mapKey.begin();
+00066
+00067 <font class="comment">// Ease Precompute.</font>
+00068 <font class="comment">//=================</font>
+00069 CKeyT &amp;key= it-&gt;second;
+00070 <font class="keywordflow">if</font>(next!=mapKey.end())
+00071 {
+00072 <font class="keywordtype">float</font> e0= it-&gt;second.EaseFrom;
+00073 <font class="keywordtype">float</font> e1= next-&gt;second.EaseTo;
+00074 <font class="keywordtype">float</font> s = e0 + e1;
+00075
+00076 <font class="comment">// "normalize".</font>
+00077 <font class="keywordflow">if</font> (s &gt; 1.0f)
+00078 {
+00079 e0 = e0/s;
+00080 e1 = e1/s;
+00081 }
+00082
+00083 <font class="comment">// precalc ease factors.</font>
+00084 key.Ease0= e0;
+00085 key.Ease1= e1;
+00086 key.EaseK= 1/(2.0f - e0 - e1);
+00087 <font class="keywordflow">if</font>(e0)
+00088 key.EaseKOverEase0= key.EaseK / e0;
+00089 <font class="keywordflow">if</font>(e1)
+00090 key.EaseKOverEase1= key.EaseK / e1;
+00091 }
+00092 <font class="keywordflow">else</font>
+00093 {
+00094 <font class="comment">// force ease() to just return d (see ease()).</font>
+00095 key.EaseK = 0.5f;
+00096 }
+00097
+00098 }
+00099 }
+00100
+00101 <font class="comment">// ease time.</font>
+<a name="l00102"></a><a class="code" href="class_CTCBTools.html#b1">00102</a> <font class="keywordtype">float</font> <a class="code" href="class_CTCBTools.html#b1">ease</a>(<font class="keyword">const</font> CKeyT *key, <font class="keywordtype">float</font> d)<font class="keyword">
+</font>00103 <font class="keyword"> </font>{
+00104 <font class="keywordflow">if</font> (d==0.0f || d==1.0f) <font class="keywordflow">return</font> d;
+00105 <font class="comment">// k==0.5f &lt;=&gt; e0+e1 == 0.</font>
+00106 <font class="keywordflow">if</font> (key-&gt;EaseK == 0.5f) <font class="keywordflow">return</font> d;
+00107
+00108 <font class="keywordflow">if</font> (d &lt; key-&gt;Ease0)
+00109 <font class="keywordflow">return</font> key-&gt;EaseKOverEase0 * d*d;
+00110 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (d &lt; 1.0f - key-&gt;Ease1)
+00111 <font class="keywordflow">return</font> key-&gt;EaseK * (2.0f*d - key-&gt;Ease0);
+00112 <font class="keywordflow">else</font>
+00113 {
+00114 d = 1.0f - d;
+00115 <font class="keywordflow">return</font> 1.0f - key-&gt;EaseKOverEase1 * d*d;
+00116 }
+00117 }
+00118
+00119 <font class="comment">// compute hermite factors.</font>
+<a name="l00120"></a><a class="code" href="class_CTCBTools.html#b2">00120</a> <font class="keywordtype">void</font> <a class="code" href="class_CTCBTools.html#b2">computeHermiteBasis</a>(<font class="keywordtype">float</font> d, <font class="keywordtype">float</font> hb[4])<font class="keyword">
+</font>00121 <font class="keyword"> </font>{
+00122 <font class="keywordtype">float</font> d2,d3,a;
+00123
+00124 d2 = d*d;
+00125 d3 = d2*d;
+00126 a = 3.0f*d2 - 2.0f*d3;
+00127 hb[0] = 1.0f - a;
+00128 hb[1] = a;
+00129 hb[2] = d3 - 2.0f*d2 + d;
+00130 hb[3] = d3 - d2;
+00131 }
+00132
+00133
+00134 <font class="comment">// compute TCB tangents factors.</font>
+<a name="l00135"></a><a class="code" href="class_CTCBTools.html#b3">00135</a> <font class="keywordtype">void</font> <a class="code" href="class_CTCBTools.html#b3">computeTCBFactors</a>(<font class="keyword">const</font> CKeyT &amp;key, <font class="keywordtype">float</font> timeBefore, <font class="keywordtype">float</font> time, <font class="keywordtype">float</font> timeAfter,
+00136 <font class="keywordtype">float</font> rangeDelta, <font class="keywordtype">bool</font> firstKey, <font class="keywordtype">bool</font> endKey, <font class="keywordtype">bool</font> isLoop, <font class="keywordtype">float</font> &amp;ksm, <font class="keywordtype">float</font> &amp;ksp, <font class="keywordtype">float</font> &amp;kdm, <font class="keywordtype">float</font> &amp;kdp)<font class="keyword">
+</font>00137 <font class="keyword"> </font>{
+00138 <font class="keywordtype">float</font> fp,fn;
+00139
+00140 <font class="keywordflow">if</font>(isLoop || (!firstKey &amp;&amp; !endKey))
+00141 {
+00142 <font class="keywordtype">float</font> dtm;
+00143 <font class="comment">// Compute Time deltas.</font>
+00144 <font class="keywordflow">if</font> (firstKey)
+00145 {
+00146 dtm = 0.5f * (rangeDelta + timeAfter - time);
+00147 fp = rangeDelta / dtm;
+00148 fn = (timeAfter - time) / dtm;
+00149 }
+00150 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (endKey)
+00151 {
+00152 dtm = 0.5f * (rangeDelta + time - timeBefore);
+00153 fp = rangeDelta / dtm;
+00154 fn = (time - timeBefore) / dtm;
+00155 }
+00156 <font class="keywordflow">else</font>
+00157 {
+00158 dtm = 0.5f * (timeAfter - timeBefore);
+00159 fp = (time - timeBefore) / dtm;
+00160 fn = (timeAfter - time) / dtm;
+00161 }
+00162 <font class="keywordtype">float</font> c= (<font class="keywordtype">float</font>)fabs( key.Continuity );
+00163 fp = fp + c - c * fp;
+00164 fn = fn + c - c * fn;
+00165 }
+00166 <font class="keywordflow">else</font>
+00167 {
+00168 <font class="comment">// firstkey and lastkey of not loop track.</font>
+00169 fp = 1.0f;
+00170 fn = 1.0f;
+00171 }
+00172
+00173 <font class="comment">// Compute tangents factors.</font>
+00174 <font class="keywordtype">float</font> tm,cm,cp,bm,bp,tmcm,tmcp;
+00175
+00176 cm = 1.0f - key.Continuity;
+00177 tm = 0.5f * ( 1.0f - key.Tension );
+00178 cp = 2.0f - cm;
+00179 bm = 1.0f - key.Bias;
+00180 bp = 2.0f - bm;
+00181 tmcm = tm*cm; tmcp = tm*cp;
+00182
+00183 <font class="comment">// tgts factors.</font>
+00184 ksm = tmcm*bp*fp; ksp = tmcp*bm*fp;
+00185 kdm = tmcp*bp*fn; kdp = tmcm*bm*fn;
+00186
+00187 }
+00188
+00189 };
+00190
+00191
+00192 <font class="comment">// ***************************************************************************
+</font>00200 <font class="comment"></font>template&lt;class CKeyT, class T&gt;
+<a name="l00201"></a><a class="code" href="class_CTrackKeyFramerTCB.html">00201</a> <font class="keyword">class </font><a class="code" href="class_CTrackKeyFramerTCB.html">CTrackKeyFramerTCB</a> : <font class="keyword">public</font> <a class="code" href="class_ITrackKeyFramer.html">ITrackKeyFramer</a>&lt;CKeyT&gt;, <font class="keyword">private</font> <a class="code" href="class_CTCBTools.html">CTCBTools</a>&lt;CKeyT, T, std::map&lt;CAnimationTime, CKeyT&gt; &gt;
+00202 {
+00203 <font class="keyword">public</font>:
+00204
+<a name="l00206"></a><a class="code" href="class_CTrackKeyFramerTCB.html#a0">00206</a> <font class="keyword">virtual</font> <font class="keyword">const</font> IAnimatedValue&amp; <a class="code" href="class_CTrackKeyFramerTCB.html#a0">getValue</a> ()<font class="keyword"> const
+</font>00207 <font class="keyword"> </font>{
+00208 <font class="keywordflow">return</font> _Value;
+00209 }
+00210
+00211 <font class="keyword">protected</font>:
+00212
+00213
+<a name="l00214"></a><a class="code" href="class_CTrackKeyFramerTCB.html#t0">00214</a> <font class="keyword">typedef</font> <font class="keyword">typename</font> CKeyT::TValueType TKeyValueType;
+00215
+00216
+00217
+00219 <font class="comment">// @{</font>
+00220
+<a name="l00222"></a><a class="code" href="class_CTrackKeyFramerTCB.html#b0">00222</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#b0">evalKey</a> ( <font class="keyword">const</font> CKeyT* previous, <font class="keyword">const</font> CKeyT* next,
+00223 CAnimationTime datePrevious, CAnimationTime dateNext,
+00224 CAnimationTime date )<font class="keyword">
+</font>00225 <font class="keyword"> </font>{
+00226 <font class="keywordflow">if</font>(previous &amp;&amp; next)
+00227 {
+00228 <font class="comment">// lerp from previous to cur.</font>
+00229 date-= datePrevious;
+00230 date*= previous-&gt;OODeltaTime;
+00231 <a class="code" href="namespace_NLMISC.html#a177">NLMISC::clamp</a>(date, 0,1);
+00232
+00233 date = <a class="code" href="class_CTCBTools.html#b1">ease</a>(previous, date);
+00234
+00235 <font class="keywordtype">float</font> hb[4];
+00236 <a class="code" href="class_CTCBTools.html#b2">computeHermiteBasis</a>(date, hb);
+00237 copyToValue(_Value.Value,
+00238 previous-&gt;Value*hb[0] + next-&gt;Value*hb[1] +
+00239 previous-&gt;TanFrom*hb[2] + next-&gt;TanTo*hb[3]);
+00240 }
+00241 <font class="keywordflow">else</font>
+00242 {
+00243 <font class="keywordflow">if</font> (previous)
+00244 copyToValue(_Value.Value, previous-&gt;Value);
+00245 <font class="keywordflow">else</font>
+00246 <font class="keywordflow">if</font> (next)
+00247 copyToValue(_Value.Value, next-&gt;Value);
+00248 }
+00249 }
+00250
+<a name="l00252"></a><a class="code" href="class_CTrackKeyFramerTCB.html#b1">00252</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#b1">compile</a>()<font class="keyword">
+</font>00253 <font class="keyword"> </font>{
+00254 ITrackKeyFramer&lt;CKeyT&gt;::compile();
+00255
+00256 <font class="comment">// Ease Precompute.</font>
+00257 <a class="code" href="class_CTCBTools.html#b0">compileTCBEase</a>(_MapKey, getLoopMode());
+00258
+00259
+00260 <font class="comment">// Tangents Precompute.</font>
+00261 sint nKeys= _MapKey.size();
+00262 <font class="keywordflow">if</font>(nKeys&lt;=1)
+00263 <font class="keywordflow">return</font>;
+00264
+00265 TMapTimeCKey::iterator it= _MapKey.begin(); <font class="comment">// first key.</font>
+00266 TMapTimeCKey::iterator itNext= it; itNext++; <font class="comment">// second key.</font>
+00267 TMapTimeCKey::iterator itPrev= _MapKey.end(); itPrev--; <font class="comment">// last key.</font>
+00268
+00269 <font class="keywordflow">if</font>(nKeys==2 &amp;&amp; !getLoopMode())
+00270 {
+00271 <a class="code" href="class_CTrackKeyFramerTCB.html#c1">computeTCBKeyLinear</a>( it-&gt;second, itNext-&gt;second );
+00272 }
+00273 <font class="keywordflow">else</font>
+00274 {
+00275 <font class="comment">// rangeDelta is the length of effective Range - length of LastKey-FirstKey.</font>
+00276 <font class="comment">// NB: if RangeLock, rangeDelta==0.</font>
+00277 <font class="keywordtype">float</font> rangeDelta;
+00278 <font class="comment">// NB: _RangeDelta has just been compiled in ITrackKeyFramer&lt;CKeyT&gt;::compile().</font>
+00279 rangeDelta= getCompiledRangeDelta();
+00280
+00281 <font class="comment">// Compute all middle keys.</font>
+00282 <font class="keywordflow">for</font>(;it!=_MapKey.end();)
+00283 {
+00284 <font class="comment">// Do the first key and the last key only in LoopMode.</font>
+00285 <font class="comment">// NB: we are the last if itNext==_MapKey.begin().</font>
+00286 <font class="keywordflow">if</font>(getLoopMode() || (it!=_MapKey.begin() &amp;&amp; itNext!=_MapKey.begin()) )
+00287 {
+00288 <a class="code" href="class_CTrackKeyFramerTCB.html#c0">computeTCBKey</a>(itPrev-&gt;second, it-&gt;second, itNext-&gt;second,
+00289 itPrev-&gt;first, it-&gt;first, itNext-&gt;first, rangeDelta,
+00290 it==_MapKey.begin(), itNext==_MapKey.begin(), getLoopMode());
+00291 }
+00292
+00293 <font class="comment">// Next key!!</font>
+00294 itPrev= it;
+00295 it++;
+00296 itNext++;
+00297 <font class="comment">// loop.</font>
+00298 <font class="keywordflow">if</font>(itNext==_MapKey.end())
+00299 itNext= _MapKey.begin();
+00300 }
+00301
+00302 <font class="comment">// In not loop mode, compute first and last key, AFTER middle keys computed.</font>
+00303 <font class="keywordflow">if</font>(!getLoopMode())
+00304 {
+00305 TMapTimeCKey::iterator it0= _MapKey.begin(); <font class="comment">// first key.</font>
+00306 TMapTimeCKey::iterator it1= it0; it1++; <font class="comment">// second key.</font>
+00307 TMapTimeCKey::iterator itLast= _MapKey.end();itLast--; <font class="comment">// last key.</font>
+00308 TMapTimeCKey::iterator itLastPrev= itLast;itLastPrev--; <font class="comment">// prev of last key.</font>
+00309
+00310 <a class="code" href="class_CTrackKeyFramerTCB.html#c2">computeFirstKey</a>(it0-&gt;second, it1-&gt;second);
+00311 <a class="code" href="class_CTrackKeyFramerTCB.html#c3">computeLastKey</a>(itLast-&gt;second, itLastPrev-&gt;second);
+00312 }
+00313 }
+00314 }
+00315
+00316 <font class="comment">// @}</font>
+00317
+00318
+00319 <font class="comment">// *****************</font>
+00320 <font class="keyword">private</font>:
+<a name="l00321"></a><a class="code" href="class_CTrackKeyFramerTCB.html#o0">00321</a> CAnimatedValueBlendable&lt;T&gt; _Value;
+00322
+00323
+00324
+<a name="l00325"></a><a class="code" href="class_CTrackKeyFramerTCB.html#c0">00325</a> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#c0">computeTCBKey</a>(CKeyT &amp;keyBefore, CKeyT &amp;key, CKeyT &amp;keyAfter, <font class="keywordtype">float</font> timeBefore, <font class="keywordtype">float</font> time, <font class="keywordtype">float</font> timeAfter,
+00326 <font class="keywordtype">float</font> rangeDelta, <font class="keywordtype">bool</font> firstKey, <font class="keywordtype">bool</font> endKey, <font class="keywordtype">bool</font> isLoop)<font class="keyword">
+</font>00327 <font class="keyword"> </font>{
+00328 <font class="keywordtype">float</font> ksm,ksp,kdm,kdp;
+00329
+00330 <font class="comment">// compute tangents factors.</font>
+00331 <a class="code" href="class_CTCBTools.html#b3">computeTCBFactors</a>(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp);
+00332
+00333 <font class="comment">// Delta.</font>
+00334 TKeyValueType delm, delp;
+00335 delm = key.Value - keyBefore.Value;
+00336 delp = keyAfter.Value - key.Value;
+00337
+00338 <font class="comment">// Tangents.</font>
+00339 key.TanTo = delm*ksm + delp*ksp;
+00340 key.TanFrom= delm*kdm + delp*kdp;
+00341
+00342 }
+00343
+00344 <font class="comment">// compute 2 TCB keys for a not-loop track =&gt; "linear".</font>
+<a name="l00345"></a><a class="code" href="class_CTrackKeyFramerTCB.html#c1">00345</a> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#c1">computeTCBKeyLinear</a>(CKeyT &amp;key0, CKeyT &amp;key1)<font class="keyword">
+</font>00346 <font class="keyword"> </font>{
+00347 <font class="keywordtype">float</font> f0, f1;
+00348 TKeyValueType dv;
+00349
+00350 f0 = 1.0f - key0.Tension;
+00351 f1 = 1.0f - key1.Tension;
+00352 dv = key1.Value - key0.Value;
+00353 key0.TanFrom= dv * f0;
+00354 key1.TanTo= dv * f1;
+00355 }
+00356
+00357 <font class="comment">// compute this AFTER computing key1.</font>
+<a name="l00358"></a><a class="code" href="class_CTrackKeyFramerTCB.html#c2">00358</a> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#c2">computeFirstKey</a>(CKeyT &amp;keyFirst, CKeyT &amp;keyAfter)<font class="keyword">
+</font>00359 <font class="keyword"> </font>{
+00360 <font class="keywordtype">float</font> tm;
+00361 tm = 0.5f * (1.0f - keyFirst.Tension);
+00362 keyFirst.TanFrom= tm * ((keyAfter.Value - keyFirst.Value) * 3.0f - keyAfter.TanTo);
+00363 }
+00364
+00365 <font class="comment">// compute this AFTER computing key(n-2).</font>
+<a name="l00366"></a><a class="code" href="class_CTrackKeyFramerTCB.html#c3">00366</a> <font class="keywordtype">void</font> <a class="code" href="class_CTrackKeyFramerTCB.html#c3">computeLastKey</a>(CKeyT &amp;keyLast, CKeyT &amp;keyBefore)<font class="keyword">
+</font>00367 <font class="keyword"> </font>{
+00368 <font class="keywordtype">float</font> tm;
+00369 tm = 0.5f * (1.0f - keyLast.Tension);
+00370 keyLast.TanTo= tm * ((keyLast.Value - keyBefore.Value) * 3.0f - keyBefore.TanFrom);
+00371 }
+00372
+00373
+00374 };
+00375
+00376
+00377 <font class="comment">// ***************************************************************************
+</font><a name="l00385"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html">00385</a> <font class="comment"></font><font class="keyword">class </font><a class="code" href="class_CTrackKeyFramerTCB.html">CTrackKeyFramerTCB</a>&lt;CKeyTCBQuat, NLMISC::CAngleAxis&gt; : <font class="keyword">public</font> <a class="code" href="class_ITrackKeyFramer.html">ITrackKeyFramer</a>&lt;CKeyTCBQuat&gt;,
+00386 <font class="keyword">private</font> <a class="code" href="class_CTCBTools.html">CTCBTools</a>&lt;CKeyTCBQuat, NLMISC::CAngleAxis, std::map&lt;CAnimationTime, CKeyTCBQuat&gt; &gt;
+00387 {
+00388 <font class="keyword">public</font>:
+00389
+<a name="l00391"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html#a0">00391</a> <font class="keyword">virtual</font> <font class="keyword">const</font> IAnimatedValue&amp; getValue ()<font class="keyword"> const
+</font>00392 <font class="keyword"> </font>{
+00393 <font class="keywordflow">return</font> _Value;
+00394 }
+00395
+00397 <font class="comment">// @{</font>
+00398
+<a name="l00400"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html#a1">00400</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> evalKey ( <font class="keyword">const</font> CKeyTCBQuat* previous, <font class="keyword">const</font> CKeyTCBQuat* next,
+00401 CAnimationTime datePrevious, CAnimationTime dateNext,
+00402 CAnimationTime date )<font class="keyword">
+</font>00403 <font class="keyword"> </font>{
+00404 <font class="keywordflow">if</font>(previous &amp;&amp; next)
+00405 {
+00406 <font class="comment">// lerp from previous to cur.</font>
+00407 date-= datePrevious;
+00408 date*= previous-&gt;OODeltaTime;
+00409 <a class="code" href="namespace_NLMISC.html#a177">NLMISC::clamp</a>(date, 0,1);
+00410
+00411 <font class="comment">// ease.</font>
+00412 date = <a class="code" href="class_CTCBTools.html#b1">ease</a>(previous, date);
+00413
+00414 <font class="comment">// quad slerp.</font>
+00415 _Value.Value= CQuat::squadrev(next-&gt;LocalAngleAxis, previous-&gt;Quat, previous-&gt;A, next-&gt;B, next-&gt;Quat, date);
+00416 }
+00417 <font class="keywordflow">else</font>
+00418 {
+00419 <font class="keywordflow">if</font> (previous)
+00420 _Value.Value= previous-&gt;Quat;
+00421 <font class="keywordflow">else</font>
+00422 <font class="keywordflow">if</font> (next)
+00423 _Value.Value= next-&gt;Quat;
+00424 }
+00425
+00426 }
+00427
+<a name="l00429"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html#a2">00429</a> <font class="keyword">virtual</font> <font class="keywordtype">void</font> compile()<font class="keyword">
+</font>00430 <font class="keyword"> </font>{
+00431 ITrackKeyFramer&lt;CKeyTCBQuat&gt;::compile();
+00432
+00433 <font class="comment">// Ease Precompute.</font>
+00434 <a class="code" href="class_CTCBTools.html#b0">compileTCBEase</a>(_MapKey, getLoopMode());
+00435
+00436 TMapTimeCKey::iterator it;
+00437 TMapTimeCKey::iterator itNext;
+00438 TMapTimeCKey::iterator itPrev;
+00439
+00440 <font class="comment">// Compute absolute quaternions.</font>
+00441 <font class="keywordflow">for</font> (it= _MapKey.begin();it!=_MapKey.end();)
+00442 {
+00443 CKeyTCBQuat &amp;key= it-&gt;second;
+00444
+00445 <font class="comment">// Compute Local AngleAxis.</font>
+00446 <font class="keywordflow">if</font>(it!= _MapKey.begin())
+00447 {
+00448 <a class="code" href="class_NLMISC__CMatrix.html">NLMISC::CMatrix</a> mat;
+00449 mat.<a class="code" href="class_NLMISC__CMatrix.html#a4">setRot</a>(itPrev-&gt;second.Quat);
+00450 mat.<a class="code" href="class_NLMISC__CMatrix.html#a38">invert</a>();
+00451 key.LocalAngleAxis.Axis= mat*key.Value.Axis;
+00452 key.LocalAngleAxis.Angle= key.Value.Angle;
+00453 }
+00454 <font class="keywordflow">else</font>
+00455 key.LocalAngleAxis= key.Value;
+00456
+00457
+00458 key.LocalAngleAxis.Axis.normalize();
+00459 <font class="comment">// make angle positive.</font>
+00460 <font class="keywordflow">if</font>(key.LocalAngleAxis.Angle&lt;0.f)
+00461 {
+00462 key.LocalAngleAxis.Axis= -key.LocalAngleAxis.Axis;
+00463 key.LocalAngleAxis.Angle= -key.LocalAngleAxis.Angle;
+00464 }
+00465
+00466 <font class="comment">// relative quat</font>
+00467 key.Quat.setAngleAxis(key.LocalAngleAxis);
+00468
+00469 <font class="comment">// absolute quat</font>
+00470 <font class="keywordflow">if</font> (it!= _MapKey.begin())
+00471 key.Quat = itPrev-&gt;second.Quat * key.Quat;
+00472
+00473 <font class="comment">// next key.</font>
+00474 itPrev= it;
+00475 it++;
+00476 }
+00477
+00478 <font class="comment">// Tangents Precompute.</font>
+00479 sint nKeys= _MapKey.size();
+00480 <font class="keywordflow">if</font>(nKeys&lt;=1)
+00481 <font class="keywordflow">return</font>;
+00482
+00483 <font class="comment">// rangeDelta is the length of effective Range - length of LastKey-FirstKey.</font>
+00484 <font class="comment">// NB: if RangeLock, rangeDelta==0.</font>
+00485 <font class="keywordtype">float</font> rangeDelta;
+00486 <font class="comment">// NB: _RangeDelta has just been compiled in ITrackKeyFramer&lt;CKeyTCBQuat&gt;::compile().</font>
+00487 rangeDelta= getCompiledRangeDelta();
+00488
+00489 it= _MapKey.begin(); <font class="comment">// first key.</font>
+00490 itNext= it; itNext++; <font class="comment">// second key.</font>
+00491 itPrev= _MapKey.end(); itPrev--; <font class="comment">// last key.</font>
+00492
+00493 <font class="comment">// Compute all keys.</font>
+00494 <font class="keywordflow">for</font>(;it!=_MapKey.end();)
+00495 {
+00496 <font class="comment">// NB: we are the last key if itNext==_MapKey.begin().</font>
+00497 computeTCBKey(itPrev-&gt;second, it-&gt;second, itNext-&gt;second,
+00498 itPrev-&gt;first, it-&gt;first, itNext-&gt;first, rangeDelta, it==_MapKey.begin(), itNext==_MapKey.begin(), getLoopMode());
+00499
+00500 <font class="comment">// Next key!!</font>
+00501 itPrev= it;
+00502 it++;
+00503 itNext++;
+00504 <font class="comment">// loop.</font>
+00505 <font class="keywordflow">if</font>(itNext==_MapKey.end())
+00506 itNext= _MapKey.begin();
+00507 }
+00508
+00509 }
+00510
+00511 <font class="comment">// @}</font>
+00512
+00513
+00514 <font class="comment">// *****************</font>
+00515 <font class="keyword">private</font>:
+<a name="l00516"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html#o0">00516</a> CAnimatedValueBlendable&lt;CQuat&gt; _Value;
+00517
+00518
+<a name="l00519"></a><a class="code" href="class_CTrackKeyFramerTCB_ltCKeyTCBQuat_x_NLMISC__CAngleAxis_gt.html#c0">00519</a> <font class="keywordtype">void</font> computeTCBKey(CKeyTCBQuat &amp;keyBefore, CKeyTCBQuat &amp;key, CKeyTCBQuat &amp;keyAfter, <font class="keywordtype">float</font> timeBefore, <font class="keywordtype">float</font> time, <font class="keywordtype">float</font> timeAfter,
+00520 <font class="keywordtype">float</font> rangeDelta, <font class="keywordtype">bool</font> firstKey, <font class="keywordtype">bool</font> endKey, <font class="keywordtype">bool</font> isLoop)<font class="keyword">
+</font>00521 <font class="keyword"> </font>{
+00522 CQuat qp, qm;
+00523
+00524 <font class="comment">// compute qm.</font>
+00525 <font class="keywordflow">if</font> (!firstKey || isLoop)
+00526 {
+00527 <font class="keywordtype">float</font> angle= key.LocalAngleAxis.Angle;
+00528 CVector &amp;axis= key.LocalAngleAxis.Axis;
+00529
+00530 <font class="keywordflow">if</font> (angle &gt; 2*NLMISC::Pi- NLMISC::QuatEpsilon)
+00531 {
+00532 qm.set(axis.x, axis.y, axis.z, 0.0f);
+00533 qm = qm.log();
+00534 }
+00535 <font class="keywordflow">else</font>
+00536 {
+00537 CQuat qprev= keyBefore.Quat;
+00538 qprev.makeClosest(key.Quat);
+00539 qm = CQuat::lnDif(qprev, key.Quat);
+00540 }
+00541 }
+00542
+00543 <font class="comment">// compute qp.</font>
+00544 <font class="keywordflow">if</font> (!endKey || isLoop)
+00545 {
+00546 <font class="keywordtype">float</font> angle= keyAfter.LocalAngleAxis.Angle;
+00547 CVector &amp;axis= keyAfter.LocalAngleAxis.Axis;
+00548
+00549 <font class="keywordflow">if</font> (angle &gt; 2*NLMISC::Pi- NLMISC::QuatEpsilon)
+00550 {
+00551 qp.set(axis.x, axis.y, axis.z, 0.0f);
+00552 qp = qp.log();
+00553 }
+00554 <font class="keywordflow">else</font>
+00555 {
+00556 CQuat qnext= keyAfter.Quat;
+00557 qnext.makeClosest(key.Quat);
+00558 qp = CQuat::lnDif(key.Quat, qnext);
+00559 }
+00560 }
+00561
+00562 <font class="comment">// not loop mgt.</font>
+00563 <font class="keywordflow">if</font> (firstKey &amp;&amp; !isLoop)
+00564 qm = qp;
+00565 <font class="keywordflow">if</font> (endKey &amp;&amp; !isLoop)
+00566 qp = qm;
+00567
+00568
+00569 <font class="comment">// compute tangents factors.</font>
+00570 <font class="keywordtype">float</font> ksm, ksp, kdm, kdp;
+00571 <a class="code" href="class_CTCBTools.html#b3">computeTCBFactors</a>(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp);
+00572
+00573
+00574 <font class="comment">// A/B.</font>
+00575 CQuat qa, qb;
+00576 qb= (qm * (1.0f-ksm) + qp * (-ksp) ) * 0.5f;
+00577 qa= (qm * kdm + qp * (kdp-1.0f) ) * 0.5f;
+00578 qa = qa.exp();
+00579 qb = qb.exp();
+00580
+00581 key.A = key.Quat * qa;
+00582 key.B = key.Quat * qb;
+00583 }
+00584
+00585
+00586
+00587 };
+00588
+00589
+</div></pre>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>