SbViewVolume.3coin2

Langue: en

Version: 379286 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

Sommaire

NAME

SbViewVolume -

The SbViewVolume class is a viewing volume in 3D space.

This class contains the necessary information for storing a view volume. It has methods for projection of primitives into the 3D volume from 2D points in the projection plane or vice versa, doing camera transforms, view volume transforms, etc.

SYNOPSIS


#include <Inventor/SbLinear.h>

Public Types


enum ProjectionType { ORTHOGRAPHIC = 0, PERSPECTIVE = 1 }

Public Member Functions


SbViewVolume (void)

~SbViewVolume (void)

void getMatrices (SbMatrix &affine, SbMatrix &proj) const

SbMatrix getMatrix (void) const

SbMatrix getCameraSpaceMatrix (void) const

void projectPointToLine (const SbVec2f &pt, SbLine &line) const

void projectPointToLine (const SbVec2f &pt, SbVec3f &line0, SbVec3f &line1) const

void projectToScreen (const SbVec3f &src, SbVec3f &dst) const

SbPlane getPlane (const float distFromEye) const

SbVec3f getSightPoint (const float distFromEye) const

SbVec3f getPlanePoint (const float distFromEye, const SbVec2f &normPoint) const

SbRotation getAlignRotation (SbBool rightAngleOnly=0) const

float getWorldToScreenScale (const SbVec3f &worldCenter, float normRadius) const

SbVec2f projectBox (const SbBox3f &box) const

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

SbViewVolume narrow (const SbBox3f &box) const

void ortho (float left, float right, float bottom, float top, float nearval, float farval)

void perspective (float fovy, float aspect, float nearval, float farval)

void frustum (float left, float right, float bottom, float top, float nearval, float farval)

void rotateCamera (const SbRotation &q)

void translateCamera (const SbVec3f &v)

SbVec3f zVector (void) const

SbViewVolume zNarrow (float nearval, float farval) const

void scale (float factor)

void scaleWidth (float ratio)

void scaleHeight (float ratio)

ProjectionType getProjectionType (void) const

const SbVec3f & getProjectionPoint (void) const

const SbVec3f & getProjectionDirection (void) const

float getNearDist (void) const

float getWidth (void) const

float getHeight (void) const

float getDepth (void) const

void print (FILE *fp) const

void getViewVolumePlanes (SbPlane planes[6]) const

void transform (const SbMatrix &matrix)

SbVec3f getViewUp (void) const

SbBool intersect (const SbVec3f &p) const

SbBool intersect (const SbVec3f &p0, const SbVec3f &p1, SbVec3f &closestpoint) const

SbBool intersect (const SbBox3f &box) const

SbBool outsideTest (const SbPlane &p, const SbVec3f &bmin, const SbVec3f &bmax) const

Public Attributes


ProjectionType type

SbVec3f projPoint

SbVec3f projDir

float nearDist

float nearToFar

SbVec3f llf

SbVec3f lrf

SbVec3f ulf

Detailed Description

The SbViewVolume class is a viewing volume in 3D space.

This class contains the necessary information for storing a view volume. It has methods for projection of primitives into the 3D volume from 2D points in the projection plane or vice versa, doing camera transforms, view volume transforms, etc.

See also:

SbViewportRegion

Member Enumeration Documentation

enum SbViewVolume::ProjectionTypeAn SbViewVolume instance can represent either an orthogonal projection volume or a perspective projection volume.

See also:

ortho(), perspective(), getProjectionType().

Enumerator:

ORTHOGRAPHIC
Orthographic projection.
PERSPECTIVE
Perspective projection.

Constructor & Destructor Documentation

SbViewVolume::SbViewVolume (void)Constructor. Note that the SbViewVolume instance will be uninitialized until you explicitly call ortho() or perspective().

See also:

ortho(), perspective().

SbViewVolume::~SbViewVolume (void)Destructor.

Member Function Documentation

void SbViewVolume::getMatrices (SbMatrix & affine, SbMatrix & proj) constReturns the view volume's affine matrix and projection matrix.

See also:

getMatrix(), getCameraSpaceMatrix()

Referenced by SoCamera::doAction(), SoNurbsProfile::getVertices(), and SoCamera::GLRender().

SbMatrix SbViewVolume::getMatrix (void) constReturns the combined affine and projection matrix.

See also:

getMatrices(), getCameraSpaceMatrix()

SbMatrix SbViewVolume::getCameraSpaceMatrix (void) constReturns a matrix which will translate the view volume camera back to origo, and rotate the camera so it'll point along the negative z axis.

Note that the matrix will not include the rotation necessary to make the camera up vector point along the positive y axis (i.e. camera roll is not accounted for).

See also:

getMatrices(), getMatrix()

void SbViewVolume::projectPointToLine (const SbVec2f & pt, SbLine & line) constProject the given 2D point from the projection plane into a 3D line.

pt coordinates should be normalized to be within [0, 1].

References SbLine::setValue().

Referenced by SoRayPickAction::computeWorldSpaceRay(), and SbProjector::getWorkingLine().

void SbViewVolume::projectPointToLine (const SbVec2f & pt, SbVec3f & line0, SbVec3f & line1) constProject the given 2D point from the projection plane into two points defining a 3D line. The first point, line0, will be the corresponding point for the projection on the near plane, while line1 will be the line endpoint, lying in the far plane.

void SbViewVolume::projectToScreen (const SbVec3f & src, SbVec3f & dst) constProject the src point to a normalized set of screen coordinates in the projection plane and place the result in dst.

It is safe to let src and be the same SbVec3f instance.

The z-coordinate of dst is monotonically increasing for points closer to the far plane. Note however that this is not a linear relationship, the dst z-coordinate is calculated as follows:

Orthogonal view: DSTz = (-2 * SRCz - far - near) / (far - near), Perspective view: DSTz = (-SRCz * (far - near) - 2*far*near) / (far - near)

The returned coordinates (dst) are normalized to be in range [0, 1].

Referenced by SbLineProjector::project().

SbPlane SbViewVolume::getPlane (const float distFromEye) constReturns an SbPlane instance which has a normal vector in the opposite direction of which the camera is pointing. This means the plane will be parallel to the near and far clipping planes.

See also:

getSightPoint()

Referenced by SbPlaneProjector::project(), SbLineProjector::project(), and SbProjector::verifyProjection().

SbVec3f SbViewVolume::getSightPoint (const float distFromEye) constReturns the point on the center line-of-sight from the camera position with the given distance.

See also:

getPlane()

SbVec3f SbViewVolume::getPlanePoint (const float distFromEye, const SbVec2f & normPoint) constReturn the 3D point which projects to normPoint and lies on the plane perpendicular to the camera direction and distFromEye distance away from the camera position.

normPoint should be given in normalized coordinates, where the visible render canvas is covered by the range [0.0, 1.0].

SbRotation SbViewVolume::getAlignRotation (SbBool rightangleonly = 0) constReturns a rotation that aligns an object so that its positive x-axis is to the right and its positive y-axis is up in the view volume.

If rightangleonly is TRUE, it will create a rotation that aligns the x and y-axis with the closest orthogonal axes to right and up.

References SbMatrix::getValue().

float SbViewVolume::getWorldToScreenScale (const SbVec3f & worldCenter, float normRadius) constGiven a sphere with center in worldCenter and an initial radius of 1.0, return the scale factor needed to make this sphere have a normRadius radius when projected onto the near clipping plane.

Referenced by SoTabPlaneDragger::reallyAdjustScaleTabSize().

SbVec2f SbViewVolume::projectBox (const SbBox3f & box) constProjects the given box onto the projection plane and returns the normalized screen space it occupies.

Referenced by SbProjector::findVanishingDistance().

SbViewVolume SbViewVolume::narrow (float left, float bottom, float right, float top) constReturns a narrowed version of the view volume which is within the given [0, 1] normalized coordinates. The coordinates are taken to be corner points of a normalized 'view window' on the near clipping plane. I.e.:

   SbViewVolume view;
   view.ortho(0, 100, 0, 100, 0.1, 1000);
   view = view.narrow(0.25, 0.5, 0.75, 1.0);
 

See also:

scale(), scaleWidth(), scaleHeight()

Referenced by SoRayPickAction::computeWorldSpaceRay().

SbViewVolume SbViewVolume::narrow (const SbBox3f & box) constReturns a narrowed version of the view volume which is within the given [0, 1] normalized coordinates. The box x and y coordinates are taken to be corner points of a normalized 'view window' on the near clipping plane. The box z coordinates are used to adjust the near and far clipping planes, and should be relative to the current clipping planes. A value of 1.0 is at the current near plane. A value of 0.0 is at the current far plane.

void SbViewVolume::ortho (float left, float right, float bottom, float top, float nearval, float farval)Set up the view volume as a rectangular box for orthographic parallel projections.

The line of sight will be along the negative z axis, through the center of the plane defined by the point

[(right+left)/2, (top+bottom)/2, 0]

See also:

perspective().

Referenced by SoNurbsProfile::getVertices(), and SoOrthographicCamera::getViewVolume().

void SbViewVolume::perspective (float fovy, float aspect, float nearval, float farval)Set up the view volume for perspective projections. The line of sight will be through origo along the negative z axis.

See also:

ortho().

Referenced by SoPerspectiveCamera::getViewVolume().

void SbViewVolume::frustum (float left, float right, float bottom, float top, float nearval, float farval)Set up the frustum for perspective projection. This is an alternative to perspective() that lets you specify any kind of view volumes (e.g. off center volumes). It has the same arguments and functionality as the corresponding OpenGL glFrustum() function.

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

Since:

Coin 2.0

See also:

perspective()

Referenced by SoFrustumCamera::getViewVolume(), and SoCamera::GLRender().

void SbViewVolume::rotateCamera (const SbRotation & q)Rotate the direction which the camera is pointing in.

See also:

translateCamera().

References SbRotation::getValue().

Referenced by SoPerspectiveCamera::getViewVolume(), SoOrthographicCamera::getViewVolume(), and SoFrustumCamera::getViewVolume().

void SbViewVolume::translateCamera (const SbVec3f & v)Translate the camera position of the view volume.

See also:

rotateCamera().

Referenced by SoPerspectiveCamera::getViewVolume(), SoOrthographicCamera::getViewVolume(), and SoFrustumCamera::getViewVolume().

SbVec3f SbViewVolume::zVector (void) constReturn the vector pointing from the center of the view volume towards the camera. This is just the vector pointing in the opposite direction of getProjectionDirection().

See also:

getProjectionDirection().

References projDir.

Referenced by SbSphereProjector::isPointInFront(), and SbCylinderProjector::isPointInFront().

SbViewVolume SbViewVolume::zNarrow (float nearval, float farval) constReturn a copy SbViewVolume with narrowed depth by supplying parameters for new near and far clipping planes.

nearval and should be relative to the current clipping planes. A value of 1.0 is at the current near plane. A value of 0.0 is at the current far plane.

See also:

zVector().

void SbViewVolume::scale (float factor)Scale width and height of viewing frustum by the given ratio around the projection plane center axis.

See also:

scaleWidth(), scaleHeight().

void SbViewVolume::scaleWidth (float ratio)Scale width of viewing frustum by the given ratio around the vertical center axis in the projection plane.

See also:

scale(), scaleHeight().

void SbViewVolume::scaleHeight (float ratio)Scale height of viewing frustum by the given ratio around the horizontal center axis in the projection plane.

See also:

scale(), scaleWidth().

SbViewVolume::ProjectionType SbViewVolume::getProjectionType (void) constReturn current view volume projection type, which can be either ORTHOGRAPHIC or PERSPECTIVE.

See also:

SbViewVolume::ProjectionType

References type.

Referenced by SoRayPickAction::computeWorldSpaceRay(), SbProjector::findVanishingDistance(), SbSphereProjector::isPointInFront(), SbCylinderProjector::isPointInFront(), print(), SbPlaneProjector::project(), and SbProjector::verifyProjection().

const SbVec3f & SbViewVolume::getProjectionPoint (void) constReturns the projection point, i.e. the camera position.

References projPoint.

Referenced by intersect(), SbSphereProjector::isPointInFront(), SbCylinderProjector::isPointInFront(), print(), and SoLOD::whichToTraverse().

const SbVec3f & SbViewVolume::getProjectionDirection (void) constReturns the direction of projection, i.e. the direction the camera is pointing.

See also:

getNearDist().

References projDir.

Referenced by SoRayPickAction::computeWorldSpaceRay(), SbProjector::findVanishingDistance(), SoCamera::GLRender(), intersect(), print(), SbSphereSheetProjector::setupPlane(), SbPlaneProjector::setupPlane(), SbCylinderSheetProjector::setupPlane(), SbSphereSectionProjector::setupTolerance(), and SbCylinderSectionProjector::setupTolerance().

float SbViewVolume::getNearDist (void) constReturns distance from projection plane to near clipping plane.

See also:

getProjectionDirection().

References nearDist.

Referenced by SoRayPickAction::computeWorldSpaceRay(), SoCamera::GLRender(), print(), SbPlaneProjector::project(), and SbLineProjector::project().

float SbViewVolume::getWidth (void) constReturns width of viewing frustum in the projection plane.

See also:

getHeight(), getDepth().

Referenced by SoCamera::audioRender(), SoRayPickAction::computeWorldSpaceRay(), SoCamera::doAction(), SoCamera::GLRender(), print(), and SoCamera::rayPick().

float SbViewVolume::getHeight (void) constReturns height of viewing frustum in the projection plane.

See also:

getWidth(), getDepth().

Referenced by SoCamera::audioRender(), SoRayPickAction::computeWorldSpaceRay(), SoCamera::doAction(), SbProjector::findVanishingDistance(), SoCamera::GLRender(), print(), and SoCamera::rayPick().

float SbViewVolume::getDepth (void) constReturns depth of viewing frustum, i.e. the distance from the near clipping plane to the far clipping plane.

See also:

getWidth(), getHeight().

References nearToFar.

Referenced by SoCamera::audioRender(), SoRayPickAction::computeWorldSpaceRay(), SoCamera::doAction(), SoCamera::GLRender(), print(), SbPlaneProjector::project(), SbLineProjector::project(), and SoCamera::rayPick().

void SbViewVolume::print (FILE * fp) constDump the state of this object to the file stream. Only works in debug version of library, method does nothing in an optimized compile.

References getDepth(), getHeight(), getNearDist(), getProjectionDirection(), getProjectionPoint(), getProjectionType(), getWidth(), llf, lrf, SbVec3f::print(), and ulf.

void SbViewVolume::getViewVolumePlanes (SbPlane planes[6]) constReturns the six planes defining the view volume in the following order: left, bottom, right, top, near, far. Plane normals are directed into the view volume.

This method is an extension for Coin, and is not available in the original Open Inventor.

Referenced by intersect().

void SbViewVolume::transform (const SbMatrix & matrix)Transform the viewing volume by matrix.

Referenced by SoCamera::audioRender(), SoCamera::doAction(), and SoCamera::GLRender().

SbVec3f SbViewVolume::getViewUp (void) constReturns the view up vector for this view volume. It's a vector which is perpendicular to the projection direction, and parallel and oriented in the same direction as the vector from the lower left corner to the upper left corner of the near plane.

Referenced by SoCamera::GLRender(), SbCylinderSheetProjector::setupPlane(), and SbCylinderSectionProjector::setupTolerance().

SbBool SbViewVolume::intersect (const SbVec3f & p) constReturns TRUE if p is inside the view volume.

Since:

Coin 2.3

References getViewVolumePlanes().

Referenced by intersect().

SbBool SbViewVolume::intersect (const SbVec3f & p0, const SbVec3f & p1, SbVec3f & closestpoint) constReturns TRUE if the line segment p0, p1 may intersect volume. Be aware that it's not 100% certain that the line segment intersects the volume even if this function returns TRUE.

closestpoint is set to the closest point on the line to the center ray of the view volume.

Since:

Coin 2.3

References SbBox3f::extendBy(), SbLine::getClosestPoints(), getProjectionDirection(), getProjectionPoint(), and intersect().

SbBool SbViewVolume::intersect (const SbBox3f & box) constReturns TRUE if box may be inside the view volume.

Since:

Coin 2.3

References SbBox3f::getMax(), SbBox3f::getMin(), and getViewVolumePlanes().

SbBool SbViewVolume::outsideTest (const SbPlane & p, const SbVec3f & bmin, const SbVec3f & bmax) constReturns TRUE if all eight corner points in bmin, bmax are outside p.

Since:

Coin 2.3

References SbPlane::isInHalfSpace().

Member Data Documentation

SbViewVolume::ProjectionType SbViewVolume::typeThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by getProjectionType().

SbVec3f SbViewVolume::projPointThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by getProjectionPoint().

SbVec3f SbViewVolume::projDirThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by getProjectionDirection(), and zVector().

float SbViewVolume::nearDistThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by getNearDist().

float SbViewVolume::nearToFarThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by getDepth().

SbVec3f SbViewVolume::llfThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by print().

SbVec3f SbViewVolume::lrfThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by print().

SbVec3f SbViewVolume::ulfThis API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Referenced by print().

Author

Generated automatically by Doxygen for Coin from the source code.