aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/channel__mixer_8cpp-source.html
blob: 26236048ea2e0549e7d3741fc455e834349e3fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<!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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/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="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/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="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>channel_mixer.cpp</h1><a href="channel__mixer_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="channel__mixer_8h.html">3d/channel_mixer.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="track_8h.html">3d/track.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="animatable_8h.html">3d/animatable.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="skeleton__weight_8h.html">3d/skeleton_weight.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00034 
00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00036 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00037 
00038 <font class="keyword">namespace </font>NL3D 
00039 {
00040 
00041 <font class="comment">// ***************************************************************************</font>
00042 
<a name="l00043"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a0">00043</a> CChannelMixer::CChannelMixer()
00044 {
00045         <font class="comment">// No channel in the list</font>
00046         <a class="code" href="classNL3D_1_1CChannelMixer.html#o3">_FirstChannelGlobal</a>=NULL;
00047         <a class="code" href="classNL3D_1_1CChannelMixer.html#o4">_FirstChannelDetail</a>=NULL;
00048 
00049         <font class="comment">// No animation set</font>
00050         <a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>=NULL;
00051 
00052         <font class="comment">// Mixer no dirty</font>
00053         <a class="code" href="classNL3D_1_1CChannelMixer.html#o6">_Dirt</a>=<font class="keyword">false</font>;
00054         <a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>= <font class="keyword">false</font>;
00055 
00056         <font class="comment">// never evaluated.</font>
00057         <a class="code" href="classNL3D_1_1CChannelMixer.html#o5">_LastEvalDetailDate</a>= -1;
00058 }
00059 
00060 <font class="comment">// ***************************************************************************</font>
00061 
<a name="l00062"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a1">00062</a> <font class="keywordtype">void</font> CChannelMixer::setAnimationSet (<font class="keyword">const</font> CAnimationSet* animationSet)
00063 {
00064         <font class="comment">// Set the animationSet Pointer</font>
00065         <a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>=animationSet;
00066 
00067         <font class="comment">// clear the channels.</font>
00068         <a class="code" href="classNL3D_1_1CChannelMixer.html#a5">resetChannels</a>();
00069 }
00070 
00071 <font class="comment">// ***************************************************************************</font>
00072 
<a name="l00073"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a2">00073</a> <font class="keyword">const</font> CAnimationSet* CChannelMixer::getAnimationSet ()<font class="keyword"> const</font>
00074 <font class="keyword"></font>{
00075         <font class="comment">// Return the animationSet Pointer</font>
00076         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>;
00077 }
00078 
00079 <font class="comment">// ***************************************************************************</font>
00080 
<a name="l00081"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a3">00081</a> <font class="keywordtype">void</font> CChannelMixer::eval (<font class="keywordtype">bool</font> detail, uint64 evalDetailDate)
00082 {
00083         <font class="comment">// Setup an array of animation that are not empty and stay</font>
00084         uint numActive=0;
00085         uint activeSlot[<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>];
00086 
00087         <font class="keywordflow">if</font>(detail &amp;&amp; (sint64)evalDetailDate== <a class="code" href="classNL3D_1_1CChannelMixer.html#o5">_LastEvalDetailDate</a>)
00088                 <font class="keywordflow">return</font>;
00089 
00090         <font class="comment">// clean list according to anim setup</font>
00091         <font class="keywordflow">if</font>(_Dirt)
00092         {
00093                 <a class="code" href="classNL3D_1_1CChannelMixer.html#c2">refreshList</a>();
00094                 <a class="code" href="classNL3D_1_1CChannelMixer.html#c0">cleanAll</a>();
00095         }
00096 
00097         <font class="comment">// clean eval list, according to channels enabled.</font>
00098         <font class="keywordflow">if</font>(_ListToEvalDirt)
00099         {
00100                 <a class="code" href="classNL3D_1_1CChannelMixer.html#c3">refreshListToEval</a>();
00101                 <a class="code" href="debug_8h.html#a6">nlassert</a>(!<a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>);
00102         }
00103 
00104         <font class="comment">// Setup it up</font>
00105         <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00106         {
00107                 <font class="comment">// Dirt, not empty and has an influence? (add)</font>
00108                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>].isEmpty() &amp;&amp; <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]._Weight&gt;0)
00109                         <font class="comment">// Add a dirt slot</font>
00110                         activeSlot[numActive++]=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
00111         }
00112 
00113         <font class="comment">// no slot enabled at all?? skip</font>
00114         <font class="keywordflow">if</font>(numActive==0)
00115                 <font class="keywordflow">return</font>;
00116 
00117         <font class="comment">// For each selected channel</font>
00118         CChannel        **channelArrayPtr = 0;
00119         uint            numChans;
00120         <font class="keywordflow">if</font>(detail)
00121         {
00122                 numChans= <a class="code" href="classNL3D_1_1CChannelMixer.html#o9">_DetailListToEval</a>.size();
00123                 <font class="keywordflow">if</font>(numChans)
00124                         channelArrayPtr= &amp;<a class="code" href="classNL3D_1_1CChannelMixer.html#o9">_DetailListToEval</a>[0];
00125                 <font class="comment">// eval the animation only one time per scene traversal.</font>
00126                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o5">_LastEvalDetailDate</a>= evalDetailDate;
00127         }
00128         <font class="keywordflow">else</font>
00129         {
00130                 numChans= <a class="code" href="classNL3D_1_1CChannelMixer.html#o8">_GlobalListToEval</a>.size();
00131                 <font class="keywordflow">if</font>(numChans)
00132                         channelArrayPtr= &amp;<a class="code" href="classNL3D_1_1CChannelMixer.html#o8">_GlobalListToEval</a>[0];
00133         }
00134 
00135 
00136         <font class="keywordflow">for</font>(;numChans&gt;0; numChans--, channelArrayPtr++)
00137         {
00138                 CChannel        *pChannel= *channelArrayPtr;
00139 
00140                 <font class="comment">// For Quat animated value only.</font>
00141                 CQuat   firstQuat;
00142 
00143                 <font class="comment">// First slot found</font>
00144                 <font class="keywordtype">bool</font> bFirst=<font class="keyword">true</font>;
00145 
00146                 <font class="comment">// Last blend factor</font>
00147                 <font class="keywordtype">float</font> lastBlend=0.0;
00148 
00149                 <font class="comment">// Eval each slot</font>
00150                 <font class="keywordflow">for</font> (uint a=0; a&lt;numActive; a++)
00151                 {
00152                         <font class="comment">// Slot number</font>
00153                         uint slot=activeSlot[a];
00154 
00155                         <font class="comment">// Current blend factor</font>
00156                         <font class="keywordtype">float</font> <a class="code" href="namespaceNLMISC.html#a286">blend</a>=pChannel-&gt;_Weights[slot]*<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o4">_Weight</a>;
00157 
00158                         <font class="keywordflow">if</font>(<a class="code" href="namespaceNLMISC.html#a286">blend</a>!=0.0f)
00159                         {
00160                                 <font class="comment">// Eval the track at this time</font>
00161                                 ((ITrack*)pChannel-&gt;_Tracks[slot])-&gt;eval (<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot]._Time);
00162 
00163                                 <font class="comment">// First track to be eval ?</font>
00164                                 <font class="keywordflow">if</font> (bFirst)
00165                                 {
00166                                         <font class="comment">// If channel is a Quaternion animated Value, must store the first Quat.</font>
00167                                         <font class="keywordflow">if</font> (pChannel-&gt;_IsQuat)
00168                                         {
00169                                                 CAnimatedValueBlendable&lt;NLMISC::CQuat&gt;  *pQuatValue=(CAnimatedValueBlendable&lt;NLMISC::CQuat&gt;*)&amp;pChannel-&gt;_Tracks[slot]-&gt;getValue();
00170                                                 firstQuat=pQuatValue-&gt;Value;
00171                                         }
00172 
00173                                         <font class="comment">// Copy the interpolated value</font>
00174                                         pChannel-&gt;_Value-&gt;affect (pChannel-&gt;_Tracks[slot]-&gt;getValue());
00175 
00176                                         <font class="comment">// First blend factor</font>
00177                                         lastBlend=<a class="code" href="namespaceNLMISC.html#a286">blend</a>;
00178 
00179                                         <font class="comment">// Not first anymore</font>
00180                                         bFirst=<font class="keyword">false</font>;
00181                                 }
00182                                 <font class="keywordflow">else</font>
00183                                 {
00184                                         <font class="comment">// If channel is a Quaternion animated Value, must makeClosest the ith result of the track, from firstQuat.</font>
00185                                         <font class="keywordflow">if</font> (pChannel-&gt;_IsQuat)
00186                                         {
00187                                                 CAnimatedValueBlendable&lt;NLMISC::CQuat&gt;  *pQuatValue=(CAnimatedValueBlendable&lt;NLMISC::CQuat&gt;*)&amp;pChannel-&gt;_Tracks[slot]-&gt;getValue();
00188                                                 pQuatValue-&gt;Value.makeClosest (firstQuat);
00189                                         }
00190 
00191                                         <font class="comment">// Blend with this value and the previous sum</font>
00192                                         pChannel-&gt;_Value-&gt;blend (pChannel-&gt;_Tracks[slot]-&gt;getValue(), lastBlend/(lastBlend+<a class="code" href="namespaceNLMISC.html#a286">blend</a>));
00193 
00194                                         <font class="comment">// last blend update</font>
00195                                         lastBlend+=<a class="code" href="namespaceNLMISC.html#a286">blend</a>;
00196                                 }
00197                         }
00198 
00199                         <font class="comment">// NB: if all weights are 0, the AnimatedValue is not modified...</font>
00200                 }
00201 
00202                 <font class="comment">// Touch the animated value and its owner to recompute them later.</font>
00203                 pChannel-&gt;_Object-&gt;touch (pChannel-&gt;_ValueId, pChannel-&gt;_OwnerValueId);
00204         }
00205 }
00206 
00207 <font class="comment">// ***************************************************************************</font>
00208 
00209 sint CChannelMixer::addChannel (<font class="keyword">const</font> string&amp; channelName, IAnimatable* animatable, IAnimatedValue* <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, ITrack* defaultValue, uint32 valueId, uint32 ownerValueId, <font class="keywordtype">bool</font> detail)
00210 {
00211         <font class="comment">// Check the animationSet has been set</font>
00212         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>);
00213 
00214         <font class="comment">// Check args</font>
00215         <a class="code" href="debug_8h.html#a6">nlassert</a> (animatable);
00216         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00217         <a class="code" href="debug_8h.html#a6">nlassert</a> (defaultValue);
00218 
00219         <font class="comment">// Get the channel Id having the same name than the tracks in this animation set.</font>
00220         uint iDInAnimationSet=<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>-&gt;getChannelIdByName (channelName);
00221 
00222         <font class="comment">// Tracks exist in this animation set?</font>
00223         <font class="keywordflow">if</font> (iDInAnimationSet!=CAnimationSet::NotFound)
00224         {
00225                 <font class="comment">// The channel entry</font>
00226                 CChannel        entry;
00227 
00228                 <font class="comment">// Set the channel name</font>
00229                 entry._ChannelName=channelName;
00230 
00231                 <font class="comment">// Set the object pointer</font>
00232                 entry._Object=animatable;
00233 
00234                 <font class="comment">// Set the pointer on the value in the object</font>
00235                 entry._Value=<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
00236 
00237                 <font class="comment">// Is this a CQuat animated value???</font>
00238                 entry._IsQuat= (<font class="keyword">typeid</font> (*(entry._Value))==<font class="keyword">typeid</font> (CAnimatedValueBlendable&lt;NLMISC::CQuat&gt;))!=0;
00239 
00240 
00241                 <font class="comment">// Set the default track pointer</font>
00242                 entry._DefaultTracks=defaultValue;
00243 
00244                 <font class="comment">// Set the value ID in the object</font>
00245                 entry._ValueId=valueId;
00246 
00247                 <font class="comment">// Set the First value ID in the object</font>
00248                 entry._OwnerValueId=ownerValueId;
00249 
00250                 <font class="comment">// in what mode is the channel?</font>
00251                 entry._Detail= detail;
00252 
00253                 <font class="comment">// All weights default to 1. All Tracks default to defaultTrack.</font>
00254                 <font class="keywordflow">for</font>(sint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0;<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>;<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00255                 {
00256                         entry._Weights[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]= 1.0f;
00257                         entry._Tracks[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]= entry._DefaultTracks;
00258                 }
00259 
00260                 <font class="comment">// add (if not already done) the entry in the map.</font>
00261                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>[iDInAnimationSet]= entry;
00262 
00263                 <font class="comment">// Dirt all the slots</font>
00264                 <a class="code" href="classNL3D_1_1CChannelMixer.html#c1">dirtAll</a> ();
00265 
00266                 <font class="comment">// Affect the default value in the animated value</font>
00267                 entry._Value-&gt;affect (entry._DefaultTracks-&gt;getValue());
00268 
00269                 <font class="comment">// Touch the animated value and its owner to recompute them later.</font>
00270                 entry._Object-&gt;touch (entry._ValueId, entry._OwnerValueId);
00271 
00272                 <font class="comment">// return the id.</font>
00273                 <font class="keywordflow">return</font> iDInAnimationSet;
00274         }
00275         <font class="keywordflow">else</font>
00276         {
00277                 <font class="comment">// return Not found.</font>
00278                 <font class="keywordflow">return</font> -1;
00279         }
00280 }
00281 
00282 <font class="comment">// ***************************************************************************</font>
00283 
<a name="l00284"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a5">00284</a> <font class="keywordtype">void</font> CChannelMixer::resetChannels ()
00285 {
00286         <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.clear();
00287         <a class="code" href="classNL3D_1_1CChannelMixer.html#c1">dirtAll</a> ();
00288 }
00289 
00290 
00291 <font class="comment">// ***************************************************************************</font>
<a name="l00292"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a6">00292</a> <font class="keywordtype">void</font> CChannelMixer::enableChannel (uint channelId, <font class="keywordtype">bool</font> enable)
00293 {
00294         std::map&lt;uint, CChannel&gt;::iterator      it= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.find(channelId);
00295         <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end())
00296         {
00297                 it-&gt;second._EnableFlags &amp;= ~CChannel::EnableUserFlag;
00298                 <font class="keywordflow">if</font>(enable)
00299                         it-&gt;second._EnableFlags |= CChannel::EnableUserFlag;
00300 
00301                 <font class="comment">// Must recompute the channels to animate.</font>
00302                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>= <font class="keyword">true</font>;
00303         }
00304 }
00305 
00306 
00307 <font class="comment">// ***************************************************************************</font>
<a name="l00308"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a7">00308</a> <font class="keywordtype">bool</font> CChannelMixer::isChannelEnabled (uint channelId)<font class="keyword"> const</font>
00309 <font class="keyword"></font>{
00310         std::map&lt;uint, CChannel&gt;::const_iterator        it= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.find(channelId);
00311         <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end())
00312         {
00313                 <font class="keywordflow">return</font> (it-&gt;second._EnableFlags &amp; CChannel::EnableUserFlag) != 0;
00314         }
00315         <font class="keywordflow">else</font>
00316                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00317 }
00318 
00319 
00320 <font class="comment">// ***************************************************************************</font>
<a name="l00321"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a8">00321</a> <font class="keywordtype">void</font> CChannelMixer::lodEnableChannel (uint channelId, <font class="keywordtype">bool</font> enable)
00322 {
00323         std::map&lt;uint, CChannel&gt;::iterator      it= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.find(channelId);
00324         <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end())
00325         {
00326                 it-&gt;second._EnableFlags &amp;= ~CChannel::EnableLodFlag;
00327                 <font class="keywordflow">if</font>(enable)
00328                         it-&gt;second._EnableFlags |= CChannel::EnableLodFlag;
00329 
00330                 <font class="comment">// Must recompute the channels to animate.</font>
00331                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>= <font class="keyword">true</font>;
00332         }
00333 }
00334 
00335 
00336 <font class="comment">// ***************************************************************************</font>
<a name="l00337"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a9">00337</a> <font class="keywordtype">bool</font> CChannelMixer::isChannelLodEnabled (uint channelId)<font class="keyword"> const</font>
00338 <font class="keyword"></font>{
00339         std::map&lt;uint, CChannel&gt;::const_iterator        it= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.find(channelId);
00340         <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end())
00341         {
00342                 <font class="keywordflow">return</font> (it-&gt;second._EnableFlags &amp; CChannel::EnableLodFlag) != 0;
00343         }
00344         <font class="keywordflow">else</font>
00345                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00346 }
00347 
00348 
00349 
00350 <font class="comment">// ***************************************************************************</font>
00351 
<a name="l00352"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a10">00352</a> <font class="keywordtype">void</font> CChannelMixer::setSlotAnimation (uint slot, uint animation)
00353 {
00354         <font class="comment">// Check alot arg</font>
00355         <a class="code" href="debug_8h.html#a6">nlassert</a> (slot&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>);
00356 
00357         <font class="comment">// Check an animationSet as been set.</font>
00358         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>);
00359 
00360         <font class="comment">// Find the animation pointer for this animation</font>
00361         <font class="keyword">const</font> CAnimation* pAnimation=<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>-&gt;getAnimation (animation);
00362 
00363         <font class="comment">// Does this animation change ?</font>
00364         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o0">_Animation</a>!=pAnimation)
00365         {
00366                 <font class="comment">// Change it</font>
00367                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o0">_Animation</a>=pAnimation;
00368 
00369                 <font class="comment">// Dirt it</font>
00370                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o5">_Dirt</a>=<font class="keyword">true</font>;
00371 
00372                 <font class="comment">// Dirt the mixer</font>
00373                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o6">_Dirt</a>=<font class="keyword">true</font>;
00374         }
00375 }
00376 
00377 <font class="comment">// ***************************************************************************</font>
00378 
<a name="l00379"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a11">00379</a> <font class="keyword">const</font> CAnimation        *CChannelMixer::getSlotAnimation(uint slot)<font class="keyword"> const</font>
00380 <font class="keyword"></font>{
00381         <a class="code" href="debug_8h.html#a6">nlassert</a>(slot &lt; <a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>);
00382         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o0">_Animation</a>;
00383 }
00384 
00385 
00386 <font class="comment">// ***************************************************************************</font>
00387 
<a name="l00388"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a14">00388</a> <font class="keywordtype">void</font> CChannelMixer::emptySlot (uint slot)
00389 {
00390         <font class="comment">// Check alot arg</font>
00391         <a class="code" href="debug_8h.html#a6">nlassert</a> (slot&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>);
00392 
00393         <font class="comment">// Does this animation already empty ?</font>
00394         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#c2">isEmpty</a> ())
00395         {
00396                 <font class="comment">// Change it</font>
00397                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#c1">empty</a> ();
00398 
00399                 <font class="comment">// Dirt it</font>
00400                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o5">_Dirt</a>=<font class="keyword">true</font>;
00401 
00402                 <font class="comment">// Dirt the mixer</font>
00403                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o6">_Dirt</a>=<font class="keyword">true</font>;
00404         }
00405 }
00406 
00407 <font class="comment">// ***************************************************************************</font>
00408 
<a name="l00409"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a15">00409</a> <font class="keywordtype">void</font> CChannelMixer::resetSlots ()
00410 {
00411         <font class="comment">// Empty all slots</font>
00412         <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00413                 <font class="comment">// Empty it</font>
00414                 <a class="code" href="classNL3D_1_1CChannelMixer.html#a14">emptySlot</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>);
00415 }
00416 
00417 <font class="comment">// ***************************************************************************</font>
00418 
<a name="l00419"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a16">00419</a> <font class="keywordtype">void</font> CChannelMixer::applySkeletonWeight (uint slot, uint skeleton, <font class="keywordtype">bool</font> invert)
00420 {
00421         <font class="comment">// Check alot arg</font>
00422         <a class="code" href="debug_8h.html#a6">nlassert</a> (slot&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>);
00423 
00424         <font class="comment">// Check the animationSet has been set</font>
00425         <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>);
00426 
00427         <font class="comment">// Get the skeleton weight</font>
00428         <font class="keyword">const</font> CSkeletonWeight *pSkeleton=<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>-&gt;getSkeletonWeight (skeleton);
00429 
00430         <font class="comment">// Something to change ?</font>
00431         <font class="keywordflow">if</font> ((pSkeleton!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o1">_SkeletonWeight</a>)||(invert!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o2">_InvertedSkeletonWeight</a>))
00432         {
00433                 <font class="comment">// Set the current skeleton</font>
00434                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o1">_SkeletonWeight</a>=pSkeleton;
00435                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o2">_InvertedSkeletonWeight</a>=invert;
00436 
00437                 <font class="comment">// Get number of node in the skeleton weight</font>
00438                 uint sizeSkel=pSkeleton-&gt;getNumNode ();
00439 
00440                 <font class="comment">// For each entry of the skeleton weight</font>
00441                 <font class="keywordflow">for</font> (uint n=0; n&lt;sizeSkel; n++)
00442                 {
00443                         <font class="comment">// Get the name of the channel for this node</font>
00444                         <font class="keyword">const</font> string&amp; channelName=pSkeleton-&gt;getNodeName (n);
00445 
00446                         <font class="comment">// Get the channel Id having the same name than the tracks in this animation set.</font>
00447                         uint channelId=<a class="code" href="classNL3D_1_1CChannelMixer.html#o1">_AnimationSet</a>-&gt;getChannelIdByName (channelName);
00448 
00449                         <font class="comment">// Tracks exist in this animation set?</font>
00450                         <font class="keywordflow">if</font> (channelId!=CAnimationSet::NotFound)
00451                         {
00452                                 <font class="comment">// Get the weight of the channel for this node</font>
00453                                 <font class="keywordtype">float</font> weight=pSkeleton-&gt;getNodeWeight (n);
00454 
00455                                 <font class="comment">// Set the weight of this channel for this slot (only if channel setuped!!)</font>
00456                                 std::map&lt;uint, CChannel&gt;::iterator ite=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.find(channelId);
00457                                 <font class="keywordflow">if</font> (ite!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end())
00458                                         ite-&gt;second._Weights[slot]=invert?1.f-weight:weight;
00459                         }
00460                 }
00461         }
00462 }
00463 
00464 <font class="comment">// ***************************************************************************</font>
00465 
<a name="l00466"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a17">00466</a> <font class="keywordtype">void</font> CChannelMixer::resetSkeletonWeight (uint slot)
00467 {
00468         <font class="comment">// Check alot arg</font>
00469         <a class="code" href="debug_8h.html#a6">nlassert</a> (slot&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>);
00470 
00471         <font class="comment">// Something to change ?</font>
00472         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o1">_SkeletonWeight</a>!=NULL)
00473         {
00474                 <font class="comment">// Set skeleton</font>
00475                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o1">_SkeletonWeight</a>=NULL;
00476                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[slot].<a class="code" href="classNL3D_1_1CChannelMixer_1_1CSlot.html#o2">_InvertedSkeletonWeight</a>=<font class="keyword">false</font>;
00477 
00478                 <font class="comment">// For each channels</font>
00479                 map&lt;uint, CChannel&gt;::iterator           itChannel;
00480                 <font class="keywordflow">for</font>(itChannel= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.begin(); itChannel!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end();itChannel++)
00481                 {
00482                         <font class="comment">// Reset</font>
00483                         (*itChannel).second._Weights[slot]=1.f;
00484                 }
00485         }
00486 }
00487 
00488 <font class="comment">// ***************************************************************************</font>
00489 
<a name="l00490"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#c0">00490</a> <font class="keywordtype">void</font> CChannelMixer::cleanAll ()
00491 {
00492         <font class="comment">// For each slot</font>
00493         <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00494         {
00495                 <font class="comment">// Clean it</font>
00496                 <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]._Dirt=<font class="keyword">false</font>;
00497         }
00498 
00499         <font class="comment">// Clean the mixer</font>
00500         <a class="code" href="classNL3D_1_1CChannelMixer.html#o6">_Dirt</a>=<font class="keyword">false</font>;
00501 }
00502 
00503 <font class="comment">// ***************************************************************************</font>
00504 
<a name="l00505"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#c1">00505</a> <font class="keywordtype">void</font> CChannelMixer::dirtAll ()
00506 {
00507         <font class="comment">// For each slot</font>
00508         <font class="keywordflow">for</font> (uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00509         {
00510                 <font class="comment">// Dirt</font>
00511                 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>].isEmpty())
00512                 {
00513                         <font class="comment">// Dirt it</font>
00514                         <a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]._Dirt=<font class="keyword">true</font>;
00515 
00516                         <font class="comment">// Dirt the mixer</font>
00517                         <a class="code" href="classNL3D_1_1CChannelMixer.html#o6">_Dirt</a>=<font class="keyword">true</font>;
00518                 }
00519         }
00520 }
00521 
00522 <font class="comment">// ***************************************************************************</font>
00523 
<a name="l00524"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#c2">00524</a> <font class="keywordtype">void</font> CChannelMixer::refreshList ()
00525 {
00526         <font class="comment">// Setup an array of animation to add</font>
00527         uint numAdd=0;
00528         uint addSlot[<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>];
00529 
00530         <font class="comment">// Setup an array of animation that are not empty and stay</font>
00531         uint numStay=0;
00532         uint staySlot[<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>];
00533 
00534         <font class="comment">// Setup it up</font>
00535         uint <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
00536         <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;<a class="code" href="classNL3D_1_1CChannelMixer.html#s1s0">NumAnimationSlot</a>; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00537         {
00538                 <font class="comment">// Dirt and not empty ? (add)</font>
00539                 <font class="keywordflow">if</font> ((<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]._Dirt)&amp;&amp;(!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>].isEmpty()))
00540                         <font class="comment">// Add a dirt slot</font>
00541                         addSlot[numAdd++]=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
00542 
00543                 <font class="comment">// Not empty and not dirt ? (stay)</font>
00544                 <font class="keywordflow">if</font> ((!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]._Dirt)&amp;&amp;(!<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>].isEmpty()))
00545                         <font class="comment">// Add a dirt slot</font>
00546                         staySlot[numStay++]=<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
00547         }
00548 
00549         <font class="comment">// Last channel pointer</font>
00550         CChannel **lastPointerGlobal=&amp;<a class="code" href="classNL3D_1_1CChannelMixer.html#o3">_FirstChannelGlobal</a>;
00551         CChannel **lastPointerDetail=&amp;<a class="code" href="classNL3D_1_1CChannelMixer.html#o4">_FirstChannelDetail</a>;
00552 
00553 
00554         <font class="comment">// Now scan each channel</font>
00555         map&lt;uint, CChannel&gt;::iterator           itChannel;
00556         <font class="keywordflow">for</font>(itChannel= <a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.begin(); itChannel!=<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.end();itChannel++)
00557         {
00558                 CChannel        &amp;channel= (*itChannel).second;
00559 
00560                 <font class="comment">// Add this channel to the list if true</font>
00561                 <font class="keywordtype">bool</font> add=<font class="keyword">false</font>;
00562 
00563                 <font class="comment">// For each slot to add</font>
00564                 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;numAdd; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00565                 {
00566                         <font class="comment">// Find the index of the channel track in the animation set</font>
00567                         uint iDTrack=<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[addSlot[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]]._Animation-&gt;getIdTrackByName (channel._ChannelName);
00568 
00569                         <font class="comment">// If this track exist</font>
00570                         <font class="keywordflow">if</font> (iDTrack!=CAnimation::NotFound)
00571                         {
00572                                 <font class="comment">// Set the track</font>
00573                                 channel._Tracks[addSlot[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]]=<a class="code" href="classNL3D_1_1CChannelMixer.html#o0">_SlotArray</a>[addSlot[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]]._Animation-&gt;getTrack (iDTrack);
00574 
00575                                 <font class="comment">// Add this channel to the list</font>
00576                                 add=<font class="keyword">true</font>;
00577                         }
00578                         <font class="keywordflow">else</font>
00579                         {
00580                                 <font class="comment">// Set the default track</font>
00581                                 channel._Tracks[addSlot[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]]=channel._DefaultTracks;
00582                         }
00583                 }
00584 
00585                 <font class="comment">// Add this channel to the list ?</font>
00586                 <font class="keywordflow">if</font> (!add)
00587                 {
00588                         <font class="comment">// Was it in the list ?</font>
00589                         <font class="keywordflow">if</font> (channel._InTheList)
00590                         {
00591                                 <font class="comment">// Check if this channel is still in use</font>
00592 
00593                                 <font class="comment">// For each slot in the stay list</font>
00594                                 <font class="keywordflow">for</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>=0; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>&lt;numStay; <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>++)
00595                                 {
00596                                         <font class="comment">// Use anything interesting ?</font>
00597                                         <font class="keywordflow">if</font> (channel._Tracks[staySlot[<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>]]!=channel._DefaultTracks)
00598                                         {
00599                                                 <font class="comment">// Ok, add it to the list</font>
00600                                                 add=<font class="keyword">true</font>;
00601 
00602                                                 <font class="comment">// Stop</font>
00603                                                 <font class="keywordflow">break</font>;
00604                                         }
00605                                 }
00606 
00607                                 <font class="comment">// Still in use?</font>
00608                                 <font class="keywordflow">if</font> (!add)
00609                                 {
00610                                         <font class="comment">// Set it's value to default and touch it's object</font>
00611                                         channel._Value-&gt;affect (channel._DefaultTracks-&gt;getValue());
00612                                         channel._Object-&gt;touch (channel._ValueId, channel._OwnerValueId);
00613                                 }
00614                         }
00615                 }
00616 
00617                 <font class="comment">// Do i have to add the channel to the list</font>
00618                 <font class="keywordflow">if</font> (add)
00619                 {
00620                         <font class="comment">// It is in the list</font>
00621                         channel._InTheList=<font class="keyword">true</font>;
00622 
00623                         <font class="keywordflow">if</font>(channel._Detail)
00624                         {
00625                                 <font class="comment">// Set the last pointer value</font>
00626                                 *lastPointerDetail=&amp;channel;
00627                                 <font class="comment">// Change last pointer</font>
00628                                 lastPointerDetail=&amp;channel._Next;
00629                         }
00630                         <font class="keywordflow">else</font>
00631                         {
00632                                 <font class="comment">// Set the last pointer value</font>
00633                                 *lastPointerGlobal=&amp;channel;
00634                                 <font class="comment">// Change last pointer</font>
00635                                 lastPointerGlobal=&amp;channel._Next;
00636                         }
00637 
00638                 }
00639                 <font class="keywordflow">else</font>
00640                 {
00641                         <font class="comment">// It is not in the list</font>
00642                         channel._InTheList=<font class="keyword">false</font>;
00643                 }
00644         }
00645 
00646         <font class="comment">// End of the list</font>
00647         *lastPointerGlobal=NULL;
00648         *lastPointerDetail=NULL;
00649 
00650         <font class="comment">// Must recompute the channels to animate.</font>
00651         <a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>= <font class="keyword">true</font>;
00652 }
00653 
00654 
00655 <font class="comment">// ***************************************************************************</font>
<a name="l00656"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#c3">00656</a> <font class="keywordtype">void</font> CChannelMixer::refreshListToEval ()
00657 {
00658         CChannel* pChannel;
00659 
00660         <font class="comment">/* NB: this save if(), especially when Used with Skeleton, and CLod mode</font>
00661 <font class="comment">        */</font>
00662 
00663         <font class="comment">// Global list.</font>
00664         <a class="code" href="classNL3D_1_1CChannelMixer.html#o8">_GlobalListToEval</a>.clear();
00665         <a class="code" href="classNL3D_1_1CChannelMixer.html#o8">_GlobalListToEval</a>.reserve(<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.size());
00666         pChannel=<a class="code" href="classNL3D_1_1CChannelMixer.html#o3">_FirstChannelGlobal</a>;
00667         <font class="keywordflow">while</font>(pChannel)
00668         {
00669                 <font class="comment">// if the channel is enabled (both user and lod), must eval all active slot.</font>
00670                 <font class="keywordflow">if</font>(pChannel-&gt;_EnableFlags == CChannel::EnableAllFlag)
00671                         <a class="code" href="classNL3D_1_1CChannelMixer.html#o8">_GlobalListToEval</a>.push_back(pChannel);
00672                 <font class="comment">// next</font>
00673                 pChannel= pChannel-&gt;_Next;
00674         }
00675 
00676         <font class="comment">// Global list.</font>
00677         <a class="code" href="classNL3D_1_1CChannelMixer.html#o9">_DetailListToEval</a>.clear();
00678         <a class="code" href="classNL3D_1_1CChannelMixer.html#o9">_DetailListToEval</a>.reserve(<a class="code" href="classNL3D_1_1CChannelMixer.html#o2">_Channels</a>.size());
00679         pChannel=<a class="code" href="classNL3D_1_1CChannelMixer.html#o4">_FirstChannelDetail</a>;
00680         <font class="keywordflow">while</font>(pChannel)
00681         {
00682                 <font class="comment">// if the channel is enabled (both user and lod), must eval all active slot.</font>
00683                 <font class="keywordflow">if</font>(pChannel-&gt;_EnableFlags == CChannel::EnableAllFlag)
00684                         <a class="code" href="classNL3D_1_1CChannelMixer.html#o9">_DetailListToEval</a>.push_back(pChannel);
00685                 <font class="comment">// next</font>
00686                 pChannel= pChannel-&gt;_Next;
00687         }
00688 
00689         <font class="comment">// done</font>
00690         <a class="code" href="classNL3D_1_1CChannelMixer.html#o7">_ListToEvalDirt</a>= <font class="keyword">false</font>;
00691 }
00692 
00693 <font class="comment">// ***************************************************************************</font>
<a name="l00694"></a><a class="code" href="classNL3D_1_1CChannelMixer.html#a18">00694</a> <font class="keywordtype">void</font> CChannelMixer::resetEvalDetailDate()
00695 {
00696         <a class="code" href="classNL3D_1_1CChannelMixer.html#o5">_LastEvalDetailDate</a>= -1;
00697 }
00698 
00699 
00700 } <font class="comment">// NL3D</font>
</pre></div>

<!-- 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=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>