NL3D::CHeatHaze Class Reference

#include <heat_haze.h>


Detailed Description

This perform a heat haze effect at the horizon of the scene. This make use of 2d deformation of the frame buffer
Parameters:
width : viewport width
height : viewport height
Author:
Nicolas Vizerie

Nevrax France

Date:
2001

Definition at line 47 of file heat_haze.h.

Static Public Member Functions

void performHeatHaze (uint width, uint height, CScene &s, IDriver *drv)


Member Function Documentation

void NL3D::CHeatHaze::performHeatHaze uint  width,
uint  height,
CScene s,
IDriver drv
[static]
 

Definition at line 51 of file heat_haze.cpp.

References NL3D::_SinWave, NLMISC::CPlane::a, NLMISC::CPlane::c, NLMISC::CPlane::d, height, NLMISC::CMatrix::inverted(), NLMISC::CPlane::make(), NLMISC::CVector::normalize(), s, NLMISC::CVector::set(), sint, uint, width, NLMISC::CVector::x, and NLMISC::CVector::z.

00052         {
00053                 NLMISC::CMatrix m  = s.getCam()->getMatrix();
00054                 NLMISC::CMatrix im = m.inverted();
00055 
00056                 // compute the shape of the horizon
00057 
00058                 // first we compute the direction of the world up vector in the viewer basis.   
00059                 NLMISC::CVector up = im * NLMISC::CVector::K;
00060                 // project onto the I and K vectors
00061                 float upNorm = (up.x * up.x + up.z * up.z);
00062 
00063                 const float threshold = 10E-4f;
00064 
00065                 if (upNorm < threshold) return; // the viewer is looking above or below  himlself
00066 
00067                 // Compute the right vector. This is done by intersecting the horizon plane with a near plane. 
00068                 // to do this, we transform the horizon plane into the view basis.This may be optimized, but is not critical.
00069                 //
00070                 NLMISC::CPlane h;
00071                 h.make(NLMISC::CVector::K, NLMISC::CVector::Null);
00072 
00073                 h = h * m; // note : this multiply by the transposition of m
00074 
00075                 // intersect with near plane : we got y = 0, which gives us, as a right vector :
00076                 // if c is not 0, we got : x = 1 and z = (-a - d) / c as a working solution.
00077                 // Else we got x = (- d - c )/ a and z = 1
00078 
00079 
00080                 NLMISC::CVector right;
00081 
00082                 if (fabsf(h.c) > threshold)
00083                 {
00084                         right.set(1, 0, (h.a + h.d) / - h.c );
00085                 }
00086                 else
00087                 {
00088                         right.set( (h.d + h.c) / h.a, 0,  1);
00089                 }
00090 
00091                 right.normalize();
00092 
00093                 // now, find a point on screen that lay on the horizon line
00094                 static std::vector<NLMISC::CVector2f> poly(4);          
00095 
00096                 
00097 
00098                 const sint xCenter = width >> 1;
00099                 const sint yCenter = height >> 1;
00100 
00101                 const float horizonHeight = (float) (height >> 2);
00102                 const float horizonWidth  = (float) (width  >> 2);
00103 
00104                 NLMISC::CVector tmp ;
00105 
00106                 tmp = horizonWidth * right + horizonHeight * up;
00107                 poly[0] = NLMISC::CVector2f(xCenter + tmp.x, yCenter + tmp.z) ;
00108                 tmp = horizonWidth   * right - horizonHeight  * up;
00109                 poly[1] = NLMISC::CVector2f(xCenter + tmp.x, yCenter + tmp.z) ;
00110                 tmp = - horizonWidth   * right - horizonHeight  * up;
00111                 poly[2] = NLMISC::CVector2f(xCenter + tmp.x, yCenter + tmp.z);
00112                 tmp = - horizonWidth   * right + horizonHeight  * up;
00113                 poly[3] = NLMISC::CVector2f(xCenter + tmp.x, yCenter + tmp.z);
00114 
00115 
00116                 CDeform2d::doDeform(poly, drv, &_SinWave);
00117 
00118 
00119 
00120 
00121         }


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:47:03 2004 for NeL by doxygen 1.3.6