aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a02629.html
blob: 65c8e8928e628a93362ff268d42efea8b873ac40 (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
<!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::CHeatHaze 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::CHeatHaze Class Reference</h1><code>#include &lt;<a class="el" href="a05784.html">heat_haze.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This perform a heat haze effect at the horizon of the scene. This make use of 2d deformation of the frame buffer <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign=top><em>width</em>&nbsp;</td><td>: viewport width </td></tr>
    <tr><td valign=top><em>height</em>&nbsp;</td><td>: viewport height </td></tr>
  </table>
</dl>
<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="a05784.html#l00047">47</a> of file <a class="el" href="a05784.html">heat_haze.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></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="a02629.html#NL3D_1_1CHeatHazee0">performHeatHaze</a> (<a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a632">width</a>, <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a633">height</a>, <a class="el" href="a03348.html">CScene</a> &amp;<a class="el" href="a04223.html#a626">s</a>, <a class="el" href="a02434.html">IDriver</a> *drv)</td></tr>

</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NL3D_1_1CHeatHazee0" doxytag="NL3D::CHeatHaze::performHeatHaze" ></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::CHeatHaze::performHeatHaze </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>width</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>height</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03348.html">CScene</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>s</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a02434.html">IDriver</a> *&nbsp;</td>
          <td class="mdname" nowrap> <em>drv</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>

<p>
Definition at line <a class="el" href="a05783.html#l00051">51</a> of file <a class="el" href="a05783.html">heat_haze.cpp</a>.
<p>
References <a class="el" href="a05363.html#a27">NL3D::_SinWave</a>, <a class="el" href="a06171.html#l00052">NLMISC::CPlane::a</a>, <a class="el" href="a06171.html#l00052">NLMISC::CPlane::c</a>, <a class="el" href="a06171.html#l00052">NLMISC::CPlane::d</a>, <a class="el" href="a05646.html#l01013">height</a>, <a class="el" href="a05972.html#l01090">NLMISC::CMatrix::inverted()</a>, <a class="el" href="a06170.html#l00036">NLMISC::CPlane::make()</a>, <a class="el" href="a06682.html#l00119">NLMISC::CVector::normalize()</a>, <a class="el" href="a05646.html#l00977">s</a>, <a class="el" href="a06682.html#l00136">NLMISC::CVector::set()</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05646.html#l01013">width</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::x</a>, and <a class="el" href="a06673.html#l00051">NLMISC::CVector::z</a>.
<p>
<div class="fragment"><pre>00052         {
00053                 <a class="code" href="a02851.html">NLMISC::CMatrix</a> m  = <a class="code" href="a04223.html#a626">s</a>.getCam()-&gt;getMatrix();
00054                 <a class="code" href="a02851.html">NLMISC::CMatrix</a> im = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1967_1">inverted</a>();
00055 
00056                 <span class="comment">// compute the shape of the horizon</span>
00057 
00058                 <span class="comment">// first we compute the direction of the world up vector in the viewer basis.   </span>
00059                 <a class="code" href="a03128.html">NLMISC::CVector</a> up = im * <a class="code" href="a03128.html#NLMISC_1_1CVectors2">NLMISC::CVector::K</a>;
00060                 <span class="comment">// project onto the I and K vectors</span>
00061                 <span class="keywordtype">float</span> upNorm = (up.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> * up.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a> + up.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a> * up.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>);
00062 
00063                 <span class="keyword">const</span> <span class="keywordtype">float</span> threshold = 10E-4f;
00064 
00065                 <span class="keywordflow">if</span> (upNorm &lt; threshold) <span class="keywordflow">return</span>; <span class="comment">// the viewer is looking above or below  himlself</span>
00066 
00067                 <span class="comment">// Compute the right vector. This is done by intersecting the horizon plane with a near plane. </span>
00068                 <span class="comment">// to do this, we transform the horizon plane into the view basis.This may be optimized, but is not critical.</span>
00069                 <span class="comment">//</span>
00070                 <a class="code" href="a03082.html">NLMISC::CPlane</a> h;
00071                 h.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_2">make</a>(NLMISC::CVector::K, NLMISC::CVector::Null);
00072 
00073                 h = h * m; <span class="comment">// note : this multiply by the transposition of m</span>
00074 
00075                 <span class="comment">// intersect with near plane : we got y = 0, which gives us, as a right vector :</span>
00076                 <span class="comment">// if c is not 0, we got : x = 1 and z = (-a - d) / c as a working solution.</span>
00077                 <span class="comment">// Else we got x = (- d - c )/ a and z = 1</span>
00078 
00079 
00080                 <a class="code" href="a03128.html">NLMISC::CVector</a> right;
00081 
00082                 <span class="keywordflow">if</span> (fabsf(h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo2">c</a>) &gt; threshold)
00083                 {
00084                         right.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2051_8">set</a>(1, 0, (h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo0">a</a> + h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo3">d</a>) / - h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo2">c</a> );
00085                 }
00086                 <span class="keywordflow">else</span>
00087                 {
00088                         right.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2051_8">set</a>( (h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo3">d</a> + h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo2">c</a>) / h.<a class="code" href="a03082.html#NLMISC_1_1CPlaneo0">a</a>, 0,  1);
00089                 }
00090 
00091                 right.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_1">normalize</a>();
00092 
00093                 <span class="comment">// now, find a point on screen that lay on the horizon line</span>
00094                 <span class="keyword">static</span> std::vector&lt;NLMISC::CVector2f&gt; poly(4);          
00095 
00096                 
00097 
00098                 <span class="keyword">const</span> <a class="code" href="a04558.html#a14">sint</a> xCenter = <a class="code" href="a04223.html#a632">width</a> &gt;&gt; 1;
00099                 <span class="keyword">const</span> <a class="code" href="a04558.html#a14">sint</a> yCenter = <a class="code" href="a04223.html#a633">height</a> &gt;&gt; 1;
00100 
00101                 <span class="keyword">const</span> <span class="keywordtype">float</span> horizonHeight = (<span class="keywordtype">float</span>) (<a class="code" href="a04223.html#a633">height</a> &gt;&gt; 2);
00102                 <span class="keyword">const</span> <span class="keywordtype">float</span> horizonWidth  = (<span class="keywordtype">float</span>) (<a class="code" href="a04223.html#a632">width</a>  &gt;&gt; 2);
00103 
00104                 <a class="code" href="a03128.html">NLMISC::CVector</a> tmp ;
00105 
00106                 tmp = horizonWidth * right + horizonHeight * up;
00107                 poly[0] = <a class="code" href="a03660.html">NLMISC::CVector2f</a>(xCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, yCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>) ;
00108                 tmp = horizonWidth   * right - horizonHeight  * up;
00109                 poly[1] = NLMISC::CVector2f(xCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, yCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>) ;
00110                 tmp = - horizonWidth   * right - horizonHeight  * up;
00111                 poly[2] = NLMISC::CVector2f(xCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, yCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>);
00112                 tmp = - horizonWidth   * right + horizonHeight  * up;
00113                 poly[3] = NLMISC::CVector2f(xCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro0">x</a>, yCenter + tmp.<a class="code" href="a03128.html#NLMISC_1_1CVectoro2">z</a>);
00114 
00115 
00116                 CDeform2d::doDeform(poly, drv, &amp;_SinWave);
00117 
00118 
00119 
00120 
00121         }
</pre></div>    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a05784.html">heat_haze.h</a><li><a class="el" href="a05783.html">heat_haze.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:47:03 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>