HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
frustum.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef GF_FRUSTUM_H
25 #define GF_FRUSTUM_H
26 
27 /// \file gf/frustum.h
28 /// \ingroup group_gf_BasicGeometry
29 
30 #include "pxr/pxr.h"
31 #include "pxr/base/gf/bbox3d.h"
32 #include "pxr/base/gf/matrix4d.h"
33 #include "pxr/base/gf/plane.h"
34 #include "pxr/base/gf/ray.h"
35 #include "pxr/base/gf/range1d.h"
36 #include "pxr/base/gf/range2d.h"
37 #include "pxr/base/gf/rotation.h"
38 #include "pxr/base/gf/vec2d.h"
39 #include "pxr/base/gf/vec3d.h"
40 #include "pxr/base/gf/api.h"
41 
42 #include <hboost/functional/hash.hpp>
43 
44 #include <iosfwd>
45 #include <vector>
46 
48 
49 /// \class GfFrustum
50 /// \ingroup group_gf_BasicGeometry
51 ///
52 /// Basic type: View frustum.
53 ///
54 /// This class represents a viewing frustum in three dimensional eye space. It
55 /// may represent either a parallel (orthographic) or perspective projection.
56 /// One can think of the frustum as being defined by 6 boundary planes.
57 ///
58 /// The frustum is specified using these parameters:
59 /// \li The \em position of the viewpoint.
60 /// \li The \em rotation applied to the default view frame, which is
61 /// looking along the -z axis with the +y axis as the "up"
62 /// direction.
63 /// \li The 2D \em window on the reference plane that defines the left,
64 /// right, top, and bottom planes of the viewing frustum, as
65 /// described below.
66 /// \li The distances to the \em near and \em far planes.
67 /// \li The \em projection \em type
68 /// \li The view distance.
69 ///
70 /// The window and near/far parameters combine to define the view frustum as
71 /// follows. Transform the -z axis and the +y axis by the frustum rotation to
72 /// get the world-space \em view \em direction and \em up \em direction. Now
73 /// consider the \em reference \em plane that is perpendicular to the view
74 /// direction, a distance of referencePlaneDepth from the viewpoint, and whose
75 /// y axis corresponds to the up direction. The window rectangle is specified
76 /// in a 2D coordinate system embedded in this plane. The origin of the
77 /// coordinate system is the point at which the view direction vector
78 /// intersects the plane. Therefore, the point (0,1) in this plane is found by
79 /// moving 1 unit along the up direction vector in this plane. The vector from
80 /// the viewpoint to the resulting point will form a 45-degree angle with the
81 /// view direction.
82 ///
83 /// The view distance is only useful for interactive applications. It can be
84 /// used to compute a look at point which is useful when rotating around an
85 /// object of interest.
86 ///
87 class GfFrustum {
88  public:
89  /// This enum is used to determine the type of projection represented by a
90  /// frustum.
92  Orthographic, ///< Orthographic projection
93  Perspective, ///< Perspective projection
94  };
95 
96  /// This constructor creates an instance with default viewing parameters:
97  /// \li The position is the origin.
98  /// \li The rotation is the identity rotation. (The view is along
99  /// the -z axis, with the +y axis as "up").
100  /// \li The window is -1 to +1 in both dimensions.
101  /// \li The near/far interval is (1, 10).
102  /// \li The view distance is 5.0.
103  /// \li The projection type is \c GfFrustum::Perspective.
104  GF_API GfFrustum();
105 
106  /// This constructor creates an instance with the given viewing
107  /// parameters.
108  GF_API GfFrustum(const GfVec3d &position, const GfRotation &rotation,
109  const GfRange2d &window, const GfRange1d &nearFar,
110  GfFrustum::ProjectionType projectionType,
111  double viewDistance = 5.0);
112 
113  /// This constructor creates an instance from a camera matrix (always of a
114  /// y-Up camera, also see SetPositionAndRotationFromMatrix) and the given
115  /// viewing parameters.
116  GF_API GfFrustum(const GfMatrix4d &camToWorldXf,
117  const GfRange2d &window, const GfRange1d &nearFar,
118  GfFrustum::ProjectionType projectionType,
119  double viewDistance = 5.0);
120 
121  friend inline size_t hash_value(const GfFrustum &f) {
122  size_t h = 0;
123  hboost::hash_combine(h, f._position);
124  hboost::hash_combine(h, f._rotation);
125  hboost::hash_combine(h, f._window);
126  hboost::hash_combine(h, f._nearFar);
127  hboost::hash_combine(h, f._viewDistance);
128  hboost::hash_combine(h, f._projectionType);
129  return h;
130  }
131 
132  // Equality operator. true iff all parts match.
133  bool operator ==(const GfFrustum& f) const {
134  if (_position != f._position) return false;
135  if (_rotation != f._rotation) return false;
136  if (_window != f._window) return false;
137  if (_nearFar != f._nearFar) return false;
138  if (_viewDistance != f._viewDistance) return false;
139  if (_projectionType != f._projectionType) return false;
140 
141  return true;
142  }
143 
144  // Inequality operator. true iff not equality.
145  bool operator !=(const GfFrustum& f) const {
146  return !(*this == f);
147  }
148 
149  /// Destructor.
150  GF_API ~GfFrustum();
151 
152  /// \name Value setting and access
153  /// The methods in this group set and access the values that are used to
154  /// define a frustum.
155  ///@{
156 
157  /// Sets the position of the frustum in world space.
158  void SetPosition(const GfVec3d &position) {
159  _position = position;
160  _DirtyFrustumPlanes();
161  }
162 
163  /// Returns the position of the frustum in world space.
164  const GfVec3d & GetPosition() const {
165  return _position;
166  }
167 
168  /// Sets the orientation of the frustum in world space as a rotation to
169  /// apply to the default frame: looking along the -z axis with the +y axis
170  /// as "up".
172  _rotation = rotation;
173  _DirtyFrustumPlanes();
174  }
175 
176  /// Returns the orientation of the frustum in world space as a rotation to
177  /// apply to the -z axis.
178  const GfRotation & GetRotation() const {
179  return _rotation;
180  }
181 
182  /// Sets the position and rotation of the frustum from a camera matrix
183  /// (always from a y-Up camera). The resulting frustum's transform will
184  /// always represent a right-handed and orthonormal coordinate sytem
185  /// (scale, shear, and projection are removed from the given \p
186  /// camToWorldXf).
187  GF_API void SetPositionAndRotationFromMatrix(const GfMatrix4d &camToWorldXf);
188 
189  /// Sets the window rectangle in the reference plane that defines the
190  /// left, right, top, and bottom planes of the frustum.
191  void SetWindow(const GfRange2d &window) {
192  _window = window;
193  _DirtyFrustumPlanes();
194  }
195 
196  /// Returns the window rectangle in the reference plane.
197  const GfRange2d & GetWindow() const {
198  return _window;
199  }
200 
201  /// Returns the depth of the reference plane.
202  static double GetReferencePlaneDepth() {
203  return 1.0;
204  }
205 
206  /// Sets the near/far interval.
207  void SetNearFar(const GfRange1d &nearFar) {
208  _nearFar = nearFar;
209  _DirtyFrustumPlanes();
210  }
211 
212  /// Returns the near/far interval.
213  const GfRange1d & GetNearFar() const {
214  return _nearFar;
215  }
216 
217  /// Sets the view distance.
218  void SetViewDistance(double viewDistance) {
219  _viewDistance = viewDistance;
220  }
221 
222  /// Returns the view distance.
223  double GetViewDistance() const {
224  return _viewDistance;
225  }
226 
227  /// Sets the projection type.
229  _projectionType = projectionType;
230  _DirtyFrustumPlanes();
231  }
232 
233  /// Returns the projection type.
235  return _projectionType;
236  }
237 
238  ///@}
239 
240  /// \name Convenience methods
241  ///
242  /// The methods in this group allow the frustum's data to be accessed and
243  /// modified in terms of different representations that may be more
244  /// convenient for certain applications.
245  ///
246  ///@{
247 
248  /// Sets up the frustum in a manner similar to \c gluPerspective().
249  ///
250  /// It sets the projection type to \c GfFrustum::Perspective and sets the
251  /// window specification so that the resulting symmetric frustum encloses
252  /// an angle of \p fieldOfViewHeight degrees in the vertical direction,
253  /// with \p aspectRatio used to figure the angle in the horizontal
254  /// direction. The near and far distances are specified as well. The
255  /// window coordinates are computed as:
256  /// \code
257  /// top = tan(fieldOfViewHeight / 2)
258  /// bottom = -top
259  /// right = top * aspectRatio
260  /// left = -right
261  /// near = nearDistance
262  /// far = farDistance
263  /// \endcode
264  ///
265  GF_API void SetPerspective(double fieldOfViewHeight,
266  double aspectRatio,
267  double nearDistance, double farDistance);
268 
269  /// Sets up the frustum in a manner similar to gluPerspective().
270  ///
271  /// It sets the projection type to \c GfFrustum::Perspective and
272  /// sets the window specification so that:
273  ///
274  /// If \a isFovVertical is true, the resulting symmetric frustum encloses
275  /// an angle of \p fieldOfView degrees in the vertical direction, with \p
276  /// aspectRatio used to figure the angle in the horizontal direction.
277  ///
278  /// If \a isFovVertical is false, the resulting symmetric frustum encloses
279  /// an angle of \p fieldOfView degrees in the horizontal direction, with
280  /// \p aspectRatio used to figure the angle in the vertical direction.
281  ///
282  /// The near and far distances are specified as well. The window
283  /// coordinates are computed as follows:
284  ///
285  /// \li if isFovVertical:
286  /// \li top = tan(fieldOfView / 2)
287  /// \li right = top * aspectRatio
288  /// \li if NOT isFovVertical:
289  /// \li right = tan(fieldOfView / 2)
290  /// \li top = right / aspectRation
291  /// \li bottom = -top
292  /// \li left = -right
293  /// \li near = nearDistance
294  /// \li far = farDistance
295  ///
296  GF_API void SetPerspective(double fieldOfView,
297  bool isFovVertical,
298  double aspectRatio,
299  double nearDistance, double farDistance);
300 
301  /// Returns the current frustum in the format used by \c SetPerspective().
302  /// If the current frustum is not a perspective projection, this returns
303  /// \c false and leaves the parameters untouched.
304  GF_API bool GetPerspective(double *fieldOfViewHeight,
305  double *aspectRatio,
306  double *nearDistance,
307  double *farDistance) const;
308 
309  /// Returns the current frustum in the format used by \c SetPerspective().
310  /// If the current frustum is not a perspective projection, this returns
311  /// \c false and leaves the parameters untouched.
312  GF_API bool GetPerspective(bool isFovVertical,
313  double *fieldOfView,
314  double *aspectRatio,
315  double *nearDistance,
316  double *farDistance) const;
317 
318  /// Returns the horizontal or vertical fov of the frustum. The fov of the
319  /// frustum is not necessarily the same value as displayed in the viewer.
320  /// The displayed fov is a function of the focal length or FOV avar. The
321  /// frustum's fov may be different due to things like lens breathing.
322  ///
323  /// If the frustum is not of type \c GfFrustum::Perspective, the returned
324  /// FOV will be 0.0.
325  ///
326  /// \note The default value for \c isFovVertical is false so calling \c
327  /// GetFOV without an argument will return the horizontal field of view
328  /// which is compatible with menv2x's old GfFrustum::GetFOV routine.
329  GF_API double GetFOV(bool isFovVertical = false);
330 
331  /// Sets up the frustum in a manner similar to \c glOrtho().
332  ///
333  /// Sets the projection to \c GfFrustum::Orthographic and sets the window
334  /// and near/far specifications based on the given values.
335  GF_API
336  void SetOrthographic(double left, double right,
337  double bottom, double top,
338  double nearPlane, double farPlane);
339 
340  /// Returns the current frustum in the format used by \c
341  /// SetOrthographic(). If the current frustum is not an orthographic
342  /// projection, this returns \c false and leaves the parameters untouched.
343  GF_API bool GetOrthographic(double *left, double *right,
344  double *bottom, double *top,
345  double *nearPlane, double *farPlane)
346  const;
347 
348  /// Modifies the frustum to tightly enclose a sphere with the given center
349  /// and radius, using the current view direction. The planes of the
350  /// frustum are adjusted as necessary. The given amount of slack is added
351  /// to the sphere's radius is used around the sphere to avoid boundary
352  /// problems.
353  GF_API void FitToSphere(const GfVec3d &center,
354  double radius,
355  double slack = 0.0);
356 
357  /// Transforms the frustum by the given matrix.
358  ///
359  /// The transformation matrix is applied as follows: the position and the
360  /// direction vector are transformed with the given matrix. Then the
361  /// length of the new direction vector is used to rescale the near and far
362  /// plane and the view distance. Finally, the points that define the
363  /// reference plane are transformed by the matrix. This method assures
364  /// that the frustum will not be sheared or perspective-projected.
365  ///
366  /// \note Note that this definition means that the transformed frustum
367  /// does not preserve scales very well. Do \em not use this function to
368  /// transform a frustum that is to be used for precise operations such as
369  /// intersection testing.
371 
372  /// Returns the normalized world-space view direction vector, which is
373  /// computed by rotating the -z axis by the frustum's rotation.
375 
376  /// Returns the normalized world-space up vector, which is computed by
377  /// rotating the y axis by the frustum's rotation.
379 
380  /// Computes the view frame defined by this frustum. The frame consists of
381  /// the view direction, up vector and side vector, as shown in this
382  /// diagram.
383  ///
384  /// \code
385  /// up
386  /// ^ ^
387  /// | /
388  /// | / view
389  /// |/
390  /// +- - - - > side
391  /// \endcode
392  ///
393  GF_API void ComputeViewFrame(GfVec3d *side,
394  GfVec3d *up,
395  GfVec3d *view) const;
396 
397  /// Computes and returns the world-space look-at point from the eye point
398  /// (position), view direction (rotation), and view distance.
400 
401  /// Returns a matrix that represents the viewing transformation for this
402  /// frustum. That is, it returns the matrix that converts points from
403  /// world space to eye (frustum) space.
405 
406  /// Returns a matrix that represents the inverse viewing transformation
407  /// for this frustum. That is, it returns the matrix that converts points
408  /// from eye (frustum) space to world space.
410 
411  /// Returns a GL-style projection matrix corresponding to the frustum's
412  /// projection.
414 
415  /// Returns the aspect ratio of the frustum, defined as the width of the
416  /// window divided by the height. If the height is zero or negative, this
417  /// returns 0.
418  GF_API double ComputeAspectRatio() const;
419 
420  /// Returns the world-space corners of the frustum as a vector of 8
421  /// points, ordered as:
422  /// \li Left bottom near
423  /// \li Right bottom near
424  /// \li Left top near
425  /// \li Right top near
426  /// \li Left bottom far
427  /// \li Right bottom far
428  /// \li Left top far
429  /// \li Right top far
430  GF_API
431  std::vector<GfVec3d> ComputeCorners() const;
432 
433  /// Returns the world-space corners of the intersection of the frustum
434  /// with a plane parallel to the near/far plane at distance d from the
435  /// apex, ordered as:
436  /// \li Left bottom
437  /// \li Right bottom
438  /// \li Left top
439  /// \li Right top
440  /// In particular, it gives the partial result of ComputeCorners when given
441  /// near or far distance.
442  GF_API
443  std::vector<GfVec3d> ComputeCornersAtDistance(double d) const;
444 
445  /// Returns a frustum that is a narrowed-down version of this frustum,
446  /// such that the frustum rectangle on the near plane encloses \p point
447  /// with at most \p halfSize[0] distance on the left and right and at most
448  /// \p halfSize[1] distance on the top and bottom. (If \p point is closer
449  /// than the half size to a side of the frustum, that side is left alone.
450  /// The point and sizes are in normalized 2D coordinates; they range from
451  /// (-1, -1) at the lower left corner of the near-plane window rectangle
452  /// to (1,1) at the upper right corner.
453  ///
454  /// \p point is a 2d point expressed as a normalized window position.
455  ///
456  /// This method is useful for computing a volume to use for interactive
457  /// picking.
459  const GfVec2d &halfSize) const;
460 
461  /// Returns a frustum that is a narrowed-down version of this frustum,
462  /// such that the frustum rectangle on the near plane encloses \p point
463  /// with at most \p halfSize[0] distance on the left and right and at most
464  /// \p halfSize[1] distance on the top and bottom. (If \p point is closer
465  /// than the half size to a side of the frustum, that side is left alone.
466  /// The point and sizes are in normalized 2D coordinates; they range from
467  /// (-1, -1) at the lower left corner of the near-plane window rectangle
468  /// to (1,1) at the upper right corner.
469  ///
470  /// \p point is a 3d point expressed in world coordinates
471  ///
472  /// This method is useful for computing a volume to use for interactive
473  /// picking.
475  const GfVec2d &halfSize) const;
476 
477  /// Builds and returns a \c GfRay that starts at the viewpoint and extends
478  /// through the given \a windowPos given in normalized coords (-1 to +1 in
479  /// both dimensions) window position.
480  ///
481  /// Contrasted with ComputePickRay(), this method returns a ray whose
482  /// origin is the eyepoint, while that method returns a ray whose origin
483  /// is on the near plane.
484  GF_API GfRay ComputeRay(const GfVec2d &windowPos) const;
485 
486  /// Builds and returns a \c GfRay that connects the viewpoint to the given
487  /// 3d point in worldspace.
488  ///
489  /// Contrasted with ComputePickRay(), this method returns a ray whose
490  /// origin is the eyepoint, while that method returns a ray whose origin
491  /// is on the near plane.
492  GF_API GfRay ComputeRay(const GfVec3d &worldSpacePos) const;
493 
494  /// Builds and returns a \c GfRay that can be used for picking at the
495  /// given normalized (-1 to +1 in both dimensions) window position.
496  ///
497  /// Contrasted with ComputeRay(), that method returns a ray whose origin
498  /// is the eyepoint, while this method returns a ray whose origin is on
499  /// the near plane.
500  GF_API GfRay ComputePickRay(const GfVec2d &windowPos) const;
501 
502  /// Builds and returns a \c GfRay that can be used for picking that
503  /// connects the viewpoint to the given 3d point in worldspace.
504  GF_API GfRay ComputePickRay(const GfVec3d &worldSpacePos) const;
505 
506  ///@}
507 
508  /// \name Intersection methods
509  ///
510  /// The methods in this group implement intersection operations
511  /// between this frustum and a given primitive.
512  ///
513  ///@{
514 
515  /// Returns true if the given axis-aligned bbox is inside or intersecting
516  /// the frustum. Otherwise, it returns false. Useful when doing picking or
517  /// frustum culling.
518  GF_API bool Intersects(const GfBBox3d &bbox) const;
519 
520  /// Returns true if the given point is inside or intersecting the frustum.
521  /// Otherwise, it returns false.
522  GF_API bool Intersects(const GfVec3d &point) const;
523 
524  /// Returns \c true if the line segment formed by the given points is
525  /// inside or intersecting the frustum. Otherwise, it returns false.
526  GF_API bool Intersects(const GfVec3d &p0,
527  const GfVec3d &p1) const;
528 
529  /// Returns \c true if the triangle formed by the given points is inside
530  /// or intersecting the frustum. Otherwise, it returns false.
531  GF_API bool Intersects(const GfVec3d &p0,
532  const GfVec3d &p1,
533  const GfVec3d &p2) const;
534 
535  /// Returns \c true if the bbox volume intersects the view volume given by
536  /// the view-projection matrix, erring on the side of false positives for
537  /// efficiency.
538  ///
539  /// This method is intended for cases where a GfFrustum is not available
540  /// or when the view-projection matrix yields a view volume that is not
541  /// expressable as a GfFrustum.
542  ///
543  /// Because it errs on the side of false positives, it is suitable for
544  /// early-out tests such as draw or intersection culling.
545  ///
546  GF_API static bool IntersectsViewVolume(const GfBBox3d &bbox,
547  const GfMatrix4d &vpMat);
548 
549  ///@}
550 
551  private:
552  // Dirty the result of _CalculateFrustumPlanes.
553  GF_API void _DirtyFrustumPlanes();
554 
555  // Calculates cached frustum planes used for intersection tests.
556  GF_API void _CalculateFrustumPlanes() const;
557 
558  // Builds and returns a \c GfRay that can be used for picking. Given an
559  // eye position and direction in camera space, offsets the ray to emanate
560  // from the near plane, then transforms into worldspace
561  GF_API GfRay _ComputePickRayOffsetToNearPlane(
562  const GfVec3d &camSpaceFrom,
563  const GfVec3d &camSpaceDir) const;
564 
565  // Returns a frustum that is a narrowed-down version of this frustum, such
566  // that the frustum rectangle on the near plane encloses \p point with at
567  // most \p halfSize[0] distance on the left and right and at most \p
568  // halfSize[1] distance on the top and bottom. (If \p point is closer than
569  // the half size to a side of the frustum, that side is left alone. The
570  // point and sizes are in normalized 2D coordinates; they range from (-1,
571  // -1) at the lower left corner of the near-plane window rectangle to
572  // (1,1) at the upper right corner.
573  //
574  // \p windowPoint is expressed in window coordinates
575  //
576  // This method is useful for computing a volume to use for interactive
577  // picking.
578  GfFrustum _ComputeNarrowedFrustumSub(const GfVec2d windowPoint,
579  const GfVec2d &halfSize) const;
580 
581  bool _SegmentIntersects(GfVec3d const &p0, uint32_t p0Mask,
582  GfVec3d const &p1, uint32_t p1Mask) const;
583 
584  // Position of the frustum in world space.
585  GfVec3d _position;
586 
587  // Orientation of the frustum in world space as a rotation to apply to the
588  // -z axis.
589  GfRotation _rotation;
590 
591  // Window rectangle in the image plane.
592  GfRange2d _window;
593 
594  // Near/far interval.
595  GfRange1d _nearFar;
596 
597  // View distance.
598  double _viewDistance;
599 
600  // Projection type.
601  ProjectionType _projectionType;
602 
603  // Cached planes.
604  // If empty, the planes have not been calculated.
605  mutable std::vector<GfPlane> _planes;
606 };
607 
608 /// Output a GfFrustum using the format [(position) (rotation) [window]
609 /// [nearFar] viewDistance type]
610 ///
611 /// The "type" is "perspective", or "orthographic, depending on the
612 /// projection type of the frustum.
613 ///
614 /// \ingroup group_gf_DebuggingOutput
615 GF_API std::ostream& operator<<(std::ostream& out, const GfFrustum& f);
616 
618 
619 #endif // GF_FRUSTUM_H
bool operator==(const GfFrustum &f) const
Definition: frustum.h:133
GF_API GfFrustum()
void SetRotation(const GfRotation &rotation)
Definition: frustum.h:171
void SetViewDistance(double viewDistance)
Sets the view distance.
Definition: frustum.h:218
friend size_t hash_value(const GfFrustum &f)
Definition: frustum.h:121
static double GetReferencePlaneDepth()
Returns the depth of the reference plane.
Definition: frustum.h:202
GF_API std::vector< GfVec3d > ComputeCorners() const
GF_API std::ostream & operator<<(std::ostream &out, const GfFrustum &f)
GF_API bool Intersects(const GfBBox3d &bbox) const
GLint left
Definition: glew.h:8008
GF_API GfVec3d ComputeViewDirection() const
GF_API bool GetOrthographic(double *left, double *right, double *bottom, double *top, double *nearPlane, double *farPlane) const
Perspective projection.
Definition: frustum.h:93
GF_API double ComputeAspectRatio() const
GF_API GfFrustum & Transform(const GfMatrix4d &matrix)
GF_API GfRay ComputePickRay(const GfVec2d &windowPos) const
GF_API void FitToSphere(const GfVec3d &center, double radius, double slack=0.0)
GF_API GfFrustum ComputeNarrowedFrustum(const GfVec2d &point, const GfVec2d &halfSize) const
const GfVec3d & GetPosition() const
Returns the position of the frustum in world space.
Definition: frustum.h:164
GF_API void SetPositionAndRotationFromMatrix(const GfMatrix4d &camToWorldXf)
Definition: vec2d.h:63
GF_API GfVec3d ComputeLookAtPoint() const
const GfRange1d & GetNearFar() const
Returns the near/far interval.
Definition: frustum.h:213
GF_API GfMatrix4d ComputeViewMatrix() const
GLint GLint bottom
Definition: glew.h:8008
GF_API GfMatrix4d ComputeViewInverse() const
GLclampf f
Definition: glew.h:3499
GF_API void SetOrthographic(double left, double right, double bottom, double top, double nearPlane, double farPlane)
GF_API GfMatrix4d ComputeProjectionMatrix() const
void SetWindow(const GfRange2d &window)
Definition: frustum.h:191
GfFrustum::ProjectionType GetProjectionType() const
Returns the projection type.
Definition: frustum.h:234
GLfloat GLfloat GLfloat top
Definition: glew.h:15186
static GF_API bool IntersectsViewVolume(const GfBBox3d &bbox, const GfMatrix4d &vpMat)
double GetViewDistance() const
Returns the view distance.
Definition: frustum.h:223
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
GF_API bool GetPerspective(double *fieldOfViewHeight, double *aspectRatio, double *nearDistance, double *farDistance) const
GLfloat right
Definition: glew.h:15186
bool operator!=(const GfFrustum &f) const
Definition: frustum.h:145
GF_API std::vector< GfVec3d > ComputeCornersAtDistance(double d) const
const GfRange2d & GetWindow() const
Returns the window rectangle in the reference plane.
Definition: frustum.h:197
const GfRotation & GetRotation() const
Definition: frustum.h:178
void SetProjectionType(GfFrustum::ProjectionType projectionType)
Sets the projection type.
Definition: frustum.h:228
ProjectionType
Definition: frustum.h:91
GF_API GfRay ComputeRay(const GfVec2d &windowPos) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1245
GA_API const UT_StringHolder up
Definition: vec3d.h:63
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
GF_API ~GfFrustum()
Destructor.
Definition: ray.h:60
Orthographic projection.
Definition: frustum.h:92
GF_API void SetPerspective(double fieldOfViewHeight, double aspectRatio, double nearDistance, double farDistance)
GF_API double GetFOV(bool isFovVertical=false)
void SetNearFar(const GfRange1d &nearFar)
Sets the near/far interval.
Definition: frustum.h:207
GF_API GfVec3d ComputeUpVector() const
GLuint GLenum matrix
Definition: glew.h:14742
#define GF_API
Definition: api.h:40
void SetPosition(const GfVec3d &position)
Sets the position of the frustum in world space.
Definition: frustum.h:158
GF_API void ComputeViewFrame(GfVec3d *side, GfVec3d *up, GfVec3d *view) const
MatType rotation(const Quat< typename MatType::value_type > &q, typename MatType::value_type eps=static_cast< typename MatType::value_type >(1.0e-8))
Return the rotation matrix specified by the given quaternion.
Definition: Mat.h:204