aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/render__trav_8cpp-source.html
blob: 9c8bc37dc3115e9924369b2275272d49f0ed9367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
<!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>render_trav.cpp</h1><a href="render__trav_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="render__trav_8h.html">3d/render_trav.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="hrc__trav_8h.html">3d/hrc_trav.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="clip__trav_8h.html">3d/clip_trav.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="light__trav_8h.html">3d/light_trav.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="light_8h.html">3d/light.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="skeleton__model_8h.html">3d/skeleton_model.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="scene_8h.html">3d/scene.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="coarse__mesh__manager_8h.html">3d/coarse_mesh_manager.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="lod__character__manager_8h.html">3d/lod_character_manager.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="hierarchical__timer_8h.html">nel/misc/hierarchical_timer.h</a>"</font>
00039 
00040 <font class="preprocessor">#include "<a class="code" href="transform_8h.html">3d/transform.h</a>"</font>
00041 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
00042 <font class="preprocessor">#include "<a class="code" href="mesh__skin__manager_8h.html">3d/mesh_skin_manager.h</a>"</font>
00043 
00044 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00045 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00046 
00047 
00048 <font class="keyword">namespace       </font>NL3D
00049 {
00050 
00051 
00052 <font class="comment">// ***************************************************************************</font>
00053 <font class="comment">// ***************************************************************************</font>
00054 <font class="comment">// CRenderTrav</font>
00055 <font class="comment">// ***************************************************************************</font>
00056 <font class="comment">// ***************************************************************************</font>
00057 
00058 
00059 <font class="comment">// ***************************************************************************</font>
<a name="l00060"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#a0">00060</a> CRenderTrav::CRenderTrav()
00061 {
00062         <a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.reserve(1024);
00063         <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.init(1024);
00064         <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.init(1024);
00065         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a> = NULL;
00066         <a class="code" href="classNL3D_1_1CRenderTrav.html#o5">_CurrentPassOpaque</a> = <font class="keyword">true</font>;
00067 
00068         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_0">_CacheLightContribution</a>= NULL;
00069 
00070         <font class="comment">// Default light Setup.</font>
00071         <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_2">LightingSystemEnabled</a>= <font class="keyword">false</font>;
00072         <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_3">AmbientGlobal</a>= CRGBA(50, 50, 50);
00073         <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_4">SunAmbient</a>= CRGBA::Black;
00074         <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_5">SunDiffuse</a>= <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_6">SunSpecular</a>= CRGBA::White;
00075         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>.set(0, 0.5, -0.5);
00076         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>.normalize();
00077 
00078         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_11">_StrongestLightTouched</a> = <font class="keyword">true</font>;
00079 
00080         <a class="code" href="classNL3D_1_1CRenderTrav.html#o7">_MeshSkinManager</a>= NULL;
00081 
00082         <a class="code" href="classNL3D_1_1CRenderTrav.html#o6">_LayersRenderingOrder</a>= <font class="keyword">true</font>;
00083 }
00084 <font class="comment">// ***************************************************************************</font>
<a name="l00085"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z745_0">00085</a> IObs            *CRenderTrav::createDefaultObs()<font class="keyword"> const</font>
00086 <font class="keyword"></font>{
00087         <font class="keywordflow">return</font> <font class="keyword">new</font> CDefaultRenderObs;
00088 }
00089 <font class="comment">// ***************************************************************************</font>
<a name="l00090"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z745_3">00090</a> <font class="keywordtype">void</font>            CRenderTrav::traverse()
00091 {
00092         <a class="code" href="hierarchical__timer_8h.html#a4">H_AUTO</a>( NL3D_TravRender );
00093 
00094         ITravCameraScene::update();
00095 
00096         <font class="comment">// Bind to Driver.</font>
00097         <a class="code" href="classNL3D_1_1CRenderTrav.html#a2">getDriver</a>()-&gt;setFrustum(<a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_0">Left</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_1">Right</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_2">Bottom</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_3">Top</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_4">Near</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_5">Far</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_6">Perspective</a>);
00098         <font class="comment">// Use setupViewMatrixEx() for ZBuffer precision.</font>
00099         <a class="code" href="classNL3D_1_1CRenderTrav.html#a2">getDriver</a>()-&gt;setupViewMatrixEx(<a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_8">ViewMatrix</a>, <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_9">CamPos</a>);
00100         <a class="code" href="classNL3D_1_1CRenderTrav.html#a2">getDriver</a>()-&gt;setupViewport(<a class="code" href="classNL3D_1_1CRenderTrav.html#o4">_Viewport</a>);
00101 
00102         <font class="comment">// reset the light setup, and set global ambient.</font>
00103         <a class="code" href="classNL3D_1_1CRenderTrav.html#z748_1">resetLightSetup</a>();
00104 
00105 
00106         <font class="comment">// reset the Skin manager, if needed</font>
00107         <font class="keywordflow">if</font>(_MeshSkinManager)
00108         {
00109                 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>!=<a class="code" href="classNL3D_1_1CRenderTrav.html#o7">_MeshSkinManager</a>-&gt;getDriver())
00110                 {
00111                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o7">_MeshSkinManager</a>-&gt;release();
00112                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o7">_MeshSkinManager</a>-&gt;init(<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>, <a class="code" href="render__trav_8h.html#a0">NL3D_MESH_SKIN_MANAGER_VERTEXFORMAT</a>, <a class="code" href="render__trav_8h.html#a1">NL3D_MESH_SKIN_MANAGER_MAXVERTICES</a>);
00113                 }
00114         }
00115 
00116 
00117         <font class="comment">// Fill OT with observers, for both Opaque and transparent pass</font>
00118         <font class="comment">// =============================</font>
00119 
00120         <font class="comment">// Sort the observers by distance from camera</font>
00121         <font class="comment">// This is done here and not in the addRenderObs because of the LoadBalancing traversal which can modify</font>
00122         <font class="comment">// the transparency flag (multi lod for instance)</font>
00123 
00124         <font class="comment">// clear the OTs, and prepare to allocate max element space</font>
00125         <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.reset(<a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.size());
00126         <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.reset(<a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.size());
00127 
00128         <font class="comment">// fill the OTs.</font>
00129         IBaseRenderObs          **itRdrObs= NULL;
00130         uint32                          nNbObs = <a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.size();
00131         <font class="keywordflow">if</font>(nNbObs)      
00132                 itRdrObs= &amp;<a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>[0];
00133         <font class="keywordtype">float</font>   rPseudoZ, rPseudoZ2;
00134 
00135         <font class="comment">// Some precalc</font>
00136         <font class="keywordtype">float</font>   OOFar= 1.0f / this-&gt;<a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_5">Far</a>;
00137         uint32  opaqueOtSize= <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.getSize();
00138         uint32  opaqueOtMax= <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.getSize()-1;
00139         uint32  transparentOtSize= <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.getSize();
00140         uint32  transparentOtMax= <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.getSize()-1;
00141         uint32  otId;
00142         <font class="comment">// fast floor</font>
00143         <a class="code" href="namespaceNL3D.html#a360">OptFastFloorBegin</a>();
00144         <font class="comment">// For all rdr observers</font>
00145         <font class="keywordflow">for</font>( ; nNbObs&gt;0; itRdrObs++, nNbObs-- )
00146         {
00147                 IBaseRenderObs          *pObs= *itRdrObs;
00148                 <font class="comment">// Only rdrObserver of transform models can be inserted!! It's a requirement</font>
00149                 CTransform                      *pTransform = safe_cast&lt;CTransform*&gt;(pObs-&gt;Model);
00150                 CTransformHrcObs        *trHrcObs= safe_cast&lt;CTransformHrcObs*&gt;(pObs-&gt;HrcObs);
00151 
00152                 <font class="comment">// Yoyo: skins are rendered through skeletons, so models WorldMatrix are all good here (even sticked objects)</font>
00153                 rPseudoZ = (trHrcObs-&gt;WorldMatrix.getPos() - <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_9">CamPos</a>).norm();
00154 
00155                 <font class="comment">// rPseudoZ from 0.0 -&gt; 1.0</font>
00156                 rPseudoZ =  sqrtf( rPseudoZ * OOFar );
00157 
00158                 <font class="keywordflow">if</font>( pTransform-&gt;isOpaque() )
00159                 {
00160                         <font class="comment">// since norm, we are sure that rPseudoZ&gt;=0</font>
00161                         rPseudoZ2 = rPseudoZ * opaqueOtSize;
00162                         otId= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(rPseudoZ2);
00163                         otId= <a class="code" href="bit__set_8cpp.html#a0">min</a>(otId, opaqueOtMax);
00164                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.insert( otId, pObs );
00165                 }
00166                 <font class="keywordflow">if</font>( pTransform-&gt;isTransparent() )
00167                 {
00168                         <font class="comment">// since norm, we are sure that rPseudoZ&gt;=0</font>
00169                         rPseudoZ2 = rPseudoZ * transparentOtSize;
00170                         otId= <a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(rPseudoZ2);
00171                         otId= <a class="code" href="bit__set_8cpp.html#a0">min</a>(otId, transparentOtMax);
00172                         <font class="comment">// must invert id, because transparent, sort from back to front</font>
00173                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.insert( pTransform-&gt;getOrderingLayer(), pObs, transparentOtMax-otId );
00174                 }
00175 
00176         }
00177         <font class="comment">// fast floor</font>
00178         <a class="code" href="namespaceNL3D.html#a361">OptFastFloorEnd</a>();
00179 
00180 
00181         <font class="comment">// Standard traverse (maybe not used)</font>
00182         <font class="comment">// =============================</font>
00183 
00184         <font class="comment">// First traverse the root.</font>
00185         <font class="keywordflow">if</font>(Root)
00186                 <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>-&gt;traverse(NULL);
00187 
00188 
00189 
00190         <font class="comment">// Render Opaque stuff.</font>
00191         <font class="comment">// =============================</font>
00192 
00193         <font class="comment">// TestYoyo</font>
00194         <font class="comment">//OrderOpaqueList.reset(0);</font>
00195         <font class="comment">//OrderTransparentList.reset(0);</font>
00196 
00197         <font class="comment">// Start LodCharacter Manager render.</font>
00198         CLodCharacterManager    *clodMngr= <a class="code" href="classNL3D_1_1ITravScene.html#m0">Scene</a>-&gt;getLodCharacterManager();
00199         <font class="keywordflow">if</font>(clodMngr)
00200                 clodMngr-&gt;beginRender(<a class="code" href="classNL3D_1_1CRenderTrav.html#a2">getDriver</a>(), <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_9">CamPos</a>);
00201 
00202         <font class="comment">// Render the opaque materials</font>
00203         <a class="code" href="classNL3D_1_1CRenderTrav.html#o5">_CurrentPassOpaque</a> = <font class="keyword">true</font>;
00204         <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.begin();
00205         IBaseRenderObs *pBRO;
00206         <font class="keywordflow">while</font>( <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.get() != NULL )
00207         {
00208                 pBRO = <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.get();
00209                 pBRO-&gt;traverse(NULL);
00210                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o1">OrderOpaqueList</a>.next();
00211         }
00212 
00213         <font class="comment">/* Render MeshBlock Manager. </font>
00214 <font class="comment">                Some Meshs may be render per block. Interesting to remove VertexBuffer and Material setup overhead.</font>
00215 <font class="comment">                Faster if rendered before lods, for ZBuffer optimisation: render first near objects then far. </font>
00216 <font class="comment">                Lods are usually far objects.</font>
00217 <font class="comment">        */</font>
00218         <a class="code" href="classNL3D_1_1CRenderTrav.html#z749_0">MeshBlockManager</a>.flush(<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>, <a class="code" href="classNL3D_1_1ITravScene.html#m0">Scene</a>, <font class="keyword">this</font>);
00219 
00220 
00221         <font class="comment">// End LodCharacter Manager render.</font>
00222         <font class="keywordflow">if</font>(clodMngr)
00223                 clodMngr-&gt;endRender();
00224 
00225 
00226         <font class="comment">/* Render Scene CoarseMeshManager. </font>
00227 <font class="comment">                Important to render them at end of Opaque rendering, because coarses instances are created/removed during</font>
00228 <font class="comment">                this model opaque rendering pass.</font>
00229 <font class="comment">        */</font>
00230         <font class="comment">// Render dynamic one.</font>
00231         <a class="code" href="classNL3D_1_1ITravScene.html#m0">Scene</a>-&gt;getDynamicCoarseMeshManager()-&gt;render(<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>);
00232         <font class="comment">// Render static one.</font>
00233         <a class="code" href="classNL3D_1_1ITravScene.html#m0">Scene</a>-&gt;getStaticCoarseMeshManager()-&gt;render(<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>);
00234 
00235 
00236         <font class="comment">// Render Transparent stuff.</font>
00237         <font class="comment">// =============================</font>
00238 
00239          <font class="comment">// Render transparent materials</font>
00240         <a class="code" href="classNL3D_1_1CRenderTrav.html#o5">_CurrentPassOpaque</a> = <font class="keyword">false</font>;
00241         <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.begin(<a class="code" href="classNL3D_1_1CRenderTrav.html#o6">_LayersRenderingOrder</a>);      
00242         <font class="keywordflow">while</font>( <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.get() != NULL )
00243         {                               
00244                 pBRO = <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.get();
00245                 pBRO-&gt;traverse(NULL);
00246                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o2">OrderTransparentList</a>.next();
00247         }
00248 
00249 
00250         <font class="comment">// END!</font>
00251         <font class="comment">// =============================</font>
00252 
00253         <font class="comment">// clean: reset the light setup</font>
00254         <a class="code" href="classNL3D_1_1CRenderTrav.html#z748_1">resetLightSetup</a>();
00255 
00256 }
00257 <font class="comment">// ***************************************************************************</font>
<a name="l00258"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z746_0">00258</a> <font class="keywordtype">void</font>            CRenderTrav::clearRenderList()
00259 {
00260         <a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.clear();
00261 }
00262 <font class="comment">// ***************************************************************************</font>
<a name="l00263"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z746_1">00263</a> <font class="keywordtype">void</font>            CRenderTrav::addRenderObs(IBaseRenderObs *o)
00264 {
00265         <a class="code" href="classNL3D_1_1CRenderTrav.html#o0">RenderList</a>.push_back(o);
00266 }
00267 
00268 
00269 <font class="comment">// ***************************************************************************</font>
<a name="l00270"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z747_0">00270</a> <font class="keywordtype">void</font>            CRenderTrav::setSunDirection(<font class="keyword">const</font> CVector &amp;dir)
00271 {
00272         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>= dir;
00273         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>.normalize();
00274 }
00275 
00276 
00277 <font class="comment">// ***************************************************************************</font>
<a name="l00278"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#a8">00278</a> <font class="keywordtype">void</font>            CRenderTrav::setMeshSkinManager(CMeshSkinManager *msm)
00279 {
00280         <a class="code" href="classNL3D_1_1CRenderTrav.html#o7">_MeshSkinManager</a>= msm;
00281 }
00282 
00283 
00284 <font class="comment">// ***************************************************************************</font>
00285 <font class="comment">// ***************************************************************************</font>
00286 <font class="comment">// LightSetup</font>
00287 <font class="comment">// ***************************************************************************</font>
00288 <font class="comment">// ***************************************************************************</font>
00289 
00290 
00291 <font class="comment">// ***************************************************************************</font>
<a name="l00292"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_1">00292</a> <font class="keywordtype">void</font>            CRenderTrav::resetLightSetup()
00293 {
00294         <font class="comment">// If lighting System disabled, skip</font>
00295         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_2">LightingSystemEnabled</a>)
00296         {
00297                 <font class="comment">// Dont modify Driver lights, but setup default lighting For VertexProgram Lighting.</font>
00298                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>= 1;
00299                 <font class="comment">// Setup A default directionnal.</font>
00300                 CVector         defDir(-0.5f, 0.0, -0.85f);
00301                 defDir.normalize();
00302                 CRGBA           aday= CRGBA(130,  105,  119);
00303                 CRGBA           dday= CRGBA(238, 225, 204);
00304                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0].setupDirectional(aday, dday, dday, defDir);
00305 
00306                 <font class="keywordflow">return</font>;
00307         }
00308         <font class="keywordflow">else</font>
00309         {
00310                 uint i;
00311 
00312                 <font class="comment">// Disable all lights.</font>
00313                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;getMaxLight(); i++)
00314                 {
00315                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;enableLight(i, <font class="keyword">false</font>);
00316                 }
00317 
00318 
00319                 <font class="comment">// setup the precise cache, and setup lights according to this cache?</font>
00320                 <font class="comment">// setup blackSun (factor==0).</font>
00321                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_3">_LastSunFactor</a>= 0;
00322                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_4">_LastSunAmbient</a>.<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>(0,0,0,255);
00323                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0].setupDirectional(CRGBA::Black, CRGBA::Black, CRGBA::Black, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>);
00324                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setLight(0, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0]);
00325                 <font class="comment">// setup NULL point lights (=&gt; cache will fail), so no need to setup other lights in Driver.</font>
00326                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="light__contribution_8h.html#a0">NL3D_MAX_LIGHT_CONTRIBUTION</a>; i++)
00327                 {
00328                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_5">_LastPointLight</a>[i]= NULL;
00329                 }
00330 
00331 
00332                 <font class="comment">// setup the precise cache, and setup lights according to this cache?</font>
00333                 <font class="comment">// setup blackSun (factor==0).</font>
00334                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_3">_LastSunFactor</a>= 0;
00335                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_4">_LastSunAmbient</a>.<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>(0,0,0,255);
00336                 CLight          light;
00337                 light.setupDirectional(CRGBA::Black, CRGBA::Black, CRGBA::Black, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>);
00338                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0].setupDirectional(CRGBA::Black, CRGBA::Black, CRGBA::Black, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>);
00339                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setLight(0, light);
00340                 <font class="comment">// setup NULL point lights (=&gt; cache will fail), so no need to setup other lights in Driver.</font>
00341                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="light__contribution_8h.html#a0">NL3D_MAX_LIGHT_CONTRIBUTION</a>; i++)
00342                 {
00343                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_5">_LastPointLight</a>[i]= NULL;
00344                 }
00345 
00346                 <font class="comment">// Set the global ambientColor</font>
00347                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setAmbientColor(<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_3">AmbientGlobal</a>);
00348 
00349 
00350                 <font class="comment">// clear the cache.</font>
00351                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_0">_CacheLightContribution</a>= NULL;
00352                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>= 0;
00353 
00354                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_11">_StrongestLightTouched</a> = <font class="keyword">true</font>;
00355         }
00356 }
00357 
00358 
00359 <font class="comment">// ***************************************************************************</font>
<a name="l00360"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_2">00360</a> <font class="keywordtype">void</font>            CRenderTrav::changeLightSetup(CLightContribution        *lightContribution, <font class="keywordtype">bool</font> useLocalAttenuation)
00361 {
00362         <font class="comment">// If lighting System disabled, skip</font>
00363         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_2">LightingSystemEnabled</a>)
00364                 <font class="keywordflow">return</font>;
00365 
00366         uint            i;
00367 
00368         <font class="comment">// if same lightContribution, no-op.</font>
00369         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_0">_CacheLightContribution</a> == lightContribution &amp;&amp;  <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_1">_LastLocalAttenuation</a> == useLocalAttenuation)
00370                 <font class="keywordflow">return</font>;
00371         <font class="comment">// else, must setup the lights into driver.</font>
00372         <font class="keywordflow">else</font>
00373         {
00374                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_11">_StrongestLightTouched</a> = <font class="keyword">true</font>;
00375                 <font class="comment">// if the setup is !NULL</font>
00376                 <font class="keywordflow">if</font>(lightContribution)
00377                 {
00378                         <font class="comment">// Compute SunAmbient / LocalAmbient</font>
00379                         <font class="comment">//-----------</font>
00380                         CRGBA   finalAmbient;
00381                         <font class="comment">// Different case if the contribution is frozen or not.</font>
00382                         <font class="keywordflow">if</font>(lightContribution-&gt;FrozenStaticLightSetup)
00383                         {
00384                                 <font class="comment">// Any FrozenAmbientLight provided??</font>
00385                                 <font class="keywordflow">if</font>(lightContribution-&gt;FrozenAmbientLight)
00386                                         <font class="comment">// Take his current (maybe animated) ambient</font>
00387                                         finalAmbient= lightContribution-&gt;FrozenAmbientLight-&gt;getAmbient();
00388                                 <font class="keywordflow">else</font>
00389                                         <font class="comment">// Take the sun ones.</font>
00390                                         finalAmbient= <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_4">SunAmbient</a>;
00391                         }
00392                         <font class="keywordflow">else</font>
00393                         {
00394                                 <font class="comment">// must interpolate between SunAmbient and localAmbient</font>
00395                                 uint    uAmbFactor= lightContribution-&gt;LocalAmbient.<a class="code" href="classNLMISC_1_1CRGBA.html#m3">A</a>;
00396                                 <font class="comment">// expand 0..255 to 0..256, to avoid loss of precision.</font>
00397                                 uAmbFactor+= uAmbFactor&gt;&gt;7;
00398                                 <font class="comment">// Blend, but LocalAmbient.r/g/b is already multiplied by a.</font>
00399                                 finalAmbient.modulateFromuiRGBOnly(<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_4">SunAmbient</a>, 256 - uAmbFactor);
00400                                 finalAmbient.addRGBOnly(finalAmbient, lightContribution-&gt;LocalAmbient);
00401                         }
00402                         <font class="comment">// Force Alpha to 255 for good cache test.</font>
00403                         finalAmbient.A= 255;
00404 
00405 
00406                         <font class="comment">// Setup the directionnal Sunlight.</font>
00407                         <font class="comment">//-----------</font>
00408                         <font class="comment">// expand 0..255 to 0..256, to avoid loss of precision.</font>
00409                         uint    ufactor= lightContribution-&gt;SunContribution;
00410                         <font class="comment">//      different SunLight as in cache ??</font>
00411                         <font class="comment">//      NB: sunSetup can't change during renderPass, so need only to test factor.</font>
00412                         <font class="keywordflow">if</font>(ufactor != <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_3">_LastSunFactor</a> || finalAmbient != <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_4">_LastSunAmbient</a>)
00413                         {
00414                                 <font class="comment">// cache (before expanding!!)</font>
00415                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_3">_LastSunFactor</a>= ufactor;
00416                                 <font class="comment">// Cache final ambient light</font>
00417                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_4">_LastSunAmbient</a>= finalAmbient;
00418 
00419                                 <font class="comment">// expand to 0..256.</font>
00420                                 ufactor+= ufactor&gt;&gt;7;   <font class="comment">// add 0 or 1.</font>
00421                                 <font class="comment">// modulate color with factor of the lightContribution.</font>
00422                                 CRGBA   sunDiffuse, sunSpecular;
00423                                 sunDiffuse.<a class="code" href="classNLMISC_1_1CRGBA.html#z321_1">modulateFromuiRGBOnly</a>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_5">SunDiffuse</a>, ufactor);
00424                                 sunSpecular.modulateFromuiRGBOnly(<a class="code" href="classNL3D_1_1CRenderTrav.html#z747_6">SunSpecular</a>, ufactor);
00425                                 <font class="comment">// setup driver light</font>
00426                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0].setupDirectional(finalAmbient, sunDiffuse, sunSpecular, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_8">_SunDirection</a>);
00427                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setLight(0, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0]);
00428                         }
00429 
00430 
00431                         <font class="comment">// Setup other point lights</font>
00432                         <font class="comment">//-----------</font>
00433                         uint    plId=0;
00434                         <font class="comment">// for the list of light.</font>
00435                         <font class="keywordflow">while</font>(lightContribution-&gt;PointLight[plId]!=NULL)
00436                         {
00437                                 CPointLight             *pl= lightContribution-&gt;PointLight[plId];
00438                                 uint                    inf;
00439                                 <font class="keywordflow">if</font>(useLocalAttenuation)
00440                                         inf= lightContribution-&gt;Factor[plId];
00441                                 <font class="keywordflow">else</font>
00442                                         inf= lightContribution-&gt;AttFactor[plId];
00443 
00444                                 <font class="comment">// different PointLight setup than in cache??</font>
00445                                 <font class="comment">// NB: pointLight setup can't change during renderPass, so need only to test pointer, </font>
00446                                 <font class="comment">// attenuation mode and factor.</font>
00447                                 <font class="keywordflow">if</font>( pl!=<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_5">_LastPointLight</a>[plId] || 
00448                                         inf!=<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_6">_LastPointLightFactor</a>[plId] ||
00449                                         useLocalAttenuation!=<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_7">_LastPointLightLocalAttenuation</a>[plId] )
00450                                 {
00451                                         <font class="comment">// need to resetup the light. Cache it.</font>
00452                                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_5">_LastPointLight</a>[plId]= pl;
00453                                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_6">_LastPointLightFactor</a>[plId]= inf;
00454                                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_7">_LastPointLightLocalAttenuation</a>[plId]= useLocalAttenuation;
00455 
00456                                         <font class="comment">// compute the driver light</font>
00457                                         <font class="keywordflow">if</font>(useLocalAttenuation)
00458                                                 pl-&gt;setupDriverLight(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[plId+1], inf);
00459                                         <font class="keywordflow">else</font>
00460                                                 <font class="comment">// Compute it with user Attenuation</font>
00461                                                 pl-&gt;setupDriverLightUserAttenuation(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[plId+1], inf);
00462 
00463                                         <font class="comment">// setup driver. decal+1 because of sun.</font>
00464                                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setLight(plId+1, <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[plId+1]);
00465                                 }
00466 
00467                                 <font class="comment">// next light?</font>
00468                                 plId++;
00469                                 <font class="keywordflow">if</font>(plId&gt;=<a class="code" href="light__contribution_8h.html#a0">NL3D_MAX_LIGHT_CONTRIBUTION</a>)
00470                                         <font class="keywordflow">break</font>;
00471                         }
00472 
00473 
00474                         <font class="comment">// Disable olds, enable news, and cache.</font>
00475                         <font class="comment">//-----------</font>
00476                         <font class="comment">// count new number of light enabled.</font>
00477                         uint    newNumLightEnabled;
00478                         <font class="comment">// number of pointLight + the sun </font>
00479                         newNumLightEnabled= plId + 1;
00480 
00481                         <font class="comment">// enable lights which are used now and were not before.</font>
00482                         <font class="keywordflow">for</font>(i=<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>; i&lt;newNumLightEnabled; i++)
00483                         {
00484                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;enableLight(i, <font class="keyword">true</font>);
00485                         }
00486 
00487                         <font class="comment">// disable lights which are no more used.</font>
00488                         <font class="keywordflow">for</font>(i=newNumLightEnabled; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>; i++)
00489                         {
00490                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;enableLight(i, <font class="keyword">false</font>);
00491                         }
00492 
00493                         <font class="comment">// cache the setup.</font>
00494                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_0">_CacheLightContribution</a> = lightContribution;
00495                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>= newNumLightEnabled;
00496                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_1">_LastLocalAttenuation</a>= useLocalAttenuation;
00497                 }
00498                 <font class="keywordflow">else</font>
00499                 {
00500                         <font class="comment">// Disable old lights, and cache.</font>
00501                         <font class="comment">//-----------</font>
00502                         <font class="comment">// disable lights which are no more used.</font>
00503                         <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>; i++)
00504                         {
00505                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;enableLight(i, <font class="keyword">false</font>);
00506                         }
00507 
00508                         <font class="comment">// cache the setup.</font>
00509                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_0">_CacheLightContribution</a> = NULL;
00510                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>= 0;
00511                 }
00512 
00513 
00514         }
00515 }
00516 
00517 <font class="comment">// ***************************************************************************</font>
00518 <font class="comment">// ***************************************************************************</font>
00519 <font class="comment">// VertexProgram LightSetup</font>
00520 <font class="comment">// ***************************************************************************</font>
00521 <font class="comment">// ***************************************************************************</font>
00522 
00523 
00524 <font class="comment">// ***************************************************************************</font>
<a name="l00525"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_3">00525</a> <font class="keywordtype">void</font>            CRenderTrav::beginVPLightSetup(uint ctStart, <font class="keywordtype">bool</font> supportSpecular, <font class="keyword">const</font> CMatrix &amp;invObjectWM)
00526 {       
00527         uint    i;               
00528         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>==4);
00529         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>= <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>, (uint)<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>);
00530         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>= ctStart;
00531         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_14">_VPSupportSpecular</a>= supportSpecular;
00532         
00533         <font class="comment">// Prepare Colors (to be multiplied by material)</font>
00534         <font class="comment">//================</font>
00535         <font class="comment">// Ambient. _VPCurrentCtStart+0</font>
00536         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_15">_VPFinalAmbient</a>= <a class="code" href="classNL3D_1_1CRenderTrav.html#z747_3">AmbientGlobal</a>;
00537         <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00538         {
00539                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_15">_VPFinalAmbient</a>+= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[i].getAmbiant();         
00540         }
00541         <font class="comment">// Diffuse. _VPCurrentCtStart+1 to 4</font>
00542         <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00543         {
00544                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[i]= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[i].getDiffuse();
00545         }
00546         <font class="comment">// reset other to 0.</font>
00547         <font class="keywordflow">for</font>(; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>; i++)
00548         {
00549                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[i]= CRGBA::Black;
00550                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+1+i, 0.f, 0.f, 0.f, 0.f);
00551         }
00552         <font class="comment">// Specular. _VPCurrentCtStart+5 to 8 (only if supportSpecular)</font>
00553         <font class="keywordflow">if</font>(supportSpecular)
00554         {
00555                 <font class="keywordflow">for</font>(i=0; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00556                 {
00557                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[i]= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[i].getSpecular();
00558                 }
00559                 <font class="comment">// reset other to 0.</font>
00560                 <font class="keywordflow">for</font>(; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>; i++)
00561                 {
00562                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[i]= CRGBA::Black;
00563                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+5+i, 0.f, 0.f, 0.f, 0.f);
00564                 }
00565         }
00566 
00567 
00568         <font class="comment">// Compute Eye position in Object space.</font>
00569         CVector         eye= invObjectWM * <a class="code" href="classNL3D_1_1ITravCameraScene.html#z877_9">CamPos</a>;
00570 
00571 
00572         <font class="comment">// Setup Sun Directionnal light.</font>
00573         <font class="comment">//================</font>
00574         CVector         lightDir;
00575         <font class="comment">// in objectSpace.</font>
00576         lightDir= invObjectWM.mulVector(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[0].getDirection());
00577         lightDir.normalize();
00578         lightDir= -lightDir; 
00579         <font class="keywordflow">if</font>(supportSpecular)
00580         {
00581                 <font class="comment">// Setup lightDir.</font>
00582                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+9, lightDir);
00583         }
00584         <font class="keywordflow">else</font>
00585         {
00586                 <font class="comment">// Setup lightDir. NB: no specular color!</font>
00587                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+5, lightDir);
00588         }
00589 
00590 
00591         <font class="comment">// Setup PointLights</font>
00592         <font class="comment">//================</font>
00593         uint            startPLPos;
00594         <font class="keywordflow">if</font>(supportSpecular)
00595         {
00596                 <font class="comment">// Setup eye in objectSpace for localViewer</font>
00597                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+11, eye);
00598                 <font class="comment">// Start at 12.</font>
00599                 startPLPos= 12;
00600         }
00601         <font class="keywordflow">else</font>
00602         {
00603                 <font class="comment">// Start at 6.</font>
00604                 startPLPos= 6;
00605         }
00606         <font class="comment">// For all pointLight enabled (other are black: don't matter)</font>
00607         <font class="keywordflow">for</font>(i=1; i&lt;<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00608         {
00609                 <font class="comment">// Setup position of light.</font>
00610                 CVector         lightPos;
00611                 lightPos= invObjectWM * <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_9">_DriverLight</a>[i].getPosition();
00612                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+startPLPos+(i-1), lightPos);
00613         }
00614 
00615 
00616         <font class="comment">// Must force real light setup at least the first time, in changeVPLightSetupMaterial()</font>
00617         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_20">_VPMaterialCacheDirty</a>= <font class="keyword">true</font>;
00618 }
00619 
00620 <font class="comment">// ***************************************************************************</font>
<a name="l00621"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_4">00621</a> <font class="keywordtype">void</font>            CRenderTrav::changeVPLightSetupMaterial(<font class="keyword">const</font> CMaterial &amp;mat, <font class="keywordtype">bool</font> excludeStrongest)
00622 {
00623         <font class="comment">// Must test if at least done one time.</font>
00624         <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_20">_VPMaterialCacheDirty</a>)
00625         {
00626                 <font class="comment">// Must test if same as in cache</font>
00627                 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_21">_VPMaterialCacheEmissive</a> == mat.getEmissive().getPacked() &amp;&amp;
00628                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_22">_VPMaterialCacheAmbient</a> == mat.getAmbient().getPacked() &amp;&amp;
00629                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_23">_VPMaterialCacheDiffuse</a> == mat.getDiffuse().getPacked() )
00630                 {
00631                         <font class="comment">// Same Diffuse part, test if same specular if necessary</font>
00632                         <font class="keywordflow">if</font>( !<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_14">_VPSupportSpecular</a> ||
00633                                 ( <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_24">_VPMaterialCacheSpecular</a> == mat.getSpecular().getPacked() &amp;&amp;
00634                                   <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_25">_VPMaterialCacheShininess</a> == mat.getShininess() )  )
00635                         {
00636                                 <font class="comment">// Then ok, skip.</font>
00637                                 <font class="keywordflow">return</font>;
00638                         }
00639                 }
00640         }
00641 
00642         <font class="comment">// If not skiped, cache now. cache all for simplification</font>
00643         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_20">_VPMaterialCacheDirty</a>= <font class="keyword">false</font>;
00644         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_21">_VPMaterialCacheEmissive</a>= mat.getEmissive().getPacked();
00645         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_22">_VPMaterialCacheAmbient</a>= mat.getDiffuse().getPacked();
00646         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_23">_VPMaterialCacheDiffuse</a>= mat.getDiffuse().getPacked();
00647         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_24">_VPMaterialCacheSpecular</a>= mat.getSpecular().getPacked();
00648         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_25">_VPMaterialCacheShininess</a>= mat.getShininess();
00649 
00650         <font class="comment">// Setup constants</font>
00651         CRGBAF  color;
00652         uint    i;
00653         CRGBAF  matDiff= mat.getDiffuse();
00654         CRGBAF  matSpec= mat.getSpecular();
00655         <font class="keywordtype">float</font>   specExp= mat.getShininess();
00656         
00657         uint strongestLightIndex = excludeStrongest ? <a class="code" href="classNL3D_1_1CRenderTrav.html#z748_6">getStrongestLightIndex</a>() : <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>;
00658 
00659         <font class="comment">// setup Ambient + Emissive</font>
00660         color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_15">_VPFinalAmbient</a> * mat.getAmbient();
00661         color+= mat.getEmissive();
00662         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+0, 1, &amp;color.R);
00663         
00664 
00665         <font class="comment">// is the strongest light is not excluded, its index should have been setup to _VPNumLights</font>
00666 
00667         <font class="comment">// setup Diffuse.</font>
00668         <font class="keywordflow">for</font>(i = 0; i &lt; strongestLightIndex; ++i)
00669         {
00670                 color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[i] * matDiff;
00671                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+1+i, 1, &amp;color.R);
00672         }
00673 
00674         
00675         <font class="keywordflow">if</font> (i != <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>)
00676         {
00677                 color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[i] * matDiff;
00678                 <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_18">_StrongestLightDiffuse</a>.<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>((uint8) (255.f * color.R), (uint8) (255.f * color.G), (uint8) (255.f * color.B), (uint8) (255.f * color.A));
00679                 <font class="comment">// setup strongest light to black for the gouraud part</font>
00680                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a> + 1 + i, 0.f, 0.f, 0.f, 0.f);
00681                 ++i;
00682                 <font class="comment">// setup other lights</font>
00683                 <font class="keywordflow">for</font>(; i &lt; <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00684                 {
00685                         color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[i] * matDiff;
00686                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a> + 1 + i, 1, &amp;color.R);
00687                 }
00688         }
00689 
00690         <font class="comment">// setup Specular</font>
00691         <font class="keywordflow">if</font>(_VPSupportSpecular)
00692         {
00693                 <font class="keywordflow">for</font>(i = 0; i &lt; strongestLightIndex; ++i)
00694                 {
00695                         color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[i] * matSpec;
00696                         color.<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>= specExp;
00697                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+5+i, 1, &amp;color.R);
00698                 }
00699 
00700                 <font class="keywordflow">if</font> (i != <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>)
00701                 {
00702                         color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[i] * matSpec;
00703                         <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_19">_StrongestLightSpecular</a>.<a class="code" href="classNLMISC_1_1CRGBA.html#a10">set</a>((uint8) (255.f * color.R), (uint8) (255.f * color.G), (uint8) (255.f * color.B), (uint8) (255.f * color.A));
00704 
00705                         <font class="comment">// setup strongest light to black (for gouraud part)</font>
00706                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a> + 5 + i, 0.f, 0.f, 0.f, 0.f);
00707                         ++i;
00708                         <font class="comment">// setup other lights</font>
00709                         <font class="keywordflow">for</font>(; i &lt; <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_13">_VPNumLights</a>; i++)
00710                         {
00711                                 color= <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[i] * matSpec;
00712                                 color.<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>= specExp;
00713                                 <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a> + 5 + i, 1, &amp;color.R);
00714                         }
00715                 }
00716         }
00717 
00718         <font class="comment">// setup alpha.</font>
00719         <font class="keyword">static</font>  <font class="keywordtype">float</font>   alphaCte[4]= {0,0,1,0};
00720         alphaCte[3]= matDiff.A;
00721         <font class="comment">// setup at good place</font>
00722         <font class="keywordflow">if</font>(_VPSupportSpecular)
00723                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+10, 1, alphaCte);
00724         <font class="keywordflow">else</font>
00725                         <a class="code" href="classNL3D_1_1CRenderTrav.html#o3">Driver</a>-&gt;setConstant(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_12">_VPCurrentCtStart</a>+9, 1, alphaCte);
00726 }
00727 
00728 <font class="comment">// ***************************************************************************</font>
<a name="l00729"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_6">00729</a> sint CRenderTrav::getStrongestLightIndex()<font class="keyword"> const</font>
00730 <font class="keyword"></font>{
00731         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_11">_StrongestLightTouched</a>) <font class="keywordflow">return</font> -1;
00732         uint vpNumLights = <a class="code" href="bit__set_8cpp.html#a0">min</a>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z750_2">_NumLightEnabled</a>, (uint)<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>);
00733         <font class="comment">// If there is only a directionnal light, use it</font>
00734         <font class="comment">// If there is any point light, use the nearest, or the directionnal light if it is brighter</font>
00735         <font class="keywordflow">if</font> (vpNumLights == 0) <font class="keywordflow">return</font> -1;
00736         <font class="keywordflow">if</font> (vpNumLights == 1) <font class="keywordflow">return</font> 0;
00737         <font class="comment">// First point light is brightest ?</font>
00738         <font class="keywordtype">float</font> lumDir = <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m0">R</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m1">G</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m2">B</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>
00739                                    + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m0">R</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m1">G</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m2">B</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[0].<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>;
00740         <font class="keywordtype">float</font> lumOmni = <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m0">R</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m1">G</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m2">B</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_16">_VPLightDiffuse</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>
00741                                    + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m0">R</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m1">G</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m2">B</a> + <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_17">_VPLightSpecular</a>[1].<a class="code" href="classNLMISC_1_1CRGBAF.html#m3">A</a>;
00742         <font class="keywordflow">return</font> lumDir &gt; lumOmni ? 0 : 1;
00743 }
00744 
00745 <font class="comment">// ***************************************************************************</font>
<a name="l00746"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_7">00746</a> <font class="keywordtype">void</font>    CRenderTrav::getStrongestLightColors(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;diffuse, <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;specular)
00747 {
00748         sint strongestLightIndex = <a class="code" href="classNL3D_1_1CRenderTrav.html#z748_6">getStrongestLightIndex</a>();
00749         <font class="keywordflow">if</font> (strongestLightIndex == -1)
00750         {
00751                 diffuse = specular = <a class="code" href="classNLMISC_1_1CRGBA.html#p0">NLMISC::CRGBA::Black</a>;              
00752         }
00753         <font class="keywordflow">else</font>
00754         {
00755                 diffuse = <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_18">_StrongestLightDiffuse</a>;
00756                 specular = <a class="code" href="classNL3D_1_1CRenderTrav.html#z750_19">_StrongestLightSpecular</a>;             
00757         }
00758 }
00759 
00760 
00761 <font class="comment">// ***************************************************************************</font>
00762 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a225">LightingVPFragmentNormalize</a>=
00763 <font class="stringliteral">"       # normalize normal                                                                                                                                      \n\</font>
00764 <font class="stringliteral">        DP3     R6.w, R6, R6;                                                                                                                                   \n\</font>
00765 <font class="stringliteral">        RSQ     R6.w, R6.w;                                                                                                                                             \n\</font>
00766 <font class="stringliteral">        MUL     R6, R6, R6.w;                                                                                                                                   \n\</font>
00767 <font class="stringliteral">"</font>;
00768 
00769 
00770 <font class="comment">// ***************************************************************************</font>
00771 <font class="comment">// NB: all CTS+x are replaced with good cte index.</font>
00772 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a226">LightingVPFragmentNoSpecular_Begin</a>=
00773 <font class="stringliteral">"                                                                                                                                                                               \n\</font>
00774 <font class="stringliteral">        # Global Ambient.                                                                                                                                       \n\</font>
00775 <font class="stringliteral">        MOV     R2, c[CTS+0];                                                                                                                                   \n\</font>
00776 <font class="stringliteral">                                                                                                                                                                                \n\</font>
00777 <font class="stringliteral">        # Diffuse Sun                                                                                                                                           \n\</font>
00778 <font class="stringliteral">        DP3     R0.x, R6, c[CTS+5];                     # R0.x= normal*-lightDir                                                        \n\</font>
00779 <font class="stringliteral">        LIT     R0.y, R0.xxxx;                          # R0.y= R0.x clamped                                                            \n\</font>
00780 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+1], R2;         # R2= summed vertex color.                                                      \n\</font>
00781 <font class="stringliteral">"</font>;
00782 
00783 <font class="comment">// The 3 point Light code.</font>
00784 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a227">LightingVPFragmentNoSpecular_PL</a>[]=
00785 {
00786 <font class="stringliteral">"       # Diffuse PointLight 0.                                                                                                                         \n\</font>
00787 <font class="stringliteral">        ADD     R0, c[CTS+6], -R5;                      # R0= lightPos-vertex                                                           \n\</font>
00788 <font class="stringliteral">        DP3     R0.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00789 <font class="stringliteral">        RSQ     R0.w, R0.w;                                                                                                                                             \n\</font>
00790 <font class="stringliteral">        MUL     R0, R0, R0.w;                                                                                                                                   \n\</font>
00791 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00792 <font class="stringliteral">        LIT     R0.y, R0.xxxx;                          # R0.y= R0.x clamped                                                            \n\</font>
00793 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+2], R2;         # R2= summed vertex color.                                                      \n\</font>
00794 <font class="stringliteral">"</font>,
00795 <font class="stringliteral">"       # Diffuse PointLight 1.                                                                                                                         \n\</font>
00796 <font class="stringliteral">        ADD     R0, c[CTS+7], -R5;                      # R0= lightPos-vertex                                                           \n\</font>
00797 <font class="stringliteral">        DP3     R0.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00798 <font class="stringliteral">        RSQ     R0.w, R0.w;                                                                                                                                             \n\</font>
00799 <font class="stringliteral">        MUL     R0, R0, R0.w;                                                                                                                                   \n\</font>
00800 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00801 <font class="stringliteral">        LIT     R0.y, R0;                                       # R0.y= R0.x clamped                                                            \n\</font>
00802 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+3], R2;         # R2= summed vertex color.                                                      \n\</font>
00803 <font class="stringliteral">"</font>,
00804 <font class="stringliteral">"       # Diffuse PointLight 2.                                                                                                                         \n\</font>
00805 <font class="stringliteral">        ADD     R0, c[CTS+8], -R5;                      # R0= lightPos-vertex                                                           \n\</font>
00806 <font class="stringliteral">        DP3     R0.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00807 <font class="stringliteral">        RSQ     R0.w, R0.w;                                                                                                                                             \n\</font>
00808 <font class="stringliteral">        MUL     R0, R0, R0.w;                                                                                                                                   \n\</font>
00809 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00810 <font class="stringliteral">        LIT     R0.y, R0;                                       # R0.y= R0.x clamped                                                            \n\</font>
00811 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+4], R2;         # R2= summed vertex color.                                                      \n\</font>
00812 <font class="stringliteral">"</font>
00813 };
00814 
00815 <font class="comment">// The End code.</font>
00816 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a228">LightingVPFragmentNoSpecular_End</a>=
00817 <font class="stringliteral">"       # output to o[COL0] only, replacing alpha with material alpha.                                          \n\</font>
00818 <font class="stringliteral">        MAD     o[COL0], R2, c[CTS+9].zzzx, c[CTS+9].xxxw;                                                                              \n\</font>
00819 <font class="stringliteral">"</font>;
00820 
00821 
00822 <font class="comment">// ***************************************************************************</font>
00823 <font class="comment">// NB: all CTS+x are replaced with good cte index.</font>
00824 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a229">LightingVPFragmentSpecular_Begin</a>=
00825 <font class="stringliteral">"                                                                                                                                                                               \n\</font>
00826 <font class="stringliteral">        # Global Ambient.                                                                                                                                       \n\</font>
00827 <font class="stringliteral">        MOV     R2, c[CTS+0];                                                                                                                                   \n\</font>
00828 <font class="stringliteral">                                                                                                                                                                                \n\</font>
00829 <font class="stringliteral">        # Always keep Specular exponent in R0.w                                                                                         \n\</font>
00830 <font class="stringliteral">        MOV     R0.w, c[CTS+5].w;                                                                                                                               \n\</font>
00831 <font class="stringliteral">                                                                                                                                                                                \n\</font>
00832 <font class="stringliteral">        # Compute vertex-to-eye vector normed.                                                                                          \n\</font>
00833 <font class="stringliteral">        ADD     R4, c[CTS+11], -R5;                                                                                                                             \n\</font>
00834 <font class="stringliteral">        DP3     R4.w, R4, R4;                                                                                                                                   \n\</font>
00835 <font class="stringliteral">        RSQ     R4.w, R4.w;                                                                                                                                             \n\</font>
00836 <font class="stringliteral">        MUL R4, R4, R4.w;                                                                                                                                       \n\</font>
00837 <font class="stringliteral">                                                                                                                                                                                \n\</font>
00838 <font class="stringliteral">        # Diffuse-Specular Sun                                                                                                                          \n\</font>
00839 <font class="stringliteral">        # Compute R1= halfAngleVector= (lightDir+R4).normed().                                                          \n\</font>
00840 <font class="stringliteral">        ADD     R1.xyz, c[CTS+9], R4;           # R1= halfAngleVector                                                           \n\</font>
00841 <font class="stringliteral">        DP3     R1.w, R1, R1;                           # normalize R1.                                                                         \n\</font>
00842 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00843 <font class="stringliteral">        MUL     R1.xyz, R1, R1.w;                                                                                                                               \n\</font>
00844 <font class="stringliteral">        # Compute Factors and colors.                                                                                                           \n\</font>
00845 <font class="stringliteral">        DP3     R0.x, R6, c[CTS+9];                     # R0.x= normal*-lightDir                                                        \n\</font>
00846 <font class="stringliteral">        DP3     R0.yz, R6, R1;                          # R0.yz= normal*halfAngleVector                                         \n\</font>
00847 <font class="stringliteral">        LIT     R0.yz, R0;                                      # R0.y= R0.x clamped, R0.z= pow(spec, R0.w) clamp       \n\</font>
00848 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+1], R2;         # R2= summed vertex color.                                                      \n\</font>
00849 <font class="stringliteral">        MUL     R3, R0.z, c[CTS+5];                     # R3= specular color.                                                           \n\</font>
00850 <font class="stringliteral">"</font>;
00851 
00852 <font class="comment">// The 3 point Light code.</font>
00853 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a230">LightingVPFragmentSpecular_PL</a>[]=
00854 {
00855 <font class="stringliteral">"       # Diffuse-Specular PointLight 0.                                                                                                        \n\</font>
00856 <font class="stringliteral">        # Compute R0= (lightPos-vertex).normed().                                                                                       \n\</font>
00857 <font class="stringliteral">        ADD     R0.xyz, c[CTS+12], -R5;         # R0= lightPos-vertex                                                           \n\</font>
00858 <font class="stringliteral">        DP3     R1.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00859 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00860 <font class="stringliteral">        MUL     R0.xyz, R0, R1.w;                                                                                                                               \n\</font>
00861 <font class="stringliteral">        # Compute R1= halfAngleVector= (R0+R4).normed().                                                                        \n\</font>
00862 <font class="stringliteral">        ADD     R1.xyz, R0, R4;                         # R1= halfAngleVector                                                           \n\</font>
00863 <font class="stringliteral">        DP3     R1.w, R1, R1;                           # normalize R1.                                                                         \n\</font>
00864 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00865 <font class="stringliteral">        MUL     R1.xyz, R1, R1.w;                                                                                                                               \n\</font>
00866 <font class="stringliteral">        # Compute Factors and colors.                                                                                                           \n\</font>
00867 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00868 <font class="stringliteral">        DP3     R0.yz, R6, R1;                          # R0.yz= normal*halfAngleVector                                         \n\</font>
00869 <font class="stringliteral">        LIT     R0.yz, R0;                                      # R0.y= R0.x clamped, R0.z= pow(spec, R0.w) clamp       \n\</font>
00870 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+2], R2;         # R2= summed vertex color.                                                      \n\</font>
00871 <font class="stringliteral">        MAD     R3, R0.z, c[CTS+6], R3;         # R3= summed specular color.                                            \n\</font>
00872 <font class="stringliteral">"</font>,
00873 <font class="stringliteral">"       # Diffuse-Specular PointLight 1.                                                                                                        \n\</font>
00874 <font class="stringliteral">        # Compute R0= (lightPos-vertex).normed().                                                                                       \n\</font>
00875 <font class="stringliteral">        ADD     R0.xyz, c[CTS+13], -R5;         # R0= lightPos-vertex                                                           \n\</font>
00876 <font class="stringliteral">        DP3     R1.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00877 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00878 <font class="stringliteral">        MUL     R0.xyz, R0, R1.w;                                                                                                                               \n\</font>
00879 <font class="stringliteral">        # Compute R1= halfAngleVector= (R0+R4).normed().                                                                        \n\</font>
00880 <font class="stringliteral">        ADD     R1.xyz, R0, R4;                         # R1= halfAngleVector                                                           \n\</font>
00881 <font class="stringliteral">        DP3     R1.w, R1, R1;                           # normalize R1.                                                                         \n\</font>
00882 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00883 <font class="stringliteral">        MUL     R1.xyz, R1, R1.w;                                                                                                                               \n\</font>
00884 <font class="stringliteral">        # Compute Factors and colors.                                                                                                           \n\</font>
00885 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00886 <font class="stringliteral">        DP3     R0.yz, R6, R1;                          # R0.yz= normal*halfAngleVector                                         \n\</font>
00887 <font class="stringliteral">        LIT     R0.yz, R0;                                      # R0.y= R0.x clamped, R0.z= pow(spec, R0.w) clamp       \n\</font>
00888 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+3], R2;         # R2= summed vertex color.                                                      \n\</font>
00889 <font class="stringliteral">        MAD     R3, R0.z, c[CTS+7], R3;         # R3= summed specular color.                                            \n\</font>
00890 <font class="stringliteral">"</font>,
00891 <font class="stringliteral">"       # Diffuse-Specular PointLight 2.                                                                                                        \n\</font>
00892 <font class="stringliteral">        # Compute R0= (lightPos-vertex).normed().                                                                                       \n\</font>
00893 <font class="stringliteral">        ADD     R0.xyz, c[CTS+14], -R5;         # R0= lightPos-vertex                                                           \n\</font>
00894 <font class="stringliteral">        DP3     R1.w, R0, R0;                           # normalize R0.                                                                         \n\</font>
00895 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00896 <font class="stringliteral">        MUL     R0.xyz, R0, R1.w;                                                                                                                               \n\</font>
00897 <font class="stringliteral">        # Compute R1= halfAngleVector= (R0+R4).normed().                                                                        \n\</font>
00898 <font class="stringliteral">        ADD     R1.xyz, R0, R4;                         # R1= halfAngleVector                                                           \n\</font>
00899 <font class="stringliteral">        DP3     R1.w, R1, R1;                           # normalize R1.                                                                         \n\</font>
00900 <font class="stringliteral">        RSQ     R1.w, R1.w;                                                                                                                                             \n\</font>
00901 <font class="stringliteral">        MUL     R1.xyz, R1, R1.w;                                                                                                                               \n\</font>
00902 <font class="stringliteral">        # Compute Factors and colors.                                                                                                           \n\</font>
00903 <font class="stringliteral">        DP3     R0.x, R6, R0;                           # R0.x= normal*lightDir                                                         \n\</font>
00904 <font class="stringliteral">        DP3     R0.yz, R6, R1;                          # R0.yz= normal*halfAngleVector                                         \n\</font>
00905 <font class="stringliteral">        LIT     R0.yz, R0;                                      # R0.y= R0.x clamped, R0.z= pow(spec, R0.w) clamp       \n\</font>
00906 <font class="stringliteral">        MAD     R2, R0.y, c[CTS+4], R2;         # R2= summed vertex color.                                                      \n\</font>
00907 <font class="stringliteral">"</font>
00908 };
00909 
00910 
00911 <font class="comment">// The End code.</font>
00912 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font>*      <a class="code" href="namespaceNL3D.html#a231">LightingVPFragmentSpecular_End</a>=
00913 <font class="stringliteral">"       # output directly to secondary color.                                                                                           \n\</font>
00914 <font class="stringliteral">        MAD     o[COL1], R0.z, c[CTS+8], R3;    # final summed specular color.                                  \n\</font>
00915 <font class="stringliteral">                                                                                                                                                                                \n\</font>
00916 <font class="stringliteral">        # output diffuse to o[COL0], replacing alpha with material alpha.                                       \n\</font>
00917 <font class="stringliteral">        MAD     o[COL0], R2, c[CTS+10].zzzx, c[CTS+10].xxxw;                                                                    \n\</font>
00918 <font class="stringliteral">"</font>;
00919 
00920 <font class="comment">// ***************************************************************************</font>
00921 <font class="keyword">static</font>  <font class="keywordtype">void</font>    <a class="code" href="namespaceNL3D.html#a456">strReplaceAll</a>(string &amp;strInOut, <font class="keyword">const</font> string &amp;tokenSrc, <font class="keyword">const</font> string &amp;tokenDst)
00922 {
00923         uint32  pos;
00924         sint    srcLen= tokenSrc.size();
00925         <font class="keywordflow">while</font>( (pos=strInOut.find(tokenSrc)) != string::npos)
00926         {
00927                 strInOut.replace(pos, srcLen, tokenDst);
00928         }
00929 }
00930 
00931 <font class="comment">// ***************************************************************************</font>
<a name="l00932"></a><a class="code" href="classNL3D_1_1CRenderTrav.html#z748_9">00932</a> std::string             CRenderTrav::getLightVPFragment(uint numActivePointLights, uint ctStart, <font class="keywordtype">bool</font> supportSpecular, <font class="keywordtype">bool</font> normalize)
00933 {
00934         string  ret;
00935 
00936         <font class="comment">// Code frag written for 4 light max.</font>
00937         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>==4);
00938         <a class="code" href="debug_8h.html#a6">nlassert</a>(numActivePointLights&lt;=<a class="code" href="classNL3D_1_1CRenderTrav.html#z748_0s0">MaxVPLight</a>-1);
00939 
00940         <font class="comment">// Add LightingVPFragmentNormalize fragment?</font>
00941         <font class="keywordflow">if</font>(normalize)
00942                 ret+= <a class="code" href="namespaceNL3D.html#a225">LightingVPFragmentNormalize</a>;
00943 
00944         <font class="comment">// Which fragment to use...</font>
00945         <font class="keywordflow">if</font>(supportSpecular)
00946         {
00947                 <font class="comment">// Add start of VP.</font>
00948                 ret+= <a class="code" href="namespaceNL3D.html#a229">LightingVPFragmentSpecular_Begin</a>;
00949 
00950                 <font class="comment">// Add needed pointLights.</font>
00951                 <font class="keywordflow">for</font>(uint i=0;i&lt;numActivePointLights;i++)
00952                 {
00953                         ret+= <a class="code" href="namespaceNL3D.html#a230">LightingVPFragmentSpecular_PL</a>[i];
00954                 }
00955 
00956                 <font class="comment">// Add end of VP.</font>
00957                 ret+= <a class="code" href="namespaceNL3D.html#a231">LightingVPFragmentSpecular_End</a>;
00958         }
00959         <font class="keywordflow">else</font>
00960         {
00961                 <font class="comment">// Add start of VP.</font>
00962                 ret+= <a class="code" href="namespaceNL3D.html#a226">LightingVPFragmentNoSpecular_Begin</a>;
00963 
00964                 <font class="comment">// Add needed pointLights.</font>
00965                 <font class="keywordflow">for</font>(uint i=0;i&lt;numActivePointLights;i++)
00966                 {
00967                         ret+= <a class="code" href="namespaceNL3D.html#a227">LightingVPFragmentNoSpecular_PL</a>[i];
00968                 }
00969 
00970                 <font class="comment">// Add end of VP.</font>
00971                 ret+= <a class="code" href="namespaceNL3D.html#a228">LightingVPFragmentNoSpecular_End</a>;
00972         }
00973 
00974         <font class="comment">// Replace all CTS+x with good index. do it for 15 possible indices: 0 to 14 if specular.</font>
00975         <font class="comment">// run from 14 to 0 so CTS+14 will not be taken for a CTS+1 !!</font>
00976         <font class="keywordflow">for</font>(sint i=14; i&gt;=0; i--)
00977         {
00978                 <font class="keywordtype">char</font>    tokenSrc[256];
00979                 sprintf(tokenSrc, <font class="stringliteral">"CTS+%d"</font>, i);
00980                 <font class="keywordtype">char</font>    tokenDst[256];
00981                 sprintf(tokenDst, <font class="stringliteral">"%d"</font>, ctStart+i);
00982                 <font class="comment">// replace all in the string</font>
00983                 <a class="code" href="namespaceNL3D.html#a456">strReplaceAll</a>(ret, tokenSrc, tokenDst);
00984         }
00985 
00986         <font class="comment">// verify no CTS+ leaved... (not all ctes parsed!!!)</font>
00987         <a class="code" href="debug_8h.html#a6">nlassert</a>( ret.find(<font class="stringliteral">"CTS+"</font>)==string::npos );
00988 
00989         <font class="keywordflow">return</font> ret;
00990 }
00991 
00992 
00993 }
</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>