SoCamera Class Reference
[Cameras]

Abstract base class for camera nodes. More...

#include <Inventor/nodes/SoCamera.h>

Inheritance diagram for SoCamera:
SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject SoOrthographicCamera SoPerspectiveCamera SoStereoCamera

List of all members.

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
}
enum  StereoMode {
  MONOSCOPIC,
  LEFT_VIEW,
  RIGHT_VIEW
}

Public Member Functions

virtual SoType getTypeId () const
void pointAt (const SbVec3f &targetPoint)
virtual void scaleHeight (float scaleFactor)=0
virtual SbViewVolume getViewVolume (float useAspectRatio=0.0) const =0
virtual SbViewVolume getViewVolume (float aspectRatio, float nearDist, float farDist, SbVec3f position, SbRotation rotation) const =0
void viewAll (SoNode *sceneRoot, const SbViewportRegion &vpRegion, float slack=1.0)
void viewAll (SoPath *path, const SbViewportRegion &vpRegion, float slack=1.0)
void viewAll (const SbBox3f &bbox, const SbViewportRegion &vpRegion)
SbViewportRegion getViewportBounds (const SbViewportRegion &region) const
void setStereoMode (StereoMode mode)
StereoMode getStereoMode () const

Static Public Member Functions

static SoType getClassTypeId ()

Public Attributes

SoSFEnum viewportMapping
SoSFVec3f position
SoSFRotation orientation
SoSFFloat aspectRatio
SoSFFloat nearDistance
SoSFFloat farDistance
SoSFFloat focalDistance

Deprecated



virtual SoDEPRECATED void setStereoAdjustment (float adjustment)
SoDEPRECATED float getStereoAdjustment () const
virtual SoDEPRECATED void setStereoAbsoluteAdjustments (SbBool absolute)
SoDEPRECATED SbBool getStereoAbsoluteAdjustment () const
virtual SoDEPRECATED void setBalanceAdjustment (float adjustment, SbBool nearFrac=false)
SoDEPRECATED float getBalanceAdjustment () const
SoDEPRECATED SbBool isBalanceAdjustmentNearFrac () const
virtual SoDEPRECATED void allowStereo (SbBool)

Detailed Description

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.

EXAMPLE

SEE ALSO

SoOrthographicCamera, SoPerspectiveCamera, SoCameraKit, SoCameraInteractor

See related examples:

MedicalAnatomicalViews


Member Enumeration Documentation

Stereo mode.

Enumerator:
MONOSCOPIC 

Monoscopic (i.e., non-stereo) viewing.

LEFT_VIEW 

Left eye view.

RIGHT_VIEW 

Right eye view.

Viewport mapping.

Enumerator:
CROP_VIEWPORT_FILL_FRAME 

Crops the viewport within the current window, so that the aspect ratio matches that of the camera.

As the window size changes, the aspect ratio remains unchanged. The cropped region is drawn as a filled gray area.

CROP_VIEWPORT_LINE_FRAME 

Crops the viewport, but draws a thin frame around the viewport.

CROP_VIEWPORT_NO_FRAME 

Crops the viewport, but gives no visual feedback as to the viewport dimensions within the window.

ADJUST_CAMERA 

Adjusts the camera aspect ratio and height to make it fit within the given window.

(The camera's fields are not affected, just the values sent to the graphics library.)

LEAVE_ALONE 

Do nothing.

Camera image may become stretched out of proportion


Member Function Documentation

virtual SoDEPRECATED void SoCamera::allowStereo ( SbBool   )  [virtual]

Allows the camera to render in stereo.

Default value is TRUE.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera instead.

Reimplemented in SoStereoCamera.

SoDEPRECATED float SoCamera::getBalanceAdjustment (  )  const

Queries the parallax balance.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and balance field instead.
static SoType SoCamera::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoNode.

Reimplemented in SoOrthographicCamera, SoPerspectiveCamera, and SoStereoCamera.

SoDEPRECATED SbBool SoCamera::getStereoAbsoluteAdjustment (  )  const

Queries the stereo absolute adjustment state.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and absoluteAdjustments field instead.
SoDEPRECATED float SoCamera::getStereoAdjustment (  )  const

Queries the stereo offset.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and offset field instead.
StereoMode SoCamera::getStereoMode (  )  const

Queries the stereo mode.

virtual SoType SoCamera::getTypeId (  )  const [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.

virtual SbViewVolume SoCamera::getViewVolume ( float  aspectRatio,
float  nearDist,
float  farDist,
SbVec3f  position,
SbRotation  rotation 
) const [pure virtual]

Computes a view volume from the given parameters.

Implemented in SoOrthographicCamera, and SoPerspectiveCamera.

virtual SbViewVolume SoCamera::getViewVolume ( float  useAspectRatio = 0.0  )  const [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:

       // Given a viewer object, get the actual rendering view volume
       float     aspect = viewer->getViewportRegion().getViewportAspectRatio();
       SoCamera* camera = viewer->getCamera();
       SbViewVolume viewVol = camera->getViewVolume( aspect );
       if (aspect < 1)
         viewVol.scale( 1 / aspect );

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.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and balanceNearFrac field instead.
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."

virtual void SoCamera::scaleHeight ( float  scaleFactor  )  [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 SoDEPRECATED void SoCamera::setBalanceAdjustment ( float  adjustment,
SbBool  nearFrac = false 
) [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.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and balance / balanceNearFrac fields instead.

Reimplemented in SoStereoCamera.

virtual SoDEPRECATED void SoCamera::setStereoAbsoluteAdjustments ( SbBool  absolute  )  [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:

 StereoCameraOffset = getStereoAdjustment();
 FrustumAsymmetry   = getBalanceAdjustment();

 glTranslated (-StereoCameraOffset, 0, 0);
 glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry,
            FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);

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.

 StereoCameraOffset   = Xrange * 0.035 * getStereoAdjustment();
 FrustumAsymmetry     = -StereoCameraOffset * getBalanceAdjustment();
 ZeroParallaxDistance = (NearClipDistance + FarClipDistance)/0.5;

 FrustumAsymmetry *= NearClipDistance / ZeroParallaxDistance;

 glTranslated (-StereoCameraOffset, 0, 0);
 glFrustum (FrustumLeft + FrustumAsymmetry, FrustumRight + FrustumAsymmetry,
            FrustumBottom, FrustumTop, NearClipDistance, FarClipDistance);

The left eye view is symmetric.

Not virtual pure for compatiblity reasons.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and absoluteAdjustments field instead.

Reimplemented in SoStereoCamera.

virtual SoDEPRECATED void SoCamera::setStereoAdjustment ( float  adjustment  )  [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.

Deprecated:

Deprecated since Open Inventor 9700
Use SoStereoCamera and offset field instead.

Reimplemented in SoStereoCamera.

void SoCamera::setStereoMode ( StereoMode  mode  ) 

Sets the stereo mode.

If the previous mode was MONOSCOPIC, the current position is saved. If the parameter mode is MONOSCOPIC, the saved value is restored in position. When rendering in stereo mode, set left view, render, set right view, render and then restore to monoscopic 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 ( 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.

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.


Member Data Documentation

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.

The distance from the camera viewpoint to the far clipping plane.

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.

The distance from the camera viewpoint to the near clipping plane.

The orientation of the camera viewpoint, defined as a rotation of the viewing direction from its default (0,0,-1) vector.

The location of the camera viewpoint.

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.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/