GClasses
GClasses::GCamera Class Reference

Detailed Description

This camera assumes the canvas is specified in cartesian coordinates. The 3D space is based on a right-handed coordinate system. (So if x goes to the right and y goes up, then z comes out of the screen toward you.)

#include <G3D.h>

Inheritance diagram for GClasses::GCamera:
GClasses::GRayTraceCamera

Public Member Functions

 GCamera (int width, int height)
 width and height specify the size of the image that this camera will produce More...
 
 GCamera (GDomNode *pNode)
 deserializing constructor More...
 
virtual ~GCamera ()
 
void computeRayDirection (int x, int y, G3DVector *pOutRay)
 Computes the direction that a ray must travel from lookFromPoint() for the specified pixel coordinates (relative to the bottom-left corner of the view image). Note that the ray is not normalized. More...
 
G3DReal halfViewHeight ()
 Returns tan(viewAngle / 2) More...
 
int imageHeight ()
 Returns the height of the 2-D image this camera will produce. More...
 
int imageWidth ()
 Returns the width of the 2-D image this camera will produce. More...
 
const G3DVectorlookDirection ()
 Returns the direction in which this camera is facing. More...
 
G3DVectorlookFromPoint ()
 Returns a reference to the location of this camera. (You can set the values in the vector this returns to move the camera.) More...
 
void project (const G3DVector *pPoint, G3DVector *pOut)
 Projects the 3D point onto the canvas. The x and y position in the output vector specify the location where the point projects onto the camera's canvas (positive x goes to the right with 0 at the left side, positive y goes up with 0 at the bottom). The z position specifies the distance from the camera. If the z position is <= 0, then x and y are set to 0. More...
 
virtual GDomNodeserialize (GDom *pDoc) const
 serializes this object More...
 
void setDirection (G3DVector *pDirection, G3DReal rollRads)
 Specifies the direction that the camera faces, and the roll in radians. (If rollRads is zero, then the horizon of the XZ-plane would appear as a horizontal line with positive Y above and negative Y below.) More...
 
void setDirection (G3DVector *pDirection, G3DVector *pUpVector)
 If pUpVector is not orthogonal to pDirection, it will be changed to the nearest vector that is orthogonal to pDirection. More...
 
void setImageSize (int width, int height)
 Specifies the size of the 2-D image this camera will produce. More...
 
void setViewAngle (G3DReal val)
 This is the vertical view angle in radians. More...
 
const G3DVectorviewSideVector ()
 Returns the right side vector with respect to this camera. More...
 
const G3DVectorviewUpVector ()
 Returns the up vector with respect to this camera. More...
 

Protected Attributes

G3DReal m_halfViewHeight
 
G3DVector m_lookDirection
 
G3DVector m_lookFromPoint
 
int m_nHeight
 
int m_nWidth
 
G3DVector m_viewSideVector
 
G3DVector m_viewUpVector
 

Constructor & Destructor Documentation

GClasses::GCamera::GCamera ( int  width,
int  height 
)
inline

width and height specify the size of the image that this camera will produce

GClasses::GCamera::GCamera ( GDomNode pNode)

deserializing constructor

virtual GClasses::GCamera::~GCamera ( )
inlinevirtual

Member Function Documentation

void GClasses::GCamera::computeRayDirection ( int  x,
int  y,
G3DVector pOutRay 
)

Computes the direction that a ray must travel from lookFromPoint() for the specified pixel coordinates (relative to the bottom-left corner of the view image). Note that the ray is not normalized.

G3DReal GClasses::GCamera::halfViewHeight ( )
inline

Returns tan(viewAngle / 2)

int GClasses::GCamera::imageHeight ( )
inline

Returns the height of the 2-D image this camera will produce.

int GClasses::GCamera::imageWidth ( )
inline

Returns the width of the 2-D image this camera will produce.

const G3DVector* GClasses::GCamera::lookDirection ( )
inline

Returns the direction in which this camera is facing.

G3DVector* GClasses::GCamera::lookFromPoint ( )
inline

Returns a reference to the location of this camera. (You can set the values in the vector this returns to move the camera.)

void GClasses::GCamera::project ( const G3DVector pPoint,
G3DVector pOut 
)

Projects the 3D point onto the canvas. The x and y position in the output vector specify the location where the point projects onto the camera's canvas (positive x goes to the right with 0 at the left side, positive y goes up with 0 at the bottom). The z position specifies the distance from the camera. If the z position is <= 0, then x and y are set to 0.

virtual GDomNode* GClasses::GCamera::serialize ( GDom pDoc) const
virtual

serializes this object

Reimplemented in GClasses::GRayTraceCamera.

void GClasses::GCamera::setDirection ( G3DVector pDirection,
G3DReal  rollRads 
)

Specifies the direction that the camera faces, and the roll in radians. (If rollRads is zero, then the horizon of the XZ-plane would appear as a horizontal line with positive Y above and negative Y below.)

void GClasses::GCamera::setDirection ( G3DVector pDirection,
G3DVector pUpVector 
)

If pUpVector is not orthogonal to pDirection, it will be changed to the nearest vector that is orthogonal to pDirection.

void GClasses::GCamera::setImageSize ( int  width,
int  height 
)
inline

Specifies the size of the 2-D image this camera will produce.

void GClasses::GCamera::setViewAngle ( G3DReal  val)

This is the vertical view angle in radians.

const G3DVector* GClasses::GCamera::viewSideVector ( )
inline

Returns the right side vector with respect to this camera.

const G3DVector* GClasses::GCamera::viewUpVector ( )
inline

Returns the up vector with respect to this camera.

Member Data Documentation

G3DReal GClasses::GCamera::m_halfViewHeight
protected
G3DVector GClasses::GCamera::m_lookDirection
protected
G3DVector GClasses::GCamera::m_lookFromPoint
protected
int GClasses::GCamera::m_nHeight
protected
int GClasses::GCamera::m_nWidth
protected
G3DVector GClasses::GCamera::m_viewSideVector
protected
G3DVector GClasses::GCamera::m_viewUpVector
protected