Abstract base class for camera nodes. More...
#include <Inventor/nodes/SoCamera.h>
Public Types | |
enum | ViewportMapping { CROP_VIEWPORT_FILL_FRAME = 0 , CROP_VIEWPORT_LINE_FRAME = 1 , CROP_VIEWPORT_NO_FRAME = 2 , ADJUST_CAMERA = 3 , LEAVE_ALONE = 4 } |
Viewport mapping. More... | |
enum | StereoMode { MONOSCOPIC , LEFT_VIEW , RIGHT_VIEW } |
Stereo mode. More... | |
Public Member Functions | |
virtual SoType | getTypeId () const |
Returns the type identifier for this specific instance. | |
void | pointAt (const SbVec3f &targetPoint) |
Sets the orientation of the camera so that it points toward the given target point while keeping the "up" direction of the camera parallel to the positive y-axis. | |
virtual void | scaleHeight (float scaleFactor)=0 |
Scales the height of the camera. | |
virtual SbViewVolume | getViewVolume (float useAspectRatio=0.0) const =0 |
Returns a view volume object, based on the camera's viewing parameters. | |
virtual SbViewVolume | getViewVolume (float aspectRatio, float nearDist, float farDist, SbVec3f position, SbRotation rotation) const =0 |
Computes a view volume from the given parameters. | |
void | viewAll (SoNode *sceneRoot, const SbViewportRegion &vpRegion, float slack=1.0) |
Sets the camera to view the scene rooted by the given node. | |
void | viewAll (SoPath *path, const SbViewportRegion &vpRegion, float slack=1.0) |
Sets the camera to view the scene defined by the given path. | |
void | viewAll (const SbBox3f &bbox, const SbViewportRegion &vpRegion) |
Sets the camera to view the region defined by the given bounding box. | |
SbViewportRegion | getViewportBounds (const SbViewportRegion ®ion) const |
Returns the viewport region this camera would use to render into the given viewport region, accounting for cropping. | |
void | setStereoMode (StereoMode mode) |
Sets the stereo mode. | |
StereoMode | getStereoMode () const |
Queries the stereo mode. | |
Deprecated | |
virtual SoDEPRECATED void | setStereoAdjustment (float adjustment) |
Sets the stereo offset (the distance of each eye from the camera position). | |
SoDEPRECATED float | getStereoAdjustment () const |
Queries the stereo offset. | |
virtual SoDEPRECATED void | setStereoAbsoluteAdjustments (SbBool absolute) |
Specifies if stereo adjustments are absolute. | |
SoDEPRECATED SbBool | getStereoAbsoluteAdjustment () const |
Queries the stereo absolute adjustment state. | |
virtual SoDEPRECATED void | setBalanceAdjustment (float adjustment, SbBool nearFrac=false) |
Sets the stereo balance (the position of the zero parallax plane) and specifies whether the balance value is defined as a fraction of the camera near distance. | |
SoDEPRECATED float | getBalanceAdjustment () const |
Queries the parallax balance. | |
SoDEPRECATED SbBool | isBalanceAdjustmentNearFrac () const |
Returns TRUE if the stereo balance adjustement is defined as a fraction of the camera near distance. | |
virtual SoDEPRECATED void | allowStereo (SbBool) |
Allows the camera to render in stereo. | |
Public Member Functions inherited from SoNode | |
virtual void | setOverride (const SbBool state) |
Turns the override flag on or off. | |
virtual SbBool | isOverride () const |
Returns the state of the override flag. | |
virtual SoNode * | copy (SbBool copyConnections=FALSE) const |
Creates and returns an exact copy of the node. | |
virtual SbBool | affectsState () const |
Returns TRUE if a node has an effect on the state during traversal. | |
virtual void | touch () |
Marks an instance as modified, simulating a change to it. | |
Public Member Functions inherited from SoFieldContainer | |
void | setToDefaults () |
Sets all fields in this object to their default values. | |
SbBool | hasDefaultValues () const |
Returns TRUE if all of the object's fields have their default values. | |
SbBool | fieldsAreEqual (const SoFieldContainer *fc) const |
Returns TRUE if this object's fields are exactly equal to fc's fields. | |
void | copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE) |
Copies the contents of fc's fields into this object's fields. | |
SoNONUNICODE SbBool | set (const char *fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
SbBool | set (const SbString &fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
void | get (SbString &fieldDataString) |
Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
virtual int | getFields (SoFieldList &list) const |
Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
virtual int | getAllFields (SoFieldList &list) const |
Returns a list of fields, including the eventIn's and eventOut's. | |
virtual SoField * | getField (const SbName &fieldName) const |
Returns a the field of this object whose name is fieldName. | |
virtual SoField * | getEventIn (const SbName &fieldName) const |
Returns a the eventIn with the given name. | |
virtual SoField * | getEventOut (const SbName &fieldName) const |
Returns the eventOut with the given name. | |
SbBool | getFieldName (const SoField *field, SbName &fieldName) const |
Returns the name of the given field in the fieldName argument. | |
SbBool | enableNotify (SbBool flag) |
Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE). | |
SbBool | isNotifyEnabled () const |
Notification is the process of telling interested objects that this object has changed. | |
virtual void | setUserData (void *data) |
Sets application data. | |
void * | getUserData (void) const |
Gets user application data. | |
Public Member Functions inherited from SoBase | |
virtual SbName | getName () const |
Returns the name of an instance. | |
virtual void | setName (const SbName &name) |
Sets the name of an instance. | |
void | setSynchronizable (const bool b) |
Sets this to be a ScaleViz synchronizable object. | |
bool | isSynchronizable () const |
Gets the ScaleViz synchronizable state of this object. | |
Public Member Functions inherited from SoRefCounter | |
void | ref () const |
Adds a reference to an instance. | |
void | unref () const |
Removes a reference from an instance. | |
void | unrefNoDelete () const |
unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero. | |
int | getRefCount () const |
Returns current reference count. | |
void | lock () const |
lock this instance. | |
void | unlock () const |
unlock this instance. | |
Public Member Functions inherited from SoTypedObject | |
SbBool | isOfType (const SoType &type) const |
Returns TRUE if this object is of the type specified in type or is derived from that type. | |
template<typename TypedObjectClass > | |
SbBool | isOfType () const |
Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class. | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Static Public Member Functions inherited from SoNode | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SoNode * | getByName (const SbName &name) |
A node's name can be set using SoBase::setName(). | |
static int | getByName (const SbName &name, SoNodeList &list) |
A node's name can be set using SoBase::setName(). | |
Static Public Member Functions inherited from SoFieldContainer | |
static SoType | getClassTypeId () |
Returns the type of this class. | |
Static Public Member Functions inherited from SoBase | |
static SoType | getClassTypeId () |
Returns type identifier for this class. | |
Static Public Member Functions inherited from SoTypedObject | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Public Attributes | |
SoSFEnum | viewportMapping |
Defines how to map the rendered image into the current viewport, when the aspect ratio of the camera differs from that of the viewport. | |
SoSFVec3f | position |
The location of the camera viewpoint. | |
SoSFRotation | orientation |
The orientation of the camera viewpoint, defined as a rotation of the viewing direction from its default (0,0,-1) vector. | |
SoSFFloat | aspectRatio |
The ratio of camera viewing width to height. | |
SoSFFloat | nearDistance |
The distance from the camera viewpoint to the near clipping plane. | |
SoSFFloat | farDistance |
The distance from the camera viewpoint to the far clipping plane. | |
SoSFFloat | focalDistance |
The distance from the viewpoint to the point of focus. | |
Abstract base class for camera nodes.
This is the abstract base class for all camera nodes. It defines the common methods and fields that all cameras have. Cameras are used to view a scene. When a camera is encountered during rendering, it sets the projection and viewing matrices and viewport appropriately; it does not draw geometry. Cameras should be placed before any shape nodes or light nodes in a scene graph; otherwise, those shapes or lights cannot be rendered properly. Cameras are affected by the current transformation, so you can position a camera by placing a transformation node before it in the scene graph. The default position and orientation of a camera is at (0,0,1) looking along the negative z-axis.
You can also use a node kit to create a camera; see the reference page for SoCameraKit.
Useful algorithms for manipulating a camera are provided in the SoCameraInteractor class.
Shortcut to get the current view vector or up vector.
Compute the current focal point.
SoOrthographicCamera, SoPerspectiveCamera, SoCameraKit, SoCameraInteractor
Definition at line 188 of file SoCamera.h.
enum SoCamera::StereoMode |
Stereo mode.
Enumerator | |
---|---|
MONOSCOPIC | Monoscopic (i.e., non-stereo) viewing. |
LEFT_VIEW | Left eye view. |
RIGHT_VIEW | Right eye view. |
Definition at line 518 of file SoCamera.h.
Viewport mapping.
Definition at line 195 of file SoCamera.h.
|
virtual |
SoDEPRECATED float SoCamera::getBalanceAdjustment | ( | ) | const |
Queries the parallax balance.
|
static |
Returns the type identifier for this class.
SoDEPRECATED SbBool SoCamera::getStereoAbsoluteAdjustment | ( | ) | const |
Queries the stereo absolute adjustment state.
SoDEPRECATED float SoCamera::getStereoAdjustment | ( | ) | const |
Queries the stereo offset.
StereoMode SoCamera::getStereoMode | ( | ) | const |
Queries the stereo mode.
|
virtual |
Returns the type identifier for this specific instance.
Reimplemented from SoNode.
Reimplemented in SoOrthographicCamera, SoPerspectiveCamera, and SoStereoCamera.
SbViewportRegion SoCamera::getViewportBounds | ( | const SbViewportRegion & | region | ) | const |
Returns the viewport region this camera would use to render into the given viewport region, accounting for cropping.
|
pure virtual |
Computes a view volume from the given parameters.
Implemented in SoOrthographicCamera, and SoPerspectiveCamera.
|
pure virtual |
Returns a view volume object, based on the camera's viewing parameters.
This object can be used, for example, to get the view and projection matrices, to project 2D screen coordinates into 3D space and to project 3D coordinates into screen space.
If the useAspectRatio parameter is 0.0 (the default), the camera uses the current value of the aspectRatio field to compute the view volume.
NOTE: In ADJUST_CAMERA mode (the default), the view volume returned when useAspectRatio = 0, is not (in general) the actual view volume used for rendering. Using this view volume to project points will not (in general) produce the correct results.
This is because, in ADJUST_CAMERA mode, Inventor automatically modifies the view volume to match the aspect ratio of the current viewport. This avoids the distortion that would be caused by "stretching" the view volume when it is mapped into the viewport. However the view volume values are not changed, only the values passed to OpenGL. In order to get the modified values (i.e., the actual view volume used for rendering) you must pass the actual viewport aspect ratio to getViewVolume. You can get the current viewport from the renderArea or viewer object that contains the Open Inventor window.
Also note that in ADJUST_CAMERA mode, when the viewport aspect ratio is less than 1, Open Inventor automatically scales the actual rendering view volume by the inverse of the aspect ratio (i.e. 1/aspect). The getViewVolume method does not automatically apply this adjustment. So a correct query of the actual rendering view volume can be done like this:
Implemented in SoOrthographicCamera, and SoPerspectiveCamera.
SoDEPRECATED SbBool SoCamera::isBalanceAdjustmentNearFrac | ( | ) | const |
Returns TRUE if the stereo balance adjustement is defined as a fraction of the camera near distance.
void SoCamera::pointAt | ( | const SbVec3f & | targetPoint | ) |
Sets the orientation of the camera so that it points toward the given target point while keeping the "up" direction of the camera parallel to the positive y-axis.
If this is not possible, it uses the positive z-axis as "up."
|
pure virtual |
Scales the height of the camera.
Perspective cameras scale their heightAngle fields, and orthographic cameras scale their height fields.
Implemented in SoOrthographicCamera, and SoPerspectiveCamera.
|
virtual |
Sets the stereo balance (the position of the zero parallax plane) and specifies whether the balance value is defined as a fraction of the camera near distance.
Note: Since the projection matrix always depends on the camera's near plane, in some cases it may be necessary to detect changes to the camera near plane and adjust by setting a new stereo balance value. Open Inventor will make these adjustments automatically if the nearFrac parameter is set to TRUE. In this case the stereo balance value is defined as a fraction of the camera near distance.
Default balance is 1.0. The default can be set using the OIV_STEREO_BALANCE environment variable. Default nearFrac is FALSE. The default can be set using the OIV_STEREO_BALANCE_NEAR_FRAC environment variable.
Reimplemented in SoStereoCamera.
|
virtual |
Specifies if stereo adjustments are absolute.
FALSE by default.
The default non-absolute mode allows the stereo settings to be valid over a range of different view volume settings. If you chose absolute mode, you are responsible for modifying the stereo settings (if necessary) when the view volume changes.
When absolute mode is TRUE, stereo offset and balance are used as shown in the following pseudo-code for the right eye view:
The left eye view is symmetric.
When absolute mode is FALSE, stereo offset and balance are used as shown in the following pseudo-code for the right eye view:
Xrange is right minus left (i.e., first two arguments of glFrustum) and multiply that difference by the ratio of the distance to the desired plane of zero parallax to the near clipping plane distance.
The left eye view is symmetric.
Not virtual pure for compatiblity reasons.
Reimplemented in SoStereoCamera.
|
virtual |
Sets the stereo offset (the distance of each eye from the camera position).
The right eye is moved plus offset and the left eye is moved minus offset. Default is 0.7. The default can be set using OIV_STEREO_OFFSET environment variable.
Reimplemented in SoStereoCamera.
void SoCamera::setStereoMode | ( | StereoMode | mode | ) |
void SoCamera::viewAll | ( | const SbBox3f & | bbox, |
const SbViewportRegion & | vpRegion | ||
) |
Sets the camera to view the region defined by the given bounding box.
The near and far clipping planes will be positioned the radius of the bounding sphere away from the bounding box's center.
See note about bounding boxes in the sceneRoot version of this method.
void SoCamera::viewAll | ( | SoNode * | sceneRoot, |
const SbViewportRegion & | vpRegion, | ||
float | slack = 1.0 |
||
) |
Sets the camera to view the scene rooted by the given node.
The near and far clipping planes will be positioned slack bounding sphere radii away from the bounding box's center. A value of 1.0 will make the near and far clipping planes the tightest around the bounding sphere.
The node applies an SoGetBoundingBoxAction to the scene graph to get the bounding box of the entire scene. The bounding box will only include shapes that are actually traversed. For example the bounding box will not include shapes under an SoSwitch with whichChild set to SO_SWITCH_NONE. The action does not consider the visibility of shapes that are traversed. In other words the bounding box will include shapes that are invisible (SoDrawStyle), shapes that are clipped (SoClipPlane), etc. Use an SoBBox node to exclude shapes from the bounding box computation. Bounding boxes are automatically cached at SoSeparator nodes, so getting the bounding box is very fast when the scene graph has not been changed.
Warning:
The SoGetBoundingBoxAction will call ref() and unref() on the specified node. If the node's reference count before calling viewAll() is zero (the default), the call to unref() will cause the node to be destroyed.
void SoCamera::viewAll | ( | SoPath * | path, |
const SbViewportRegion & | vpRegion, | ||
float | slack = 1.0 |
||
) |
Sets the camera to view the scene defined by the given path.
The near and far clipping planes will be positioned slack bounding sphere radii away from the bounding box's center. A value of 1.0 will make the near and far clipping planes the tightest around the bounding sphere.
See note about bounding boxes in the sceneRoot version of this method.
SoSFFloat SoCamera::aspectRatio |
The ratio of camera viewing width to height.
This value must be greater than 0.0. There are several standard camera aspect ratios defined in SoCamera.h.
Definition at line 252 of file SoCamera.h.
SoSFFloat SoCamera::farDistance |
The distance from the camera viewpoint to the far clipping plane.
Definition at line 262 of file SoCamera.h.
SoSFFloat SoCamera::focalDistance |
The distance from the viewpoint to the point of focus.
This is typically ignored during rendering, but may be used by some viewers to define a point of interest.
Definition at line 269 of file SoCamera.h.
SoSFFloat SoCamera::nearDistance |
The distance from the camera viewpoint to the near clipping plane.
Definition at line 257 of file SoCamera.h.
SoSFRotation SoCamera::orientation |
The orientation of the camera viewpoint, defined as a rotation of the viewing direction from its default (0,0,-1) vector.
Definition at line 246 of file SoCamera.h.
SoSFVec3f SoCamera::position |
The location of the camera viewpoint.
Definition at line 240 of file SoCamera.h.
SoSFEnum SoCamera::viewportMapping |
Defines how to map the rendered image into the current viewport, when the aspect ratio of the camera differs from that of the viewport.
Use enum ViewportMapping. Default is ADJUST_CAMERA.
Definition at line 235 of file SoCamera.h.