1SbViewVolume(3IV)() SbViewVolume(3IV)()
2
3
4
6 SbViewVolume — 3D viewing volume class
7
9 SbViewVolume
10
12 #include <Inventor/SbLinear.h>
13
14 enum ProjectionType {
15 SbViewVolume::ORTHOGRAPHIC Orthographic projection
16 SbViewVolume::PERSPECTIVE Perspective projection
17 }
18
19 Methods from class SbViewVolume:
20
21 SbViewVolume()
22 ~SbViewVolume()
23 void getMatrices(SbMatrix &affine, SbMatrix &proj) const
24 SbMatrix getMatrix() const
25 SbMatrix getCameraSpaceMatrix() const
26 void projectPointToLine(const SbVec2f &pt, SbLine &line)
27 const
28 void projectPointToLine(const SbVec2f &pt, SbVec3f &line0,
29 SbVec3f &line1) const
30 void projectToScreen(const SbVec3f &src, SbVec3f &dst)
31 const
32 SbPlane getPlane(float distFromEye) const
33 SbVec3f getSightPoint(float distFromEye) const
34 SbVec3f getPlanePoint(float distFromEye, const SbVec2f &norm‐
35 Point) const
36 SbRotation getAlignRotation(SbBool rightAngleOnly = FALSE) const
37 float getWorldToScreenScale(const SbVec3f &worldCenter,
38 float normRadius) const
39 SbVec2f projectBox(const SbBox3f &box) const
40 SbViewVolume narrow(float left, float bottom, float right, float
41 top) const
42 SbViewVolume narrow(const SbBox3f &box) const
43 void ortho(float left, float right, float bottom, float
44 top, float near, float far)
45 void perspective(float fovy, float aspect, float near,
46 float far)
47 void rotateCamera(const SbRotation &q)
48 void translateCamera(const SbVec3f &v)
49 SbVec3f zVector() const
50 SbViewVolume zNarrow(float near, float far) const
51 void scale(float factor)
52 void scaleWidth(float ratio)
53 void scaleHeight(float ratio)
54 ProjectionType getProjectionType() const
55 const SbVec3f & getProjectionPoint() const
56 const SbVec3f & getProjectionDirection() const
57 float getNearDist() const
58 float getWidth() const
59 float getHeight() const
60 float getDepth() const
61
62
64 Class used to represent a 3D viewing volume. This class is used to rep‐
65 resent viewing frusta and picking volumes. For perspective projection,
66 the view volume is a frustum. For orthographic (parallel) projection,
67 the view volume is a rectangular prism.
68
70 SbViewVolume()
71 ~SbViewVolume()
72 Constructor and destructor.
73
74 void getMatrices(SbMatrix &affine, SbMatrix &proj) const
75 Returns two matrices corresponding to the view volume. The first is
76 a viewing matrix, which is guaranteed to be an affine transforma‐
77 tion. The second is suitable for use as a projection matrix in
78 OpenGL.
79
80 SbMatrix getMatrix() const
81 Like the method above, but returns the affine and projection parts
82 together in one matrix (i.e., affine.multRight( proj ) ).
83
84 SbMatrix getCameraSpaceMatrix() const
85 Returns a matrix that transforms the view volume into camera space:
86 it translates the view volume so the viewpoint is at the origin, and
87 rotates it so the view direction is along the negative z axis.
88
89 void projectPointToLine(const SbVec2f &pt, SbLine &line)
90 const
91 void projectPointToLine(const SbVec2f &pt, SbVec3f &line0,
92 SbVec3f &line1) const
93 Maps a 2D point (in 0 <= x,y <= 1) to a 3D line.
94
95 void projectToScreen(const SbVec3f &src, SbVec3f &dst)
96 const
97 Maps the 3D point in world coordinates to a 2D point in normalized
98 screen coordinates (0 <= x,y,z <= 1). The z-screen coordinate repre‐
99 sents the homogenized z coordinate which goes (nonlinearly) from 0
100 at the near clipping plane to 1 at the far clipping plane.
101
102 SbPlane getPlane(float distFromEye) const
103 Returns a plane parallel to the near (or far) plane of the view vol‐
104 ume at a given distance from the projection point (eye).
105
106 SbVec3f getSightPoint(float distFromEye) const
107 Returns the point along the line of sight at the given distance from
108 the projection point (eye).
109
110 SbVec3f getPlanePoint(float distFromEye, const SbVec2f &norm‐
111 Point) const
112 Returns the projection of a given point in normalized screen coordi‐
113 nates (see projectToScreen()) onto the plane parallel to the near
114 plane that is at distFromEye units from the eye.
115
116 SbRotation getAlignRotation(SbBool rightAngleOnly = FALSE) const
117 Returns a rotation that would align a viewed object so that its pos‐
118 itive x-axis (of its object space) is to the right in the view and
119 its positive y-axis is up. If rightAngleOnly is TRUE, it will come
120 as close as it can to this goal by using only 90 degree rotations.
121
122 float getWorldToScreenScale(const SbVec3f &worldCenter,
123 float normRadius) const
124 Returns a scale factor that would scale a unit sphere centered at
125 worldCenter so that it would appear to have the given radius in nor‐
126 malized screen coordinates when projected onto the near plane.
127
128 SbVec2f projectBox(const SbBox3f &box) const
129 Projects the given 3D bounding box onto the near plane and returns
130 the size (in normalized screen coordinates) of the rectangular
131 region that encloses it.
132
133 SbViewVolume narrow(float left, float bottom, float right, float
134 top) const
135 Given a view volume, narrows the view to the given sub-rectangle of
136 the near plane. The coordinates of the rectangle are between 0 and
137 1, where (0,0) is the lower-left corner of the near plane and (1,1)
138 is the upper-right corner.
139
140 SbViewVolume narrow(const SbBox3f &box) const
141 Narrows a view volume by the given box. The box must lie inside the
142 unit cube, and the view will be shrunk according to the size of the
143 box.
144
145 void ortho(float left, float right, float bottom, float
146 top, float near, float far)
147 Sets up an orthographic view volume with the given sides. The param‐
148 eters are the same as for the OpenGL glOrtho() routine.
149
150 void perspective(float fovy, float aspect, float near,
151 float far)
152 Sets up a perspective view volume with the given field of view and
153 aspect ratio. The parameters are the same as for the OpenGL gluPer‐
154 spective() routine, except that the field of view angle is specified
155 in radians.
156
157 void rotateCamera(const SbRotation &q)
158 Rotate the camera view direction. Note that this accomplishes the
159 reverse of doing an OpenGL glRotate() command after defining a cam‐
160 era, which rotates the scene viewed by the camera.
161
162 void translateCamera(const SbVec3f &v)
163 Translate the camera viewpoint. Note that this accomplishes the
164 reverse of doing an OpenGL glTranslate() command after defining a
165 camera, which translates the scene viewed by the camera.
166
167 SbVec3f zVector() const
168 Returns the positive z axis in eye space. In this coordinate system,
169 the z value of the near plane should be GREATER than the z value of
170 the far plane.
171
172 SbViewVolume zNarrow(float near, float far) const
173 Returns a narrowed view volume which contains as tightly as possible
174 the given interval on the z axis (in eye space). The returned view
175 volume will never be larger than the current volume, however. near
176 and far are given in terms of zVector(): this means that near > far
177 must hold.
178
179 void scale(float factor)
180 Scales width and height of view volume by given factor.
181
182 void scaleWidth(float ratio)
183 void scaleHeight(float ratio)
184 Scales view volume to be the given ratio of its current width or
185 height, leaving the resulting view volume centered about the same
186 point (in the near plane) as the current one.
187
188 ProjectionType getProjectionType() const
189 const SbVec3f & getProjectionPoint() const
190 const SbVec3f & getProjectionDirection() const
191 Returns projection information.
192
193 float getNearDist() const
194 Returns distance from projection point to near plane.
195
196 float getWidth() const
197 float getHeight() const
198 float getDepth() const
199 Returns bounds of viewing frustum.
200
201
203 SbVec3f, SbVec2f, SbBox3f, SbMatrix, SbRotation
204
205
206
207
208 SbViewVolume(3IV)()