Provided by: inventor-doc_2.1.5-10-18_all

**NAME**

SbViewVolume — 3D viewing volume class

**INHERITS** **FROM**

SbViewVolume

**SYNOPSIS**

#include<Inventor/SbLinear.h>enumProjectionType{SbViewVolume::ORTHOGRAPHICOrthographic projectionSbViewVolume::PERSPECTIVEPerspective projection}Methods from class SbViewVolume:SbViewVolume()~SbViewVolume()voidgetMatrices(SbMatrix&affine,SbMatrix&proj)constSbMatrixgetMatrix()constSbMatrixgetCameraSpaceMatrix()constvoidprojectPointToLine(constSbVec2f&pt,SbLine&line)constvoidprojectPointToLine(constSbVec2f&pt,SbVec3f&line0,SbVec3f&line1)constvoidprojectToScreen(constSbVec3f&src,SbVec3f&dst)constSbPlanegetPlane(floatdistFromEye)constSbVec3fgetSightPoint(floatdistFromEye)constSbVec3fgetPlanePoint(floatdistFromEye,constSbVec2f&normPoint)constSbRotationgetAlignRotation(SbBoolrightAngleOnly=FALSE)constfloatgetWorldToScreenScale(constSbVec3f&worldCenter,floatnormRadius)constSbVec2fprojectBox(constSbBox3f&box)constSbViewVolumenarrow(floatleft,floatbottom,floatright,floattop)constSbViewVolumenarrow(constSbBox3f&box)constvoidortho(floatleft,floatright,floatbottom,floattop,floatnear,floatfar)voidperspective(floatfovy,floataspect,floatnear,floatfar)voidrotateCamera(constSbRotation&q)voidtranslateCamera(constSbVec3f&v)SbVec3fzVector()constSbViewVolumezNarrow(floatnear,floatfar)constvoidscale(floatfactor)voidscaleWidth(floatratio)voidscaleHeight(floatratio)ProjectionTypegetProjectionType()constconstSbVec3f&getProjectionPoint()constconstSbVec3f&getProjectionDirection()constfloatgetNearDist()constfloatgetWidth()constfloatgetHeight()constfloatgetDepth()const

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

**METHODS**

SbViewVolume()~SbViewVolume()Constructor and destructor.voidgetMatrices(SbMatrix&affine,SbMatrix&proj)constReturns two matrices corresponding to the view volume. 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.SbMatrixgetMatrix()constLike the method above, but returns the affine and projection parts together in one matrix (i.e.,affine.multRight(proj)).SbMatrixgetCameraSpaceMatrix()constReturns 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.voidprojectPointToLine(constSbVec2f&pt,SbLine&line)constvoidprojectPointToLine(constSbVec2f&pt,SbVec3f&line0,SbVec3f&line1)constMaps a 2D point (in 0 <= x,y <= 1) to a 3D line.voidprojectToScreen(constSbVec3f&src,SbVec3f&dst)constMaps the 3D point in world coordinates to a 2D point in normalized screen coordinates (0 <= x,y,z <= 1). 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.SbPlanegetPlane(floatdistFromEye)constReturns a plane parallel to the near (or far) plane of the view volume at a given distance from the projection point (eye).SbVec3fgetSightPoint(floatdistFromEye)constReturns the point along the line of sight at the given distance from the projection point (eye).SbVec3fgetPlanePoint(floatdistFromEye,constSbVec2f&normPoint)constReturns the projection of a given point in normalized screen coordinates (seeprojectToScreen()) onto the plane parallel to the near plane that is atdistFromEyeunits from the eye.SbRotationgetAlignRotation(SbBoolrightAngleOnly=FALSE)constReturns 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. IfrightAngleOnlyis TRUE, it will come as close as it can to this goal by using only 90 degree rotations.floatgetWorldToScreenScale(constSbVec3f&worldCenter,floatnormRadius)constReturns a scale factor that would scale a unit sphere centered atworldCenterso that it would appear to have the given radius in normalized screen coordinates when projected onto the near plane.SbVec2fprojectBox(constSbBox3f&box)constProjects the given 3D bounding box onto the near plane and returns the size (in normalized screen coordinates) of the rectangular region that encloses it.SbViewVolumenarrow(floatleft,floatbottom,floatright,floattop)constGiven a view volume, narrows the view to the given sub-rectangle of the near plane. 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.SbViewVolumenarrow(constSbBox3f&box)constNarrows a view volume by the given box. The box must lie inside the unit cube, and the view will be shrunk according to the size of the box.voidortho(floatleft,floatright,floatbottom,floattop,floatnear,floatfar)Sets up an orthographic view volume with the given sides. The parameters are the same as for the OpenGLglOrtho()routine.voidperspective(floatfovy,floataspect,floatnear,floatfar)Sets up a perspective view volume with the given field of view and aspect ratio. The parameters are the same as for the OpenGLgluPerspective()routine, except that the field of view angle is specified in radians.voidrotateCamera(constSbRotation&q)Rotate the camera view direction. Note that this accomplishes the reverse of doing an OpenGLglRotate()command after defining a camera, which rotates the scene viewed by the camera.voidtranslateCamera(constSbVec3f&v)Translate the camera viewpoint. Note that this accomplishes the reverse of doing an OpenGLglTranslate()command after defining a camera, which translates the scene viewed by the camera.SbVec3fzVector()constReturns the positive z axis in eye space. In this coordinate system, the z value of the near plane should be GREATER than the z value of the far plane.SbViewVolumezNarrow(floatnear,floatfar)constReturns a narrowed view volume which contains as tightly as possible the given interval on the z axis (in eye space). The returned view volume will never be larger than the current volume, however.nearandfarare given in terms ofzVector(): this means thatnear>farmust hold.voidscale(floatfactor)Scales width and height of view volume by given factor.voidscaleWidth(floatratio)voidscaleHeight(floatratio)Scales view volume to be the given ratio of its current width or height, leaving the resulting view volume centered about the same point (in the near plane) as the current one.ProjectionTypegetProjectionType()constconstSbVec3f&getProjectionPoint()constconstSbVec3f&getProjectionDirection()constReturns projection information.floatgetNearDist()constReturns distance from projection point to near plane.floatgetWidth()constfloatgetHeight()constfloatgetDepth()constReturns bounds of viewing frustum.

**SEE** **ALSO**

SbVec3f,SbVec2f,SbBox3f,SbMatrix,SbRotationSbViewVolume(3IV)()