aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/async__file__manager__3d_8cpp-source.html
blob: a5066fa8b597a1b0f8f9393eae762625eb0e7857 (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
<!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=><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>async_file_manager_3d.cpp</h1><a href="async__file__manager__3d_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2000 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="async__file__manager__3d_8h.html">3d/async_file_manager_3d.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="shape_8h.html">3d/shape.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="mesh_8h.html">3d/mesh.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="texture__file_8h.html">3d/texture_file.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="scene__group_8h.html">3d/scene_group.h</a>"</font>
00033 
00034 <font class="preprocessor">#include "<a class="code" href="instance__group__user_8h.html">3d/instance_group_user.h</a>"</font>
00035 
00036 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="path_8h.html">nel/misc/path.h</a>"</font>
00038 
00039 
00040 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00041 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00042 
<a name="l00043"></a><a class="code" href="async__file__manager__3d_8cpp.html#a0">00043</a> <font class="preprocessor">#define NL3D_MEM_INSTANCE                                       NL_ALLOC_CONTEXT( 3dInst )</font>
<a name="l00044"></a><a class="code" href="async__file__manager__3d_8cpp.html#a1">00044</a> <font class="preprocessor"></font><font class="preprocessor">#define NL3D_MEM_IG                                                     NL_ALLOC_CONTEXT( 3dIg )</font>
00045 <font class="preprocessor"></font>
00046 <font class="keyword">namespace </font>NL3D
00047 {
00048 
<a name="l00049"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">00049</a> CAsyncFileManager3D *CAsyncFileManager3D::_Singleton = NULL;
00050 
00051 <font class="comment">// ***************************************************************************</font>
00052 
<a name="l00053"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#c0">00053</a> CAsyncFileManager3D::CAsyncFileManager3D()
00054 {
00055 }
00056 
00057 <font class="comment">// ***************************************************************************</font>
00058 
<a name="l00059"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#d0">00059</a> CAsyncFileManager3D &amp;CAsyncFileManager3D::getInstance()
00060 {
00061         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">_Singleton</a> == NULL)
00062         {
00063                 <a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">_Singleton</a> = <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#c0">CAsyncFileManager3D</a>();
00064         }
00065         <font class="keywordflow">return</font> *<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">_Singleton</a>;
00066 }
00067 
00068 <font class="comment">// ***************************************************************************</font>
00069 
<a name="l00070"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#d1">00070</a> <font class="keywordtype">void</font> CAsyncFileManager3D::terminate ()
00071 {
00072         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">_Singleton</a> != NULL)
00073         {
00074                 <font class="keyword">delete</font> &amp;<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#d0">getInstance</a>();
00075                 <a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#r0">_Singleton</a> = NULL;
00076         }
00077 }
00078 
00079 <font class="comment">// ***************************************************************************</font>
00080         
<a name="l00081"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a0">00081</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadMesh(<font class="keyword">const</font> std::string&amp; meshName, IShape **ppShp, IDriver *pDriver)
00082 {
00083         CAsyncFileManager::getInstance().addLoadTask(<font class="keyword">new</font> CMeshLoad(meshName, ppShp, pDriver));
00084 }
00085 
00086 <font class="comment">// ***************************************************************************</font>
00087 
00088 <font class="comment">// Callback class for canceling a loadMesh</font>
<a name="l00089"></a><a class="code" href="classNL3D_1_1CLoadMeshCancel.html">00089</a> <font class="keyword">class </font>CLoadMeshCancel : <font class="keyword">public</font> NLMISC::CAsyncFileManager::ICancelCallback
00090 {
00091 <font class="keyword">public</font>:
<a name="l00092"></a><a class="code" href="classNL3D_1_1CLoadMeshCancel.html#a0">00092</a>         <a class="code" href="classNL3D_1_1CLoadMeshCancel.html#a0">CLoadMeshCancel</a> (<font class="keyword">const</font> std::string &amp;meshName)
00093                 : <a class="code" href="classNL3D_1_1CLoadMeshCancel.html#o0">_MeshName</a>(meshName)
00094         {}
00095 
00096 <font class="keyword">private</font>:        
<a name="l00097"></a><a class="code" href="classNL3D_1_1CLoadMeshCancel.html#o0">00097</a>         std::string     <a class="code" href="classNL3D_1_1CLoadMeshCancel.html#o0">_MeshName</a>;
00098 
<a name="l00099"></a><a class="code" href="classNL3D_1_1CLoadMeshCancel.html#c0">00099</a>         <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CLoadMeshCancel.html#c0">callback</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1IRunnable.html">NLMISC::IRunnable</a> *prunnable)<font class="keyword"> const</font>
00100 <font class="keyword">        </font>{
00101                 <font class="keyword">const</font> CAsyncFileManager3D::CMeshLoad *pML = dynamic_cast&lt;const CAsyncFileManager3D::CMeshLoad*&gt;(prunnable);
00102                 <font class="keywordflow">if</font> (pML != NULL)
00103                 {
00104                         <font class="keywordflow">if</font> (pML-&gt;MeshName == <a class="code" href="classNL3D_1_1CLoadMeshCancel.html#o0">_MeshName</a>)
00105                         {
00106                                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00107                         }
00108                 }
00109                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00110         }
00111 };
00112 
<a name="l00113"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a1">00113</a> <font class="keywordtype">bool</font> CAsyncFileManager3D::cancelLoadMesh(<font class="keyword">const</font> std::string&amp; sMeshName)
00114 {
00115         <font class="keywordflow">return</font> CAsyncFileManager::getInstance().cancelLoadTask(<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#l0">CLoadMeshCancel</a>(sMeshName));
00116 }
00117 
00118 <font class="comment">// ***************************************************************************</font>
00119         
<a name="l00120"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a2">00120</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadIG (<font class="keyword">const</font> std::string&amp; IGName, CInstanceGroup **ppIG)
00121 {
00122         CAsyncFileManager::getInstance().addLoadTask(<font class="keyword">new</font> CIGLoad(IGName, ppIG));
00123 }
00124 
00125 <font class="comment">// ***************************************************************************</font>
00126         
<a name="l00127"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a3">00127</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadIGUser (<font class="keyword">const</font> std::string&amp; IGName, UInstanceGroup **ppIG)
00128 {
00129         CAsyncFileManager::getInstance().addLoadTask (<font class="keyword">new</font> CIGLoadUser(IGName, ppIG));
00130 }
00131 
00132 <font class="comment">// ***************************************************************************</font>
<a name="l00133"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a4">00133</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadTexture (CTextureFile *textureFile, <font class="keywordtype">bool</font> *pSgn)
00134 {
00135         <a class="code" href="debug_8h.html#a6">nlassert</a>(textureFile &amp;&amp; pSgn);
00136         CAsyncFileManager::getInstance().addLoadTask(<font class="keyword">new</font> CTextureLoad(textureFile, pSgn));
00137 }
00138 
00139 <font class="comment">// Callback class for canceling a load texture </font>
<a name="l00140"></a><a class="code" href="classNL3D_1_1CLoadTextureCancel.html">00140</a> <font class="keyword">class </font>CLoadTextureCancel : <font class="keyword">public</font> NLMISC::CAsyncFileManager::ICancelCallback
00141 {
00142 <font class="keyword">public</font>:
<a name="l00143"></a><a class="code" href="classNL3D_1_1CLoadTextureCancel.html#a0">00143</a>         <a class="code" href="classNL3D_1_1CLoadTextureCancel.html#a0">CLoadTextureCancel</a> (CTextureFile *ptextureFile)
00144                 : <a class="code" href="classNL3D_1_1CLoadTextureCancel.html#o0">_TextureFile</a>(ptextureFile)
00145         {}
00146 
00147 <font class="keyword">private</font>:        
<a name="l00148"></a><a class="code" href="classNL3D_1_1CLoadTextureCancel.html#o0">00148</a>         CTextureFile    *<a class="code" href="classNL3D_1_1CLoadTextureCancel.html#o0">_TextureFile</a>;
00149 
<a name="l00150"></a><a class="code" href="classNL3D_1_1CLoadTextureCancel.html#c0">00150</a>         <font class="keywordtype">bool</font> <a class="code" href="classNL3D_1_1CLoadTextureCancel.html#c0">callback</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1IRunnable.html">NLMISC::IRunnable</a> *prunnable)<font class="keyword"> const</font>
00151 <font class="keyword">        </font>{
00152                 <font class="keyword">const</font> CAsyncFileManager3D::CTextureLoad *pTL = dynamic_cast&lt;const CAsyncFileManager3D::CTextureLoad*&gt;(prunnable);
00153                 <font class="keywordflow">if</font> (pTL != NULL)
00154                 {
00155                         <font class="keywordflow">if</font> (pTL-&gt;TextureFile == <a class="code" href="classNL3D_1_1CLoadTextureCancel.html#o0">_TextureFile</a>)
00156                         {
00157                                 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00158                         }
00159                 }
00160                 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00161         }
00162 };
00163 
00164 
00165 <font class="comment">// ***************************************************************************</font>
<a name="l00166"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a5">00166</a> <font class="keywordtype">bool</font> CAsyncFileManager3D::cancelLoadTexture (CTextureFile *textFile)
00167 {
00168         <font class="keywordflow">return</font> CAsyncFileManager::getInstance().cancelLoadTask(<a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#l1">CLoadTextureCancel</a>(textFile));
00169 }
00170 
00171 
00172 <font class="comment">// ***************************************************************************</font>
00173         
<a name="l00174"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a6">00174</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadFile (<font class="keyword">const</font> std::string&amp; sFileName, uint8 **ppFile)
00175 {
00176         CAsyncFileManager::getInstance().loadFile (sFileName, ppFile);
00177 }
00178 
00179 <font class="comment">// ***************************************************************************</font>
00180 
<a name="l00181"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a7">00181</a> <font class="keywordtype">void</font> CAsyncFileManager3D::loadFiles (<font class="keyword">const</font> std::vector&lt;std::string&gt; &amp;vFileNames, <font class="keyword">const</font> std::vector&lt;uint8**&gt; &amp;vPtrs)
00182 {
00183         CAsyncFileManager::getInstance().loadFiles (vFileNames, vPtrs);
00184 }
00185 
00186 <font class="comment">// ***************************************************************************</font>
00187 
<a name="l00188"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a8">00188</a> <font class="keywordtype">void</font> CAsyncFileManager3D::signal (<font class="keywordtype">bool</font> *pSgn)
00189 {
00190         CAsyncFileManager::getInstance().signal(pSgn);
00191 }
00192 
00193 <font class="comment">// ***************************************************************************</font>
00194 
<a name="l00195"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D.html#a9">00195</a> <font class="keywordtype">void</font> CAsyncFileManager3D::cancelSignal (<font class="keywordtype">bool</font> *pSgn)
00196 {
00197         CAsyncFileManager::getInstance().cancelSignal(pSgn);
00198 }
00199 
00200 <font class="comment">// ***************************************************************************</font>
00201 <font class="comment">// TASKS</font>
00202 <font class="comment">// ***************************************************************************</font>
00203 
00204 <font class="comment">// ***************************************************************************</font>
00205 <font class="comment">// MeshLoad</font>
00206 <font class="comment">// ***************************************************************************</font>
00207 
<a name="l00208"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#a0">00208</a> CAsyncFileManager3D::CMeshLoad::CMeshLoad(<font class="keyword">const</font> std::string&amp; sMeshName, IShape** ppShp, IDriver *pDriver)
00209 {
00210         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o1">_pDriver</a> = pDriver;
00211         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#m0">MeshName</a> = sMeshName;
00212         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o0">_ppShp</a> = ppShp;
00213 }
00214 
00215 <font class="comment">// ***************************************************************************</font>
00216 
<a name="l00217"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#a1">00217</a> <font class="keywordtype">void</font> CAsyncFileManager3D::CMeshLoad::run()
00218 {
00219         <a class="code" href="async__file__manager__3d_8cpp.html#a0">NL3D_MEM_INSTANCE</a>
00220         <font class="comment">// This set represent the texture already loaded in memory</font>
00221         <font class="comment">// We have to have this set because the driver load the textures only on the </font>
00222         <font class="comment">// setupTexture, done in CShapeBank::isPresent. This must be done in the main</font>
00223         <font class="comment">// thread because setupTexture upload texture to VRAM.</font>
00224         <font class="keyword">typedef</font> set&lt;string&gt; TAlreadyPresentTextureSet;
00225         TAlreadyPresentTextureSet AlreadyPresentTextureSet;
00226 
00227         <font class="keywordflow">try</font>
00228         {
00229                 <font class="comment">// Load from file the mesh</font>
00230                 CShapeStream mesh;
00231                 CIFile meshfile;
00232                 meshfile.setAsyncLoading (<font class="keyword">true</font>);
00233                 meshfile.setCacheFileOnOpen (<font class="keyword">true</font>);
00234                 meshfile.open (CPath::lookup(<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#m0">MeshName</a>));
00235                 meshfile.serial (mesh);
00236                 meshfile.close ();
00237 
00238                 <font class="comment">// Is the pointer is invalid return -1</font>
00239                 <font class="keywordflow">if</font> (mesh.getShapePointer() == NULL)
00240                 {
00241                         <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Couldn't load '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#m0">MeshName</a>.c_str());
00242                         *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o0">_ppShp</a> = (IShape*)-1;
00243                         <font class="keyword">delete</font> <font class="keyword">this</font>;
00244                         <font class="keywordflow">return</font>;
00245                 }
00246 
00247                 CMeshBase *pMesh = dynamic_cast&lt;CMeshBase *&gt;(mesh.getShapePointer());
00248 
00249                 <font class="comment">// If the shape is a mesh but the driver is not given or if the shape is not a mesh </font>
00250                 <font class="comment">// so do not try to load the textures</font>
00251 
00252                 <font class="keywordflow">if</font> ((pMesh == NULL) || ((pMesh != NULL) &amp;&amp; (<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o1">_pDriver</a> == NULL)))
00253                 {
00254                         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o1">_pDriver</a> == NULL || mesh.getShapePointer() == NULL)
00255                         {                       
00256                                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"mesh or driver is NULL for file '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#m0">MeshName</a>.c_str());
00257                         }
00258                         
00259                         *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o0">_ppShp</a> = mesh.getShapePointer();
00260                         <font class="keyword">delete</font> <font class="keyword">this</font>;
00261                         <font class="keywordflow">return</font>;
00262                 }
00263                 <font class="comment">// Here we are sure that the shape is a mesh and the driver is not null</font>
00264                 <font class="comment">// Parse all materials of the mesh</font>
00265                 uint i, j;
00266                 uint nNbMat = pMesh-&gt;getNbMaterial();
00267                 ITexture *pText;
00268 
00269                 <font class="keywordflow">for</font>(i = 0; i &lt; nNbMat; ++i)
00270                 {
00271                         <font class="keyword">const</font> CMaterial &amp;rMat = pMesh-&gt;getMaterial(i);
00272                         <font class="comment">// Parse all textures from this material and generate them</font>
00273                         <font class="keywordflow">for</font>(j = 0; j &lt; <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++j)
00274                         <font class="keywordflow">if</font> (rMat.texturePresent(j))
00275                         {
00276                                 pText = rMat.getTexture (j);
00277                                 <font class="comment">// For all texture that are texture file we have to load them</font>
00278                                 CTextureFile *pTextFile = dynamic_cast&lt;CTextureFile*&gt;(pText);
00279                                 <font class="comment">// Does this texture is a texture file ?</font>
00280                                 <font class="keywordflow">if</font>(pTextFile != NULL)
00281                                 <font class="comment">// Yes -&gt; Does the texture is already present in the driver ?</font>
00282                                 <font class="keywordflow">if</font>( ! <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o1">_pDriver</a>-&gt;isTextureExist(*pTextFile) )
00283                                 {
00284                                         <font class="comment">// No -&gt; So we have perhaps to load it</font>
00285                                         TAlreadyPresentTextureSet::iterator aptmIt = AlreadyPresentTextureSet.find (pTextFile-&gt;getFileName());
00286                                         <font class="comment">// Is the texture already loaded ?</font>
00287                                         <font class="keywordflow">if</font>(aptmIt == AlreadyPresentTextureSet.end())
00288                                         {
00289                                                 <font class="comment">// Texture not already present</font>
00290                                                 <font class="comment">// add it</font>
00291                                                 AlreadyPresentTextureSet.insert (pTextFile-&gt;getFileName());
00292                                                 <font class="comment">// And load it (to RAM only (upload in VRAM is done in the shape bank))</font>
00293                                                 pTextFile-&gt;setAsyncLoading (<font class="keyword">true</font>);
00294                                                 pTextFile-&gt;generate();
00295                                                 pTextFile-&gt;setAsyncLoading (<font class="keyword">false</font>);
00296                                         }
00297                                 }
00298                         }
00299 
00300                         <font class="comment">// Do the same with lightmaps</font>
00301                         <font class="keywordflow">if</font> (rMat.getShader() == CMaterial::LightMap)
00302                         {
00303                                 j = 0; pText = rMat.getLightMap (j);
00304                                 <font class="keywordflow">while</font> (pText != NULL)
00305                                 {
00306                                         CTextureFile *pTextFile = dynamic_cast&lt;CTextureFile*&gt;(pText);
00307                                         <font class="comment">// Does this texture is a texture file ?</font>
00308                                         <font class="keywordflow">if</font>(pTextFile != NULL)
00309                                         <font class="comment">// Yes -&gt; Does the texture is already present in the driver ?</font>
00310                                         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o1">_pDriver</a>-&gt;isTextureExist(*pTextFile))
00311                                         {
00312                                                 <font class="comment">// No -&gt; So we have perhaps to load it</font>
00313                                                 TAlreadyPresentTextureSet::iterator aptmIt = AlreadyPresentTextureSet.find (pTextFile-&gt;getFileName());
00314                                                 <font class="comment">// Is the texture already loaded ?</font>
00315                                                 <font class="keywordflow">if</font>(aptmIt == AlreadyPresentTextureSet.end())
00316                                                 {
00317                                                         <font class="comment">// Texture not already present -&gt; add it and load it to RAM</font>
00318                                                         AlreadyPresentTextureSet.insert (pTextFile-&gt;getFileName());
00319                                                         pTextFile-&gt;setAsyncLoading (<font class="keyword">true</font>);
00320                                                         pTextFile-&gt;generate();
00321                                                         pTextFile-&gt;setAsyncLoading (<font class="keyword">false</font>);
00322                                                 }
00323                                         }                               
00324                                         ++j; pText = rMat.getLightMap (j);
00325                                 }
00326                         }
00327                 }
00328                 <font class="comment">// Finally affect the pointer (Trans-Thread operation -&gt; this operation must be atomic)</font>
00329                 *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o0">_ppShp</a> = mesh.getShapePointer();
00330         }
00331         <font class="keywordflow">catch</font>(EPathNotFound &amp;)
00332         {
00333                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Couldn't load '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#m0">MeshName</a>.c_str());
00334                 *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CMeshLoad.html#o0">_ppShp</a> = (IShape*)-1;
00335                 <font class="keyword">delete</font> <font class="keyword">this</font>;
00336                 <font class="keywordflow">return</font>;
00337         }
00338         <font class="keyword">delete</font> <font class="keyword">this</font>;
00339 }
00340 
00341 <font class="comment">// ***************************************************************************</font>
00342 <font class="comment">// IGLoad</font>
00343 <font class="comment">// ***************************************************************************</font>
00344 
00345 <font class="comment">// ***************************************************************************</font>
<a name="l00346"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#a0">00346</a> CAsyncFileManager3D::CIGLoad::CIGLoad (<font class="keyword">const</font> std::string &amp;IGName, CInstanceGroup **ppIG)
00347 {
00348         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o0">_IGName</a> = IGName;
00349         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o1">_ppIG</a> = ppIG;
00350 }
00351 
00352 <font class="comment">// ***************************************************************************</font>
<a name="l00353"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#a1">00353</a> <font class="keywordtype">void</font> CAsyncFileManager3D::CIGLoad::run (<font class="keywordtype">void</font>)
00354 {
00355         <font class="keywordflow">try</font>
00356         {
00357                 CIFile igfile;
00358                 igfile.setAsyncLoading (<font class="keyword">true</font>);
00359                 igfile.setCacheFileOnOpen (<font class="keyword">true</font>);
00360                 igfile.open (CPath::lookup (<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o0">_IGName</a>));
00361                 CInstanceGroup *pIG = <font class="keyword">new</font> CInstanceGroup();
00362                 pIG-&gt;serial (igfile);
00363                 igfile.close();
00364 
00365                 *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o1">_ppIG</a> = pIG;
00366         }
00367         <font class="keywordflow">catch</font>(EPathNotFound &amp;)
00368         {
00369                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Couldn't load '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o0">_IGName</a>.c_str());
00370                 *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoad.html#o1">_ppIG</a> = (CInstanceGroup*)-1;
00371                 <font class="keyword">delete</font> <font class="keyword">this</font>;
00372                 <font class="keywordflow">return</font>;
00373         }
00374         <font class="keyword">delete</font> <font class="keyword">this</font>;
00375 }
00376 
00377 <font class="comment">// ***************************************************************************</font>
00378 <font class="comment">// IGLoadUser</font>
00379 <font class="comment">// ***************************************************************************</font>
00380 
00381 <font class="comment">// ***************************************************************************</font>
<a name="l00382"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#a0">00382</a> CAsyncFileManager3D::CIGLoadUser::CIGLoadUser (<font class="keyword">const</font> std::string &amp;IGName, UInstanceGroup **ppIG)
00383 {
00384         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o0">_IGName</a> = IGName;
00385         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o1">_ppIG</a> = ppIG;
00386 }
00387 
00388 <font class="comment">// ***************************************************************************</font>
<a name="l00389"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#a1">00389</a> <font class="keywordtype">void</font> CAsyncFileManager3D::CIGLoadUser::run (<font class="keywordtype">void</font>)
00390 {
00391         <a class="code" href="async__file__manager__3d_8cpp.html#a1">NL3D_MEM_IG</a>
00392         <font class="keywordflow">try</font>
00393         {
00394                 CInstanceGroupUser *pIG = <font class="keyword">new</font> CInstanceGroupUser();
00395                 <font class="keywordflow">if</font> (pIG-&gt;init (<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o0">_IGName</a>))
00396                 {               
00397                         *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o1">_ppIG</a> = pIG;
00398                 }
00399                 <font class="keywordflow">else</font>
00400                 {
00401                         <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Couldn't init '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o0">_IGName</a>.c_str());
00402                         *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o1">_ppIG</a> = (UInstanceGroup*)-1;
00403                         <font class="keyword">delete</font> <font class="keyword">this</font>;
00404                         <font class="keywordflow">return</font>;
00405                 }
00406         }
00407         <font class="keywordflow">catch</font>(EPathNotFound &amp;)
00408         {
00409                 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Couldn't load '%s'"</font>, <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o0">_IGName</a>.c_str());
00410                 *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CIGLoadUser.html#o1">_ppIG</a> = (UInstanceGroup*)-1;
00411                 <font class="keyword">delete</font> <font class="keyword">this</font>;
00412                 <font class="keywordflow">return</font>;
00413         }
00414         <font class="keyword">delete</font> <font class="keyword">this</font>;
00415 }
00416 
00417 <font class="comment">// ***************************************************************************</font>
00418 <font class="comment">// CTextureLoad</font>
00419 <font class="comment">// ***************************************************************************</font>
00420 
00421 <font class="comment">// ***************************************************************************</font>
<a name="l00422"></a><a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CTextureLoad.html#a1">00422</a> <font class="keywordtype">void</font>    CAsyncFileManager3D::CTextureLoad::run()
00423 {
00424         <font class="comment">// Load the texture.</font>
00425         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CTextureLoad.html#m0">TextureFile</a>-&gt;setAsyncLoading (<font class="keyword">true</font>);
00426         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CTextureLoad.html#m0">TextureFile</a>-&gt;generate();
00427         <a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CTextureLoad.html#m0">TextureFile</a>-&gt;setAsyncLoading (<font class="keyword">false</font>);
00428         <font class="comment">// Ok</font>
00429         *<a class="code" href="classNL3D_1_1CAsyncFileManager3D_1_1CTextureLoad.html#m1">Signal</a>= <font class="keyword">true</font>;
00430 
00431         <font class="keyword">delete</font> <font class="keyword">this</font>;
00432 }
00433 
00434 } <font class="comment">// NL3D</font>
00435 
00436 
</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>