aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03271.html
blob: 955f45f4efbf90adc4b074f6eaa8c6f99a14e5dc (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
<!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::CQuadEffect 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::CQuadEffect Class Reference</h1><code>#include &lt;<a class="el" href="a06299.html">quad_effect.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This class allow to create a sequence of small quads that tesselate a poly. <dl compact><dt><b>Author:</b></dt><dd>Nicolas Vizerie <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a06299.html#l00046">46</a> of file <a class="el" href="a06299.html">quad_effect.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::vector&lt; <a class="el" href="a03660.html">NLMISC::CVector2f</a> &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">a vector of 2d points  <a href="#NL3D_1_1CQuadEffectw0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::vector&lt; std::pair&lt;<br>
 float, float &gt; &gt;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03271.html#NL3D_1_1CQuadEffectw1">TRasters</a></td></tr>

<tr><td colspan=2><br><h2>Static 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="a03271.html#NL3D_1_1CQuadEffecte0">makeRasters</a> (const <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;poly, float quadWidth, float quadHeight, <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw1">TRasters</a> &amp;dest, float &amp;startY)</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03271.html#NL3D_1_1CQuadEffecte1">processPoly</a> (const <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;poly, float quadWidth, float quadHeight, <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;dest)</td></tr>

</table>
<hr><h2>Member Typedef Documentation</h2>
<a class="anchor" name="NL3D_1_1CQuadEffectw0" doxytag="NL3D::CQuadEffect::TPoint2DVect" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::vector&lt;<a class="el" href="a03660.html">NLMISC::CVector2f</a>&gt; <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">NL3D::CQuadEffect::TPoint2DVect</a>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
a vector of 2d points 
<p>

<p>
Definition at line <a class="el" href="a06299.html#l00050">50</a> of file <a class="el" href="a06299.html">quad_effect.h</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CQuadEffectw1" doxytag="NL3D::CQuadEffect::TRasters" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> typedef std::vector&lt; std::pair&lt; float, float&gt; &gt; <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw1">NL3D::CQuadEffect::TRasters</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="a06299.html#l00053">53</a> of file <a class="el" href="a06299.html">quad_effect.h</a>.
<p>
Referenced by <a class="el" href="a06298.html#l00061">makeRasters()</a>, and <a class="el" href="a06298.html#l00234">processPoly()</a>.    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CQuadEffecte0" doxytag="NL3D::CQuadEffect::makeRasters" ></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::CQuadEffect::makeRasters </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>poly</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>quadWidth</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>quadHeight</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03271.html#NL3D_1_1CQuadEffectw1">TRasters</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>dest</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>startY</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</code></td>
        </tr>

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

<p>
Make raters from the given clipped polygon. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>poly</em>&nbsp;</td><td>a polygon that describe the area where datas are taken from. </td></tr>
    <tr><td valign=top><em>quadWidth</em>&nbsp;</td><td>width of the quad </td></tr>
    <tr><td valign=top><em>quadHeight</em>&nbsp;</td><td>height of the quad </td></tr>
    <tr><td valign=top><em>dest</em>&nbsp;</td><td>a vector that will be filled with the given rasters </td></tr>
    <tr><td valign=top><em>startY</em>&nbsp;</td><td>will be filled with the start y position on screen</td></tr>
  </table>
</dl>

<p>
edge is in scope. compute its extreme positions so we need to intersect it with the y = currY and y = currY + quadHeight lines 
<p>
Definition at line <a class="el" href="a06298.html#l00061">61</a> of file <a class="el" href="a06298.html">quad_effect.cpp</a>.
<p>
References <a class="el" href="a05484.html#l00038">min</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a06298.html#l00058">NL3D::TEdgeList</a>, <a class="el" href="a06299.html#l00053">TRasters</a>, and <a class="el" href="a05981.html#l00105">uint</a>.
<p>
Referenced by <a class="el" href="a06298.html#l00234">processPoly()</a>.
<p>
<div class="fragment"><pre>00065 {
00066 
00067         dest.clear();
00068     <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 10E-5f;
00069 
00070         <a class="code" href="a04558.html#a14">sint</a> <a class="code" href="a04223.html#a587">size</a> = poly.size();
00071         <a class="code" href="a04558.html#a15">uint</a> aelSize = 0; <span class="comment">// size of active edge list</span>
00072 
00073         <a class="code" href="a04558.html#a14">sint</a> k; <span class="comment">// loop counter</span>
00074 
00075 
00076 
00077         dest.clear();
00078 
00079         <span class="keywordflow">if</span> (!<a class="code" href="a04223.html#a587">size</a>) <span class="keywordflow">return</span>;
00080 
00081         <span class="keyword">static</span> <a class="code" href="a05363.html#a275">TEdgeList</a> lel, ael; <span class="comment">// the left edge list, and the active edge list</span>
00082         <span class="keywordtype">float</span> highest = poly[0].y;
00083         lel.clear();
00084         ael.clear();
00085         
00087 
00088         <span class="keywordflow">for</span> (k = 0; k &lt; <a class="code" href="a04223.html#a587">size</a>; ++k)
00089         {
00090 
00091                 lel.push_front(
00092                                                 CEdge(poly[k], poly[k == (size - 1) ? 0 : k + 1])
00093                                   );
00094                 <span class="keywordflow">if</span> (poly[k].y &lt; highest) { highest = poly[k].y; }               
00095         }
00096 
00098         std::sort(lel.begin(), lel.end());
00099 
00100         <span class="keywordtype">bool</span>  borderFound;
00101         <span class="keywordtype">float</span> left, right, inter, diff;
00102         <span class="keywordtype">float</span> currY = highest;
00103         startY = highest;
00104         
00105         TEdgeList::iterator elIt; 
00106 
00107         <span class="keywordflow">do</span>
00108         {               
00110                 <span class="keywordflow">while</span> (<a class="code" href="a04223.html#a587">size</a> 
00111                            &amp;&amp; lel.begin()-&gt;P1.y &lt; (currY +  quadHeight)
00112                           )
00113                 {
00114                         ael.push_front(lel.front());
00115                         lel.pop_front();
00116                         --<a class="code" href="a04223.html#a587">size</a>;
00117                         ++ aelSize;
00118                 }
00119 
00120                 <span class="keywordflow">if</span> (aelSize)
00121                 {
00122 
00123                         borderFound = <span class="keyword">false</span>;
00124 
00125                         <span class="keywordflow">for</span> (elIt = ael.begin(); elIt != ael.end();)
00126                         {
00127                                 <span class="keywordflow">if</span> (elIt-&gt;P2.y &lt;= currY)
00128                                 {
00129                                         <span class="comment">// edge has gone out of active edge list</span>
00130                                         elIt = ael.erase(elIt);
00131                                         <span class="keywordflow">if</span> (! --aelSize) <span class="keywordflow">return</span>;
00132                                         <span class="keywordflow">continue</span>;
00133                                 }
00134                                 <span class="keywordflow">else</span>
00135                                 {
00136 
00141 
00142                                         <span class="keywordflow">if</span> (elIt-&gt;P1.y &gt;= currY) 
00143                                         {                                               
00144                                                 <span class="keywordflow">if</span> (!borderFound)
00145                                                 {
00146                                                         left = right = elIt-&gt;P1.x;
00147                                                         borderFound = <span class="keyword">true</span>;
00148                                                 }
00149                                                 <span class="keywordflow">else</span>
00150                                                 {
00151                                                         left = <a class="code" href="a04061.html#a0">std::min</a>(left, elIt-&gt;P1.x);
00152                                                         right = std::max(right, elIt-&gt;P1.x);
00153                                                 }
00154                                         }
00155                                         <span class="keywordflow">else</span>
00156                                         {
00157                                                 <span class="comment">// compute intersection</span>
00158                                                 diff = elIt-&gt;P2.y - elIt-&gt;P1.y;
00159                                                 <span class="keywordflow">if</span> (diff &gt; epsilon)
00160                                                 {
00161                                                         inter = elIt-&gt;P1.x + (elIt-&gt;P2.x - elIt-&gt;P1.x) * (currY - elIt-&gt;P1.y) / diff;
00162                                                 }
00163                                                 <span class="keywordflow">else</span>
00164                                                 {
00165                                                         inter = elIt-&gt;P2.x;
00166                                                 }
00167 
00168                                                 <span class="keywordflow">if</span> (!borderFound)
00169                                                 {
00170                                                         left = right = inter;
00171                                                         borderFound = <span class="keyword">true</span>;
00172                                                 }
00173                                                 <span class="keywordflow">else</span>
00174                                                 {
00175                                                         left = <a class="code" href="a04061.html#a0">std::min</a>(left, inter);
00176                                                         right = std::max(right, inter);
00177                                                 }
00178                                         }
00179 
00181 
00182                                         <span class="keywordflow">if</span> (elIt-&gt;P2.y &lt;= currY + quadHeight) 
00183                                         {                                               
00184                                                 <span class="keywordflow">if</span> (!borderFound)
00185                                                 {
00186                                                         left = right = elIt-&gt;P2.x;
00187                                                         borderFound = <span class="keyword">true</span>;
00188                                                 }
00189                                                 <span class="keywordflow">else</span>
00190                                                 {
00191                                                         left = <a class="code" href="a04061.html#a0">std::min</a>(left, elIt-&gt;P2.x);
00192                                                         right = std::max(right, elIt-&gt;P2.x);
00193                                                 }
00194                                         }
00195                                         <span class="keywordflow">else</span>
00196                                         {
00197                                                 <span class="comment">// compute intersection</span>
00198                                                 diff = elIt-&gt;P2.y - elIt-&gt;P1.y;
00199                                                 <span class="keywordflow">if</span> (diff &gt; epsilon)
00200                                                 {
00201                                                         inter = elIt-&gt;P1.x + (elIt-&gt;P2.x - elIt-&gt;P1.x) * (currY + quadHeight - elIt-&gt;P1.y) / diff;
00202                                                 }
00203                                                 <span class="keywordflow">else</span>
00204                                                 {
00205                                                         inter = elIt-&gt;P2.x;
00206                                                 }
00207 
00208                                                 <span class="keywordflow">if</span> (!borderFound)
00209                                                 {
00210                                                         left = right = inter;
00211                                                         borderFound = <span class="keyword">true</span>;
00212                                                 }
00213                                                 <span class="keywordflow">else</span>
00214                                                 {
00215                                                         left = <a class="code" href="a04061.html#a0">std::min</a>(left, inter);
00216                                                         right = std::max(right, inter);
00217                                                 }
00218                                         }
00219                                         
00220                                 }
00221                                 ++ elIt;                                
00222                         }               
00223 
00224                         dest.push_back(std::make_pair(left, right));
00225                 }
00226 
00227                 currY += quadHeight;
00228 
00229         } <span class="keywordflow">while</span> (<a class="code" href="a04223.html#a587">size</a> || aelSize);      
00230 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NL3D_1_1CQuadEffecte1" doxytag="NL3D::CQuadEffect::processPoly" ></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::CQuadEffect::processPoly </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>poly</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>quadWidth</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>float&nbsp;</td>
          <td class="mdname" nowrap> <em>quadHeight</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03271.html#NL3D_1_1CQuadEffectw0">TPoint2DVect</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>dest</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [static]</code></td>
        </tr>

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

<p>
Tesselate the given clipped polygon , by using the given quad dimensions The coordinates of the poly are given in screen coordinate. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>poly</em>&nbsp;</td><td>a polygon that describe the area where datas are taken from. </td></tr>
    <tr><td valign=top><em>quadWidth</em>&nbsp;</td><td>width of the quad </td></tr>
    <tr><td valign=top><em>quadHeight</em>&nbsp;</td><td>height of the quad </td></tr>
    <tr><td valign=top><em>dest</em>&nbsp;</td><td>a vector that will contains the pos of all the quads that cover the poly</td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="a06298.html#l00234">234</a> of file <a class="el" href="a06298.html">quad_effect.cpp</a>.
<p>
References <a class="el" href="a06298.html#l00061">makeRasters()</a>, <a class="el" href="a05981.html#l00104">sint</a>, and <a class="el" href="a06299.html#l00053">TRasters</a>.
<p>
<div class="fragment"><pre>00238 {
00239         <span class="keyword">static</span> <a class="code" href="a03271.html#NL3D_1_1CQuadEffectw1">TRasters</a> rDest;
00240         <span class="keywordtype">float</span> currY;
00241         <a class="code" href="a03271.html#NL3D_1_1CQuadEffecte0">makeRasters</a>(poly, quadWidth, quadHeight, rDest, currY);
00242         <span class="keywordflow">if</span> (dest.size())
00243         {
00244                 TRasters::const_iterator it, endIt = rDest.end();
00245                 <span class="keywordflow">for</span> (it = rDest.begin(); it != endIt; ++it)
00246                 {
00247                         <span class="keyword">const</span> <a class="code" href="a04558.html#a14">sint</a> nbQuad = (<a class="code" href="a04558.html#a14">sint</a>) ceilf( (it-&gt;second - it-&gt;first) / quadWidth);
00248                         <span class="keywordtype">float</span> currX = it-&gt;first;
00249                         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a14">sint</a> k = 0; k &lt; nbQuad; ++k)
00250                         {
00251                                 dest.push_back(<a class="code" href="a03660.html">NLMISC::CVector2f</a>(currX, currY));                                                                                  
00252                                 currX += quadWidth;
00253                         }
00254                         currY += quadHeight;
00255                 }
00256         }
00257 }
</pre></div>    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06299.html">quad_effect.h</a><li><a class="el" href="a06298.html">quad_effect.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 07:33:32 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>