| http://www.sim.no/ http://www.coin3d.org/

Public Types | Public Member Functions | List of all members
SbDPViewVolume Class Reference
Base Classes

The SbDPViewVolume class is a double precision viewing volume in 3D space.This class contains the necessary information for storing a view volume. It has methods for projection of primitives from or into the 3D volume, doing camera transforms, view volume transforms etc. More...

`#include <Inventor/SbLinear.h>`

## Public Types

enum | ProjectionType { ORTHOGRAPHIC = 0, PERSPECTIVE = 1 }

## Public Member Functions

| SbDPViewVolume (void)
| ~SbDPViewVolume (void)
void | getMatrices (SbDPMatrix &affine, SbDPMatrix &proj) const
SbDPMatrix | getMatrix (void) const
SbDPMatrix | getCameraSpaceMatrix (void) const
void | projectPointToLine (const SbVec2d &pt, SbDPLine &line) const
void | projectPointToLine (const SbVec2d &pt, SbVec3d &line0, SbVec3d &line1) const
void | projectToScreen (const SbVec3d &src, SbVec3d &dst) const
SbPlane | getPlane (const double distFromEye) const
SbVec3d | getSightPoint (const double distFromEye) const
SbVec3d | getPlanePoint (const double distFromEye, const SbVec2d &normPoint) const
SbDPRotation | getAlignRotation (SbBool rightAngleOnly=FALSE) const
double | getWorldToScreenScale (const SbVec3d &worldCenter, double normRadius) const
SbVec2d | projectBox (const SbBox3f &box) const
SbDPViewVolume | narrow (double left, double bottom, double right, double top) const
SbDPViewVolume | narrow (const SbBox3f &box) const
void | ortho (double left, double right, double bottom, double top, double nearval, double farval)
void | perspective (double fovy, double aspect, double nearval, double farval)
void | frustum (double left, double right, double bottom, double top, double nearval, double farval)
void | rotateCamera (const SbDPRotation &q)
void | translateCamera (const SbVec3d &v)
SbVec3d | zVector (void) const
SbDPViewVolume | zNarrow (double nearval, double farval) const
void | scale (double factor)
void | scaleWidth (double ratio)
void | scaleHeight (double ratio)
ProjectionType | getProjectionType (void) const
const SbVec3d & | getProjectionPoint (void) const
const SbVec3d & | getProjectionDirection (void) const
double | getNearDist (void) const
double | getWidth (void) const
double | getHeight (void) const
double | getDepth (void) const
void | print (FILE *fp) const
void | getViewVolumePlanes (SbPlane planes[6]) const
void | transform (const SbDPMatrix &matrix)
SbVec3d | getViewUp (void) const
void | copyValues (SbViewVolume &vv)

## Detailed Description

The SbDPViewVolume class is a double precision viewing volume in 3D space.

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

Be aware that this class is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

See also
  SbViewportRegion

Since
  Coin 2.0

## Member Enumeration Documentation

## ◆ ProjectionType

enum SbDPViewVolume::ProjectionType

An SbDPViewVolume 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

## ◆ SbDPViewVolume()

SbDPViewVolume::SbDPViewVolume | ( | void |  | ) |

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

See also
  ortho(), perspective().

## ◆ ~SbDPViewVolume()

SbDPViewVolume::~SbDPViewVolume | ( | void |  | ) |

Destructor.

## Member Function Documentation

## ◆ getMatrices()

void SbDPViewVolume::getMatrices | ( | SbDPMatrix & | affine,
|  | SbDPMatrix & | proj
| ) |  | const

Returns the view volume's affine matrix and projection matrix.

See also
  getMatrix(), getCameraSpaceMatrix()

## ◆ getMatrix()

SbDPMatrix SbDPViewVolume::getMatrix | ( | void |  | ) | const

Returns the combined affine and projection matrix.

See also
  getMatrices(), getCameraSpaceMatrix()

## ◆ getCameraSpaceMatrix()

SbDPMatrix SbDPViewVolume::getCameraSpaceMatrix | ( | void |  | ) | const

Returns 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()

## ◆ projectPointToLine() [1/2]

void SbDPViewVolume::projectPointToLine | ( | const SbVec2d & | pt,
|  | SbDPLine & | line
| ) |  | const

Project the given 2D point from the projection plane into a 3D line.

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

## ◆ projectPointToLine() [2/2]

void SbDPViewVolume::projectPointToLine | ( | const SbVec2d & | pt,
|  | SbVec3d & | line0,
|  | SbVec3d & | line1
| ) |  | const

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

## ◆ projectToScreen()

void SbDPViewVolume::projectToScreen | ( | const SbVec3d & | src,
|  | SbVec3d & | dst
| ) |  | const

Project 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 SbVec3d 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].

## ◆ getPlane()

SbPlane SbDPViewVolume::getPlane | ( | const double | distFromEye | ) | const

Returns 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()

## ◆ getSightPoint()

SbVec3d SbDPViewVolume::getSightPoint | ( | const double | distFromEye | ) | const

Returns the point on the center line-of-sight from the camera position with the given distance.

See also
  getPlane()

## ◆ getPlanePoint()

SbVec3d SbDPViewVolume::getPlanePoint | ( | const double | distFromEye,
|  | const SbVec2d & | normPoint
| ) |  | const

Return 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].

## ◆ getAlignRotation()

SbDPRotation SbDPViewVolume::getAlignRotation | ( | SbBool | rightangleonly = `FALSE` | ) | const

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

## ◆ getWorldToScreenScale()

double SbDPViewVolume::getWorldToScreenScale | ( | const SbVec3d & | worldCenter,
|  | double | normRadius
| ) |  | const

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

## ◆ projectBox()

SbVec2d SbDPViewVolume::projectBox | ( | const SbBox3f & | box | ) | const

Projects the given box onto the projection plane and returns the normalized screen space it occupies.

## ◆ narrow() [1/2]

SbDPViewVolume SbDPViewVolume::narrow | ( | double | left,
|  | double | bottom,
|  | double | right,
|  | double | top
| ) |  | const

Returns 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.:

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

..will give a view volume with corner points <25, 75> and <50, 100>.

See also
  scale(), scaleWidth(), scaleHeight()

## ◆ narrow() [2/2]

SbDPViewVolume SbDPViewVolume::narrow | ( | const SbBox3f & | box | ) | const

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

## ◆ ortho()

void SbDPViewVolume::ortho | ( | double | left,
|  | double | right,
|  | double | bottom,
|  | double | top,
|  | double | nearval,
|  | double | 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().

## ◆ perspective()

void SbDPViewVolume::perspective | ( | double | fovy,
|  | double | aspect,
|  | double | nearval,
|  | double | 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().

## ◆ frustum()

void SbDPViewVolume::frustum | ( | double | left,
|  | double | right,
|  | double | bottom,
|  | double | top,
|  | double | nearval,
|  | double | 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.

See also
  perspective()

## ◆ rotateCamera()

void SbDPViewVolume::rotateCamera | ( | const SbDPRotation & | q | ) |

Rotate the direction which the camera is pointing in.

See also
  translateCamera().

## ◆ translateCamera()

void SbDPViewVolume::translateCamera | ( | const SbVec3d & | v | ) |

Translate the camera position of the view volume.

See also
  rotateCamera().

## ◆ zVector()

SbVec3d SbDPViewVolume::zVector | ( | void |  | ) | const

Return 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().

## ◆ zNarrow()

SbDPViewVolume SbDPViewVolume::zNarrow | ( | double | nearval,
|  | double | farval
| ) |  | const

Return a copy SbDPViewVolume 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().

## ◆ scale()

void SbDPViewVolume::scale | ( | double | factor | ) |

Scale width and height of viewing frustum by the given ratio around the projection plane center axis.

See also
  scaleWidth(), scaleHeight().

## ◆ scaleWidth()

void SbDPViewVolume::scaleWidth | ( | double | ratio | ) |

Scale width of viewing frustum by the given ratio around the vertical center axis in the projection plane.

See also
  scale(), scaleHeight().

## ◆ scaleHeight()

void SbDPViewVolume::scaleHeight | ( | double | ratio | ) |

Scale height of viewing frustum by the given ratio around the horizontal center axis in the projection plane.

See also
  scale(), scaleWidth().

## ◆ getProjectionType()

SbDPViewVolume::ProjectionType SbDPViewVolume::getProjectionType | ( | void |  | ) | const

Return current view volume projection type, which can be either ORTHOGRAPHIC or PERSPECTIVE.

See also
  SbDPViewVolume::ProjectionType

## ◆ getProjectionPoint()

const SbVec3d & SbDPViewVolume::getProjectionPoint | ( | void |  | ) | const

Returns coordinates of center point in the projection plane.

## ◆ getProjectionDirection()

const SbVec3d & SbDPViewVolume::getProjectionDirection | ( | void |  | ) | const

Returns the direction of projection, i.e. the direction the camera is pointing.

See also
  getNearDist().

## ◆ getNearDist()

double SbDPViewVolume::getNearDist | ( | void |  | ) | const

Returns distance from projection plane to near clipping plane.

See also
  getProjectionDirection().

## ◆ getWidth()

double SbDPViewVolume::getWidth | ( | void |  | ) | const

Returns width of viewing frustum in the projection plane.

See also
  getHeight(), getDepth().

## ◆ getHeight()

double SbDPViewVolume::getHeight | ( | void |  | ) | const

Returns height of viewing frustum in the projection plane.

See also
  getWidth(), getDepth().

## ◆ getDepth()

double SbDPViewVolume::getDepth | ( | void |  | ) | const

Returns depth of viewing frustum, i.e. the distance from the near clipping plane to the far clipping plane.

See also
  getWidth(), getHeight().

## ◆ print()

void SbDPViewVolume::print | ( | FILE * | fp | ) | const

Dump the state of this object to the file stream. Only works in debug version of library, method does nothing in an optimized compile.

## ◆ getViewVolumePlanes()

void SbDPViewVolume::getViewVolumePlanes | ( | SbPlane | planes[6] | ) | const

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

## ◆ transform()

void SbDPViewVolume::transform | ( | const SbDPMatrix & | matrix | ) |

Transform the viewing volume by matrix.

## ◆ getViewUp()

SbVec3d SbDPViewVolume::getViewUp | ( | void |  | ) | const

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

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

- SbDPViewVolume.h
- SbDPViewVolume.cpp

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.