| 1 |
NAME SbViewVolume SbViewVol SB_VIEW_VOL_ { 3D viewing volume class } |
| 2 |
INCLUDE SbLinear.h |
| 3 |
DESC { |
| 4 |
Class used to represent a 3D viewing volume. This class is used |
| 5 |
to represent viewing frusta and picking volumes. For perspective projection, |
| 6 |
the view volume is a frustum. For orthographic (parallel) projection, the |
| 7 |
view volume is a rectangular prism. |
| 8 |
} |
| 9 |
METHOD "" SbViewVolume() {} |
| 10 |
METHOD "" ~SbViewVolume() { |
| 11 |
Constructor and destructor. |
| 12 |
} |
| 13 |
METHOD getMxs void getMatrices(SbMatrix &affine, SbMatrix &proj) const { |
| 14 |
Returns two matrices corresponding to the view volume. The |
| 15 |
first is a viewing matrix, which is guaranteed to be an affine |
| 16 |
transformation. The second is suitable for use as a projection |
| 17 |
matrix in OpenGL. |
| 18 |
} |
| 19 |
METHOD getMx SbMatrix getMatrix() const { |
| 20 |
Like the method above, but returns the affine and projection parts |
| 21 |
together in one matrix (i.e., \caffine.multRight( proj )\. ). |
| 22 |
} |
| 23 |
METHOD getBoxMx SbMatrix getCameraSpaceMatrix() const { |
| 24 |
Returns a matrix that transforms the view volume into camera |
| 25 |
space: it translates the view volume so the viewpoint is at |
| 26 |
the origin, and rotates it so the view direction is along the |
| 27 |
negative z axis. |
| 28 |
} |
| 29 |
METHOD projPtToLine void projectPointToLine(const SbVec2f &pt, |
| 30 |
SbLine &line) const {} |
| 31 |
METHOD projPtToLinePts void projectPointToLine(const SbVec2f &pt, |
| 32 |
SbVec3f &line0, SbVec3f &line1) const { |
| 33 |
Maps a 2D point (in 0 <= x,y <= 1) to a 3D line. |
| 34 |
} |
| 35 |
METHOD projToScreen void projectToScreen(const SbVec3f &src, |
| 36 |
SbVec3f &dst) const { |
| 37 |
Maps the 3D point in world coordinates to a 2D point in |
| 38 |
normalized screen coordinates (0 <= x,y,z <= 1). |
| 39 |
The z-screen coordinate represents the homogenized z coordinate |
| 40 |
which goes (nonlinearly) from 0 at the near clipping plane to |
| 41 |
1 at the far clipping plane. |
| 42 |
} |
| 43 |
METHOD getPln SbPlane getPlane(float distFromEye) const { |
| 44 |
Returns a plane parallel to the near (or far) plane of the view |
| 45 |
volume at a given distance from the projection point (eye). |
| 46 |
} |
| 47 |
METHOD getSightPt SbVec3f getSightPoint(float distFromEye) const { |
| 48 |
Returns the point along the line of sight at the given distance |
| 49 |
from the projection point (eye). |
| 50 |
} |
| 51 |
METHOD getPlnPt SbVec3f getPlanePoint(float distFromEye, |
| 52 |
const SbVec2f &normPoint) const { |
| 53 |
Returns the projection of a given point in normalized screen |
| 54 |
coordinates (see \mprojectToScreen()\.) onto the plane parallel to the |
| 55 |
near plane that is at \adistFromEye\. units from the eye. |
| 56 |
} |
| 57 |
METHOD getAlignRot SbRotation getAlignRotation( |
| 58 |
SbBool rightAngleOnly = FALSE) const { |
| 59 |
Returns a rotation that would align a viewed object so that |
| 60 |
its positive x-axis (of its object space) is to the right in |
| 61 |
the view and its positive y-axis is up. If \arightAngleOnly\. is |
| 62 |
TRUE, it will come as close as it can to this goal by using |
| 63 |
only 90 degree rotations. |
| 64 |
} |
| 65 |
METHOD "" float getWorldToScreenScale(const SbVec3f &worldCenter, |
| 66 |
float normRadius) const { |
| 67 |
Returns a scale factor that would scale a unit sphere centered |
| 68 |
at \aworldCenter\. so that it would appear to have the given radius |
| 69 |
in normalized screen coordinates when projected onto the near plane. |
| 70 |
} |
| 71 |
METHOD projBox SbVec2f projectBox(const SbBox3f &box) const { |
| 72 |
Projects the given 3D bounding box onto the near plane and |
| 73 |
returns the size (in normalized screen coordinates) of the |
| 74 |
rectangular region that encloses it. |
| 75 |
} |
| 76 |
METHOD narrow2d SbViewVolume narrow(float left, float bottom, |
| 77 |
float right, float top) const { |
| 78 |
Given a view volume, narrows the view to the given sub-rectangle |
| 79 |
of the near plane. The coordinates of the rectangle are between |
| 80 |
0 and 1, where (0,0) is the lower-left corner of the near plane |
| 81 |
and (1,1) is the upper-right corner. |
| 82 |
} |
| 83 |
METHOD narrow3d SbViewVolume narrow(const SbBox3f &box) const { |
| 84 |
Narrows a view volume by the given box. The box must lie inside |
| 85 |
the unit cube, and the view will be shrunk according to the |
| 86 |
size of the box. |
| 87 |
} |
| 88 |
METHOD "" void ortho(float left, float right, |
| 89 |
float bottom, float top, |
| 90 |
float near, float far) { |
| 91 |
Sets up an orthographic view volume with the given sides. |
| 92 |
The parameters are the same as for the OpenGL \mglOrtho()\. routine. |
| 93 |
} |
| 94 |
METHOD persp void perspective(float fovy, float aspect, |
| 95 |
float near, float far) { |
| 96 |
Sets up a perspective view volume with the given field of view |
| 97 |
and aspect ratio. The parameters are the same as for the OpenGL |
| 98 |
\mgluPerspective()\. routine, except that the field of view angle is |
| 99 |
specified in radians. |
| 100 |
} |
| 101 |
METHOD rotCam void rotateCamera(const SbRotation &q) { |
| 102 |
Rotate the camera view direction. Note that this accomplishes |
| 103 |
the reverse of doing an OpenGL \mglRotate()\. command after defining a |
| 104 |
camera, which rotates the scene viewed by the camera. |
| 105 |
} |
| 106 |
METHOD xlateCam void translateCamera(const SbVec3f &v) { |
| 107 |
Translate the camera viewpoint. Note that this accomplishes |
| 108 |
the reverse of doing an OpenGL \mglTranslate()\. command after defining a |
| 109 |
camera, which translates the scene viewed by the camera. |
| 110 |
} |
| 111 |
METHOD zVec SbVec3f zVector() const { |
| 112 |
Returns the positive z axis in eye space. In this coordinate |
| 113 |
system, the z value of the near plane should be GREATER than the |
| 114 |
z value of the far plane. |
| 115 |
} |
| 116 |
METHOD "" SbViewVolume zNarrow(float near, float far) const { |
| 117 |
Returns a narrowed view volume which contains as tightly as |
| 118 |
possible the given interval on the z axis (in eye space). The |
| 119 |
returned view volume will never be larger than the current volume, |
| 120 |
however. \anear\. and \afar\. are given in terms of \mzVector()\.: this |
| 121 |
means that \anear\. > \afar\. must hold. |
| 122 |
} |
| 123 |
METHOD "" void scale(float factor) { |
| 124 |
Scales width and height of view volume by given factor. |
| 125 |
} |
| 126 |
METHOD "" void scaleWidth(float ratio) {} |
| 127 |
METHOD "" void scaleHeight(float ratio) { |
| 128 |
Scales view volume to be the given ratio of its current width |
| 129 |
or height, leaving the resulting view volume centered about the |
| 130 |
same point (in the near plane) as the current one. |
| 131 |
} |
| 132 |
ENUM ProjectionType { |
| 133 |
ORTHOGRAPHIC "Orthographic projection", |
| 134 |
PERSPECTIVE "Perspective projection" |
| 135 |
} |
| 136 |
METHOD getProjType ProjectionType getProjectionType() const {} |
| 137 |
METHOD getProjPt const SbVec3f & getProjectionPoint() const {} |
| 138 |
METHOD getProjDir const SbVec3f & getProjectionDirection() const { |
| 139 |
Returns projection information. |
| 140 |
} |
| 141 |
METHOD "" float getNearDist() const { |
| 142 |
Returns distance from projection point to near plane. |
| 143 |
} |
| 144 |
METHOD "" float getWidth() const {} |
| 145 |
METHOD "" float getHeight() const {} |
| 146 |
METHOD "" float getDepth() const { |
| 147 |
Returns bounds of viewing frustum. |
| 148 |
} |
| 149 |
ALSO { SbVec3f, SbVec2f, SbBox3f, SbMatrix, SbRotation } |
| 150 |
|
| 151 |
|