class SG_EXPORT osg::Camera

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

Inheritance:


Public Methods

[more] Camera(DisplaySettings* ds=NULL)
[more] Camera(const Camera&)
[more]Camera& operator=(const Camera&)
[more]virtual ~Camera()
[more]const ProjectionType getProjectionType() const
Get the projection type set by setOtho,setOtho2D,setFrustum, and set perspective methods
[more]void setOrtho(const double left, const double right, const double bottom, const double top, const double zNear, const double zFar)
Set a orthographic projection.
[more]void setOrtho2D(const double left, const double right, const double bottom, const double top)
Set a 2D orthographic projection.
[more]void setFrustum(const double left, const double right, const double bottom, const double top, const double zNear, const double zFar)
Set a perspective projection.
[more]void setPerspective(const double fovy, const double aspectRatio, const double zNear, const double zFar)
Set a symmetrical perspective projection, See gluPerspective for further details.
[more]void setFOV(const double fovx, const double fovy, const double zNear, const double zFar)
Set a sysmmetical perspective projection using field of view
[more]void setNearFar(const double zNear, const double zFar)
Set the near and far clipping planes
[more]void setAdjustAspectRatioMode(const AdjustAspectRatioMode aam)
Set the way that the vertical or horizontal dimensions of the window are adjusted on a resize.
[more]const AdjustAspectRatioMode getAdjustAspectRatioMode() const
Get the way that the vertical or horizontal dimensions of the window are adjusted on a resize.
[more]void adjustAspectRatio(const double newAspectRatio)
Adjust the clipping planes to account for a new window aspect ratio.
[more]void adjustAspectRatio(const double newAspectRatio, const AdjustAspectRatioMode aa)
Adjust the clipping planes to account for a new window aspect ratio.
[more]const double left() const
[more]const double right() const
[more]const double top() const
[more]const double bottom() const
[more]const double zNear() const
[more]const double zFar() const
[more]const double calc_fovy() const
Calculate and return the equivalent fovx for the current project setting.
[more]const double calc_fovx() const
Calculate and return the equivalent fovy for the current project setting.
[more]const double calc_aspectRatio() const
Calculate and return the projection aspect ratio.
[more]const Matrix& getProjectionMatrix() const
[more]const LookAtType getLookAtType() const
[more]void home()
hardwired home view for now, looking straight down the Z axis at the origin, with 'up' being the y axis
[more]void setView(const Vec3& eyePoint, const Vec3& lookPoint, const Vec3& upVector)
Set the View, the up vector should be orthogonal to the look vector.
[more]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
[more]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
[more]void transformLookAt(const Matrix& matrix)
post multiple the existing eye point and orientation by matrix.
[more]void ensureOrthogonalUpVector()
[more]inline const Vec3& getEyePoint() const
get the eye point.
[more]inline const Vec3& getCenterPoint() const
get the center point.
[more]inline const Vec3& getUpVector() const
get the up vector
[more]const Vec3 getLookVector() const
calculate look vector
[more]const Vec3 getSideVector() const
calculate side vector
[more]inline float getLookDistance() const
calculate the look distance which is the distance between the eye and the center
[more]void attachTransform(const TransformMode mode, Matrix* modelTransform=0)
Attach a transform matrix which is applied after the camera look at.
[more]void dirtyTransform()
must be called after you modify an attachedTransform.
[more]Matrix* getTransform(const TransformMode mode)
[more]const Matrix* getTransform(const TransformMode mode) const
[more]const Vec3 getEyePoint_Model() const
[more]const Vec3 getCenterPoint_Model() const
[more]const Vec3 getLookVector_Model() const
[more]const Vec3 getUpVector_Model() const
[more]const Vec3 getSideVector_Model() const
[more]const Matrix& getModelViewMatrix() const
Get the ModelView matrix.
[more]void setUseNearClippingPlane(const bool use)
Switch on/off the use of the near clipping plane which creating the getClippingVolume(), uses the camera _znear value for the position of the near clipping plane.
[more]const bool getUseNearClippingPlane() const
get whether the ClippingVolume uses a near clipping plane
[more]void setUseFarClippingPlane(const bool use)
Switch on/off the use of the far clipping plane which creating the getClippingVolume(), uses the camera _zfar value for the position of the far clipping plane.
[more]const bool getUseFarClippingPlane() const
Get whether the ClippingVolume uses a far clipping plane
[more]const ClippingVolume& getClippingVolume() const
get the view frustum clipping in model coordinates
[more]const bool project(const Vec3& obj, const Viewport& viewport, Vec3& win) const
Map object coordinates into windows coordinates.
[more]const bool unproject(const Vec3& win, const Viewport& viewport, Vec3& obj) const
Map window coordinates into object coordinates.
[more]void setFusionDistanceMode(FusionDistanceMode mode)
Set the mode of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.
[more]FusionDistanceMode getFusionDistanceMode() const
Get the mode of the fusion distance function
[more]void setFusionDistanceRatio(float ratio)
Set the ratio of the fusion distance function which in use to calculate the fusion distance used in stereo rendering.
[more]float getFusionDistanceRatio() const
Get the ratio of the fusion distance function
[more]const float getFusionDistance() const
Calculate and return the fusion distance, using the FusionDistanceFunction
[more]void setScreenDistance(float screenDistance)
Set the physical distance between the viewers eyes and the display system.
[more]const float getScreenDistance() const
Get the physical distance between the viewers eyes and the display system
[more]void adjustEyeOffsetForStereo(const osg::Vec3& offset)
Convinience method for adjusting the project and model view to account for and eye offset, as used in stereo work, assumes that the users will use a seperate camera for each eye, adjustEyePointForStereo() being used to specialize the camera for each eye view
[more]virtual void apply(State& state)
Set up the OpenGL projection and model view matrices

Public Members

[more]enum ProjectionType
Range of projection types.
[more]enum AdjustAspectRatioMode
Use in combination with adjustAspectRatio, to control the change in frustum clipping planes to account for changes in windows aspect ratio,
[more]enum LookAtType
[more]enum TransformMode
[more]enum FusionDistanceMode

Protected Fields

[more]ProjectionType _projectionType
[more]AdjustAspectRatioMode _adjustAspectRatioMode
[more]double _left
[more]double _right
[more]double _bottom
[more]double _top
[more]double _zNear
[more]double _zFar
[more]LookAtType _lookAtType
[more]Vec3 _eye
[more]Vec3 _center
[more]Vec3 _up
[more]TransformMode _attachedTransformMode
[more]ref_ptr<Matrix> _eyeToModelTransform
[more]ref_ptr<Matrix> _modelToEyeTransform
[more]bool _useNearClippingPlane
[more]bool _useFarClippingPlane
[more]mutable bool _dirty
[more]mutable ref_ptr<Matrix> _projectionMatrix
[more]mutable ref_ptr<Matrix> _modelViewMatrix
[more]mutable ClippingVolume _clippingVolume
[more]mutable ref_ptr<Matrix> _mp
[more]mutable ref_ptr<Matrix> _inversemp
[more]bool _useEyeOffset
[more]osg::Vec3 _eyeOffset
[more]float _screenDistance
[more]FusionDistanceMode _fusionDistanceMode
[more]float _fusionDistanceRatio

Protected Methods

[more]void copy(const Camera&)
[more]void calculateMatricesAndClippingVolume() const


Inherited from Referenced:

Public Methods

oinline Referenced& operator = (Referenced&)
oinline void ref() const
oinline void unref() const
oinline const int referenceCount() const

Protected Fields

omutable int _refCount


Documentation

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.
o Camera(DisplaySettings* ds=NULL)

o Camera(const Camera&)

oCamera& operator=(const Camera&)

ovirtual ~Camera()

oenum 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.

o ORTHO

o ORTHO2D

o FRUSTUM

o PERSPECTIVE

oconst ProjectionType getProjectionType() const
Get the projection type set by setOtho,setOtho2D,setFrustum, and set perspective methods

ovoid 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.

ovoid setOrtho2D(const double left, const double right, const double bottom, const double top)
Set a 2D orthographic projection. See gluOrtho2D for further details.

ovoid 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.

ovoid 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.

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

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

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

o ADJUST_VERTICAL

o ADJUST_HORIZONTAL

o ADJUST_NONE

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

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

ovoid adjustAspectRatio(const double newAspectRatio)
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.

ovoid 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.

oconst double left() const

oconst double right() const

oconst double top() const

oconst double bottom() const

oconst double zNear() const

oconst double zFar() const

oconst double 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.

oconst double 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.

oconst double calc_aspectRatio() const
Calculate and return the projection aspect ratio. Aspect ratio is defined as width/height.

oconst Matrix& getProjectionMatrix() const

oenum LookAtType

o USE_HOME_POSITON

o USE_EYE_AND_QUATERNION

o USE_EYE_CENTER_AND_UP

oconst LookAtType getLookAtType() const

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

ovoid 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.

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

ovoid 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

ovoid transformLookAt(const Matrix& matrix)
post multiple the existing eye point and orientation by matrix. note, does not affect any ModelTransforms that are applied.

ovoid ensureOrthogonalUpVector()

oinline const Vec3& getEyePoint() const
get the eye point.

oinline const Vec3& getCenterPoint() const
get the center point.

oinline const Vec3& getUpVector() const
get the up vector

oconst Vec3 getLookVector() const
calculate look vector

oconst Vec3 getSideVector() const
calculate side vector

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

oenum TransformMode

o EYE_TO_MODEL

o MODEL_TO_EYE

o NO_ATTACHED_TRANSFORM

ovoid 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. However, if you modify the attached transform then you must call dirtyTransform, to allow the OSG to update matrices accordingly.

ovoid dirtyTransform()
must be called after you modify an attachedTransform.

oMatrix* getTransform(const TransformMode mode)

oconst Matrix* getTransform(const TransformMode mode) const

oconst Vec3 getEyePoint_Model() const

oconst Vec3 getCenterPoint_Model() const

oconst Vec3 getLookVector_Model() const

oconst Vec3 getUpVector_Model() const

oconst Vec3 getSideVector_Model() const

oconst Matrix& 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.

ovoid setUseNearClippingPlane(const bool use)
Switch on/off the use of the near clipping plane which creating the getClippingVolume(), uses the camera _znear value for the position of the near clipping plane. By default this value is off.

oconst bool getUseNearClippingPlane() const
get whether the ClippingVolume uses a near clipping plane

ovoid setUseFarClippingPlane(const bool use)
Switch on/off the use of the far clipping plane which creating the getClippingVolume(), uses the camera _zfar value for the position of the far clipping plane. By default this value is off.

oconst bool getUseFarClippingPlane() const
Get whether the ClippingVolume uses a far clipping plane

oconst ClippingVolume& getClippingVolume() const
get the view frustum clipping in model coordinates

oconst bool project(const Vec3& obj, const Viewport& viewport, Vec3& win) const
Map object coordinates into windows coordinates. Equivalent to gluProject(...).

oconst bool unproject(const Vec3& win, const Viewport& viewport, Vec3& obj) const
Map window coordinates into object coordinates. Equivalent to gluUnProject(...).

oenum FusionDistanceMode

o PROPORTIONAL_TO_LOOK_DISTANCE

o PROPORTIONAL_TO_SCREEN_DISTANCE

ovoid setFusionDistanceMode(FusionDistanceMode mode)
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).

oFusionDistanceMode getFusionDistanceMode() const
Get the mode of the fusion distance function

ovoid setFusionDistanceRatio(float ratio)
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(..).

ofloat getFusionDistanceRatio() const
Get the ratio of the fusion distance function

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

ovoid setScreenDistance(float screenDistance)
Set the physical distance between the viewers eyes and the display system. Note, only used when rendering in stereo.

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

ovoid adjustEyeOffsetForStereo(const osg::Vec3& offset)
Convinience method for adjusting the project and model view to account for and eye offset, as used in stereo work, assumes that the users will use a seperate camera for each eye, adjustEyePointForStereo() being used to specialize the camera for each eye view

ovirtual void apply(State& state)
Set up the OpenGL projection and model view matrices

ovoid copy(const Camera&)

oProjectionType _projectionType

oAdjustAspectRatioMode _adjustAspectRatioMode

odouble _left

odouble _right

odouble _bottom

odouble _top

odouble _zNear

odouble _zFar

oLookAtType _lookAtType

oVec3 _eye

oVec3 _center

oVec3 _up

oTransformMode _attachedTransformMode

oref_ptr<Matrix> _eyeToModelTransform

oref_ptr<Matrix> _modelToEyeTransform

obool _useNearClippingPlane

obool _useFarClippingPlane

omutable bool _dirty

omutable ref_ptr<Matrix> _projectionMatrix

omutable ref_ptr<Matrix> _modelViewMatrix

omutable ClippingVolume _clippingVolume

omutable ref_ptr<Matrix> _mp

omutable ref_ptr<Matrix> _inversemp

ovoid calculateMatricesAndClippingVolume() const

obool _useEyeOffset

oosg::Vec3 _eyeOffset

ofloat _screenDistance

oFusionDistanceMode _fusionDistanceMode

ofloat _fusionDistanceRatio


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.