NL3D::CViewport Class Reference

#include <viewport.h>


Detailed Description

CViewport is the description of the viewport used to render with a driver

Definition at line 52 of file viewport.h.

Public Member Functions

 CViewport ()
 Default constructor. Setup a fullscreen viewport.

float getHeight () const
void getRayWithPoint (float x, float y, CVector &pos, CVector &dir, const CMatrix &camMatrix, const CFrustum &camFrust) const
void getValues (float &x, float &y, float &width, float &height) const
float getWidth () const
float getX () const
float getY () const
void init (float x, float y, float width, float height)
void init16_9 ()
 Setup a 16/9 viewport.

void initFullScreen ()
 Setup a fullscreen viewport.


Private Attributes

float _Height
float _Width
float _X
float _Y


Constructor & Destructor Documentation

NL3D::CViewport::CViewport  ) 
 

Default constructor. Setup a fullscreen viewport.

Definition at line 37 of file viewport.cpp.

References initFullScreen(), and NL3D_MEM_VIEWPORT.

00038 {
00039         NL3D_MEM_VIEWPORT
00040         initFullScreen ();
00041 }


Member Function Documentation

float NL3D::CViewport::getHeight  )  const [inline]
 

Definition at line 105 of file viewport.h.

Referenced by NL3D::CFlareModel::traverseRender().

00105 { return _Height; }     

void NL3D::CViewport::getRayWithPoint float  x,
float  y,
CVector pos,
CVector dir,
const CMatrix camMatrix,
const CFrustum camFrust
const
 

Get a 3d ray with a 2d point

Parameters:
x is the x coordinate in the window coordinate system of the 2d point.
y is the y coordinate in the window coordinate system of the 2d point.
pos gets the position of a 3d point on the ray. It is also the position of the camera
dir gets the direction of the ray. The direction is the same than the camera one. It is NOT normalized.
camMatrix is the matrix of the camera in use in this viewport.
camFrust is the frustum of the camera in use in this viewport.

Definition at line 81 of file viewport.cpp.

References NLMISC::CMatrix::getPos(), NL3D::CFrustum::getValues(), NL3D_MEM_VIEWPORT, NLMISC::CMatrix::setPos(), NLMISC::CVector::x, x, NLMISC::CVector::y, y, and NLMISC::CVector::z.

Referenced by NL3D::CEvent3dMouseListener::operator()().

00082 {
00083         NL3D_MEM_VIEWPORT
00084         float xVP=(x-_X)/_Width;
00085         float yVP=(y-_Y)/_Height;
00086 
00087         // Pos of the ray
00088         pos= camMatrix.getPos();
00089 
00090         // Get camera frustrum
00091         float left;
00092         float right;
00093         float bottom;
00094         float top;
00095         float znear;
00096         float zfar;
00097         camFrust.getValues (left, right, bottom, top, znear, zfar);
00098 
00099         // Get a local direction
00100         dir.x=left+(right-left)*xVP;
00101         dir.y=znear;
00102         dir.z=bottom+(top-bottom)*yVP;
00103 
00104         // Get a world direction
00105         CMatrix mat=camMatrix;
00106         mat.setPos (CVector (0,0,0));
00107         dir=mat*dir;
00108 }

void NL3D::CViewport::getValues float &  x,
float &  y,
float &  width,
float &  height
const [inline]
 

Get the viewport values

Parameters:
x get the x coordinate of the left edge of the viewport in the window coordinate system . Must be between 0.f and 1.f.
y get the y coordinate of the bottom edge of the viewport in the window coordinate system . Must be between 0.f and 1.f.
width get the width of the view port. Must be between 0.f and 1.f-x.
height get the height of the view port. Must be between 0.f and 1.f-y.

Definition at line 93 of file viewport.h.

References height, NL3D_MEM_VIEWPORT, width, x, and y.

00094         {
00095                 NL3D_MEM_VIEWPORT
00096                 x=_X;
00097                 y=_Y;
00098                 width=_Width;
00099                 height=_Height;
00100         }

float NL3D::CViewport::getWidth  )  const [inline]
 

Definition at line 104 of file viewport.h.

Referenced by NL3D::CFlareModel::traverseRender().

00104 { return _Width; }      

float NL3D::CViewport::getX  )  const [inline]
 

Definition at line 102 of file viewport.h.

Referenced by NL3D::CFlareModel::traverseRender().

00102 { return _X; }  

float NL3D::CViewport::getY  )  const [inline]
 

Definition at line 103 of file viewport.h.

Referenced by NL3D::CFlareModel::traverseRender().

00103 { return _Y; }  

void NL3D::CViewport::init float  x,
float  y,
float  width,
float  height
 

Constructor

Parameters:
x coordinate of the left edge of the viewport in the window coordinate system . Must be between 0.f and 1.f.
y coordinate of the bottom edge of the viewport in the window coordinate system . Must be between 0.f and 1.f.
width of the view port. Must be between 0.f and 1.f-x.
height of the view port. Must be between 0.f and 1.f-y.

Definition at line 44 of file viewport.cpp.

References NLMISC::clamp(), height, NL3D_MEM_VIEWPORT, width, x, and y.

Referenced by NL3D::CCloud::genBill(), NL3D::CShadowMapManager::renderGenerate(), and NL3D::CDriverGL::setupViewport().

00045 {
00046         NL3D_MEM_VIEWPORT
00047         // Simply copy
00048         _X=x;
00049         clamp (_X, 0.f, 1.f);
00050         _Y=y;
00051         clamp (_Y, 0.f, 1.f);
00052         _Width=width;
00053         clamp (_Width, 0.f, 1.f-_X);
00054         _Height=height;
00055         clamp (_Height, 0.f, 1.f-_Y);
00056 }

void NL3D::CViewport::init16_9  ) 
 

Setup a 16/9 viewport.

Definition at line 70 of file viewport.cpp.

References NL3D_MEM_VIEWPORT.

00071 {
00072         NL3D_MEM_VIEWPORT
00073         // Very easy
00074         _X=0.f;
00075         _Y=(1.f-0.75f)/2;
00076         _Width=1.f;
00077         _Height=0.75f;
00078 }

void NL3D::CViewport::initFullScreen  ) 
 

Setup a fullscreen viewport.

Definition at line 59 of file viewport.cpp.

References NL3D_MEM_VIEWPORT.

Referenced by NL3D::CEvent3dMouseListener::CEvent3dMouseListener(), CViewport(), NL3D::CCloud::genBill(), NL3D::CShadowMapManager::renderGenerate(), and NL3D::CDriverUser::setDisplay().

00060 {
00061         NL3D_MEM_VIEWPORT
00062         // Very easy
00063         _X=0.f;
00064         _Y=0.f;
00065         _Width=1.f;
00066         _Height=1.f;
00067 }


Field Documentation

float NL3D::CViewport::_Height [private]
 

Definition at line 112 of file viewport.h.

float NL3D::CViewport::_Width [private]
 

Definition at line 111 of file viewport.h.

float NL3D::CViewport::_X [private]
 

Definition at line 109 of file viewport.h.

float NL3D::CViewport::_Y [private]
 

Definition at line 110 of file viewport.h.


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 08:26:17 2004 for NeL by doxygen 1.3.6