aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a02367.html
blob: d08e6fa51a4ef7f638f43f840334418e72723257 (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NL3D::CCoarseMeshBuild class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NL3D::CCoarseMeshBuild Class Reference</h1><code>#include &lt;<a class="el" href="a05568.html">coarse_mesh_build.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Class used to build the coarse meshes<p>
The build method take an array of <a class="el" href="a02878.html">CMeshGeom</a> an a bitmap. This class will compute a single texture used to map every coarse mesh passed in the array.<p>
Each mesh geom should be a coarse mesh.<p>
The uv texture coodinates of those coarse meshes will be adjusted to fit in a single texture.<p>
<dl compact><dt><b>Author:</b></dt><dd>Cyril 'Hulud' Corvazier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a05568.html#l00062">62</a> of file <a class="el" href="a05568.html">coarse_mesh_build.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuilda0">build</a> (const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;coarseMeshes, std::vector&lt; <a class="el" href="a02268.html">NLMISC::CBitmap</a> &gt; &amp;bitmaps, <a class="el" href="a02370.html">CStats</a> &amp;stats, float mulArea)</td></tr>

<tr><td colspan=2><br><h2>Private Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map&lt; std::string,<br>
 <a class="el" href="a02368.html">CBitmapDesc</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a></td></tr>

<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildd0">buildBitmap</a> (const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;coarseMeshes, std::vector&lt; <a class="el" href="a02268.html">NLMISC::CBitmap</a> &gt; &amp;bitmaps, <a class="el" href="a02370.html">CStats</a> &amp;stats, <a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a> &amp;desc, float mulArea)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildd1">expand</a> (<a class="el" href="a02268.html">NLMISC::CBitmap</a> &amp;bitmap)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildd2">remapCoordinates</a> (const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;coarseMeshes, const <a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a> &amp;desc, <a class="el" href="a04558.html#a15">uint</a> outputBitmapCount)</td></tr>

</table>
<hr><h2>Member Typedef Documentation</h2>
<a class="anchor" name="NL3D_1_1CCoarseMeshBuildy0" doxytag="NL3D::CCoarseMeshBuild::MapBitmapDesc" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::map&lt;std::string, <a class="el" href="a02368.html">CBitmapDesc</a>&gt; <a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">NL3D::CCoarseMeshBuild::MapBitmapDesc</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05568.html#l00132">132</a> of file <a class="el" href="a05568.html">coarse_mesh_build.h</a>.
<p>
Referenced by <a class="el" href="a05567.html#l00039">build()</a>, <a class="el" href="a05567.html#l00070">buildBitmap()</a>, and <a class="el" href="a05567.html#l00430">remapCoordinates()</a>.    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CCoarseMeshBuilda0" doxytag="NL3D::CCoarseMeshBuild::build" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NL3D::CCoarseMeshBuild::build </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>coarseMeshes</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>std::vector&lt; <a class="el" href="a02268.html">NLMISC::CBitmap</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>bitmaps</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02370.html">CStats</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>stats</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>mulArea</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The build method. This method will build a single texture and adjuste the UV texture coordinates of each mesh geom.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>coarseMeshes</em>&nbsp;</td><td>is a vector of coarse mesh to compute. </td></tr>
    <tr><td valign=top><em>bitmap</em>&nbsp;</td><td>will receive the final bitmap. </td></tr>
    <tr><td valign=top><em>start</em>&nbsp;</td><td>will receive various statistics about the build process. </td></tr>
    <tr><td valign=top><em>mulArea</em>&nbsp;</td><td>is the mul factor used to increase to theorical global texture size.</td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="a05567.html#l00039">39</a> of file <a class="el" href="a05567.html">coarse_mesh_build.cpp</a>.
<p>
References <a class="el" href="a05567.html#l00070">buildBitmap()</a>, <a class="el" href="a05568.html#l00132">MapBitmapDesc</a>, and <a class="el" href="a05567.html#l00430">remapCoordinates()</a>.
<p>
<div class="fragment"><pre>00040 {
00041         <span class="comment">// 1. build the bitmap</span>
00042         <a class="code" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a> desc;
00043         <span class="keywordflow">if</span> (<a class="code" href="a02367.html#NL3D_1_1CCoarseMeshBuildd0">buildBitmap</a> (coarseMeshes, bitmaps, stats, desc, mulArea)==<span class="keyword">false</span>)
00044                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00045 
00046         <span class="comment">// 2. remap coordinates</span>
00047         <a class="code" href="a02367.html#NL3D_1_1CCoarseMeshBuildd2">remapCoordinates</a> (coarseMeshes, desc, bitmaps.size ());
00048 
00049         <span class="comment">// 3. ok</span>
00050         <span class="keywordflow">return</span> <span class="keyword">true</span>;
00051 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CCoarseMeshBuildd0" doxytag="NL3D::CCoarseMeshBuild::buildBitmap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> bool NL3D::CCoarseMeshBuild::buildBitmap </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>coarseMeshes</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>std::vector&lt; <a class="el" href="a02268.html">NLMISC::CBitmap</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>bitmaps</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02370.html">CStats</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>stats</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>desc</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>mulArea</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05567.html#l00070">70</a> of file <a class="el" href="a05567.html">coarse_mesh_build.cpp</a>.
<p>
References <a class="el" href="a05568.html#l00126">NL3D::CCoarseMeshBuild::CBitmapDesc::Bitmaps</a>, <a class="el" href="a05486.html#l00926">NLMISC::CBitmap::convertToType()</a>, <a class="el" href="a05567.html#l00367">expand()</a>, <a class="el" href="a05568.html#l00122">NL3D::CCoarseMeshBuild::CBitmapDesc::FactorU</a>, <a class="el" href="a05568.html#l00123">NL3D::CCoarseMeshBuild::CBitmapDesc::FactorV</a>, <a class="el" href="a06506.html#l00309">NL3D::ITexture::generate()</a>, <a class="el" href="a05486.html#l01388">NLMISC::CBitmap::getHeight()</a>, <a class="el" href="a05992.html#l00179">NL3D::CMeshBase::getMaterial()</a>, <a class="el" href="a05990.html#l00393">NL3D::CMeshGeom::getNbMatrixBlock()</a>, <a class="el" href="a05990.html#l00398">NL3D::CMeshGeom::getNbRdrPass()</a>, <a class="el" href="a05586.html#l00358">NLMISC::getPowerOf2()</a>, <a class="el" href="a05990.html#l00413">NL3D::CMeshGeom::getRdrPassMaterial()</a>, <a class="el" href="a06506.html#l00338">NL3D::ITexture::getShareName()</a>, <a class="el" href="a05641.html#l00046">NL3D::CMaterial::getTexture()</a>, <a class="el" href="a05486.html#l01363">NLMISC::CBitmap::getWidth()</a>, <a class="el" href="a05567.html#l00061">NL3D::CInsertedBitmap::Height</a>, <a class="el" href="a05646.html#l01013">height</a>, <a class="el" href="a05568.html#l00132">MapBitmapDesc</a>, <a class="el" href="a05568.html#l00129">NL3D::CCoarseMeshBuild::CBitmapDesc::Name</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05586.html#l00349">NLMISC::raiseToNextPowerOf2()</a>, <a class="el" href="a05486.html#l01508">NLMISC::CBitmap::resample()</a>, <a class="el" href="a06506.html#l00360">NL3D::ITexture::selectTexture()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, <a class="el" href="a06506.html#l00332">NL3D::ITexture::supportSharing()</a>, <a class="el" href="a05568.html#l00098">NL3D::CCoarseMeshBuild::CStats::TextureUsed</a>, <a class="el" href="a06229.html#l02652">NLMISC::toString()</a>, <a class="el" href="a05567.html#l00064">NL3D::CInsertedBitmap::U</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, <a class="el" href="a05567.html#l00065">NL3D::CInsertedBitmap::V</a>, <a class="el" href="a05646.html#l00237">v</a>, <a class="el" href="a05567.html#l00060">NL3D::CInsertedBitmap::Width</a>, and <a class="el" href="a05646.html#l01013">width</a>.
<p>
Referenced by <a class="el" href="a05567.html#l00039">build()</a>.
<p>
<div class="fragment"><pre>00071 {
00072         <span class="comment">// Total area used by texture</span>
00073         <a class="code" href="a04558.html#a15">uint</a> totalArea=0;
00074 
00075         <span class="comment">// ***************************************************************************</span>
00076 
00077         <span class="comment">// 1. scan each bitmap: calc the area of the bitmap and it its name in the maps sorted by area</span>
00078         <span class="keyword">typedef</span> std::multimap&lt;uint, CBitmapDesc*&gt; MapAreaBitmap;
00079         MapAreaBitmap mapArea;
00080         <a class="code" href="a04558.html#a15">uint</a> mesh;
00081         <span class="keywordflow">for</span> (mesh=0; mesh&lt;coarseMeshes.size(); mesh++)
00082         {
00083                 <span class="comment">// Geom mesh pointer</span>
00084                 CMeshGeom *meshGeom=coarseMeshes[mesh].MeshGeom;
00085 
00086                 <span class="comment">// Base mesh pointer</span>
00087                 <span class="keyword">const</span> CMeshBase *meshBase=coarseMeshes[mesh].MeshBase;
00088 
00089                 <span class="comment">// For each matrix block</span>
00090                 <a class="code" href="a04558.html#a15">uint</a> matrixBlock;
00091                 <a class="code" href="a04558.html#a15">uint</a> nbMatrixBlock=meshGeom-&gt;getNbMatrixBlock();
00092                 <span class="keywordflow">for</span> (matrixBlock=0; matrixBlock&lt;nbMatrixBlock; matrixBlock++)
00093                 {
00094                         <span class="comment">// For each render pass</span>
00095                         <a class="code" href="a04558.html#a15">uint</a> renderPass;
00096                         <a class="code" href="a04558.html#a15">uint</a> numRenderPass=meshGeom-&gt;getNbRdrPass(matrixBlock);
00097                         <span class="keywordflow">for</span> (renderPass=0; renderPass&lt;numRenderPass; renderPass++)
00098                         {
00099                                 <span class="comment">// Render pass material</span>
00100                                 <a class="code" href="a04558.html#a11">uint32</a> matId=meshGeom-&gt;getRdrPassMaterial(matrixBlock, renderPass);
00101 
00102                                 <span class="comment">// Checks</span>
00103                                 <a class="code" href="a04199.html#a6">nlassert</a> (matId&lt;meshBase-&gt;getNbMaterial());
00104 
00105                                 <span class="comment">// Get the material</span>
00106                                 <span class="keyword">const</span> CMaterial &amp;material=meshBase-&gt;getMaterial(matId);
00107 
00108                                 <span class="comment">// Get the texture</span>
00109                                 ITexture *texture=material.getTexture(0);
00110                                 <span class="keywordflow">if</span> (texture)
00111                                 {
00112                                         <span class="comment">// For each bitmaps</span>
00113                                         <a class="code" href="a04558.html#a15">uint</a> i;
00114                                         std::string name;
00115                                         <span class="keywordflow">for</span> (i=0; i&lt;bitmaps.size (); i++)
00116                                         {
00117                                                 <span class="comment">// Select the good slot</span>
00118                                                 texture-&gt;selectTexture (i);
00119 
00120                                                 <span class="comment">// Get its name</span>
00121                                                 <span class="keywordflow">if</span> (texture-&gt;supportSharing())
00122                                                 {
00123                                                         <span class="comment">// Get sharing name</span>
00124                                                         name+=<a class="code" href="a05378.html#a273">strlwr</a>(texture-&gt;getShareName());
00125                                                 }
00126                                                 <span class="keywordflow">else</span>
00127                                                 {
00128                                                         <span class="comment">// Build a name</span>
00129                                                         name+=<a class="code" href="a05378.html#a244">toString</a> ((<a class="code" href="a04558.html#a15">uint</a>)texture);
00130                                                 }
00131                                         }
00132 
00133                                         <span class="comment">// Already added ?</span>
00134                                         <span class="keywordflow">if</span> (desc.find (name)==desc.end())
00135                                         {
00136                                                 <span class="comment">// Add it..</span>
00137 
00138                                                 <span class="comment">// Insert it in the maps</span>
00139                                                 MapBitmapDesc::iterator ite = desc.insert (MapBitmapDesc::value_type (name, CBitmapDesc ())).first;
00140 
00141                                                 <span class="comment">// Descriptor for this texture</span>
00142                                                 CBitmapDesc &amp;descBitmap = ite-&gt;second;
00143 
00144                                                 <span class="comment">// Backup original size</span>
00145                                                 <a class="code" href="a04558.html#a15">uint</a> originalWidth;
00146                                                 <a class="code" href="a04558.html#a15">uint</a> originalHeight;
00147 
00148                                                 <span class="comment">// For each bitmaps</span>
00149                                                 <a class="code" href="a04558.html#a15">uint</a> i;
00150                                                 descBitmap.Bitmaps.resize (bitmaps.size ());
00151                                                 <span class="keywordflow">for</span> (i=0; i&lt;bitmaps.size (); i++)
00152                                                 {
00153                                                         <span class="comment">// Select the good slot</span>
00154                                                         texture-&gt;selectTexture (i);
00155 
00156                                                         <span class="comment">// Generate the texture</span>
00157                                                         texture-&gt;generate();
00158 
00159                                                         <span class="comment">// Convert to RGBA</span>
00160                                                         texture-&gt;convertToType (CBitmap::RGBA);
00161 
00162                                                         <span class="comment">// First texture ?</span>
00163                                                         <span class="keywordflow">if</span> (i == 0)
00164                                                         {
00165                                                                 <span class="comment">// Backup original size</span>
00166                                                                 originalWidth = texture-&gt;getWidth();
00167                                                                 originalHeight = texture-&gt;getHeight();
00168                                                         }
00169 
00170                                                         <span class="comment">// Resample, if needed</span>
00171                                                         <span class="keywordflow">if</span> (i != 0)
00172                                                         {
00173                                                                 <span class="comment">// New size</span>
00174                                                                 <span class="keywordflow">if</span> ( ( originalWidth != texture-&gt;getWidth () ) || originalHeight != texture-&gt;getHeight  () )
00175                                                                 {
00176                                                                         texture-&gt;resample (originalWidth, originalHeight);
00177                                                                 }
00178                                                         }
00179 
00180                                                         <span class="comment">// Copy the texture</span>
00181                                                         descBitmap.Bitmaps[i] = *texture;
00182 
00183                                                         <span class="comment">// Expand the texture</span>
00184                                                         <a class="code" href="a02367.html#NL3D_1_1CCoarseMeshBuildd1">expand</a> (descBitmap.Bitmaps[i]);
00185                                                 }
00186 
00187                                                 <span class="comment">// Texture area</span>
00188                                                 <a class="code" href="a04558.html#a15">uint</a> area = descBitmap.Bitmaps[0].getWidth() * descBitmap.Bitmaps[0].getHeight();
00189                                                 descBitmap.Name = name;
00190                                                 descBitmap.FactorU = (<span class="keywordtype">float</span>)originalWidth;
00191                                                 descBitmap.FactorV = (<span class="keywordtype">float</span>)originalHeight;
00192 
00193                                                 <span class="comment">// Insert in the map area</span>
00194                                                 mapArea.insert (MapAreaBitmap::value_type(area, &amp;(ite-&gt;second)));
00195 
00196                                                 <span class="comment">// Sum area if added</span>
00197                                                 totalArea+=area;
00198                                         }
00199                                 }
00200                         }
00201                 }
00202         }
00203 
00204         <span class="comment">// ***************************************************************************</span>
00205 
00206         <span class="comment">// 2. Calc the best area for the dest texture and resize the bitmap</span>
00207         
00208         <span class="comment">// Total area used by the textures + a little more</span>
00209         <a class="code" href="a04558.html#a15">uint</a> newArea=<a class="code" href="a05378.html#a263">getPowerOf2</a> (raiseToNextPowerOf2 (totalArea));
00210         <span class="keywordflow">while</span> ((1&lt;&lt;newArea)&lt;(<a class="code" href="a04558.html#a14">sint</a>)(mulArea*(<span class="keywordtype">float</span>)totalArea))
00211         {
00212                 newArea++;
00213         }
00214 
00215         <span class="comment">// Calc width and height with HEIGHT==WIDTH or HEIGHT=2*WIDTH</span>
00216         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a632">width</a>=1&lt;&lt;(newArea/2);
00217         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a633">height</a>=1&lt;&lt;(newArea/2 + (newArea&amp;1));
00218 
00219         <span class="comment">// Resize the bitmap and set the pixel format</span>
00220         <a class="code" href="a04558.html#a15">uint</a> i;
00221         <span class="keywordflow">for</span> (i=0; i&lt;bitmaps.size (); i++)
00222                 bitmaps[i].resize (width, height, CBitmap::RGBA);
00223 
00224         <span class="comment">// Checks</span>
00225         <span class="keywordflow">if</span> (totalArea==0)
00226         {
00227                 <span class="comment">// No texture, ok computed.</span>
00228                 stats.TextureUsed=1;
00229 
00230                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00231         }
00232 
00233         <span class="comment">// ***************************************************************************</span>
00234 
00235         <span class="comment">// 3. Place each texture in the bitmap in uncreasing order</span>
00236         <span class="keyword">typedef</span> std::multimap&lt;sint, CInsertedBitmap&gt; mapInsertedBitmap;
00237         
00238         <span class="comment">// For each texture</span>
00239         MapAreaBitmap::iterator ite=mapArea.end();
00240 
00241         <span class="comment">// Inserted bitmap desc</span>
00242         mapInsertedBitmap inserted;
00243 
00244         <span class="comment">// Max texture height</span>
00245         <a class="code" href="a04558.html#a15">uint</a> maxTexHeight=0;
00246 
00247         <span class="keywordflow">do</span> 
00248         {
00249                 ite--;
00250                 <a class="code" href="a04199.html#a6">nlassert</a> (ite!=mapArea.end());
00251 
00252                 <span class="comment">// Size of the texture</span>
00253                 <a class="code" href="a04558.html#a15">uint</a> widthTex=ite-&gt;second-&gt;Bitmaps[0].getWidth();
00254                 <a class="code" href="a04558.html#a15">uint</a> heightTex=ite-&gt;second-&gt;Bitmaps[0].getHeight();
00255 
00256                 <span class="comment">// Some checks</span>
00257                 <a class="code" href="a04199.html#a6">nlassert</a> (bitmaps.size () == ite-&gt;second-&gt;Bitmaps.size ());
00258 
00259                 <span class="comment">// Width and height max</span>
00260                 <a class="code" href="a04558.html#a15">uint</a> widthMax=<a class="code" href="a04223.html#a632">width</a>-widthTex;
00261                 <a class="code" href="a04558.html#a15">uint</a> heightMax=<a class="code" href="a04223.html#a633">height</a>-heightTex;
00262 
00263                 <span class="comment">// Test against others..</span>
00264                 <span class="keywordtype">bool</span> enter=<span class="keyword">false</span>;
00265 
00266                 <span class="comment">// For each row and each column</span>
00267                 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a576">v</a>=0; <a class="code" href="a04223.html#a576">v</a>&lt;heightMax; <a class="code" href="a04223.html#a576">v</a>++)
00268                 {
00269                         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> u=0; u&lt;widthMax; u++)
00270                         {
00271                                 <span class="comment">// Test against others..</span>
00272                                 enter=<span class="keyword">true</span>;
00273 
00274                                 <span class="comment">// Get the first to test</span>
00275                                 mapInsertedBitmap::iterator toTest=inserted.lower_bound ((<a class="code" href="a04558.html#a14">sint</a>)v-(<a class="code" href="a04558.html#a14">sint</a>)maxTexHeight);
00276                                 <span class="keywordflow">while</span> (toTest!=inserted.end())
00277                                 {
00278                                         <span class="comment">// Make a test ?</span>
00279                                         <span class="keywordflow">if</span> ((<a class="code" href="a04558.html#a14">sint</a>)(<a class="code" href="a04223.html#a576">v</a>+heightTex)&lt;=(toTest-&gt;first))
00280                                         {
00281                                                 <span class="comment">// Ok, end test</span>
00282                                                 <span class="keywordflow">break</span>;
00283                                         }
00284 
00285                                         <span class="comment">// Test it</span>
00286                                         <a class="code" href="a04558.html#a15">uint</a> otherU=toTest-&gt;second.U;
00287                                         <a class="code" href="a04558.html#a15">uint</a> otherV=toTest-&gt;second.V;
00288                                         <a class="code" href="a04558.html#a15">uint</a> otherWidth=toTest-&gt;second.Width;
00289                                         <a class="code" href="a04558.html#a15">uint</a> otherHeight=toTest-&gt;second.Height;
00290                                         <span class="keywordflow">if</span> ((<a class="code" href="a04223.html#a576">v&lt;otherV+otherHeight) &amp;&amp; (v+heightTex&gt;</a>otherV) &amp;&amp;
00291                                                 (u&lt;otherU+otherWidth) &amp;&amp; (u+widthTex&gt;otherU))
00292                                         {
00293                                                 <span class="comment">// Collision</span>
00294                                                 enter=<span class="keyword">false</span>;
00295                                                 u=toTest-&gt;second.U+otherWidth-1;
00296                                                 <span class="keywordflow">break</span>;
00297                                         }
00298 
00299                                         <span class="comment">// Next to test</span>
00300                                         toTest++;
00301                                 }
00302 
00303                                 <span class="comment">// Enter ?</span>
00304                                 <span class="keywordflow">if</span> (enter)
00305                                 {
00306                                         <span class="comment">// Ok, enter</span>
00307 
00308                                         <span class="comment">// Insert an inserted descriptor</span>
00309                                         CInsertedBitmap descInserted;
00310                                         descInserted.Width=widthTex;
00311                                         descInserted.Height=heightTex;
00312                                         descInserted.U=u;
00313                                         descInserted.V=<a class="code" href="a04223.html#a576">v</a>;
00314                                         inserted.insert (mapInsertedBitmap::value_type (v, descInserted));
00315         
00316                                         <span class="comment">// Max height</span>
00317                                         <span class="keywordflow">if</span> (heightTex&gt;maxTexHeight)
00318                                                 maxTexHeight=heightTex;
00319 
00320                                         <span class="comment">// Blit in the texture</span>
00321                                         <a class="code" href="a04558.html#a15">uint</a> i;
00322                                         <span class="keywordflow">for</span> (i=0; i&lt;bitmaps.size (); i++)
00323                                         {
00324                                                 <span class="comment">// Check..</span>
00325                                                 <a class="code" href="a04199.html#a6">nlassert</a> (      (ite-&gt;second-&gt;Bitmaps[0].getWidth () == ite-&gt;second-&gt;Bitmaps[i].getWidth ()) &amp;&amp; 
00326                                                                         (ite-&gt;second-&gt;Bitmaps[0].getHeight () == ite-&gt;second-&gt;Bitmaps[i].getHeight ())  );
00327 
00328                                                 <span class="comment">// Blit it</span>
00329                                                 bitmaps[i].blit (&amp;(ite-&gt;second-&gt;Bitmaps[i]), u, v);
00330                                         }                                       
00331 
00332                                         <span class="comment">// Set the U and V texture coordinates</span>
00333                                         ite-&gt;second-&gt;U=(<span class="keywordtype">float</span>)(u+1)/(<span class="keywordtype">float</span>)<a class="code" href="a04223.html#a632">width</a>;
00334                                         ite-&gt;second-&gt;V=(<span class="keywordtype">float</span>)(<a class="code" href="a04223.html#a576">v</a>+1)/(<span class="keywordtype">float</span>)<a class="code" href="a04223.html#a633">height</a>;
00335 
00336                                         <span class="comment">// Set ratio</span>
00337                                         ite-&gt;second-&gt;FactorU /= (<span class="keywordtype">float</span>)<a class="code" href="a04223.html#a632">width</a>;
00338                                         ite-&gt;second-&gt;FactorV /= (<span class="keywordtype">float</span>)<a class="code" href="a04223.html#a633">height</a>;
00339 
00340                                         <span class="comment">// End</span>
00341                                         <span class="keywordflow">break</span>;
00342                                 }
00343 
00344                                 <span class="comment">// next..</span>
00345                         }
00346 
00347                         <span class="comment">// Enter ?</span>
00348                         <span class="keywordflow">if</span> (enter)
00349                                 <span class="keywordflow">break</span>;
00350                 }
00351 
00352                 <span class="comment">// Not enter ?</span>
00353                 <span class="keywordflow">if</span> (!enter)
00354                         <span class="comment">// Texture too small..</span>
00355                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
00356         }
00357         <span class="keywordflow">while</span> (ite!=mapArea.begin());
00358 
00359         <span class="comment">// Some stats</span>
00360         stats.TextureUsed=(<span class="keywordtype">float</span>)totalArea/(<span class="keywordtype">float</span>)(<a class="code" href="a04223.html#a632">width</a>*<a class="code" href="a04223.html#a633">height</a>);
00361 
00362         <span class="keywordflow">return</span> <span class="keyword">true</span>;
00363 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CCoarseMeshBuildd1" doxytag="NL3D::CCoarseMeshBuild::expand" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CCoarseMeshBuild::expand </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a02268.html">NLMISC::CBitmap</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>bitmap</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05567.html#l00367">367</a> of file <a class="el" href="a05567.html">coarse_mesh_build.cpp</a>.
<p>
References <a class="el" href="a05486.html#l02332">NLMISC::CBitmap::blit()</a>, <a class="el" href="a05486.html#l01388">NLMISC::CBitmap::getHeight()</a>, <a class="el" href="a05487.html#l00308">NLMISC::CBitmap::getPixels()</a>, <a class="el" href="a05486.html#l01363">NLMISC::CBitmap::getWidth()</a>, <a class="el" href="a05646.html#l01013">height</a>, <a class="el" href="a05486.html#l01545">NLMISC::CBitmap::resize()</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05646.html#l01013">width</a>.
<p>
Referenced by <a class="el" href="a05567.html#l00070">buildBitmap()</a>.
<p>
<div class="fragment"><pre>00368 {
00369         <span class="comment">// Get size</span>
00370         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a632">width</a>=bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturea20">getWidth</a>();
00371         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a633">height</a>=bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturea12">getHeight</a>();
00372 
00373         <span class="comment">// Valid size ?</span>
00374         <span class="keywordflow">if</span> ((<a class="code" href="a04223.html#a632">width</a>!=0) &amp;&amp; (<a class="code" href="a04223.html#a633">height</a>!=0))
00375         {
00376                 <span class="comment">// Copy the bitmap</span>
00377                 <a class="code" href="a02268.html">CBitmap</a> copy=bitmap;
00378 
00379                 <span class="comment">// Resize the bitmap</span>
00380                 bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturea33">resize</a> (width+2, height+2);
00381 
00382                 <span class="comment">// Copy old bitmap</span>
00383                 bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturea2">blit</a> (&amp;copy, 1, 1);
00384 
00385                 <span class="comment">// Make a top and bottom border</span>
00386                 <a class="code" href="a04558.html#a11">uint32</a> *topSrc=(<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
00387                 <a class="code" href="a04558.html#a11">uint32</a> *topDest=((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+1;
00388                 memcpy (topDest, topSrc, 4*width);
00389                 <a class="code" href="a04558.html#a11">uint32</a> *bottomSrc=topSrc+<a class="code" href="a04223.html#a632">width</a>*(<a class="code" href="a04223.html#a633">height</a>-1);
00390                 <a class="code" href="a04558.html#a11">uint32</a> *bottomDest=((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+(<a class="code" href="a04223.html#a632">width</a>+2)*(<a class="code" href="a04223.html#a633">height</a>+1)+1;
00391                 memcpy (bottomDest, bottomSrc, 4*width);
00392 
00393                 <span class="comment">// Make a left and right border</span>
00394                 <a class="code" href="a04558.html#a11">uint32</a> *leftSrc=(<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
00395                 <a class="code" href="a04558.html#a11">uint32</a> *leftDest=((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+<a class="code" href="a04223.html#a632">width</a>+2;
00396                 <a class="code" href="a04558.html#a11">uint32</a> *rightSrc=leftSrc+<a class="code" href="a04223.html#a632">width</a>-1;
00397                 <a class="code" href="a04558.html#a11">uint32</a> *rightDest=leftDest+<a class="code" href="a04223.html#a632">width</a>+1;
00398                 <a class="code" href="a04558.html#a15">uint</a> i;
00399                 <span class="keywordflow">for</span> (i=0; i&lt;<a class="code" href="a04223.html#a633">height</a>; i++)
00400                 {
00401                         <span class="comment">// Copy the borders</span>
00402                         *leftDest=*leftSrc;
00403                         *rightDest=*rightSrc;
00404 
00405                         <span class="comment">// Move pointers</span>
00406                         leftDest+=<a class="code" href="a04223.html#a632">width</a>+2;
00407                         rightDest+=<a class="code" href="a04223.html#a632">width</a>+2;
00408                         leftSrc+=<a class="code" href="a04223.html#a632">width</a>;
00409                         rightSrc+=<a class="code" href="a04223.html#a632">width</a>;
00410                 }
00411 
00412                 <span class="comment">// Make corners</span>
00413 
00414                 <span class="comment">// Left top</span>
00415                 *(<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0])=*(<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
00416 
00417                 <span class="comment">// Rigth top</span>
00418                 *(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+<a class="code" href="a04223.html#a632">width</a>+1)=*(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+<a class="code" href="a04223.html#a632">width</a>-1);
00419 
00420                 <span class="comment">// Rigth bottom</span>
00421                 *(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+(<a class="code" href="a04223.html#a632">width</a>+2)*(<a class="code" href="a04223.html#a633">height</a>+2)-1)=*(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+<a class="code" href="a04223.html#a632">width</a>*<a class="code" href="a04223.html#a633">height</a>-1);
00422 
00423                 <span class="comment">// Left bottom</span>
00424                 *(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(bitmap.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+(<a class="code" href="a04223.html#a632">width</a>+2)*(<a class="code" href="a04223.html#a633">height</a>+1))=*(((<a class="code" href="a04558.html#a11">uint32</a>*)&amp;(copy.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]))+<a class="code" href="a04223.html#a632">width</a>*(<a class="code" href="a04223.html#a633">height</a>-1));
00425         }
00426 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CCoarseMeshBuildd2" doxytag="NL3D::CCoarseMeshBuild::remapCoordinates" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CCoarseMeshBuild::remapCoordinates </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a02369.html">CCoarseMeshDesc</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>coarseMeshes</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a02367.html#NL3D_1_1CCoarseMeshBuildy0">MapBitmapDesc</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>desc</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>outputBitmapCount</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [private]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a05567.html#l00430">430</a> of file <a class="el" href="a05567.html">coarse_mesh_build.cpp</a>.
<p>
References <a class="el" href="a05568.html#l00122">NL3D::CCoarseMeshBuild::CBitmapDesc::FactorU</a>, <a class="el" href="a05568.html#l00123">NL3D::CCoarseMeshBuild::CBitmapDesc::FactorV</a>, <a class="el" href="a05992.html#l00179">NL3D::CMeshBase::getMaterial()</a>, <a class="el" href="a05990.html#l00393">NL3D::CMeshGeom::getNbMatrixBlock()</a>, <a class="el" href="a05990.html#l00398">NL3D::CMeshGeom::getNbRdrPass()</a>, <a class="el" href="a06198.html#l00141">NL3D::CPrimitiveBlock::getNumQuad()</a>, <a class="el" href="a06198.html#l00108">NL3D::CPrimitiveBlock::getNumTri()</a>, <a class="el" href="a06197.html#l00149">NL3D::CPrimitiveBlock::getQuadPointer()</a>, <a class="el" href="a05990.html#l00413">NL3D::CMeshGeom::getRdrPassMaterial()</a>, <a class="el" href="a05990.html#l00404">NL3D::CMeshGeom::getRdrPassPrimitiveBlock()</a>, <a class="el" href="a06506.html#l00338">NL3D::ITexture::getShareName()</a>, <a class="el" href="a06710.html#l00497">NL3D::CVertexBuffer::getTexCoordPointer()</a>, <a class="el" href="a05641.html#l00046">NL3D::CMaterial::getTexture()</a>, <a class="el" href="a06197.html#l00091">NL3D::CPrimitiveBlock::getTriPointer()</a>, <a class="el" href="a05990.html#l00390">NL3D::CMeshGeom::getVertexBuffer()</a>, <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05568.html#l00132">MapBitmapDesc</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06506.html#l00360">NL3D::ITexture::selectTexture()</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, <a class="el" href="a06506.html#l00332">NL3D::ITexture::supportSharing()</a>, <a class="el" href="a06229.html#l02652">NLMISC::toString()</a>, <a class="el" href="a05568.html#l00118">NL3D::CCoarseMeshBuild::CBitmapDesc::U</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05568.html#l00119">NL3D::CCoarseMeshBuild::CBitmapDesc::V</a>.
<p>
Referenced by <a class="el" href="a05567.html#l00039">build()</a>.
<p>
<div class="fragment"><pre>00431 {
00432         <span class="comment">// 1. scan each bitmap: calc the area of the bitmap and it its name in the maps sorted by area</span>
00433         <span class="keyword">typedef</span> std::multimap&lt;float, CBitmapDesc&gt; MapAreaBitmap;
00434         MapAreaBitmap mapArea;
00435         <a class="code" href="a04558.html#a15">uint</a> mesh;
00436         <span class="keywordflow">for</span> (mesh=0; mesh&lt;coarseMeshes.size(); mesh++)
00437         {
00438                 <span class="comment">// Geom mesh pointer</span>
00439                 CMeshGeom *meshGeom=coarseMeshes[mesh].MeshGeom;
00440 
00441                 <span class="comment">// Base mesh pointer</span>
00442                 <span class="keyword">const</span> CMeshBase *meshBase=coarseMeshes[mesh].MeshBase;
00443 
00444                 <span class="comment">// The vertex buffer</span>
00445                 CVertexBuffer &amp;vertexBuffer=const_cast&lt;CVertexBuffer&amp;&gt; (meshGeom-&gt;getVertexBuffer());
00446 
00447                 <span class="comment">// For each matrix block</span>
00448                 <a class="code" href="a04558.html#a15">uint</a> matrixBlock;
00449                 <a class="code" href="a04558.html#a15">uint</a> nbMatrixBlock=meshGeom-&gt;getNbMatrixBlock();
00450                 <span class="keywordflow">for</span> (matrixBlock=0; matrixBlock&lt;nbMatrixBlock; matrixBlock++)
00451                 {
00452                         <span class="comment">// For each render pass</span>
00453                         <a class="code" href="a04558.html#a15">uint</a> renderPass;
00454                         <a class="code" href="a04558.html#a15">uint</a> numRenderPass=meshGeom-&gt;getNbRdrPass(matrixBlock);
00455                         <span class="keywordflow">for</span> (renderPass=0; renderPass&lt;numRenderPass; renderPass++)
00456                         {
00457                                 <span class="comment">// Render pass material</span>
00458                                 <a class="code" href="a04558.html#a11">uint32</a> matId=meshGeom-&gt;getRdrPassMaterial(matrixBlock, renderPass);
00459 
00460                                 <span class="comment">// Checks</span>
00461                                 <a class="code" href="a04199.html#a6">nlassert</a> (matId&lt;meshBase-&gt;getNbMaterial());
00462 
00463                                 <span class="comment">// Get the material</span>
00464                                 <span class="keyword">const</span> CMaterial &amp;material=meshBase-&gt;getMaterial(matId);
00465 
00466                                 <span class="comment">// Get the texture</span>
00467                                 ITexture *texture=material.getTexture(0);
00468                                 <span class="keywordflow">if</span> (texture)
00469                                 {
00470                                         <span class="comment">// Get its name</span>
00471                                         std::string name;
00472                                         <a class="code" href="a04558.html#a15">uint</a> i;
00473                                         <span class="keywordflow">for</span> (i=0; i&lt;outputBitmapCount; i++)
00474                                         {
00475                                                 <span class="comment">// Select the good slot</span>
00476                                                 texture-&gt;selectTexture (i);
00477 
00478                                                 <span class="comment">// Get its name</span>
00479                                                 <span class="keywordflow">if</span> (texture-&gt;supportSharing())
00480                                                 {
00481                                                         <span class="comment">// Get sharing name</span>
00482                                                         name+=<a class="code" href="a05378.html#a273">strlwr</a>(texture-&gt;getShareName());
00483                                                 }
00484                                                 <span class="keywordflow">else</span>
00485                                                 {
00486                                                         <span class="comment">// Build a name</span>
00487                                                         name+=<a class="code" href="a05378.html#a244">toString</a> ((<a class="code" href="a04558.html#a15">uint</a>)texture);
00488                                                 }
00489                                         }
00490 
00491                                         <span class="comment">// Find the texture</span>
00492                                         MapBitmapDesc::const_iterator ite=desc.find (name);
00493                                         <a class="code" href="a04199.html#a6">nlassert</a> (ite!=desc.end());
00494 
00495                                         <span class="comment">// Descriptor ref</span>
00496                                         <span class="keyword">const</span> CBitmapDesc&amp; descBitmap=ite-&gt;second;
00497 
00498                                         <span class="comment">// Get primitives</span>
00499                                         <span class="keyword">const</span> CPrimitiveBlock &amp;primitiveBlock=meshGeom-&gt;getRdrPassPrimitiveBlock(matrixBlock,renderPass);
00500 
00501                                         <span class="comment">// Set of vertex to remap</span>
00502                                         std::set&lt;uint&gt; vertexToRemap;
00503 
00504                                         <span class="comment">// Remap triangles</span>
00505                                         <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a>;
00506                                         <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> *indexPtr=primitiveBlock.getTriPointer();
00507                                         <a class="code" href="a04558.html#a11">uint32</a> numIndex=3*primitiveBlock.getNumTri();
00508                                         <span class="keywordflow">for</span> (<a class="code" href="a04223.html#a566">index</a>=0; <a class="code" href="a04223.html#a566">index</a>&lt;numIndex; <a class="code" href="a04223.html#a566">index</a>++)
00509                                                 vertexToRemap.insert (indexPtr[index]);
00510 
00511                                         <span class="comment">// Remap quad</span>
00512                                         indexPtr=primitiveBlock.getQuadPointer();
00513                                         numIndex=4*primitiveBlock.getNumQuad();
00514                                         <span class="keywordflow">for</span> (<a class="code" href="a04223.html#a566">index</a>=0; <a class="code" href="a04223.html#a566">index</a>&lt;numIndex; <a class="code" href="a04223.html#a566">index</a>++)
00515                                                 vertexToRemap.insert (indexPtr[index]);
00516 
00517                                         <span class="comment">// Remap the vertex</span>
00518                                         std::set&lt;uint&gt;::iterator iteRemap=vertexToRemap.begin();
00519                                         <span class="keywordflow">while</span> (iteRemap!=vertexToRemap.end())
00520                                         {
00521                                                 <span class="comment">// Remap the vertex</span>
00522                                                 <span class="keywordtype">float</span> *UVCoordinate=(<span class="keywordtype">float</span>*)vertexBuffer.getTexCoordPointer(*iteRemap);
00523                                                 UVCoordinate[0]=UVCoordinate[0]*descBitmap.FactorU+descBitmap.U;
00524                                                 UVCoordinate[1]=UVCoordinate[1]*descBitmap.FactorV+descBitmap.V;
00525 
00526                                                 <span class="comment">// Next vertex</span>
00527                                                 iteRemap++;
00528                                         }                                       
00529                                 }
00530                         }
00531                 }
00532         }
00533 }
</pre></div>    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a05568.html">coarse_mesh_build.h</a><li><a class="el" href="a05567.html">coarse_mesh_build.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:45:23 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>