From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02937.html | 443 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 443 insertions(+) create mode 100644 docs/doxygen/nel/a02937.html (limited to 'docs/doxygen/nel/a02937.html') diff --git a/docs/doxygen/nel/a02937.html b/docs/doxygen/nel/a02937.html new file mode 100644 index 00000000..a5d827ee --- /dev/null +++ b/docs/doxygen/nel/a02937.html @@ -0,0 +1,443 @@ + + +NeL: NL3D::CMotionBlur class Reference + + + +
+

NL3D::CMotionBlur Class Reference

#include <motion_blur.h> +

+


Detailed Description

+This class help perfoming motion blur on a portion of the screen
Author:
Nicolas Vizerie

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 45 of file motion_blur.h. + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

 CMotionBlur ()
void performMotionBlur (IDriver *driver, float motionBlurAmount)
void releaseMotionBlur ()
 release the resources used by motion blur

void startMotionBlur (uint x, uint y, uint width, uint height)

Protected Attributes

uint _H
NLMISC::CSmartPtr< ITexture_Tex
uint _W
uint _X
uint _Y
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CMotionBlur::CMotionBlur  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 39 of file motion_blur.cpp. +

+

00039                          : _Tex(NULL), _X(0), _Y(0), _W(0), _H(0)
+00040 {
+00041 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CMotionBlur::performMotionBlur IDriver driver,
float  motionBlurAmount
+
+ + + + + +
+   + + +

+perform motion blur, using the given driver This can only have been called between a startMotionBlur / releaseMotionBlur pair. It must be called after the scene has been drawn of course. WARNING : this change the projection matrix and the frustum in the driver.

Parameters:
+ + +
motionBlurAmount ranges from 0.f to 1.f. Blend using the following : motionBlurAmount * previous frame + (1 - motionBlurAmount) * current Frame buffer state
+
+ +

+Definition at line 62 of file motion_blur.cpp. +

+References _H, _W, NL3D::IDriver::activeVertexBuffer(), NL3D::IDriver::copyFrameBufferToTexture(), NL3D::IDriver::getWindowSize(), height, nlassert, NLMISC::raiseToNextPowerOf2(), NL3D::IDriver::renderQuads(), NL3D::CMaterial::setBlend(), NL3D::CMaterial::setBlendFunc(), NL3D::CMaterial::setColor(), NL3D::CMaterial::setDoubleSided(), NL3D::IDriver::setFrustum(), NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setTexCoord(), NL3D::CMaterial::setTexture(), NL3D::IDriver::setupModelMatrix(), NL3D::IDriver::setupViewMatrix(), NL3D::CVertexBuffer::setVertexCoord(), NL3D::CVertexBuffer::setVertexFormat(), NL3D::CMaterial::setZFunc(), NL3D::CMaterial::setZWrite(), NL3D::CMaterial::texEnvArg0Alpha(), NL3D::CMaterial::texEnvOpAlpha(), NL3D::CMaterial::texEnvOpRGB(), uint, uint32, uint8, and width. +

+

00063 {
+00064         nlassert(_Tex) ;  //start motion blur has not been called !!
+00065         nlassert(driver) ;
+00066         nlassert(motionBlurAmount >= 0.f && motionBlurAmount <= 1.f) ;
+00067         
+00068         static CVertexBuffer  vb ;
+00069         vb.setVertexFormat(CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag ) ;
+00070         vb.setNumVertices(4) ;
+00071 
+00072         uint32 width, height ;
+00073         driver->getWindowSize(width, height) ;
+00074 
+00075         float widthRatio = _W / (float) NLMISC::raiseToNextPowerOf2 (_W) ;
+00076         float heightRatio = _H / (float) NLMISC::raiseToNextPowerOf2 (_H) ;
+00077 
+00078         driver->setFrustum(0, (float) width, 0, (float) height, -1, 1, false) ;
+00079 
+00080         for (uint sn = 0 ; sn < 2 ; ++sn)
+00081         {
+00082                 vb.setTexCoord(0, sn, CUV(0, 0)) ; 
+00083                 vb.setTexCoord(1, sn, CUV(widthRatio, 0)) ; 
+00084                 vb.setTexCoord(2, sn, CUV(widthRatio, heightRatio)) ; 
+00085                 vb.setTexCoord(3, sn, CUV(0, heightRatio)) ; 
+00086         }
+00087 
+00088 
+00089         static CMaterial mbMat ;
+00090         static bool matSetup = false ; // set to true when mbMat has Been setup
+00091         if (!matSetup)
+00092         {
+00093                 mbMat.setBlend(true) ;
+00094                 mbMat.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha) ;       
+00095                 mbMat.setZWrite(false) ;
+00096                 mbMat.setZFunc(CMaterial::always) ;     
+00097                 // stage 0          
+00098                 mbMat.setTexture(0, _Tex) ;
+00099                 mbMat.texEnvOpRGB(0, CMaterial::Replace );
+00100 
+00101                 mbMat.texEnvArg0Alpha(0, CMaterial::Diffuse, CMaterial::SrcAlpha);
+00102                 mbMat.texEnvOpAlpha(0, CMaterial::Replace);
+00103                 
+00104                 mbMat.setDoubleSided(true) ;
+00105                 matSetup = true ;
+00106         }
+00107 
+00108 
+00109         mbMat.setColor(CRGBA(255, 255, 255, (uint8) (255.f * motionBlurAmount) ) ) ;            
+00110 
+00111 
+00112         vb.setVertexCoord(0, CVector((float) _X, 0, 0) ) ;
+00113         vb.setVertexCoord(1, CVector((float) (_X + _W), 0 ,0) ) ;
+00114         vb.setVertexCoord(2, CVector((float) (_X + _W), 0, (float) (_Y + _H) ) );
+00115         vb.setVertexCoord(3, CVector(0 , 0, (float) (_Y + _H) ) ) ;
+00116 
+00117         driver->setupViewMatrix(CMatrix::Identity) ;
+00118         driver->setupModelMatrix(CMatrix::Identity) ;
+00119         
+00120 
+00121         driver->activeVertexBuffer(vb) ;
+00122         driver->renderQuads(mbMat, 0, 1) ;
+00123 
+00124         // blit back frame buffer to save this frame
+00125 
+00126 
+00127 
+00128         driver->copyFrameBufferToTexture(_Tex, 0, 0, 0, _X, _Y, _W, _H) ;
+00129         
+00130 
+00131 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CMotionBlur::releaseMotionBlur  ) 
+
+ + + + + +
+   + + +

+release the resources used by motion blur +

+ +

+Definition at line 56 of file motion_blur.cpp. +

+References _H, and _W. +

+

00057 {
+00058         _Tex = NULL ;
+00059         _X = _Y = _W = _H = 0 ;
+00060 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CMotionBlur::startMotionBlur uint  x,
uint  y,
uint  width,
uint  height
+
+ + + + + +
+   + + +

+Must be called before performing motion blur on a image sequence. Motion blur is performed on a rectangular area. 2 calls -> nlassert. Once motion blur must be stopped, you must call releaseMotionBlur.

Parameters:
+ + + + + +
x the x position of the top-left coener of the rectangle on which motion blur apply
y the y position of the top-left coener of the rectangle on which motion blur apply
width the width of the rectangle on which motion blur apply
height the height of the rectangle on which motion blur apply
+
+ +

+Definition at line 45 of file motion_blur.cpp. +

+References _H, _W, height, nlassert, uint, width, x, and y. +

+

00046 {
+00047         nlassert(width > 0 && height > 0) ;
+00048         _X = x ;
+00049         _Y = y ;
+00050         _W = width ;
+00051         _H = height ;
+00052         _Tex = new CTextureBlank ;
+00053         _Tex->resize(NLMISC::raiseToNextPowerOf2(width), NLMISC::raiseToNextPowerOf2(height)) ;
+00054 }
+
+


Field Documentation

+

+ + + + +
+ + +
uint NL3D::CMotionBlur::_H [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 73 of file motion_blur.h. +

+Referenced by performMotionBlur(), releaseMotionBlur(), and startMotionBlur().

+

+ + + + +
+ + +
NLMISC::CSmartPtr<ITexture> NL3D::CMotionBlur::_Tex [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 72 of file motion_blur.h.

+

+ + + + +
+ + +
uint NL3D::CMotionBlur::_W [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 73 of file motion_blur.h. +

+Referenced by performMotionBlur(), releaseMotionBlur(), and startMotionBlur().

+

+ + + + +
+ + +
uint NL3D::CMotionBlur::_X [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 73 of file motion_blur.h.

+

+ + + + +
+ + +
uint NL3D::CMotionBlur::_Y [protected] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 73 of file motion_blur.h.

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:56:29 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1