aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03708.html
blob: ca8ba8f5920b5ac6a8c941be64bd69d1be7ddccf (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NL3D::CVisualCollisionManager::CMeshCol class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NL3D::CVisualCollisionManager::CMeshCol Class Reference</h1><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshCola0">build</a> (const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;vertices, const std::vector&lt; <a class="el" href="a04558.html#a9">uint16</a> &gt; &amp;triangles)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>float&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshCola1">getCameraCollision</a> (class <a class="el" href="a02317.html">CCameraCol</a> &amp;camCol)</td></tr>

<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02156.html">NLMISC::CAABBox</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo0">BBox</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03709.html">CStaticGrid</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">QuadGrid</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03273.html">CQuadGrid</a>&lt; <a class="el" href="a03708.html">CMeshCol</a> * &gt;::CIterator&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo2">QuadGridIt</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector&lt; <a class="el" href="a04558.html#a9">uint16</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo3">Triangles</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo4">Vertices</a></td></tr>

</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshCola0" doxytag="NL3D::CVisualCollisionManager::CMeshCol::build" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> void NL3D::CVisualCollisionManager::CMeshCol::build </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::vector&lt; <a class="el" href="a03128.html">CVector</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>vertices</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const std::vector&lt; <a class="el" href="a04558.html#a9">uint16</a> &gt; &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>triangles</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

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

<p>

<p>
Definition at line <a class="el" href="a06729.html#l00370">370</a> of file <a class="el" href="a06729.html">visual_collision_manager.cpp</a>.
<p>
References <a class="el" href="a06729.html#l00200">NL3D::CVisualCollisionManager::CStaticGrid::add()</a>, <a class="el" href="a06729.html#l00233">NL3D::CVisualCollisionManager::CStaticGrid::compile()</a>, <a class="el" href="a06729.html#l00172">NL3D::CVisualCollisionManager::CStaticGrid::create()</a>, <a class="el" href="a05384.html#l00215">NLMISC::CAABBox::extend()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06730.html#l00192">QuadGrid</a>, <a class="el" href="a05385.html#l00066">NLMISC::CAABBox::setCenter()</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06729.html#l00401">NL3D::CVisualCollisionManager::addMeshCollision()</a>.
<p>
<div class="fragment"><pre>00371 {
00372         <a class="code" href="a04558.html#a15">uint</a>    i;
00373         <a class="code" href="a04199.html#a6">nlassert</a>(!vertices.empty());
00374 
00375         <span class="comment">// copy</span>
00376         <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo4">Vertices</a>= vertices;
00377         <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo3">Triangles</a>= triangles;
00378         
00379         <span class="comment">// Build the bbox for this col mesh</span>
00380         <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo0">BBox</a>.<a class="code" href="a02156.html#NLMISC_1_1CAABBoxz1902_1">setCenter</a>(vertices[0]);
00381         <span class="keywordflow">for</span>(i=1;i&lt;vertices.size();i++)
00382                 <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo0">BBox</a>.<a class="code" href="a02156.html#NLMISC_1_1CAABBoxExtz1902_0">extend</a>(vertices[i]);
00383 
00384         <span class="comment">// Build the Static Grid</span>
00385         <a class="code" href="a04558.html#a15">uint</a>    numTris= triangles.size()/3;
00386         <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">QuadGrid</a>.create(16, numTris, BBox);
00387         <span class="comment">// Add all triangles</span>
00388         <span class="keywordflow">for</span>(i=0;i&lt;numTris;i++)
00389         {
00390                 CAABBox         bb;
00391                 bb.setCenter(Vertices[Triangles[i*3+0]]);
00392                 bb.extend(Vertices[Triangles[i*3+1]]);
00393                 bb.extend(Vertices[Triangles[i*3+2]]);
00394                 <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">QuadGrid</a>.add(i, bb);
00395         }
00396         <span class="comment">// compile</span>
00397         <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">QuadGrid</a>.compile();
00398 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshCola1" doxytag="NL3D::CVisualCollisionManager::CMeshCol::getCameraCollision" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> float NL3D::CVisualCollisionManager::CMeshCol::getCameraCollision </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">class <a class="el" href="a02317.html">CCameraCol</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>camCol</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

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

<p>

<p>
Definition at line <a class="el" href="a06729.html#l00330">330</a> of file <a class="el" href="a06729.html">visual_collision_manager.cpp</a>.
<p>
References <a class="el" href="a05533.html#l00057">NL3D::CCameraCol::BBox</a>, <a class="el" href="a05533.html#l00050">NL3D::CCameraCol::End</a>, <a class="el" href="a05384.html#l00107">NLMISC::CAABBox::intersect()</a>, <a class="el" href="a05484.html#l00038">min</a>, <a class="el" href="a05532.html#l00131">NL3D::CCameraCol::minimizeDistanceAgainstTri()</a>, <a class="el" href="a06730.html#l00192">QuadGrid</a>, <a class="el" href="a06729.html#l00279">NL3D::CVisualCollisionManager::CStaticGrid::select()</a>, <a class="el" href="a05533.html#l00048">NL3D::CCameraCol::Start</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
<div class="fragment"><pre>00331 {
00332         <span class="comment">// first test if intersect with the bboxes</span>
00333         <span class="keywordflow">if</span>(!camCol.BBox.intersect(BBox))
00334                 <span class="keywordflow">return</span> 1;
00335 
00336         <span class="comment">// Select triangles</span>
00337         <span class="keyword">static</span> std::vector&lt;uint16&gt;              selection;
00338         <a class="code" href="a04558.html#a15">uint</a>    numSel= <a class="code" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">QuadGrid</a>.select(camCol.BBox, selection);
00339 
00340         <span class="comment">// **** For all triangles, test if intersect the camera collision</span>
00341         <span class="keywordtype">float</span>           sqrMinDist= FLT_MAX;
00342         <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> i=0;i&lt;numSel;i++)
00343         {
00344                 <a class="code" href="a04558.html#a15">uint</a>                    triId= selection[i];
00345                 <span class="comment">// build the triangle</span>
00346                 camCol.minimizeDistanceAgainstTri(
00347                         Vertices[Triangles[triId*3+0]],
00348                         Vertices[Triangles[triId*3+1]],
00349                         Vertices[Triangles[triId*3+2]],
00350                         sqrMinDist);
00351         }
00352         
00353         <span class="comment">// **** return the collision found, between [0,1]</span>
00354         <span class="keywordflow">if</span>(sqrMinDist == FLT_MAX)
00355                 <span class="keywordflow">return</span> 1;
00356         <span class="keywordflow">else</span>
00357         {
00358                 <span class="keywordtype">float</span>   f= 1;
00359                 <span class="keywordtype">float</span>   d= (camCol.End-camCol.Start).norm();
00360                 <span class="keywordflow">if</span>(d&gt;0)
00361                 {
00362                         f= sqrtf(sqrMinDist) / d;
00363                         f= <a class="code" href="a04061.html#a0">min</a>(f, 1.f);
00364                 }
00365                 <span class="keywordflow">return</span> f;
00366         }
00367 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshColo0" doxytag="NL3D::CVisualCollisionManager::CMeshCol::BBox" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a02156.html">NLMISC::CAABBox</a> <a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo0">NL3D::CVisualCollisionManager::CMeshCol::BBox</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06730.html#l00188">188</a> of file <a class="el" href="a06730.html">visual_collision_manager.h</a>.
<p>
Referenced by <a class="el" href="a06729.html#l00401">NL3D::CVisualCollisionManager::addMeshCollision()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshColo1" doxytag="NL3D::CVisualCollisionManager::CMeshCol::QuadGrid" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03709.html">CStaticGrid</a> <a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo1">NL3D::CVisualCollisionManager::CMeshCol::QuadGrid</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06730.html#l00192">192</a> of file <a class="el" href="a06730.html">visual_collision_manager.h</a>.
<p>
Referenced by <a class="el" href="a06729.html#l00370">build()</a>, and <a class="el" href="a06729.html#l00330">getCameraCollision()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshColo2" doxytag="NL3D::CVisualCollisionManager::CMeshCol::QuadGridIt" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> <a class="el" href="a03273.html">CQuadGrid</a>&lt;<a class="el" href="a03708.html">CMeshCol</a>*&gt;::CIterator <a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo2">NL3D::CVisualCollisionManager::CMeshCol::QuadGridIt</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06730.html#l00190">190</a> of file <a class="el" href="a06730.html">visual_collision_manager.h</a>.
<p>
Referenced by <a class="el" href="a06729.html#l00401">NL3D::CVisualCollisionManager::addMeshCollision()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshColo3" doxytag="NL3D::CVisualCollisionManager::CMeshCol::Triangles" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> std::vector&lt;<a class="el" href="a04558.html#a9">uint16</a>&gt; <a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo3">NL3D::CVisualCollisionManager::CMeshCol::Triangles</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06730.html#l00186">186</a> of file <a class="el" href="a06730.html">visual_collision_manager.h</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CVisualCollisionManager_1_1CMeshColo4" doxytag="NL3D::CVisualCollisionManager::CMeshCol::Vertices" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> std::vector&lt;<a class="el" href="a03128.html">CVector</a>&gt; <a class="el" href="a03708.html#NL3D_1_1CVisualCollisionManager_1_1CMeshColo4">NL3D::CVisualCollisionManager::CMeshCol::Vertices</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06730.html#l00185">185</a> of file <a class="el" href="a06730.html">visual_collision_manager.h</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06730.html">visual_collision_manager.h</a><li><a class="el" href="a06729.html">visual_collision_manager.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 08:27:05 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>