DepthOfFieldCamera Class Reference

#include <DepthOfFieldCamera.h>

Inherits Camera.

Inheritance diagram for DepthOfFieldCamera:

Inheritance graph
[legend]
Collaboration diagram for DepthOfFieldCamera:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DepthOfFieldCamera (Vec3f pos, Vec3f dir, Vec3f up, float angle, int resX, int resY)
virtual ~DepthOfFieldCamera ()
virtual Ray initRay (float x, float y)
void setPos (Vec3f pos)
void setDir (Vec3f dir)
void setUp (Vec3f up)
virtual const Vec3fdir () const
const Vec3fup () const
float angle () const
float aspect () const
virtual const float focusDistance () const
virtual const float aperture () const
int depthSamples () const
void setDepthSamples (unsigned int i)
void setFocusDistance (float f)
void setAperture (float a)
void setSlowCorrect ()
void setFastIncorrect ()

Private Attributes

Vec3f mDir
 View direction.
Vec3f mUp
 Up direction.
float mAngle
 Vertical opening angle in radian.
float mFocus
 Focus length.
float mAspect
 Aspect ratio x/y.
Vec3f mXAxis
 Screen width.
Vec3f mYAxis
 Screen height.
float mFocusDistance
 the distance to the focus plane
float mAperture
 the Aperture opening (how much we should blure)
unsigned int mDepthSamples
 number of samples we use for the depth of field effect
bool mSlowCorrect
 chooses the algorithm we use
int mActSample
 act samples

Detailed Description

Depth of field camera. Rays are sent through a virtual screen perpendicular to the view direction We also use random to get the right blur effect by setting an image plane where every ray from the lens hits at a specific point. The image plane has the distance focusDistance

We have 2 different algorithms here, which can be switched by using setFastIncorrect and setSlowCorrect The first version is faster but incorrect and changes the direction of the camera slightly The second version is correct but needs a plane, intersects it and do some Vec3f calculations, so it is slower some benchmarks for both algorithms: fast way: 70,25s user 0,30s system 168% cpu 41,902 total slow way 69,69s user 0,31s system 161% cpu 43,280 total

the default is the slow algorithm

Author:
Christian Engels

Definition at line 24 of file DepthOfFieldCamera.h.


Constructor & Destructor Documentation

DepthOfFieldCamera::DepthOfFieldCamera ( Vec3f  pos,
Vec3f  dir,
Vec3f  up,
float  angle,
int  resX,
int  resY 
) [inline]

Constructor

Parameters:
pos Position of the camera
dir View direction
up Up direction
angle Vertical opening angle in degree
resX X resolution
resY Y resolution

Definition at line 36 of file DepthOfFieldCamera.h.

References Vec3f::cross(), mAngle, mAspect, mDir, mFocus, mUp, mXAxis, mYAxis, Vec3f::normal(), and Vec3f::normalize().

virtual DepthOfFieldCamera::~DepthOfFieldCamera (  )  [inline, virtual]

Destructor

Definition at line 67 of file DepthOfFieldCamera.h.


Member Function Documentation

virtual Ray DepthOfFieldCamera::initRay ( float  x,
float  y 
) [inline, virtual]

Initialize a ray for pixel. Fractional coordinates are possible

Parameters:
x X coordinate of the pixel
y Y coordinate of the pixel

Implements Camera.

Definition at line 75 of file DepthOfFieldCamera.h.

References dir(), frand(), Ray::hitPoint(), Ray::init(), InfinitePlane::intersect(), mActSample, mAperture, mAspect, mDepthSamples, mDir, mFocus, mFocusDistance, Camera::mPos, Camera::mResX, Camera::mResY, mSlowCorrect, mXAxis, mYAxis, Vec3f::normalize(), and Camera::pos().

void DepthOfFieldCamera::setPos ( Vec3f  pos  )  [inline, virtual]

sets the position of the camera

Implements Camera.

Definition at line 123 of file DepthOfFieldCamera.h.

References Camera::mPos, and Camera::pos().

void DepthOfFieldCamera::setDir ( Vec3f  dir  )  [inline, virtual]

sets the viewing direction of the camera and calculates mXAxis and mYAxis

Implements Camera.

Definition at line 130 of file DepthOfFieldCamera.h.

References Vec3f::cross(), dir(), mAngle, mAspect, mDir, mFocus, Camera::mResX, Camera::mResY, mUp, mXAxis, mYAxis, Vec3f::normal(), and Vec3f::normalize().

void DepthOfFieldCamera::setUp ( Vec3f  up  )  [inline, virtual]

sets the up vector of the camera and calculates the mXAxis and mYAxis

Implements Camera.

Definition at line 146 of file DepthOfFieldCamera.h.

References Vec3f::cross(), mAngle, mAspect, mDir, mFocus, Camera::mResX, Camera::mResY, mUp, mXAxis, mYAxis, Vec3f::normal(), Vec3f::normalize(), and up().

virtual const Vec3f& DepthOfFieldCamera::dir (  )  const [inline, virtual]

Get view direction

Implements Camera.

Definition at line 162 of file DepthOfFieldCamera.h.

References mDir.

Referenced by initRay(), and setDir().

const Vec3f& DepthOfFieldCamera::up (  )  const [inline, virtual]

Get up direction

Implements Camera.

Definition at line 169 of file DepthOfFieldCamera.h.

References mUp.

Referenced by setUp().

float DepthOfFieldCamera::angle (  )  const [inline]

Get vertical opening angle in degree

Definition at line 176 of file DepthOfFieldCamera.h.

References mAngle.

float DepthOfFieldCamera::aspect (  )  const [inline]

Get aspect ratio x/y

Definition at line 183 of file DepthOfFieldCamera.h.

References mAspect.

virtual const float DepthOfFieldCamera::focusDistance (  )  const [inline, virtual]

gets the focus distance of the camera

Implements Camera.

Definition at line 190 of file DepthOfFieldCamera.h.

References mFocusDistance.

virtual const float DepthOfFieldCamera::aperture (  )  const [inline, virtual]

gets the aperture of the camera

Implements Camera.

Definition at line 197 of file DepthOfFieldCamera.h.

References mAperture.

int DepthOfFieldCamera::depthSamples (  )  const [inline, virtual]

number of samples needed (at the moment only>1 for depth of field

Implements Camera.

Definition at line 203 of file DepthOfFieldCamera.h.

References mDepthSamples.

void DepthOfFieldCamera::setDepthSamples ( unsigned int  i  )  [inline, virtual]

set the number of samples we use for the depth of field effect

Implements Camera.

Definition at line 210 of file DepthOfFieldCamera.h.

References LOG, and mDepthSamples.

Referenced by DepthOfFieldCameraFactory::create().

void DepthOfFieldCamera::setFocusDistance ( float  f  )  [inline, virtual]

sets the focus plane

Implements Camera.

Definition at line 218 of file DepthOfFieldCamera.h.

References LOG, and mFocusDistance.

Referenced by DepthOfFieldCameraFactory::create().

void DepthOfFieldCamera::setAperture ( float  a  )  [inline, virtual]

sets the aperture

Implements Camera.

Definition at line 227 of file DepthOfFieldCamera.h.

References LOG, and mAperture.

Referenced by DepthOfFieldCameraFactory::create().

void DepthOfFieldCamera::setSlowCorrect (  )  [inline, virtual]

sets the algorithm to the slow but correct one (for further information see class info for DepthOfFieldCamera)

Implements Camera.

Definition at line 236 of file DepthOfFieldCamera.h.

References mSlowCorrect.

void DepthOfFieldCamera::setFastIncorrect (  )  [inline, virtual]

sets the algorithm to the faster but incorrect one (for further information see class info for DepthOfFieldCamera)

Implements Camera.

Definition at line 243 of file DepthOfFieldCamera.h.

References mSlowCorrect.


Member Data Documentation

Vec3f DepthOfFieldCamera::mDir [private]

View direction.

Definition at line 250 of file DepthOfFieldCamera.h.

Referenced by DepthOfFieldCamera(), dir(), initRay(), setDir(), and setUp().

Vec3f DepthOfFieldCamera::mUp [private]

Up direction.

Definition at line 253 of file DepthOfFieldCamera.h.

Referenced by DepthOfFieldCamera(), setDir(), setUp(), and up().

float DepthOfFieldCamera::mAngle [private]

Vertical opening angle in radian.

Definition at line 256 of file DepthOfFieldCamera.h.

Referenced by angle(), DepthOfFieldCamera(), setDir(), and setUp().

float DepthOfFieldCamera::mFocus [private]

Focus length.

Definition at line 259 of file DepthOfFieldCamera.h.

Referenced by DepthOfFieldCamera(), initRay(), setDir(), and setUp().

float DepthOfFieldCamera::mAspect [private]

Aspect ratio x/y.

Definition at line 262 of file DepthOfFieldCamera.h.

Referenced by aspect(), DepthOfFieldCamera(), initRay(), setDir(), and setUp().

Vec3f DepthOfFieldCamera::mXAxis [private]

Screen width.

Definition at line 265 of file DepthOfFieldCamera.h.

Referenced by DepthOfFieldCamera(), initRay(), setDir(), and setUp().

Vec3f DepthOfFieldCamera::mYAxis [private]

Screen height.

Definition at line 268 of file DepthOfFieldCamera.h.

Referenced by DepthOfFieldCamera(), initRay(), setDir(), and setUp().

float DepthOfFieldCamera::mFocusDistance [private]

the distance to the focus plane

Definition at line 271 of file DepthOfFieldCamera.h.

Referenced by focusDistance(), initRay(), and setFocusDistance().

float DepthOfFieldCamera::mAperture [private]

the Aperture opening (how much we should blure)

Definition at line 274 of file DepthOfFieldCamera.h.

Referenced by aperture(), initRay(), and setAperture().

unsigned int DepthOfFieldCamera::mDepthSamples [private]

number of samples we use for the depth of field effect

Definition at line 277 of file DepthOfFieldCamera.h.

Referenced by depthSamples(), initRay(), and setDepthSamples().

bool DepthOfFieldCamera::mSlowCorrect [private]

chooses the algorithm we use

Definition at line 280 of file DepthOfFieldCamera.h.

Referenced by initRay(), setFastIncorrect(), and setSlowCorrect().

int DepthOfFieldCamera::mActSample [private]

act samples

Definition at line 283 of file DepthOfFieldCamera.h.

Referenced by initRay().


The documentation for this class was generated from the following file:
Generated on Fri Feb 1 00:02:17 2008 for Grayfall by  doxygen 1.5.1