Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoPerspectiveCamera Class Reference

Perspective camera node. More...

#include <Inventor/nodes/SoPerspectiveCamera.h>

+ Inheritance diagram for SoPerspectiveCamera:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoPerspectiveCamera ()
 Creates a perspective camera node with default settings.
 
virtual void scaleHeight (float scaleFactor)
 Scales the height of the camera, in this case, the heightAngle field.
 
virtual SbViewVolume getViewVolume (float useAspectRatio=0.0) const
 Fills in a view volume structure, based on the camera.
 
virtual SbViewVolume getViewVolume (float useAspectRatio, float nearDist, float farDist, SbVec3f position, SbRotation orientation) const
 Returns a view volume object, based on the camera's viewing parameters.
 
- Public Member Functions inherited from SoCamera
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.
 
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 &region) 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.
 
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 SoNodecopy (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 SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (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 SoCamera
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 SoNodegetByName (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

SoSFFloat heightAngle
 Vertical angle of the viewing volume.
 
- Public Attributes inherited from SoCamera
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.
 

Additional Inherited Members

- Public Types inherited from SoCamera
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...
 

Detailed Description

Perspective camera node.

A perspective camera defines a perspective projection from a viewpoint. The viewing volume for a perspective camera is a truncated right pyramid.

By default, the camera is located at (0,0,1) and looks along the negative z-axis; the position and orientation fields can be used to change these values. The heightAngle field defines the total vertical angle of the viewing volume; this and the aspectRatio field determine the horizontal angle.

See the base class SoCamera for more information about the inherited fields.

Useful algorithms for manipulating a camera are provided in the SoCameraInteractor class.

FILE FORMAT/DEFAULT

    PerspectiveCamera {
    viewportMapping ADJUST_CAMERA
    position 0 0 1
    orientation 0 0 1 0
    aspectRatio 1
    nearDistance 1
    farDistance 10
    focalDistance 5
    heightAngle 0.785398
    }

ACTION BEHAVIOR

SEE ALSO

SbViewVolume, SoOrthographicCamera, SoCameraInteractor

Definition at line 113 of file SoPerspectiveCamera.h.

Constructor & Destructor Documentation

◆ SoPerspectiveCamera()

SoPerspectiveCamera::SoPerspectiveCamera ( )

Creates a perspective camera node with default settings.

Member Function Documentation

◆ getClassTypeId()

static SoType SoPerspectiveCamera::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoPerspectiveCamera::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoCamera.

Reimplemented in SoStereoCamera.

◆ getViewVolume() [1/2]

virtual SbViewVolume SoPerspectiveCamera::getViewVolume ( float  useAspectRatio,
float  nearDist,
float  farDist,
SbVec3f  position,
SbRotation  orientation 
) const
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 );
3D viewing volume class.
void scale(float factor)
Scales width and height of view volume by given factor.
Abstract base class for camera nodes.
Definition SoCamera.h:188
virtual SbViewVolume getViewVolume(float useAspectRatio=0.0) const =0
Returns a view volume object, based on the camera's viewing parameters.

Implements SoCamera.

◆ getViewVolume() [2/2]

virtual SbViewVolume SoPerspectiveCamera::getViewVolume ( float  useAspectRatio = 0.0) const
virtual

Fills in a view volume structure, based on the camera.

If the useAspectRatio field is not 0.0 (the default), the camera uses that ratio instead of the one it has.

Note that in ADJUST_CAMERA mode, Inventor automatically modifies the view volume based on the aspect ratio of 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 to render) you must pass the actual viewport aspect ratio to getViewVolume.

Implements SoCamera.

◆ scaleHeight()

virtual void SoPerspectiveCamera::scaleHeight ( float  scaleFactor)
virtual

Scales the height of the camera, in this case, the heightAngle field.

Implements SoCamera.

Member Data Documentation

◆ heightAngle

SoSFFloat SoPerspectiveCamera::heightAngle

Vertical angle of the viewing volume.

Definition at line 124 of file SoPerspectiveCamera.h.


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