Open Inventor Reference
SbViewVolume Class Reference

3D viewing volume class. More...

#include <Inventor/SbLinear.h>

Public Types

enum  ProjectionType { ORTHOGRAPHIC , PERSPECTIVE }
 Return projection information. More...
 

Public Member Functions

 SbViewVolume ()
 Constructor and destructor. More...
 
 ~SbViewVolume ()
 Constructor and destructor. More...
 
void getMatrices (SbMatrix &affine, SbMatrix &proj) const
 Returns two matrices corresponding to the view volume. More...
 
SbMatrix getViewingMatrix () const
 Returns the affine viewing matrix. More...
 
SbMatrix getProjectionMatrix () const
 Returns the projection matrix. More...
 
SbMatrix getMatrix () const
 Like the method above, but returns the affine and projection parts together in one matrix (i.e., affine.multRight( proj ) ). More...
 
SbMatrix getCameraSpaceMatrix () const
 Returns a matrix that transforms the view volume into camera space: it translates the view volume so the viewpoint is at the origin, and rotates it so the view direction is along the negative z axis. More...
 
void projectPointToLine (const SbVec2f &pt, SbLine &line) const
 Maps a 2d point (in 0 <= x,y <= 1) to a 3d line. More...
 
void projectPointToLine (const SbVec2f &pt, SbVec3f &line0, SbVec3f &line1) const
 
SbLine projectPointToLine (const SbVec2f &pt) const
 Maps a 2d point (in 0 <= x,y <= 1) to a 3d line. More...
 
void projectToScreen (const SbVec3f &src, SbVec3f &dst) const
 Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,y,z <= 1). More...
 
SbVec3f projectToScreen (const SbVec3f &src) const
 Maps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,y,z <= 1). More...
 
SbPlane getPlane (float distFromEye) const
 Returns a plane parallel to the near (or far) plane of the view volume at a given distance from the projection point (eye). More...
 
SbVec3f getSightPoint (float distFromEye) const
 Returns the point along the line of sight at the given distance from the projection point (eye). More...
 
SbVec3f getPlanePoint (float distFromEye, const SbVec2f &normPoint) const
 Returns the projection of a given point in normalized screen coordinates (see projectToScreen()) onto the plane parallel to the near plane that is at distFromEye units from the eye. More...
 
SbRotation getAlignRotation (bool rightAngleOnly=FALSE) const
 Returns a rotation that would align a viewed object so that its positive x-axis (of its object space) is to the right in the view and its positive y-axis is up. More...
 
float getWorldToScreenScale (const SbVec3f &worldCenter, float normRadius) const
 Returns a scale factor that would scale a unit sphere centered at worldCenter so that it would appear to have the given radius in normalized screen coordinates when projected onto the near plane. More...
 
SbVec2f projectBox (const SbBox3f &box) const
 Projects the given 3D bounding box onto the near plane and returns the size (in normalized screen coordinates) of the rectangular region that encloses it. More...
 
SbViewVolume narrow (float left, float bottom, float right, float top) const
 Given a view volume, this narrows the view to the given sub-rectangle of the near plane. More...
 
SbViewVolume narrow (const SbBox3f &box) const
 Narrow a view volume by the given box. More...
 
void ortho (float left, float right, float bottom, float top, float nearVal, float farVal)
 Sets up an orthographic view volume with the given sides. More...
 
void perspective (float fovy, float aspect, float nearVal, float farVal)
 Sets up a perspective view volume with the given field of view and aspect ratio. More...
 
void rotateCamera (const SbRotation &q)
 Rotate the camera view direction. More...
 
void translateCamera (const SbVec3f &v)
 Translate the camera viewpoint. More...
 
SbVec3f zVector () const
 Returns the positive z axis in eye space. More...
 
SbViewVolume zNarrow (float nearVal, float farVal) const
 Returns a narrowed view volume which contains as tightly as possible the given interval on the z axis (in eye space). More...
 
void scale (float factor)
 Scales width and height of view volume by given factor. More...
 
void scaleWidth (float ratio)
 Scales view volume to be the given ratio of its current width, leaving the resulting view volume centered about the same point (in the near plane) as the current one. More...
 
void scaleHeight (float ratio)
 Scales view volume to be the given ratio of its current height, leaving the resulting view volume centered about the same point (in the near plane) as the current one. More...
 
ProjectionType getProjectionType () const
 Returns projection information. More...
 
const SbVec3fgetProjectionPoint () const
 Returns projection information. More...
 
const SbVec3fgetProjectionDirection () const
 Returns projection information. More...
 
float getNearDist () const
 Returns distance from projection point to near plane. More...
 
float getFarDist () const
 Returns distance from projection point to far plane. More...
 
float getWidth () const
 Returns bounds of viewing frustum. More...
 
float getHeight () const
 Returns bounds of viewing frustum. More...
 
float getDepth () const
 Returns bounds of viewing frustum. More...
 
void transform (const SbMatrix &matrix)
 Transforms the view volume by the given matrix. More...
 
bool intersect (const SbVec3f &point) const
 Returns TRUE if view volume contains point. More...
 
bool intersect (const SbVec3f &p0, const SbVec3f &p1, SbVec3f &closestPoint) const
 Returns TRUE if line segment between 2 points may intersect volume. More...
 
bool intersect (const SbBox3f &box) const
 Returns TRUE if bounding box may intersect volume. More...
 
bool outsideTest (const SbPlane &p, const SbVec3f &min, const SbVec3f &max) const
 Returns TRUE if the bounding box defined by min,max is totally outside plane p. More...
 

Public Attributes

ProjectionType type
 
SbVec3f projPoint
 Note that there is redundant info in this data structure and its elements should not be changed by hand. More...
 
SbVec3f projDir
 
float nearDist
 distance to near plane More...
 
float nearToFar
 distance between z clips More...
 
SbVec3f llf
 
SbVec3f lrf
 
SbVec3f ulf
 

Detailed Description

Class used to represent a 3D viewing volume. This class is used to represent viewing frusta and picking volumes. For perspective projection, the view volume is a frustum. For orthographic (parallel) projection, the view volume is a rectangular prism.

See Also
SbVec3f, SbVec2f, SbBox3f, SbMatrix, SbRotation

Definition at line 1058 of file SbLinear.h.

Member Enumeration Documentation

◆ ProjectionType

Enumerator
ORTHOGRAPHIC 
PERSPECTIVE 

Definition at line 1203 of file SbLinear.h.

Constructor & Destructor Documentation

◆ SbViewVolume()

SbViewVolume::SbViewVolume ( )

◆ ~SbViewVolume()

SbViewVolume::~SbViewVolume ( )
inline

Definition at line 1064 of file SbLinear.h.

Member Function Documentation

◆ getAlignRotation()

SbRotation SbViewVolume::getAlignRotation ( bool  rightAngleOnly = FALSE) const

If rightAngleOnly is TRUE, it will come as close as it can to this goal by using only 90 degree rotations.

◆ getCameraSpaceMatrix()

SbMatrix SbViewVolume::getCameraSpaceMatrix ( ) const

◆ getDepth()

float SbViewVolume::getDepth ( ) const
inline

Definition at line 1228 of file SbLinear.h.

◆ getFarDist()

float SbViewVolume::getFarDist ( ) const
inline

Definition at line 1221 of file SbLinear.h.

◆ getHeight()

float SbViewVolume::getHeight ( ) const
inline

Definition at line 1226 of file SbLinear.h.

◆ getMatrices()

void SbViewVolume::getMatrices ( SbMatrix affine,
SbMatrix proj 
) const

The first is a viewing matrix, which is guaranteed to be an affine transformation. The second is suitable for use as a projection matrix in OpenGL.

◆ getMatrix()

SbMatrix SbViewVolume::getMatrix ( ) const

◆ getNearDist()

float SbViewVolume::getNearDist ( ) const
inline

Definition at line 1218 of file SbLinear.h.

◆ getPlane()

SbPlane SbViewVolume::getPlane ( float  distFromEye) const

◆ getPlanePoint()

SbVec3f SbViewVolume::getPlanePoint ( float  distFromEye,
const SbVec2f normPoint 
) const

◆ getProjectionDirection()

const SbVec3f& SbViewVolume::getProjectionDirection ( ) const
inline

Definition at line 1215 of file SbLinear.h.

◆ getProjectionMatrix()

SbMatrix SbViewVolume::getProjectionMatrix ( ) const
inline

Definition at line 1076 of file SbLinear.h.

◆ getProjectionPoint()

const SbVec3f& SbViewVolume::getProjectionPoint ( ) const
inline

Definition at line 1212 of file SbLinear.h.

◆ getProjectionType()

ProjectionType SbViewVolume::getProjectionType ( ) const
inline

Definition at line 1209 of file SbLinear.h.

◆ getSightPoint()

SbVec3f SbViewVolume::getSightPoint ( float  distFromEye) const

◆ getViewingMatrix()

SbMatrix SbViewVolume::getViewingMatrix ( ) const
inline

Definition at line 1073 of file SbLinear.h.

◆ getWidth()

float SbViewVolume::getWidth ( ) const
inline

Definition at line 1224 of file SbLinear.h.

◆ getWorldToScreenScale()

float SbViewVolume::getWorldToScreenScale ( const SbVec3f worldCenter,
float  normRadius 
) const

◆ intersect() [1/3]

bool SbViewVolume::intersect ( const SbBox3f box) const

◆ intersect() [2/3]

bool SbViewVolume::intersect ( const SbVec3f p0,
const SbVec3f p1,
SbVec3f closestPoint 
) const

Returns closest point on line to center ray of volume if intersection is found.

◆ intersect() [3/3]

bool SbViewVolume::intersect ( const SbVec3f point) const

◆ narrow() [1/2]

SbViewVolume SbViewVolume::narrow ( const SbBox3f box) const

The box must lie inside the unit cube, and the view will be shrunk according to the size of the box.

◆ narrow() [2/2]

SbViewVolume SbViewVolume::narrow ( float  left,
float  bottom,
float  right,
float  top 
) const

The coordinates of the rectangle are between 0 and 1, where (0,0) is the lower-left corner of the near plane and (1,1) is the upper-right corner.

◆ ortho()

void SbViewVolume::ortho ( float  left,
float  right,
float  bottom,
float  top,
float  nearVal,
float  farVal 
)

The parameters are the same as for the OpenGL glOrtho() routine.

◆ outsideTest()

bool SbViewVolume::outsideTest ( const SbPlane p,
const SbVec3f min,
const SbVec3f max 
) const

◆ perspective()

void SbViewVolume::perspective ( float  fovy,
float  aspect,
float  nearVal,
float  farVal 
)

The parameters are the same as for the OpenGL gluPerspective() routine, except that the field of view angle is specified in radians.

◆ projectBox()

SbVec2f SbViewVolume::projectBox ( const SbBox3f box) const

◆ projectPointToLine() [1/3]

SbLine SbViewVolume::projectPointToLine ( const SbVec2f pt) const

◆ projectPointToLine() [2/3]

void SbViewVolume::projectPointToLine ( const SbVec2f pt,
SbLine line 
) const

◆ projectPointToLine() [3/3]

void SbViewVolume::projectPointToLine ( const SbVec2f pt,
SbVec3f line0,
SbVec3f line1 
) const

◆ projectToScreen() [1/2]

SbVec3f SbViewVolume::projectToScreen ( const SbVec3f src) const
inline

The z-screen coordinate represents the homogenized z coordinate which goes (nonlinearly) from 0 at the near clipping plane to 1 at the far clipping plane.

Definition at line 1109 of file SbLinear.h.

References projectToScreen().

Referenced by projectToScreen().

◆ projectToScreen() [2/2]

void SbViewVolume::projectToScreen ( const SbVec3f src,
SbVec3f dst 
) const

The z-screen coordinate represents the homogenized z coordinate which goes (nonlinearly) from 0 at the near clipping plane to 1 at the far clipping plane.

◆ rotateCamera()

void SbViewVolume::rotateCamera ( const SbRotation q)

Note that this accomplishes the reverse of doing an OpenGL glRotate() command after defining a camera, which rotates the scene viewed by the camera.

◆ scale()

void SbViewVolume::scale ( float  factor)

◆ scaleHeight()

void SbViewVolume::scaleHeight ( float  ratio)

◆ scaleWidth()

void SbViewVolume::scaleWidth ( float  ratio)

◆ transform()

void SbViewVolume::transform ( const SbMatrix matrix)

NOTE: if the matrix performs a scale and a rotation, angles between the transformed projection direction and the sides of the view volume may not be preserved.

◆ translateCamera()

void SbViewVolume::translateCamera ( const SbVec3f v)

Note that this accomplishes the reverse of doing an OpenGL glTranslate() command after defining a camera, which translates the scene viewed by the camera.

◆ zNarrow()

SbViewVolume SbViewVolume::zNarrow ( float  nearVal,
float  farVal 
) const

The returned view volume will never be larger than the current volume, however. near and far are given in terms of zVector(): this means that near > far must hold.

◆ zVector()

SbVec3f SbViewVolume::zVector ( ) const

In this coordinate system, the z value of the near plane should be GREATER than the z value of the far plane.

Member Data Documentation

◆ llf

SbVec3f SbViewVolume::llf

Definition at line 1239 of file SbLinear.h.

◆ lrf

SbVec3f SbViewVolume::lrf

Definition at line 1240 of file SbLinear.h.

◆ nearDist

float SbViewVolume::nearDist

Definition at line 1237 of file SbLinear.h.

◆ nearToFar

float SbViewVolume::nearToFar

Definition at line 1238 of file SbLinear.h.

◆ projDir

SbVec3f SbViewVolume::projDir

Definition at line 1236 of file SbLinear.h.

◆ projPoint

SbVec3f SbViewVolume::projPoint


must be (0,0,0) for ortho

Definition at line 1235 of file SbLinear.h.

◆ type

ProjectionType SbViewVolume::type

Definition at line 1231 of file SbLinear.h.

◆ ulf

SbVec3f SbViewVolume::ulf

Definition at line 1241 of file SbLinear.h.


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