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
|
<!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> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/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>
<!-- 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> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>env_sound_user.cpp</h1><a href="env__sound__user_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="stdsound_8h.html">stdsound.h</a>"</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="env__sound__user_8h.html">env_sound_user.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="sound_8h.html">sound.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="bounding__shape_8h.html">bounding_shape.h</a>"</font>
00031 <font class="preprocessor">#include <stdlib.h></font>
00032
00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00035
00036
00037 <font class="keyword">namespace </font>NLSOUND {
00038
00039
00040 <font class="comment">/*</font>
00041 <font class="comment"> * Constructor</font>
00042 <font class="comment"> */</font>
<a name="l00043"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a0">00043</a> CEnvSoundUser::CEnvSoundUser() : _Play(false), _Source(NULL), _BoundingShape(NULL), _Transition(false), _Parent(NULL), _Mark(false), _Gain(1.0f)
00044 {
00045 }
00046
00047
00048 <font class="comment">/*</font>
00049 <font class="comment"> * Destructor</font>
00050 <font class="comment"> */</font>
<a name="l00051"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a1">00051</a> CEnvSoundUser::~CEnvSoundUser()
00052 {
00053 vector<CEnvSoundUser*>::iterator ipe;
00054 <font class="keywordflow">for</font> ( ipe=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipe!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipe )
00055 {
00056 <font class="keyword">delete</font> (*ipe);
00057 }
00058
00059 vector<IPlayable*>::iterator ipp;
00060 <font class="keywordflow">for</font> ( ipp=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.begin(); ipp!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.end(); ++ipp )
00061 {
00062 <font class="comment">// An IPlayable object can be a CAmbiantSource or a CSourceUser.</font>
00063 <font class="comment">// A CAmbiantSource removes its source (channels) in destructor, but not a CSourceUser</font>
00064 <font class="keywordflow">if</font> ( dynamic_cast<CSourceUser*>(*ipp) )
00065 {
00066 CAudioMixerUser::instance()->removeSource( static_cast<CSourceUser*>(*ipp) );
00067 }
00068 <font class="keywordflow">else</font>
00069 {
00070 <font class="keywordflow">if</font> ( (*ipp) != NULL )
00071 {
00072 <font class="keyword">delete</font> (*ipp);
00073 }
00074 }
00075 }
00076
00077 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> != NULL )
00078 {
00079 <font class="keyword">delete</font> <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>;
00080 }
00081 }
00082
00083
00084 <font class="comment">/*</font>
00085 <font class="comment"> * Serialize (recursive)</font>
00086 <font class="comment"> */</font>
<a name="l00087"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a2">00087</a> <font class="keywordtype">void</font> CEnvSoundUser::serial( <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a>& <a class="code" href="driver__opengl__extension__def_8h.html#a244">s</a> )
00088 {
00089 <font class="comment">// If you change this, increment the version number in CEnvSoundUser::load() !</font>
00090
00091 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o5">_Transition</a> );
00092 s.<a class="code" href="classNLMISC_1_1IStream.html#a28">serialPolyPtr</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> );
00093 s.<a class="code" href="classNLMISC_1_1IStream.html#a22">serialContPolyPtr</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a> ); <font class="comment">// serializes sound and looping state only</font>
00094
00095 <a class="code" href="types__nl_8h.html#a7">uint16</a> srcindex;
00096
00097 <font class="keywordflow">if</font> ( s.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() )
00098 {
00099 <font class="comment">// Select the source in the bank</font>
00100 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( srcindex );
00101 <font class="keywordflow">if</font> ( ! <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.empty() )
00102 {
00103 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>[srcindex];
00104 }
00105 <font class="keywordflow">else</font>
00106 {
00107 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> = NULL;
00108 }
00109
00110 <font class="comment">// Set the position which was not serialized</font>
00111 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a>!=NULL) && (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> != NULL) )
00112 {
00113 vector<IPlayable*>::iterator ipp;
00114 <font class="keywordflow">for</font> ( ipp=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.begin(); ipp!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.end(); ++ipp )
00115 {
00116 (*ipp)->moveTo( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->getCenter() );
00117 }
00118 }
00119
00120 <font class="comment">// Init the source (not transition)</font>
00121 <font class="keywordflow">if</font> ( ! <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o5">_Transition</a> )
00122 {
00123 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> != NULL) )
00124 {
00125 vector<IPlayable*>::iterator ipp;
00126 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> != NULL )
00127 {
00128 <font class="keywordflow">for</font> ( ipp=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.begin(); ipp!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.end(); ++ipp )
00129 {
00130 (*ipp)->initPos( const_cast<CVector*>(&(<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->getCenter())) );
00131 }
00132 }
00133 <font class="keywordflow">else</font>
00134 {
00135 <font class="comment">// The world envsound will be heard at the listener</font>
00136 <font class="keywordflow">for</font> ( ipp=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.begin(); ipp!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.end(); ++ipp )
00137 {
00138 (*ipp)->initPos( &CAudioMixerUser::instance()->getListenPosVector() );
00139 }
00140 }
00141 }
00142 }
00143 }
00144 <font class="keywordflow">else</font>
00145 {
00146 <a class="code" href="types__nl_8h.html#a13">uint</a> i;
00147 <font class="comment">// Find the index of the current source in the bank and serialize it out</font>
00148 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.size() != 0 )
00149 {
00150 <font class="keywordflow">for</font> ( i=0; i!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.size(); i++ )
00151 {
00152 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>[i] == <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> )
00153 {
00154 <font class="keywordflow">break</font>;
00155 }
00156 }
00157 <a class="code" href="debug_8h.html#a6">nlassert</a>( i != <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.size() );
00158 <a class="code" href="debug_8h.html#a6">nlassert</a>( i < 0x10000 ); <font class="comment">// 16-bit value</font>
00159 srcindex = i;
00160 }
00161 <font class="keywordflow">else</font>
00162 {
00163 srcindex = 0;
00164 }
00165 s.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( srcindex );
00166 }
00167
00168 <font class="comment">// Tags</font>
00169 s.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a> );
00170 <font class="preprocessor">#ifdef NL_DEBUG</font>
00171 <font class="preprocessor"></font> <a class="code" href="namespaceNLMISC.html#a11">DebugLog</a>->display( <font class="stringliteral">"Envsound tags:"</font>);
00172 vector<string>::iterator ist;
00173 <font class="keywordflow">for</font> ( ist=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a>.begin(); ist!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a>.end(); ++ist )
00174 {
00175 <a class="code" href="namespaceNLMISC.html#a11">DebugLog</a>->displayRaw( (<font class="stringliteral">" "</font> + (*ist)).c_str() );
00176 }
00177 <a class="code" href="namespaceNLMISC.html#a11">DebugLog</a>->displayRawNL(<font class="stringliteral">""</font>);
00178 <font class="preprocessor">#endif</font>
00179 <font class="preprocessor"></font>
00180 <font class="comment">// Children envsounds</font>
00181 s.<a class="code" href="classNLMISC_1_1IStream.html#a27">serialPtr</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> );
00182 s.<a class="code" href="classNLMISC_1_1IStream.html#a17">serialContPtr</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a> );
00183 }
00184
00185
00186 <font class="comment">/*</font>
00187 <font class="comment"> * Select current env</font>
00188 <font class="comment"> */</font>
<a name="l00189"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a5">00189</a> <font class="keywordtype">void</font> CEnvSoundUser::selectEnv( <font class="keyword">const</font> <font class="keywordtype">char</font> *tag, <font class="keywordtype">bool</font> children_too )
00190 {
00191 <a class="code" href="types__nl_8h.html#a13">uint</a> i;
00192 <font class="keywordflow">for</font> ( i=0; i!= <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a>.size(); i++ )
00193 {
00194 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a>[i] == string(tag) )
00195 {
00196 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> != NULL )
00197 {
00198 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a>->enable( <font class="keyword">false</font>, 1.0f );
00199 }
00200 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>[i];
00201 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"AM: EnvSound: Environment changed to %s"</font>, tag );
00202 CAudioMixerUser::instance()->getEnvSounds()->recompute();
00203 <font class="keywordflow">break</font>;
00204 }
00205 }
00206 <font class="comment">//nldebug( "AM: EnvSound: Environment %s not found", tag );</font>
00207 <font class="comment">// Don't change _Source if not found</font>
00208
00209 <font class="comment">// Apply to descendants</font>
00210 <font class="keywordflow">if</font> ( children_too )
00211 {
00212 vector<CEnvSoundUser*>::iterator ipc;
00213 <font class="keywordflow">for</font> ( ipc=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipc!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipc )
00214 {
00215 (*ipc)->selectEnv( tag, children_too );
00216 }
00217 }
00218 }
00219
00220
00221 <font class="comment">/*</font>
00222 <font class="comment"> * Serialize file header</font>
00223 <font class="comment"> */</font>
<a name="l00224"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#d0">00224</a> <font class="keywordtype">void</font> CEnvSoundUser::serialFileHeader( <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a>& <a class="code" href="driver__opengl__extension__def_8h.html#a244">s</a> )
00225 {
00226 <font class="comment">// Envsounds file header</font>
00227 s.<a class="code" href="classNLMISC_1_1IStream.html#a30">serialCheck</a>( (<a class="code" href="types__nl_8h.html#a9">uint32</a>)'SEN' ); <font class="comment">// NeL Environment Sounds</font>
00228 <font class="keywordflow">if</font> ( s.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>( 2 ) < 2 )
00229 {
00230 <font class="keywordflow">throw</font> EOlderStream(s);
00231 }
00232
00233 <font class="comment">// Check CSound version (and prepare CSound::serial() backward compatibility)</font>
00234 CSound::FileVersion = s.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>( CSound::CurrentVersion );
00235 <font class="keywordflow">if</font> ( CSound::FileVersion == 0 ) <font class="comment">// warning: not multithread-compliant</font>
00236 {
00237 <font class="comment">// Not supporting version 0 anymore</font>
00238 <font class="keywordflow">throw</font> EOlderStream(s);
00239 }
00240 }
00241
00242
00243 <font class="comment">/*</font>
00244 <font class="comment"> * Count the envs in the tree (call on the root)</font>
00245 <font class="comment"> */</font>
<a name="l00246"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b4">00246</a> <a class="code" href="types__nl_8h.html#a9">uint32</a> CEnvSoundUser::getCount()<font class="keyword"> const</font>
00247 <font class="keyword"></font>{
00248 <a class="code" href="types__nl_8h.html#a9">uint32</a> cnt=1;
00249 vector<CEnvSoundUser*>::const_iterator ipe;
00250 <font class="keywordflow">for</font> ( ipe=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipe!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipe )
00251 {
00252 cnt += (*ipe)->getCount();
00253 }
00254 <font class="keywordflow">return</font> cnt;
00255 }
00256
00257
00258 <font class="comment">/*</font>
00259 <font class="comment"> * Load several envsounds and return the number of envsounds loaded</font>
00260 <font class="comment"> */</font>
<a name="l00261"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#d1">00261</a> <a class="code" href="types__nl_8h.html#a9">uint32</a> CEnvSoundUser::load( CEnvSoundUser* &envSoundTreeRoot, <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a>& <a class="code" href="driver__opengl__extension__def_8h.html#a244">s</a> )
00262 {
00263 <font class="keywordflow">if</font> ( s.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() )
00264 {
00265 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#d0">serialFileHeader</a>( s );
00266 s.<a class="code" href="classNLMISC_1_1IStream.html#a27">serialPtr</a>( envSoundTreeRoot );
00267 <font class="keywordflow">return</font> envSoundTreeRoot->getCount();
00268
00269 <font class="comment">// Reset CSound version</font>
00270 CSound::FileVersion = CSound::CurrentVersion; <font class="comment">// warning: not multithread-compliant : do not serialize in different threads !</font>
00271 }
00272 <font class="keywordflow">else</font>
00273 {
00274 <a class="code" href="debug_8h.html#a12">nlstop</a>;
00275 <font class="keywordflow">return</font> 0;
00276 }
00277 }
00278
00279
00280 <font class="comment">/*</font>
00281 <font class="comment"> * Update the stereo mixes (call evenly on the root) (recursive)</font>
00282 <font class="comment"> */</font>
<a name="l00283"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a8">00283</a> <font class="keywordtype">void</font> CEnvSoundUser::update()
00284 {
00285 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> != NULL )
00286 {
00287 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a>->update();
00288 }
00289 vector<CEnvSoundUser*>::iterator ipe;
00290 <font class="keywordflow">for</font> ( ipe=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipe!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipe )
00291 {
00292 (*ipe)->update();
00293 }
00294 }
00295
00296
00297 <font class="comment">/*</font>
00298 <font class="comment"> * Find the area where the listener is located (recursive)</font>
00299 <font class="comment"> */</font>
<a name="l00300"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b2">00300</a> CEnvSoundUser *CEnvSoundUser::findCurrentEnv( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& listenerpos )
00301 {
00302 <font class="comment">// Find in children first (check from leaves to root)</font>
00303 vector<CEnvSoundUser*>::iterator ipe = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin();
00304 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a0">CEnvSoundUser</a> *found = NULL;
00305 <font class="keywordflow">while</font> ( ! ( (found) || (ipe==<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end()) ) )
00306 {
00307 found = (*ipe)->findCurrentEnv( listenerpos );
00308 ipe++;
00309 }
00310 <font class="keywordflow">if</font> ( found )
00311 <font class="keywordflow">return</font> found;
00312 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> == NULL) || (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->include( listenerpos )) )
00313 <font class="keywordflow">return</font> <font class="keyword">this</font>;
00314 <font class="keywordflow">else</font>
00315 <font class="keywordflow">return</font> NULL;
00316 }
00317
00318
00319 <font class="comment">/*</font>
00320 <font class="comment"> * Return the position</font>
00321 <font class="comment"> */</font>
<a name="l00322"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a3">00322</a> <font class="keywordtype">void</font> CEnvSoundUser::getPos( <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& pos )<font class="keyword"> const</font>
00323 <font class="keyword"></font>{
00324 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> == NULL )
00325 {
00326 pos = CVector::Null;
00327 }
00328 <font class="keywordflow">else</font>
00329 {
00330 pos = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->getCenter();
00331 }
00332 }
00333
00334
00335 <font class="comment">/*</font>
00336 <font class="comment"> * Moves the envsound (and its transition envsound if it has one)</font>
00337 <font class="comment"> */</font>
<a name="l00338"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a4">00338</a> <font class="keywordtype">void</font> CEnvSoundUser::setPos( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& pos )
00339 {
00340 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> != NULL )
00341 {
00342 <font class="comment">// Get the vector between the pos of this envsound and the pos of its transition envsound</font>
00343 CVector newpos;
00344 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> != NULL) && ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Transition ) )
00345 {
00346 newpos = pos + <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_BoundingShape->getCenter() - <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->getCenter();
00347 }
00348 <font class="keywordflow">else</font>
00349 {
00350 newpos = pos;
00351 }
00352
00353 <font class="comment">// Set the new pos</font>
00354 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->setCenter( pos );
00355 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> != NULL) && ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Transition ) )
00356 {
00357 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_BoundingShape->setCenter( newpos );
00358 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Source != NULL )
00359 {
00360 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Source->moveTo( newpos );
00361 }
00362 }
00363
00364 <font class="comment">// Recompute the entire tree</font>
00365 CAudioMixerUser::instance()->getEnvSounds()->recompute();
00366 }
00367 }
00368
00369
00370 <font class="comment">/*</font>
00371 <font class="comment"> * Return the children envsounds</font>
00372 <font class="comment"> */</font>
<a name="l00373"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a6">00373</a> std::vector<UEnvSound*>& CEnvSoundUser::getChildren()
00374 {
00375 <font class="keywordflow">return</font> (vector<UEnvSound*>&)(_Children);
00376 }
00377
00378
00379 <font class="comment">/*</font>
00380 <font class="comment"> * Play or stop the sources (call only on the root env)</font>
00381 <font class="comment"> */</font>
<a name="l00382"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a7">00382</a> <font class="keywordtype">void</font> CEnvSoundUser::recompute()
00383 {
00384 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b0">isRoot</a>() );
00385
00386 <font class="comment">// Find the area of the listener</font>
00387 CVector listenerpos;
00388 CAudioMixerUser::instance()->getListener()->getPos( listenerpos );
00389 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a0">CEnvSoundUser</a> *current = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b2">findCurrentEnv</a>( listenerpos );
00390
00391 <font class="comment">// Mark the envs that have to play their source</font>
00392 <font class="keywordflow">if</font> ( current != NULL )
00393 {
00394 current->markSources( listenerpos, 1.0f );
00395 }
00396
00397 <font class="comment">// Enable/disable the sources in the hierarchy, and reset the marks</font>
00398 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b1">applySourcesMarks</a>();
00399 }
00400
00401
00402 <font class="comment">/* Prepare the related sources to play (recursive).</font>
00403 <font class="comment"> * In each children branch, there must be an env which is not a transition, for the recursion to stop</font>
00404 <font class="comment"> */</font>
<a name="l00405"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b3">00405</a> <font class="keywordtype">void</font> CEnvSoundUser::markSources( <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>& listenerpos, <font class="keywordtype">float</font> gain )
00406 {
00407 <font class="comment">// Is the listener in a transition area ?</font>
00408 <font class="keywordflow">if</font> ( _Transition )
00409 {
00410 <font class="comment">//nldebug( "AM: EnvSound: Marking sources for transition between child and parent" );</font>
00411
00412 <font class="comment">// Compute the listener position to find the ratio between up and down envs</font>
00413 <a class="code" href="debug_8h.html#a6">nlassert</a>( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.size() == 1) && (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>[0] != NULL) && (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> != NULL) );
00414 <a class="code" href="debug_8h.html#a6">nlassert</a>( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> && <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>[0]-><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> );
00415 <font class="keywordtype">float</font> ratio = <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a>->getRatio( listenerpos, <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>[0]-><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> );
00416 <a class="code" href="debug_8h.html#a6">nlassert</a>( ratio >= 0.0f && ratio <= 1.0f );
00417
00418 <font class="comment">// The child env plays at gain*ratio</font>
00419 <font class="comment">// The recursion stops because the child env is not a transition area</font>
00420 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>[0]->markSources( listenerpos, gain * ratio );
00421
00422 <font class="comment">// The parent env (therefore the 3d source of the current env as well) plays at gain*(1-ratio)</font>
00423 <font class="comment">// The recursion stops because the parent env is not a transition area</font>
00424 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->markSources( listenerpos, gain * (1.0f-ratio) );
00425 }
00426 <font class="keywordflow">else</font>
00427 {
00428 <font class="comment">//nldebug( "AM: EnvSound: Marking sources for environnement" );</font>
00429
00430 <font class="comment">// The listener in an environment, containing other environments (e.g. a town) or not (e.g. a room).</font>
00431 <font class="comment">// The current env plays</font>
00432 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o8">_Mark</a> = <font class="keyword">true</font>;
00433 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o9">_Gain</a> = gain;
00434
00435 <font class="comment">// The children env (next level only) play</font>
00436 vector<CEnvSoundUser*>::iterator ipe;
00437 <font class="keywordflow">for</font>( ipe=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipe!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipe )
00438 {
00439 (*ipe)->_Mark = <font class="keyword">true</font>;
00440 (*ipe)->_Gain = gain;
00441 }
00442 }
00443 }
00444
00445
00446 <font class="comment">/*</font>
00447 <font class="comment"> * Enable/disable the source and set general gain if enabled, and reset the source mark (recursive)</font>
00448 <font class="comment"> */</font>
<a name="l00449"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b1">00449</a> <font class="keywordtype">void</font> CEnvSoundUser::applySourcesMarks()
00450 {
00451 <font class="keywordflow">if</font> ( ! <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o0">_Play</a> )
00452 {
00453 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o8">_Mark</a> = <font class="keyword">false</font>;
00454 }
00455 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> != NULL )
00456 {
00457 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a>->enable( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o8">_Mark</a>, <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o9">_Gain</a> );
00458 }
00459 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o8">_Mark</a> = <font class="keyword">false</font>;
00460
00461 <font class="comment">// Apply on children</font>
00462 vector<CEnvSoundUser*>::iterator ipe;
00463 <font class="keywordflow">for</font> ( ipe=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipe!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipe )
00464 {
00465 (*ipe)->applySourcesMarks();
00466 }
00467 }
00468
00469
00470 <font class="comment">/*</font>
00471 <font class="comment"> * Set properties (EDIT)</font>
00472 <font class="comment"> */</font>
<a name="l00473"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a12">00473</a> <font class="keywordtype">void</font> CEnvSoundUser::setProperties( <font class="keywordtype">bool</font> transition, IBoundingShape *bshape )
00474 {
00475 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o5">_Transition</a> = transition;
00476 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o4">_BoundingShape</a> = bshape;
00477 }
00478
00479
00480 <font class="comment">/*</font>
00481 <font class="comment"> * Add an environment source/tag (EDIT) (set a NULL source for no source at all)</font>
00482 <font class="comment"> * The current source always becomes the first one.</font>
00483 <font class="comment"> */</font>
<a name="l00484"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a14">00484</a> <font class="keywordtype">void</font> CEnvSoundUser::addEnvTag( IPlayable *source, <font class="keyword">const</font> std::string& tag )
00485 {
00486 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o2">_SrcBank</a>.push_back( source );
00487 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o3">_Tags</a>.push_back( tag );
00488
00489 <font class="keywordflow">if</font> ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> == NULL ) <font class="comment">// becomes the first one and stays there</font>
00490 {
00491 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o1">_Source</a> = source;
00492 }
00493 }
00494
00495
00496 <font class="comment">/*</font>
00497 <font class="comment"> * Save (output stream only) (EDIT)</font>
00498 <font class="comment"> */</font>
<a name="l00499"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#d2">00499</a> <font class="keywordtype">void</font> CEnvSoundUser::save( CEnvSoundUser *envSoundTreeRoot, <a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a>& <a class="code" href="driver__opengl__extension__def_8h.html#a244">s</a> )
00500 {
00501 <a class="code" href="debug_8h.html#a6">nlassert</a>( ! s.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>() );
00502 <a class="code" href="debug_8h.html#a6">nlassert</a>( envSoundTreeRoot->isRoot() );
00503
00504 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#d0">serialFileHeader</a>( s );
00505 s.<a class="code" href="classNLMISC_1_1IStream.html#a27">serialPtr</a>( envSoundTreeRoot );
00506 }
00507
00508
00509 <font class="comment">/*</font>
00510 <font class="comment"> * Play</font>
00511 <font class="comment"> */</font>
<a name="l00512"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a9">00512</a> <font class="keywordtype">void</font> CEnvSoundUser::play( <font class="keywordtype">bool</font> children_too )
00513 {
00514 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b5">playSub</a>( children_too );
00515
00516 CAudioMixerUser::instance()->getEnvSounds()->recompute();
00517 }
00518
00519
00520 <font class="comment">/*</font>
00521 <font class="comment"> * Stop playing</font>
00522 <font class="comment"> */</font>
<a name="l00523"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a10">00523</a> <font class="keywordtype">void</font> CEnvSoundUser::stop( <font class="keywordtype">bool</font> children_too )
00524 {
00525 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b6">stopSub</a>( children_too );
00526
00527 CAudioMixerUser::instance()->getEnvSounds()->recompute();
00528 }
00529
00530
00531 <font class="comment">/*</font>
00532 <font class="comment"> * Play this node, and all descendants if children_too is true, but do not recompute</font>
00533 <font class="comment"> */</font>
<a name="l00534"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b5">00534</a> <font class="keywordtype">void</font> CEnvSoundUser::playSub( <font class="keywordtype">bool</font> children_too )
00535 {
00536 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o0">_Play</a> = <font class="keyword">true</font>;
00537
00538 <font class="comment">// Start transition as well</font>
00539 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> != NULL) && ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Transition ) )
00540 {
00541 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Play = <font class="keyword">true</font>;
00542 }
00543
00544 <font class="comment">// Apply to descendants</font>
00545 <font class="keywordflow">if</font> ( children_too )
00546 {
00547 vector<CEnvSoundUser*>::iterator ipc;
00548 <font class="keywordflow">for</font> ( ipc=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipc!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipc )
00549 {
00550 (*ipc)->playSub( children_too );
00551 }
00552 }
00553 }
00554
00555
00556 <font class="comment">/*</font>
00557 <font class="comment"> * Stop playing this node, and all descendants if children_too is true, but do not recompute</font>
00558 <font class="comment"> */</font>
<a name="l00559"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#b6">00559</a> <font class="keywordtype">void</font> CEnvSoundUser::stopSub( <font class="keywordtype">bool</font> children_too )
00560 {
00561 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o0">_Play</a> = <font class="keyword">false</font>;
00562
00563 <font class="comment">// Stop transition as well</font>
00564 <font class="keywordflow">if</font> ( (<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a> != NULL) && ( <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Transition ) )
00565 {
00566 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o6">_Parent</a>->_Play = <font class="keyword">false</font>;
00567 }
00568
00569 <font class="comment">// Apply to descendants</font>
00570 <font class="keywordflow">if</font> ( children_too )
00571 {
00572 vector<CEnvSoundUser*>::iterator ipc;
00573 <font class="keywordflow">for</font> ( ipc=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.begin(); ipc!=<a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.end(); ++ipc )
00574 {
00575 (*ipc)->stopSub( children_too );
00576 }
00577 }
00578 }
00579
00580
00581 <font class="comment">/*</font>
00582 <font class="comment"> * Add a child (EDIT)</font>
00583 <font class="comment"> */</font>
<a name="l00584"></a><a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#a13">00584</a> <font class="keywordtype">void</font> CEnvSoundUser::addChild( CEnvSoundUser *child )
00585 {
00586 child->_Parent = <font class="keyword">this</font>;
00587 <a class="code" href="classNLSOUND_1_1CEnvSoundUser.html#o7">_Children</a>.push_back( child );
00588 }
00589
00590
00591 } <font class="comment">// NLSOUND</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|