aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/mesh__mrm__skin_8cpp-source.html
blob: a1e9be423d900b7a05919a96f92f0f928f2f39f9 (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
<!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>mesh_mrm_skin.cpp</h1><a href="mesh__mrm__skin_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="bsphere_8h.html">nel/misc/bsphere.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="fast__mem_8h.html">nel/misc/fast_mem.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="system__info_8h.html">nel/misc/system_info.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="mesh__mrm_8h.html">3d/mesh_mrm.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="mrm__builder_8h.html">3d/mrm_builder.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="mrm__parameters_8h.html">3d/mrm_parameters.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="mesh__mrm__instance_8h.html">3d/mesh_mrm_instance.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="skeleton__model_8h.html">3d/skeleton_model.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="stripifier_8h.html">3d/stripifier.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="matrix__3x4_8h.html">3d/matrix_3x4.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="raw__skin_8h.html">3d/raw_skin.h</a>"</font>
00040 
00041 
00042 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00043 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00044 
00045 
00046 <font class="keyword">namespace </font>NL3D 
00047 {
00048 
00049 
00050 <font class="comment">// ***************************************************************************</font>
00051 <font class="comment">// ***************************************************************************</font>
00052 <font class="comment">// CMatrix3x4SSE array correctly aligned</font>
00053 <font class="comment">// ***************************************************************************</font>
00054 <font class="comment">// ***************************************************************************</font>
00055 
00056 
00057 
00058 <font class="comment">// ***************************************************************************</font>
<a name="l00059"></a><a class="code" href="mesh__mrm__skin_8cpp.html#a0">00059</a> <font class="preprocessor">#define NL3D_SSE_ALIGNEMENT             16</font>
00060 <font class="preprocessor"></font>
<a name="l00063"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html">00063</a> <font class="keyword">class   </font>CMatrix3x4SSEArray
00064 {
00065 <font class="keyword">private</font>:
<a name="l00066"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">00066</a>         <font class="keywordtype">void</font>    *<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>;
<a name="l00067"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">00067</a>         <font class="keywordtype">void</font>    *<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>;
<a name="l00068"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">00068</a>         <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>;
<a name="l00069"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">00069</a>         <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>;
00070 
00071 <font class="keyword">public</font>:
<a name="l00072"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">00072</a>         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">CMatrix3x4SSEArray</a>()
00073         {
00074                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>= NULL;
00075                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>= NULL;
00076                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>= 0;
00077                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>= 0;
00078         }
<a name="l00079"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a1">00079</a>         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a1">~CMatrix3x4SSEArray</a>()
00080         {
00081                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a5">clear</a>();
00082         }
<a name="l00083"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a2">00083</a>         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">CMatrix3x4SSEArray</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">CMatrix3x4SSEArray</a> &amp;other)
00084         {
00085                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>= NULL;
00086                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>= NULL;
00087                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>= 0;
00088                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>= 0;
00089                 *<font class="keyword">this</font>= other;
00090         }
<a name="l00091"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a3">00091</a>         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">CMatrix3x4SSEArray</a> &amp;<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a3">operator=</a>(<font class="keyword">const</font> <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a0">CMatrix3x4SSEArray</a> &amp;other)
00092         {
00093                 <font class="keywordflow">if</font>( <font class="keyword">this</font> == &amp;other)
00094                         <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00095                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a6">resize</a>(other.size());
00096                 <font class="comment">// copy data from aligned pointers to aligned pointers.</font>
00097                 memcpy(<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>, other._Data, <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a8">size</a>() * <font class="keyword">sizeof</font>(CMatrix3x4SSE) );
00098 
00099                 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00100         }
00101 
00102 
<a name="l00103"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a4">00103</a>         CMatrix3x4SSE   *<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a4">getPtr</a>()
00104         {
00105                 <font class="keywordflow">return</font> (CMatrix3x4SSE*)<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>;
00106         }
00107 
<a name="l00108"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a5">00108</a>         <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a5">clear</a>()
00109         {
00110                 free(<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>);
00111                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>= NULL;
00112                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>= NULL;
00113                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>= 0;
00114                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>= 0;
00115         }
00116 
<a name="l00117"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a6">00117</a>         <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a6">resize</a>(<a class="code" href="types__nl_8h.html#a14">uint</a> n)
00118         {
00119                 <font class="comment">// reserve ??</font>
00120                 <font class="keywordflow">if</font>(n&gt;<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>)
00121                         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a7">reserve</a>( max(2*<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>, n));
00122                 <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>= n;
00123         }
00124 
<a name="l00125"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a7">00125</a>         <font class="keywordtype">void</font>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a7">reserve</a>(<a class="code" href="types__nl_8h.html#a14">uint</a> n)
00126         {
00127                 <font class="keywordflow">if</font>(n==0)
00128                         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a5">clear</a>();
00129                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(n&gt;<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>)
00130                 {
00131                         <font class="comment">// Alloc new data.</font>
00132                         <font class="keywordtype">void</font>    *newAllocData;
00133                         <font class="keywordtype">void</font>    *newData;
00134 
00135                         <font class="comment">// Alloc for alignement.</font>
00136                         newAllocData= malloc(n * <font class="keyword">sizeof</font>(CMatrix3x4SSE) + <a class="code" href="mesh__mrm__skin_8cpp.html#a0">NL3D_SSE_ALIGNEMENT</a>-1);
00137                         <font class="keywordflow">if</font>(newAllocData==NULL)
00138                                 <font class="keywordflow">throw</font> Exception(<font class="stringliteral">"SSE Allocation Failed"</font>);
00139 
00140                         <font class="comment">// Align ptr</font>
00141                         newData= (<font class="keywordtype">void</font>*) ( ((uint32)newAllocData+<a class="code" href="mesh__mrm__skin_8cpp.html#a0">NL3D_SSE_ALIGNEMENT</a>-1) &amp; (~(<a class="code" href="mesh__mrm__skin_8cpp.html#a0">NL3D_SSE_ALIGNEMENT</a>-1)) );
00142 
00143                         <font class="comment">// copy valid data from old to new.</font>
00144                         memcpy(newData, <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>, <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a8">size</a>() * <font class="keyword">sizeof</font>(CMatrix3x4SSE) );
00145 
00146                         <font class="comment">// change ptrs and capacity.</font>
00147                         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>= newData;
00148                         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o0">_AllocData</a>= newAllocData;
00149                         <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o3">_Capacity</a>= n;
00150                 }
00151         }
00152 
<a name="l00153"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a8">00153</a>         <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a8">size</a>()<font class="keyword"> const </font>{<font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o2">_Size</a>;}
00154 
00155 
<a name="l00156"></a><a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a9">00156</a>         CMatrix3x4SSE   &amp;<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#a9">operator[]</a>(<a class="code" href="types__nl_8h.html#a14">uint</a> i) {<font class="keywordflow">return</font> ((CMatrix3x4SSE*)<a class="code" href="classNL3D_1_1CMatrix3x4SSEArray.html#o1">_Data</a>)[i];}
00157 };
00158 
00159 
00160 
00161 <font class="comment">// ***************************************************************************</font>
00162 <font class="comment">// ***************************************************************************</font>
00163 <font class="comment">// Matrix manip</font>
00164 <font class="comment">// ***************************************************************************</font>
00165 <font class="comment">// ***************************************************************************</font>
00166 
00167 
00168 <font class="comment">// ***************************************************************************</font>
00169 <font class="keyword">template</font> &lt;<font class="keyword">class</font> TMatrixArray&gt;
00170 <font class="keyword">inline</font> <font class="keywordtype">void</font>     <a class="code" href="namespaceNL3D.html#a364">computeBoneMatrixes3x4</a>(TMatrixArray &amp;boneMat3x4, <font class="keyword">const</font> vector&lt;uint32&gt; &amp;matInfs, <font class="keyword">const</font> CSkeletonModel *skeleton)
00171 {
00172         <font class="comment">// For all matrix this lod use.</font>
00173         <font class="keywordflow">for</font>(<a class="code" href="types__nl_8h.html#a14">uint</a> i= 0; i&lt;matInfs.size(); i++)
00174         {
00175                 <font class="comment">// Get Matrix info.</font>
00176                 <a class="code" href="types__nl_8h.html#a14">uint</a>    matId= matInfs[i];
00177                 <font class="keyword">const</font> CMatrix           &amp;boneMat= skeleton-&gt;getActiveBoneSkinMatrix(matId);
00178 
00179                 <font class="comment">// compute "fast" matrix 3x4.</font>
00180                 <font class="comment">// resize Matrix3x4.</font>
00181                 <font class="keywordflow">if</font>(matId&gt;=boneMat3x4.size())
00182                 {
00183                         boneMat3x4.resize(matId+1);
00184                 }
00185                 boneMat3x4[matId].set(boneMat);
00186         }
00187 }
00188 
00189 
00190 <font class="comment">// ***************************************************************************</font>
00191 <font class="comment">// ***************************************************************************</font>
00192 <font class="comment">// Simple (slow) skinning version with position only.</font>
00193 <font class="comment">// ***************************************************************************</font>
00194 <font class="comment">// ***************************************************************************</font>
00195 
00196 
00197 <font class="comment">// ***************************************************************************</font>
<a name="l00198"></a><a class="code" href="classNL3D_1_1CMeshMRMGeom.html#c8">00198</a> <font class="keywordtype">void</font>    CMeshMRMGeom::applySkin(CLod &amp;lod, <font class="keyword">const</font> CSkeletonModel *skeleton)
00199 {
00200         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o0">_Skinned</a>);
00201         <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o6">_SkinWeights</a>.size()==0)
00202                 <font class="keywordflow">return</font>;
00203 
00204         <font class="comment">// get vertexPtr.</font>
00205         <font class="comment">//===========================</font>
00206         <a class="code" href="types__nl_8h.html#a6">uint8</a>           *destVertexPtr= (<a class="code" href="types__nl_8h.html#a6">uint8</a>*)<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o5">_VBufferFinal</a>.getVertexCoordPointer();
00207         <a class="code" href="types__nl_8h.html#a14">uint</a>            flags= <a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o5">_VBufferFinal</a>.getVertexFormat();
00208         <a class="code" href="types__nl_8h.html#a9">sint32</a>          vertexSize= <a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o5">_VBufferFinal</a>.getVertexSize();
00209         <font class="comment">// must have XYZ.</font>
00210         <a class="code" href="debug_8h.html#a6">nlassert</a>(flags &amp; CVertexBuffer::PositionFlag);
00211 
00212 
00213         <font class="comment">// compute src array.</font>
00214         CMesh::CSkinWeight      *srcSkinPtr;
00215         CVector                         *srcVertexPtr;
00216         srcSkinPtr= &amp;<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o6">_SkinWeights</a>[0];
00217         srcVertexPtr= &amp;<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o1">_OriginalSkinVertices</a>[0];
00218 
00219 
00220 
00221         <font class="comment">// Compute usefull Matrix for this lod.</font>
00222         <font class="comment">//===========================</font>
00223         <font class="comment">// Those arrays map the array of bones in skeleton.</font>
00224         <font class="keyword">static</font>  vector&lt;CMatrix3x4&gt;                      boneMat3x4;
00225         <a class="code" href="namespaceNL3D.html#a364">computeBoneMatrixes3x4</a>(boneMat3x4, lod.MatrixInfluences, skeleton);
00226 
00227 
00228         <font class="comment">// apply skinning.</font>
00229         <font class="comment">//===========================</font>
00230         <font class="comment">// assert, code below is written especially for 4 per vertex.</font>
00231         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="mesh_8h.html#a0">NL3D_MESH_SKINNING_MAX_MATRIX</a>==4);
00232         <font class="keywordflow">for</font>(<a class="code" href="types__nl_8h.html#a14">uint</a> i=0;i&lt;<a class="code" href="mesh_8h.html#a0">NL3D_MESH_SKINNING_MAX_MATRIX</a>;i++)
00233         {
00234                 <a class="code" href="types__nl_8h.html#a14">uint</a>            nInf= lod.InfluencedVertices[i].size();
00235                 <font class="keywordflow">if</font>( nInf==0 )
00236                         <font class="keywordflow">continue</font>;
00237                 <a class="code" href="types__nl_8h.html#a10">uint32</a>          *infPtr= &amp;(lod.InfluencedVertices[i][0]);
00238 
00239                 <font class="comment">// apply the skin to the vertices</font>
00240                 <font class="keywordflow">switch</font>(i)
00241                 {
00242                 <font class="comment">//=========</font>
00243                 <font class="keywordflow">case</font> 0:
00244                         <font class="comment">// Special case for Vertices influenced by one matrix. Just copy result of mul.</font>
00245                         <font class="comment">//  for all InfluencedVertices only.</font>
00246                         <font class="keywordflow">for</font>(;nInf&gt;0;nInf--, infPtr++)
00247                         {
00248                                 <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>= *infPtr;
00249                                 CMesh::CSkinWeight      *srcSkin= srcSkinPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00250                                 CVector                         *srcVertex= srcVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00251                                 <a class="code" href="types__nl_8h.html#a6">uint8</a>                           *dstVertexVB= destVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> * vertexSize;
00252                                 CVector                         *dstVertex= (CVector*)(dstVertexVB);
00253 
00254 
00255                                 <font class="comment">// Vertex.</font>
00256                                 boneMat3x4[ srcSkin-&gt;MatrixId[0] ].mulSetPoint( *srcVertex, *dstVertex);
00257                         }
00258                         <font class="keywordflow">break</font>;
00259 
00260                 <font class="comment">//=========</font>
00261                 <font class="keywordflow">case</font> 1:
00262                         <font class="comment">//  for all InfluencedVertices only.</font>
00263                         <font class="keywordflow">for</font>(;nInf&gt;0;nInf--, infPtr++)
00264                         {
00265                                 <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>= *infPtr;
00266                                 CMesh::CSkinWeight      *srcSkin= srcSkinPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00267                                 CVector                         *srcVertex= srcVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00268                                 <a class="code" href="types__nl_8h.html#a6">uint8</a>                           *dstVertexVB= destVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> * vertexSize;
00269                                 CVector                         *dstVertex= (CVector*)(dstVertexVB);
00270 
00271 
00272                                 <font class="comment">// Vertex.</font>
00273                                 boneMat3x4[ srcSkin-&gt;MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin-&gt;Weights[0], *dstVertex);
00274                                 boneMat3x4[ srcSkin-&gt;MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[1], *dstVertex);
00275                         }
00276                         <font class="keywordflow">break</font>;
00277 
00278                 <font class="comment">//=========</font>
00279                 <font class="keywordflow">case</font> 2:
00280                         <font class="comment">//  for all InfluencedVertices only.</font>
00281                         <font class="keywordflow">for</font>(;nInf&gt;0;nInf--, infPtr++)
00282                         {
00283                                 <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>= *infPtr;
00284                                 CMesh::CSkinWeight      *srcSkin= srcSkinPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00285                                 CVector                         *srcVertex= srcVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00286                                 <a class="code" href="types__nl_8h.html#a6">uint8</a>                           *dstVertexVB= destVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> * vertexSize;
00287                                 CVector                         *dstVertex= (CVector*)(dstVertexVB);
00288 
00289 
00290                                 <font class="comment">// Vertex.</font>
00291                                 boneMat3x4[ srcSkin-&gt;MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin-&gt;Weights[0], *dstVertex);
00292                                 boneMat3x4[ srcSkin-&gt;MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[1], *dstVertex);
00293                                 boneMat3x4[ srcSkin-&gt;MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[2], *dstVertex);
00294                         }
00295                         <font class="keywordflow">break</font>;
00296 
00297                 <font class="comment">//=========</font>
00298                 <font class="keywordflow">case</font> 3:
00299                         <font class="comment">//  for all InfluencedVertices only.</font>
00300                         <font class="keywordflow">for</font>(;nInf&gt;0;nInf--, infPtr++)
00301                         {
00302                                 <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>= *infPtr;
00303                                 CMesh::CSkinWeight      *srcSkin= srcSkinPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00304                                 CVector                         *srcVertex= srcVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>;
00305                                 <a class="code" href="types__nl_8h.html#a6">uint8</a>                           *dstVertexVB= destVertexPtr + <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> * vertexSize;
00306                                 CVector                         *dstVertex= (CVector*)(dstVertexVB);
00307 
00308 
00309                                 <font class="comment">// Vertex.</font>
00310                                 boneMat3x4[ srcSkin-&gt;MatrixId[0] ].mulSetPoint( *srcVertex, srcSkin-&gt;Weights[0], *dstVertex);
00311                                 boneMat3x4[ srcSkin-&gt;MatrixId[1] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[1], *dstVertex);
00312                                 boneMat3x4[ srcSkin-&gt;MatrixId[2] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[2], *dstVertex);
00313                                 boneMat3x4[ srcSkin-&gt;MatrixId[3] ].mulAddPoint( *srcVertex, srcSkin-&gt;Weights[3], *dstVertex);
00314                         }
00315                         <font class="keywordflow">break</font>;
00316 
00317                 }
00318         }
00319 }
00320 
00321 
00322 <font class="comment">// ***************************************************************************</font>
00323 <font class="comment">// ***************************************************************************</font>
00324 <font class="comment">// Old school Template skinning: SSE or not.</font>
00325 <font class="comment">// ***************************************************************************</font>
00326 <font class="comment">// ***************************************************************************</font>
00327 
00328 
00329 <font class="comment">// RawSkin Cache constants</font>
00330 <font class="comment">//===============</font>
00331 <font class="comment">// The number of byte to process per block</font>
00332 <font class="keyword">const</font>   <a class="code" href="types__nl_8h.html#a14">uint</a>    <a class="code" href="namespaceNL3D.html#a144">NL_BlockByteL1</a>= 4096;
00333 
00334 <font class="comment">// Number of vertices per block to process with 1 matrix.</font>
<a name="l00335"></a><a class="code" href="classNL3D_1_1CMeshMRMGeom.html#z575_0">00335</a> <a class="code" href="types__nl_8h.html#a14">uint</a>    CMeshMRMGeom::NumCacheVertexNormal1= <a class="code" href="namespaceNL3D.html#a144">NL_BlockByteL1</a> / <font class="keyword">sizeof</font>(CRawVertexNormalSkin1);
00336 <font class="comment">// Number of vertices per block to process with 2 matrix.</font>
<a name="l00337"></a><a class="code" href="classNL3D_1_1CMeshMRMGeom.html#z575_1">00337</a> <a class="code" href="types__nl_8h.html#a14">uint</a>    CMeshMRMGeom::NumCacheVertexNormal2= <a class="code" href="namespaceNL3D.html#a144">NL_BlockByteL1</a> / <font class="keyword">sizeof</font>(CRawVertexNormalSkin2);
00338 <font class="comment">// Number of vertices per block to process with 3/4 matrix.</font>
<a name="l00339"></a><a class="code" href="classNL3D_1_1CMeshMRMGeom.html#z575_2">00339</a> <a class="code" href="types__nl_8h.html#a14">uint</a>    CMeshMRMGeom::NumCacheVertexNormal4= <a class="code" href="namespaceNL3D.html#a144">NL_BlockByteL1</a> / <font class="keyword">sizeof</font>(CRawVertexNormalSkin4);
00340 
00341 
00342 <font class="comment">// Old School template: include the same file with define switching</font>
00343 <font class="preprocessor">#undef NL_SKIN_SSE</font>
00344 <font class="preprocessor"></font><font class="preprocessor">#include "<a class="code" href="mesh__mrm__skin__template_8cpp.html">mesh_mrm_skin_template.cpp</a>"</font>
00345 <font class="preprocessor">#define NL_SKIN_SSE</font>
00346 <font class="preprocessor"></font><font class="preprocessor">#include "<a class="code" href="mesh__mrm__skin__template_8cpp.html">mesh_mrm_skin_template.cpp</a>"</font>
00347 
00348 
00349 
00350 <font class="comment">// ***************************************************************************</font>
00351 <font class="comment">// ***************************************************************************</font>
00352 <font class="comment">// Misc.</font>
00353 <font class="comment">// ***************************************************************************</font>
00354 <font class="comment">// ***************************************************************************</font>
00355 
00356 
00357 
00358 <font class="comment">// ***************************************************************************</font>
00359 <font class="keywordtype">void</font>                            CMeshMRMGeom::fillAGPSkinPart(CLod &amp;lod, IVertexBufferHard *currentVBHard)
00360 {
00361         <font class="comment">// if VBHard OK</font>
00362         <font class="keywordflow">if</font>(currentVBHard)
00363         {
00364                 <font class="comment">// lock buffer.</font>
00365                 <a class="code" href="types__nl_8h.html#a6">uint8</a>           *vertexDst= (<a class="code" href="types__nl_8h.html#a6">uint8</a>*)currentVBHard-&gt;lock();
00366 
00367                 <font class="comment">// do it.</font>
00368                 <a class="code" href="classNL3D_1_1CMeshMRMGeom.html#z574_3">fillAGPSkinPartWithVBHardPtr</a>(lod, vertexDst);
00369 
00370                 <font class="comment">// release</font>
00371                 currentVBHard-&gt;unlock();
00372         }
00373 }
00374 
00375 
00376 <font class="comment">// ***************************************************************************</font>
00377 <font class="keywordtype">void</font>                            CMeshMRMGeom::fillAGPSkinPartWithVBHardPtr(CLod &amp;lod, <a class="code" href="types__nl_8h.html#a6">uint8</a> *vertexDst)
00378 {
00379         <font class="comment">// Fill AGP vertices used by this lod from RAM. (not geomorphed ones).</font>
00380         <font class="keywordflow">if</font>( lod.SkinVertexBlocks.size()&gt;0 )
00381         {
00382                 <font class="comment">// Get VB info, and lock buffers.</font>
00383                 <a class="code" href="types__nl_8h.html#a6">uint8</a>           *vertexSrc= (<a class="code" href="types__nl_8h.html#a6">uint8</a>*)<a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o5">_VBufferFinal</a>.getVertexCoordPointer();
00384                 <a class="code" href="types__nl_8h.html#a10">uint32</a>          vertexSize= <a class="code" href="classNL3D_1_1CMeshMRMGeom.html#o5">_VBufferFinal</a>.getVertexSize();
00385 
00386                 <font class="comment">// big copy of all vertices and their data.</font>
00387                 <font class="comment">// NB: this not help RAM bandwidth, but this help AGP write combiners.</font>
00388                 <font class="comment">// For the majority of mesh (vertex/normal/uv), this is better (6/10).</font>
00389 
00390                 <font class="comment">// Also, this is a requirement for MeshMorpher to work, because the MehsMorpher may modify</font>
00391                 <font class="comment">// UV and color</font>
00392 
00393 
00394                 <font class="comment">// For all block of vertices.</font>
00395                 CVertexBlock    *vBlock= &amp;lod.SkinVertexBlocks[0];
00396                 <a class="code" href="types__nl_8h.html#a14">uint</a>    n= lod.SkinVertexBlocks.size();
00397 
00398                 <font class="comment">/*</font>
00399 <font class="comment">                        It appears that it is not a so good idea to use CFastMem::memcpySSE() here, maybe because</font>
00400 <font class="comment">                        data is often already in cache (written by skinning), and maybe because movntq is not usefull here since</font>
00401 <font class="comment">                        AGP is already a write-combining memory.</font>
00402 <font class="comment">                */</font>
00403                 <font class="keywordflow">for</font>(;n&gt;0; n--, vBlock++)
00404                 {
00405                         <font class="comment">// For all vertices of this block, copy it from RAM to VRAM.</font>
00406                         <a class="code" href="types__nl_8h.html#a6">uint8</a>           *src= vertexSrc + vertexSize * vBlock-&gt;VertexStart;
00407                         <a class="code" href="types__nl_8h.html#a6">uint8</a>           *dst= vertexDst + vertexSize * vBlock-&gt;VertexStart;
00408 
00409                         memcpy(dst, src, vBlock-&gt;NVertices * vertexSize);
00410                 }
00411         }
00412 }
00413 
00414 
00415 
00416 } <font class="comment">// NL3D</font>
00417 
</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>