Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

osg::Camera Class Reference

Camera class for encapsulating the view position and orientation and projection (lens) used. More...

Inheritance diagram for osg::Camera:

Inheritance graph
[legend]
List of all members.

Public Types

enum  ProjectionType { ORTHO, ORTHO2D, FRUSTUM, PERSPECTIVE }
 Range of projection types. More...

enum  AdjustAspectRatioMode { ADJUST_VERTICAL, ADJUST_HORIZONTAL, ADJUST_NONE }
 Use in combination with adjustAspectRatio, to control the change in frustum clipping planes to account for changes in windows aspect ratio,. More...

enum  LookAtType { USE_HOME_POSITON, USE_EYE_AND_QUATERNION, USE_EYE_CENTER_AND_UP }
enum  TransformMode { EYE_TO_MODEL, MODEL_TO_EYE, NO_ATTACHED_TRANSFORM }
enum  FusionDistanceMode { PROPORTIONAL_TO_LOOK_DISTANCE, PROPORTIONAL_TO_SCREEN_DISTANCE }

Public Methods

 Camera (DisplaySettings *ds=NULL)
 Camera (const Camera &)
Camera & operator= (const Camera &)
virtual ~Camera ()
const ProjectionType getProjectionType () const
 Get the projection type set by setOtho,setOtho2D,setFrustum, and set perspective methods.

void setOrtho (const double left, const double right, const double bottom, const double top, const double zNear, const double zFar)
 Set a orthographic projection.

void setOrtho2D (const double left, const double right, const double bottom, const double top)
 Set a 2D orthographic projection.

void setFrustum (const double left, const double right, const double bottom, const double top, const double zNear, const double zFar)
 Set a perspective projection.

void setPerspective (const double fovy, const double aspectRatio, const double zNear, const double zFar)
 Set a symmetrical perspective projection, See gluPerspective for further details.

void setFOV (const double fovx, const double fovy, const double zNear, const double zFar)
 Set a sysmmetical perspective projection using field of view.

void setNearFar (const double zNear, const double zFar)
 Set the near and far clipping planes.

void setAdjustAspectRatioMode (const AdjustAspectRatioMode aam)
 Set the way that the vertical or horizontal dimensions of the window are adjusted on a resize.

const AdjustAspectRatioMode getAdjustAspectRatioMode () const
 Get the way that the vertical or horizontal dimensions of the window are adjusted on a resize.

void adjustAspectRatio (const double newAspectRatio)
 Adjust the clipping planes to account for a new window aspect ratio.

void adjustAspectRatio (const double newAspectRatio, const AdjustAspectRatioMode aa)
 Adjust the clipping planes to account for a new window aspect ratio.

const double left () const
const double right () const
const double bottom () const
const double top () const
const double zNear () const
const double zFar () const
const double calc_fovy () const
 Calculate and return the equivalent fovx for the current project setting.

const double calc_fovx () const
 Calculate and return the equivalent fovy for the current project setting.

const double calc_aspectRatio () const
 Calculate and return the projection aspect ratio.

const LookAtType getLookAtType () const
void home ()
 hardwired home view for now, looking straight down the Z axis at the origin, with 'up' being the y axis.

void setView (const Vec3 &eyePoint, const Vec3 &lookPoint, const Vec3 &upVector)
 Set the View, the up vector should be orthogonal to the look vector.

void setLookAt (const Vec3 &eye, const Vec3 &center, const Vec3 &up)
 set the position and orientation of the camera, using the same convention as gluLookAt.

void setLookAt (const double eyeX, const double eyeY, const double eyeZ, const double centerX, const double centerY, const double centerZ, const double upX, const double upY, const double upZ)
 set the position and orientation of the camera, using the same convention as gluLookAt.

void transformLookAt (const Matrix &matrix)
 post multiple the existing eye point and orientation by matrix.

void ensureOrthogonalUpVector ()
const Vec3getEyePoint () const
 get the eye point.

const Vec3getCenterPoint () const
 get the center point.

const Vec3getUpVector () const
 get the up vector

const Vec3 getLookVector () const
 calculate look vector.

const Vec3 getSideVector () const
 calculate side vector.

float getLookDistance () const
 calculate the look distance which is the distance between the eye and the center.

void attachTransform (const TransformMode mode, Matrix *modelTransform=0)
 Attach a transform matrix which is applied after the camera look at.

MatrixgetTransform (const TransformMode mode)
const MatrixgetTransform (const TransformMode mode) const
void setFusionDistanceMode (FusionDistanceMode mode)
 Set the mode of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.

FusionDistanceMode getFusionDistanceMode () const
 Get the mode of the fusion distance function.

void setFusionDistanceRatio (float ratio)
 Set the ratio of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.

float getFusionDistanceRatio () const
 Get the ratio of the fusion distance function.

const float getFusionDistance () const
 Calculate and return the fusion distance, using the FusionDistanceFunction.

void setScreenDistance (float screenDistance)
 Set the physical distance between the viewers eyes and the display system.

const float getScreenDistance () const
 Get the physical distance between the viewers eyes and the display system.

const Matrix getProjectionMatrix () const
 Get the Projection Matrix.

const Matrix getModelViewMatrix () const
 Get the ModelView matrix.

Polytope getViewFrustum () const
 Get the camera view frustum.


Protected Methods

void copy (const Camera &)

Protected Attributes

ProjectionType _projectionType
AdjustAspectRatioMode _adjustAspectRatioMode
double _left
double _right
double _bottom
double _top
double _zNear
double _zFar
LookAtType _lookAtType
Vec3 _eye
Vec3 _center
Vec3 _up
TransformMode _attachedTransformMode
ref_ptr< Matrix_eyeToModelTransform
ref_ptr< Matrix_modelToEyeTransform
float _screenDistance
FusionDistanceMode _fusionDistanceMode
float _fusionDistanceRatio

Detailed Description

Camera class for encapsulating the view position and orientation and projection (lens) used.

Creates a projection and modelview matrices which can be used to set OpenGL's PROJECTION and MODELVIEW matrices respectively.


Member Enumeration Documentation

enum osg::Camera::AdjustAspectRatioMode
 

Use in combination with adjustAspectRatio, to control the change in frustum clipping planes to account for changes in windows aspect ratio,.

Enumeration values:
ADJUST_VERTICAL 
ADJUST_HORIZONTAL 
ADJUST_NONE 

enum osg::Camera::FusionDistanceMode
 

Enumeration values:
PROPORTIONAL_TO_LOOK_DISTANCE 
PROPORTIONAL_TO_SCREEN_DISTANCE 

enum osg::Camera::LookAtType
 

Enumeration values:
USE_HOME_POSITON 
USE_EYE_AND_QUATERNION 
USE_EYE_CENTER_AND_UP 

enum osg::Camera::ProjectionType
 

Range of projection types.

ORTHO2D is a special case of ORTHO where the near and far planes are equal to -1 and 1 respectively. PERSPECTIVE is a special case of FRUSTUM where the left & right and bottom and top and symmetrical.

Enumeration values:
ORTHO 
ORTHO2D 
FRUSTUM 
PERSPECTIVE 

enum osg::Camera::TransformMode
 

Enumeration values:
EYE_TO_MODEL 
MODEL_TO_EYE 
NO_ATTACHED_TRANSFORM 


Constructor & Destructor Documentation

osg::Camera::Camera DisplaySettings   ds = NULL
 

osg::Camera::Camera const Camera &   
 

virtual osg::Camera::~Camera   [virtual]
 


Member Function Documentation

void osg::Camera::adjustAspectRatio const double    newAspectRatio,
const AdjustAspectRatioMode    aa
 

Adjust the clipping planes to account for a new window aspect ratio.

Typicall used after resizeing a window. Aspect ratio is defined as width/height.

void osg::Camera::adjustAspectRatio const double    newAspectRatio [inline]
 

Adjust the clipping planes to account for a new window aspect ratio.

Typically used after resizing a window. Aspect ratio is defined as width/height.

void osg::Camera::attachTransform const TransformMode    mode,
Matrix   modelTransform = 0
 

Attach a transform matrix which is applied after the camera look at.

The attached matrix can work in two ways, either as transform of the eye into the model coordinates - EYE_TO_MODEL, or as a transform of the model to the eye - MODEL_TO_EYE. The former is equivalent to attaching a camera internal to the scene graph. The later is equivalent to adding a osg::Transform at root of the scene to move the scene to the eye point. Typical used in conjunction with the LookAt position set to home, in which case it is simply treated as a model view matrix. If the same behavior as IRIS Performer's setViewMat is desired then set the LookAt to be (0,0,0),(0,1,0),(0,0,1) since Performer's default direction is along the y axis, unlike OpenGL and the default OSG. If modelTransfor is NULL then do not use any model transform - just use the basic LookAt values. note: Camera internals maintains the both EYE_TO_MODEL and MODEL_TO_EYE internally and ensures that they are the inverse of one another.

const double osg::Camera::bottom   const [inline]
 

const double osg::Camera::calc_aspectRatio   const
 

Calculate and return the projection aspect ratio.

Aspect ratio is defined as width/height.

const double osg::Camera::calc_fovx   const
 

Calculate and return the equivalent fovy for the current project setting.

This value is only valid for when a symmetric perspective projection exists. i.e. getProjectionType()==PERSPECTIVE.

const double osg::Camera::calc_fovy   const
 

Calculate and return the equivalent fovx for the current project setting.

This value is only valid for when a symmetric perspective projection exists. i.e. getProjectionType()==PERSPECTIVE.

void osg::Camera::copy const Camera &    [protected]
 

void osg::Camera::ensureOrthogonalUpVector  
 

const AdjustAspectRatioMode osg::Camera::getAdjustAspectRatioMode   const [inline]
 

Get the way that the vertical or horizontal dimensions of the window are adjusted on a resize.

const Vec3& osg::Camera::getCenterPoint   const [inline]
 

get the center point.

const Vec3& osg::Camera::getEyePoint   const [inline]
 

get the eye point.

const float osg::Camera::getFusionDistance   const
 

Calculate and return the fusion distance, using the FusionDistanceFunction.

FusionDistanceMode osg::Camera::getFusionDistanceMode   const [inline]
 

Get the mode of the fusion distance function.

float osg::Camera::getFusionDistanceRatio   const [inline]
 

Get the ratio of the fusion distance function.

const LookAtType osg::Camera::getLookAtType   const [inline]
 

float osg::Camera::getLookDistance   const [inline]
 

calculate the look distance which is the distance between the eye and the center.

const Vec3 osg::Camera::getLookVector   const
 

calculate look vector.

const Matrix osg::Camera::getModelViewMatrix   const
 

Get the ModelView matrix.

If a ModelTransform is supplied then the ModelView matrix is created by multiplying the current LookAt by ModelTransform. Otherwise it is simply created by using the current LookAt, equivalent to using gluLookAt.

const Matrix osg::Camera::getProjectionMatrix   const
 

Get the Projection Matrix.

const ProjectionType osg::Camera::getProjectionType   const [inline]
 

Get the projection type set by setOtho,setOtho2D,setFrustum, and set perspective methods.

const float osg::Camera::getScreenDistance   const [inline]
 

Get the physical distance between the viewers eyes and the display system.

const Vec3 osg::Camera::getSideVector   const
 

calculate side vector.

const Matrix* osg::Camera::getTransform const TransformMode    mode const
 

Matrix* osg::Camera::getTransform const TransformMode    mode
 

const Vec3& osg::Camera::getUpVector   const [inline]
 

get the up vector

Polytope osg::Camera::getViewFrustum   const [inline]
 

Get the camera view frustum.

void osg::Camera::home  
 

hardwired home view for now, looking straight down the Z axis at the origin, with 'up' being the y axis.

const double osg::Camera::left   const [inline]
 

Camera& osg::Camera::operator= const Camera &   
 

const double osg::Camera::right   const [inline]
 

void osg::Camera::setAdjustAspectRatioMode const AdjustAspectRatioMode    aam [inline]
 

Set the way that the vertical or horizontal dimensions of the window are adjusted on a resize.

void osg::Camera::setFOV const double    fovx,
const double    fovy,
const double    zNear,
const double    zFar
 

Set a sysmmetical perspective projection using field of view.

void osg::Camera::setFrustum const double    left,
const double    right,
const double    bottom,
const double    top,
const double    zNear,
const double    zFar
 

Set a perspective projection.

See glFrustum for further details.

void osg::Camera::setFusionDistanceMode FusionDistanceMode    mode [inline]
 

Set the mode of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.

Default value is PROPORTIONAL_TO_LOOK_DISTANCE. Use in conjunction with setFusionDistanceRatio(float).

void osg::Camera::setFusionDistanceRatio float    ratio [inline]
 

Set the ratio of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.

Default value is 1.0f Use in conjunction with setFusionDistanceMode(..).

void osg::Camera::setLookAt const double    eyeX,
const double    eyeY,
const double    eyeZ,
const double    centerX,
const double    centerY,
const double    centerZ,
const double    upX,
const double    upY,
const double    upZ
 

set the position and orientation of the camera, using the same convention as gluLookAt.

void osg::Camera::setLookAt const Vec3   eye,
const Vec3   center,
const Vec3   up
 

set the position and orientation of the camera, using the same convention as gluLookAt.

void osg::Camera::setNearFar const double    zNear,
const double    zFar
 

Set the near and far clipping planes.

void osg::Camera::setOrtho const double    left,
const double    right,
const double    bottom,
const double    top,
const double    zNear,
const double    zFar
 

Set a orthographic projection.

See glOrtho for further details.

void osg::Camera::setOrtho2D const double    left,
const double    right,
const double    bottom,
const double    top
 

Set a 2D orthographic projection.

See gluOrtho2D for further details.

void osg::Camera::setPerspective const double    fovy,
const double    aspectRatio,
const double    zNear,
const double    zFar
 

Set a symmetrical perspective projection, See gluPerspective for further details.

Aspect ratio is defined as width/height.

void osg::Camera::setScreenDistance float    screenDistance [inline]
 

Set the physical distance between the viewers eyes and the display system.

Note, only used when rendering in stereo.

void osg::Camera::setView const Vec3   eyePoint,
const Vec3   lookPoint,
const Vec3   upVector
 

Set the View, the up vector should be orthogonal to the look vector.

setView is now mapped to setLookAt(eye,center,up), and is only kept for backwards compatibility.

const double osg::Camera::top   const [inline]
 

void osg::Camera::transformLookAt const Matrix   matrix
 

post multiple the existing eye point and orientation by matrix.

note, does not affect any ModelTransforms that are applied.

const double osg::Camera::zFar   const [inline]
 

const double osg::Camera::zNear   const [inline]
 


Member Data Documentation

AdjustAspectRatioMode osg::Camera::_adjustAspectRatioMode [protected]
 

TransformMode osg::Camera::_attachedTransformMode [protected]
 

double osg::Camera::_bottom [protected]
 

Vec3 osg::Camera::_center [protected]
 

Vec3 osg::Camera::_eye [protected]
 

ref_ptr<Matrix> osg::Camera::_eyeToModelTransform [protected]
 

FusionDistanceMode osg::Camera::_fusionDistanceMode [protected]
 

float osg::Camera::_fusionDistanceRatio [protected]
 

double osg::Camera::_left [protected]
 

LookAtType osg::Camera::_lookAtType [protected]
 

ref_ptr<Matrix> osg::Camera::_modelToEyeTransform [protected]
 

ProjectionType osg::Camera::_projectionType [protected]
 

double osg::Camera::_right [protected]
 

float osg::Camera::_screenDistance [protected]
 

double osg::Camera::_top [protected]
 

Vec3 osg::Camera::_up [protected]
 

double osg::Camera::_zFar [protected]
 

double osg::Camera::_zNear [protected]
 


The documentation for this class was generated from the following file:
Generated at Wed Sep 18 13:55:26 2002 for the Open Scene Graph by doxygen 1.2.16.