1 // Created on: 2013-05-29
2 // Created by: Anton POLETAEV
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Graphic3d_Camera_HeaderFile
17 #define _Graphic3d_Camera_HeaderFile
19 #include <Graphic3d_CameraTile.hxx>
20 #include <Graphic3d_Mat4d.hxx>
21 #include <Graphic3d_Mat4.hxx>
22 #include <Graphic3d_Vec3.hxx>
23 #include <Graphic3d_WorldViewProjState.hxx>
24 #include <NCollection_Lerp.hxx>
25 #include <NCollection_Array1.hxx>
30 #include <Standard_Macro.hxx>
31 #include <Standard_TypeDef.hxx>
33 #include <Bnd_Box.hxx>
35 //! Forward declaration
36 class Graphic3d_WorldViewProjState;
38 //! Camera class provides object-oriented approach to setting up projection
39 //! and orientation properties of 3D view.
40 class Graphic3d_Camera : public Standard_Transient
44 //! Template container for cached matrices or Real/ShortReal types.
45 template<typename Elem_t>
46 struct TransformMatrices
49 //! Default constructor.
50 TransformMatrices() : myIsOrientationValid (Standard_False), myIsProjectionValid (Standard_False) {}
52 //! Initialize orientation.
53 void InitOrientation()
55 myIsOrientationValid = Standard_True;
56 Orientation.InitIdentity();
59 //! Initialize projection.
62 myIsProjectionValid = Standard_True;
63 MProjection.InitIdentity();
64 LProjection.InitIdentity();
65 RProjection.InitIdentity();
68 //! Invalidate orientation.
69 void ResetOrientation() { myIsOrientationValid = Standard_False; }
71 //! Invalidate projection.
72 void ResetProjection() { myIsProjectionValid = Standard_False; }
74 //! Return true if Orientation was not invalidated.
75 Standard_Boolean IsOrientationValid() const { return myIsOrientationValid; }
77 //! Return true if Projection was not invalidated.
78 Standard_Boolean IsProjectionValid() const { return myIsProjectionValid; }
82 NCollection_Mat4<Elem_t> Orientation;
83 NCollection_Mat4<Elem_t> MProjection;
84 NCollection_Mat4<Elem_t> LProjection;
85 NCollection_Mat4<Elem_t> RProjection;
89 Standard_Boolean myIsOrientationValid;
90 Standard_Boolean myIsProjectionValid;
96 //! Enumerates supported monographic projections.
97 //! - Projection_Orthographic : orthographic projection.
98 //! - Projection_Perspective : perspective projection.
99 //! - Projection_Stereo : stereographic projection.
100 //! - Projection_MonoLeftEye : mono projection for stereo left eye.
101 //! - Projection_MonoRightEye : mono projection for stereo right eye.
104 Projection_Orthographic,
105 Projection_Perspective,
107 Projection_MonoLeftEye,
108 Projection_MonoRightEye
111 //! Enumerates approaches to define stereographic focus.
112 //! - FocusType_Absolute : focus is specified as absolute value.
113 //! - FocusType_Relative : focus is specified relative to
114 //! (as coefficient of) camera focal length.
121 //! Enumerates approaches to define Intraocular distance.
122 //! - IODType_Absolute : Intraocular distance is defined as absolute value.
123 //! - IODType_Relative : Intraocular distance is defined relative to
124 //! (as coefficient of) camera focal length.
133 //! Default constructor.
134 //! Initializes camera with the following properties:
135 //! Eye (0, 0, -2); Center (0, 0, 0); Up (0, 1, 0);
136 //! Type (Orthographic); FOVy (45); Scale (1000); IsStereo(false);
137 //! ZNear (0.001); ZFar (3000.0); Aspect(1);
138 //! ZFocus(1.0); ZFocusType(Relative); IOD(0.05); IODType(Relative)
139 Standard_EXPORT Graphic3d_Camera();
141 //! Copy constructor.
142 //! @param theOther [in] the camera to copy from.
143 Standard_EXPORT Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther);
145 //! Initialize mapping related parameters from other camera handle.
146 Standard_EXPORT void CopyMappingData (const Handle(Graphic3d_Camera)& theOtherCamera);
148 //! Initialize orientation related parameters from other camera handle.
149 Standard_EXPORT void CopyOrientationData (const Handle(Graphic3d_Camera)& theOtherCamera);
151 //! Copy properties of another camera.
152 //! @param theOther [in] the camera to copy from.
153 Standard_EXPORT void Copy (const Handle(Graphic3d_Camera)& theOther);
155 //! @name Public camera properties
158 //! Get camera look direction.
159 //! @return camera look direction.
160 const gp_Dir& Direction() const { return myDirection; }
162 //! Sets camera look direction preserving the current Eye() position.
163 //! WARNING! This method does NOT verify that the current Up() vector is orthogonal to the new Direction.
164 //! @param theDir [in] the direction.
165 Standard_EXPORT void SetDirectionFromEye (const gp_Dir& theDir);
167 //! Sets camera look direction and computes the new Eye position relative to current Center.
168 //! WARNING! This method does NOT verify that the current Up() vector is orthogonal to the new Direction.
169 //! @param theDir [in] the direction.
170 Standard_EXPORT void SetDirection (const gp_Dir& theDir);
172 //! Get camera Up direction vector.
173 //! @return Camera's Up direction vector.
174 const gp_Dir& Up() const { return myUp; }
176 //! Sets camera Up direction vector, orthogonal to camera direction.
177 //! WARNING! This method does NOT verify that the new Up vector is orthogonal to the current Direction().
178 //! @param theUp [in] the Up direction vector.
179 //! @sa OrthogonalizeUp().
180 Standard_EXPORT void SetUp (const gp_Dir& theUp);
182 //! Orthogonalize up direction vector.
183 Standard_EXPORT void OrthogonalizeUp();
185 //! Return a copy of orthogonalized up direction vector.
186 Standard_EXPORT gp_Dir OrthogonalizedUp() const;
188 //! Get camera Eye position.
189 //! @return camera eye location.
190 const gp_Pnt& Eye() const { return myEye; }
192 //! Sets camera Eye position.
193 //! Unlike SetEye(), this method only changes Eye point and preserves camera direction.
194 //! @param theEye [in] the location of camera's Eye.
196 Standard_EXPORT void MoveEyeTo (const gp_Pnt& theEye);
198 //! Sets camera Eye and Center positions.
199 //! @param theEye [in] the location of camera's Eye
200 //! @param theCenter [in] the location of camera's Center
201 Standard_EXPORT void SetEyeAndCenter (const gp_Pnt& theEye,
202 const gp_Pnt& theCenter);
204 //! Sets camera Eye position.
205 //! WARNING! For backward compatibility reasons, this method also changes view direction,
206 //! so that the new direction is computed from new Eye position to old Center position.
207 //! @param theEye [in] the location of camera's Eye.
208 //! @sa MoveEyeTo(), SetEyeAndCenter()
209 Standard_EXPORT void SetEye (const gp_Pnt& theEye);
211 //! Get Center of the camera, e.g. the point where camera looks at.
212 //! This point is computed as Eye() translated along Direction() at Distance().
213 //! @return the point where the camera looks at.
214 gp_Pnt Center() const
216 return myEye.XYZ() + myDirection.XYZ() * myDistance;
219 //! Sets Center of the camera, e.g. the point where camera looks at.
220 //! This methods changes camera direction, so that the new direction is computed
221 //! from current Eye position to specified Center position.
222 //! @param theCenter [in] the point where the camera looks at.
223 Standard_EXPORT void SetCenter (const gp_Pnt& theCenter);
225 //! Get distance of Eye from camera Center.
226 //! @return the distance.
227 Standard_Real Distance() const { return myDistance; }
229 //! Set distance of Eye from camera Center.
230 //! @param theDistance [in] the distance.
231 Standard_EXPORT void SetDistance (const Standard_Real theDistance);
233 //! Get camera scale.
234 //! @return camera scale factor.
235 Standard_EXPORT Standard_Real Scale() const;
237 //! Sets camera scale. For orthographic projection the scale factor
238 //! corresponds to parallel scale of view mapping (i.e. size
239 //! of viewport). For perspective camera scale is converted to
240 //! distance. The scale specifies equal size of the view projection in
241 //! both dimensions assuming that the aspect is 1.0. The projection height
242 //! and width are specified with the scale and correspondingly multiplied
244 //! @param theScale [in] the scale factor.
245 Standard_EXPORT void SetScale (const Standard_Real theScale);
247 //! Get camera axial scale.
248 //! @return Camera's axial scale.
249 const gp_XYZ& AxialScale() const { return myAxialScale; }
251 //! Set camera axial scale.
252 //! @param theAxialScale [in] the axial scale vector.
253 Standard_EXPORT void SetAxialScale (const gp_XYZ& theAxialScale);
255 //! Change camera projection type.
256 //! When switching to perspective projection from orthographic one,
257 //! the ZNear and ZFar are reset to default values (0.001, 3000.0)
258 //! if less than 0.0.
259 //! @param theProjectionType [in] the camera projection type.
260 Standard_EXPORT void SetProjectionType (const Projection theProjection);
262 //! @return camera projection type.
263 Projection ProjectionType() const
268 //! Check that the camera projection is orthographic.
269 //! @return boolean flag that indicates whether the camera's projection is
270 //! orthographic or not.
271 Standard_Boolean IsOrthographic() const
273 return (myProjType == Projection_Orthographic);
276 //! Check whether the camera projection is stereo.
277 //! Please note that stereo rendering is now implemented with support of
279 //! @return boolean flag indicating whether the stereographic L/R projection
281 Standard_Boolean IsStereo() const
283 return (myProjType == Projection_Stereo);
286 //! Set Field Of View (FOV) in y axis for perspective projection.
287 //! @param theFOVy [in] the FOV in degrees.
288 Standard_EXPORT void SetFOVy (const Standard_Real theFOVy);
290 //! Get Field Of View (FOV) in y axis.
291 //! @return the FOV value in degrees.
292 Standard_Real FOVy() const
297 //! Estimate Z-min and Z-max planes of projection volume to match the
298 //! displayed objects. The methods ensures that view volume will
299 //! be close by depth range to the displayed objects. Fitting assumes that
300 //! for orthogonal projection the view volume contains the displayed objects
301 //! completely. For zoomed perspective view, the view volume is adjusted such
302 //! that it contains the objects or their parts, located in front of the camera.
303 //! @param theScaleFactor [in] the scale factor for Z-range.
304 //! The range between Z-min, Z-max projection volume planes
305 //! evaluated by z fitting method will be scaled using this coefficient.
306 //! Program error exception is thrown if negative or zero value is passed.
307 //! @param theMinMax [in] applicative min max boundaries.
308 //! @param theScaleFactor [in] real graphical boundaries (not accounting infinite flag).
309 Standard_EXPORT bool ZFitAll (const Standard_Real theScaleFactor,
310 const Bnd_Box& theMinMax,
311 const Bnd_Box& theGraphicBB,
312 Standard_Real& theZNear,
313 Standard_Real& theZFar) const;
315 //! Change Z-min and Z-max planes of projection volume to match the displayed objects.
316 void ZFitAll (const Standard_Real theScaleFactor, const Bnd_Box& theMinMax, const Bnd_Box& theGraphicBB)
318 Standard_Real aZNear = 0.0, aZFar = 1.0;
319 ZFitAll (theScaleFactor, theMinMax, theGraphicBB, aZNear, aZFar);
320 SetZRange (aZNear, aZFar);
323 //! Change the Near and Far Z-clipping plane positions.
324 //! For orthographic projection, theZNear, theZFar can be negative or positive.
325 //! For perspective projection, only positive values are allowed.
326 //! Program error exception is raised if non-positive values are
327 //! specified for perspective projection or theZNear >= theZFar.
328 //! @param theZNear [in] the distance of the plane from the Eye.
329 //! @param theZFar [in] the distance of the plane from the Eye.
330 Standard_EXPORT void SetZRange (const Standard_Real theZNear, const Standard_Real theZFar);
332 //! Get the Near Z-clipping plane position.
333 //! @return the distance of the plane from the Eye.
334 Standard_Real ZNear() const
339 //! Get the Far Z-clipping plane position.
340 //! @return the distance of the plane from the Eye.
341 Standard_Real ZFar() const
346 //! Changes width / height display ratio.
347 //! @param theAspect [in] the display ratio.
348 Standard_EXPORT void SetAspect (const Standard_Real theAspect);
350 //! Get camera display ratio.
351 //! @return display ratio.
352 Standard_Real Aspect() const
357 //! Sets stereographic focus distance.
358 //! @param theType [in] the focus definition type. Focus can be defined
359 //! as absolute value or relatively to (as coefficient of) coefficient of
360 //! camera focal length.
361 //! @param theZFocus [in] the focus absolute value or coefficient depending
362 //! on the passed definition type.
363 Standard_EXPORT void SetZFocus (const FocusType theType, const Standard_Real theZFocus);
365 //! Get stereographic focus value.
366 //! @return absolute or relative stereographic focus value
367 //! depending on its definition type.
368 Standard_Real ZFocus() const
373 //! Get stereographic focus definition type.
374 //! @return definition type used for stereographic focus.
375 FocusType ZFocusType() const
380 //! Sets Intraocular distance.
381 //! @param theType [in] the IOD definition type. IOD can be defined as
382 //! absolute value or relatively to (as coefficient of) camera focal length.
383 //! @param theIOD [in] the Intraocular distance.
384 Standard_EXPORT void SetIOD (const IODType theType, const Standard_Real theIOD);
386 //! Get Intraocular distance value.
387 //! @return absolute or relative IOD value depending on its definition type.
388 Standard_Real IOD() const
393 //! Get Intraocular distance definition type.
394 //! @return definition type used for Intraocular distance.
395 IODType GetIODType() const
400 //! Get current tile.
401 const Graphic3d_CameraTile& Tile() const { return myTile; }
403 //! Sets the Tile defining the drawing sub-area within View.
404 //! Note that tile defining a region outside the view boundaries is also valid - use method Graphic3d_CameraTile::Cropped() to assign a cropped copy.
405 //! @param theTile tile definition
406 Standard_EXPORT void SetTile (const Graphic3d_CameraTile& theTile);
408 //! @name Basic camera operations
411 //! Transform orientation components of the camera:
412 //! Eye, Up and Center points.
413 //! @param theTrsf [in] the transformation to apply.
414 Standard_EXPORT void Transform (const gp_Trsf& theTrsf);
416 //! Calculate view plane size at center (target) point
417 //! and distance between ZFar and ZNear planes.
418 //! @return values in form of gp_Pnt (Width, Height, Depth).
419 gp_XYZ ViewDimensions() const
421 return ViewDimensions (Distance());
424 //! Calculate view plane size at center point with specified Z offset
425 //! and distance between ZFar and ZNear planes.
426 //! @param theZValue [in] the distance from the eye in eye-to-center direction
427 //! @return values in form of gp_Pnt (Width, Height, Depth).
428 Standard_EXPORT gp_XYZ ViewDimensions (const Standard_Real theZValue) const;
430 //! Calculate WCS frustum planes for the camera projection volume.
431 //! Frustum is a convex volume determined by six planes directing
433 //! The frustum planes are usually used as inputs for camera algorithms.
434 //! Thus, if any changes to projection matrix calculation are necessary,
435 //! the frustum planes calculation should be also touched.
436 //! @param theLeft [out] the frustum plane for left side of view.
437 //! @param theRight [out] the frustum plane for right side of view.
438 //! @param theBottom [out] the frustum plane for bottom side of view.
439 //! @param theTop [out] the frustum plane for top side of view.
440 //! @param theNear [out] the frustum plane for near side of view.
441 //! @param theFar [out] the frustum plane for far side of view.
442 Standard_EXPORT void Frustum (gp_Pln& theLeft,
447 gp_Pln& theFar) const;
449 //! @name Projection methods
452 //! Project point from world coordinate space to
453 //! normalized device coordinates (mapping).
454 //! @param thePnt [in] the 3D point in WCS.
455 //! @return mapped point in NDC.
456 Standard_EXPORT gp_Pnt Project (const gp_Pnt& thePnt) const;
458 //! Unproject point from normalized device coordinates
459 //! to world coordinate space.
460 //! @param thePnt [in] the NDC point.
461 //! @return 3D point in WCS.
462 Standard_EXPORT gp_Pnt UnProject (const gp_Pnt& thePnt) const;
464 //! Convert point from view coordinate space to
465 //! projection coordinate space.
466 //! @param thePnt [in] the point in VCS.
467 //! @return point in NDC.
468 Standard_EXPORT gp_Pnt ConvertView2Proj (const gp_Pnt& thePnt) const;
470 //! Convert point from projection coordinate space
471 //! to view coordinate space.
472 //! @param thePnt [in] the point in NDC.
473 //! @return point in VCS.
474 Standard_EXPORT gp_Pnt ConvertProj2View (const gp_Pnt& thePnt) const;
476 //! Convert point from world coordinate space to
477 //! view coordinate space.
478 //! @param thePnt [in] the 3D point in WCS.
479 //! @return point in VCS.
480 Standard_EXPORT gp_Pnt ConvertWorld2View (const gp_Pnt& thePnt) const;
482 //! Convert point from view coordinate space to
483 //! world coordinates.
484 //! @param thePnt [in] the 3D point in VCS.
485 //! @return point in WCS.
486 Standard_EXPORT gp_Pnt ConvertView2World (const gp_Pnt& thePnt) const;
488 //! @name Camera modification state
491 //! @return projection modification state of the camera.
492 const Graphic3d_WorldViewProjState& WorldViewProjState() const
494 return myWorldViewProjState;
498 //! Returns modification state of camera projection matrix
499 Standard_Size ProjectionState() const
501 return myWorldViewProjState.ProjectionState();
504 //! Returns modification state of camera world view transformation matrix.
505 Standard_Size WorldViewState() const
507 return myWorldViewProjState.WorldViewState();
510 //! @name Lazily-computed orientation and projection matrices derived from camera parameters
513 //! Get orientation matrix.
514 //! @return camera orientation matrix.
515 Standard_EXPORT const Graphic3d_Mat4d& OrientationMatrix() const;
517 //! Get orientation matrix of Standard_ShortReal precision.
518 //! @return camera orientation matrix.
519 Standard_EXPORT const Graphic3d_Mat4& OrientationMatrixF() const;
521 //! Get monographic or middle point projection matrix used for monographic
522 //! rendering and for point projection / unprojection.
523 //! @return monographic projection matrix.
524 Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
526 //! Get monographic or middle point projection matrix of Standard_ShortReal precision used for monographic
527 //! rendering and for point projection / unprojection.
528 //! @return monographic projection matrix.
529 Standard_EXPORT const Graphic3d_Mat4& ProjectionMatrixF() const;
531 //! @return stereographic matrix computed for left eye. Please note
532 //! that this method is used for rendering for <i>Projection_Stereo</i>.
533 Standard_EXPORT const Graphic3d_Mat4d& ProjectionStereoLeft() const;
535 //! @return stereographic matrix of Standard_ShortReal precision computed for left eye.
536 //! Please note that this method is used for rendering for <i>Projection_Stereo</i>.
537 Standard_EXPORT const Graphic3d_Mat4& ProjectionStereoLeftF() const;
539 //! @return stereographic matrix computed for right eye. Please note
540 //! that this method is used for rendering for <i>Projection_Stereo</i>.
541 Standard_EXPORT const Graphic3d_Mat4d& ProjectionStereoRight() const;
543 //! @return stereographic matrix of Standard_ShortReal precision computed for right eye.
544 //! Please note that this method is used for rendering for <i>Projection_Stereo</i>.
545 Standard_EXPORT const Graphic3d_Mat4& ProjectionStereoRightF() const;
547 //! Invalidate state of projection matrix.
548 //! The matrix will be updated on request.
549 Standard_EXPORT void InvalidateProjection();
551 //! Invalidate orientation matrix.
552 //! The matrix will be updated on request.
553 Standard_EXPORT void InvalidateOrientation();
555 //! Dumps the content of me into the stream
556 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
558 //! @name Managing projection and orientation cache
561 //! Compute projection matrices.
562 //! @param theMatrices [in] the matrices data container.
563 template <typename Elem_t>
565 TransformMatrices<Elem_t>& UpdateProjection (TransformMatrices<Elem_t>& theMatrices) const;
567 //! Compute orientation matrix.
568 //! @param theMatrices [in] the matrices data container.
569 template <typename Elem_t>
571 TransformMatrices<Elem_t>& UpdateOrientation (TransformMatrices<Elem_t>& theMatrices) const;
575 //! Compose orthographic projection matrix for
576 //! the passed camera volume mapping.
577 //! @param theLeft [in] the left mapping (clipping) coordinate.
578 //! @param theRight [in] the right mapping (clipping) coordinate.
579 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
580 //! @param theTop [in] the top mapping (clipping) coordinate.
581 //! @param theNear [in] the near mapping (clipping) coordinate.
582 //! @param theFar [in] the far mapping (clipping) coordinate.
583 //! @param theOutMx [out] the projection matrix.
584 template <typename Elem_t>
586 OrthoProj (const Elem_t theLeft,
587 const Elem_t theRight,
588 const Elem_t theBottom,
590 const Elem_t theNear,
592 NCollection_Mat4<Elem_t>& theOutMx);
594 //! Compose perspective projection matrix for
595 //! the passed camera volume mapping.
596 //! @param theLeft [in] the left mapping (clipping) coordinate.
597 //! @param theRight [in] the right mapping (clipping) coordinate.
598 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
599 //! @param theTop [in] the top mapping (clipping) coordinate.
600 //! @param theNear [in] the near mapping (clipping) coordinate.
601 //! @param theFar [in] the far mapping (clipping) coordinate.
602 //! @param theOutMx [out] the projection matrix.
603 template <typename Elem_t>
605 PerspectiveProj (const Elem_t theLeft,
606 const Elem_t theRight,
607 const Elem_t theBottom,
609 const Elem_t theNear,
611 NCollection_Mat4<Elem_t>& theOutMx);
613 //! Compose projection matrix for L/R stereo eyes.
614 //! @param theLeft [in] the left mapping (clipping) coordinate.
615 //! @param theRight [in] the right mapping (clipping) coordinate.
616 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
617 //! @param theTop [in] the top mapping (clipping) coordinate.
618 //! @param theNear [in] the near mapping (clipping) coordinate.
619 //! @param theFar [in] the far mapping (clipping) coordinate.
620 //! @param theIOD [in] the Intraocular distance.
621 //! @param theZFocus [in] the z coordinate of off-axis
622 //! projection plane with zero parallax.
623 //! @param theIsLeft [in] boolean flag to choose between L/R eyes.
624 //! @param theOutMx [out] the projection matrix.
625 template <typename Elem_t>
627 StereoEyeProj (const Elem_t theLeft,
628 const Elem_t theRight,
629 const Elem_t theBottom,
631 const Elem_t theNear,
634 const Elem_t theZFocus,
635 const Standard_Boolean theIsLeft,
636 NCollection_Mat4<Elem_t>& theOutMx);
638 //! Construct "look at" orientation transformation.
639 //! Reference point differs for perspective and ortho modes
640 //! (made for compatibility, to be improved..).
641 //! @param theEye [in] the eye coordinates in 3D space.
642 //! @param theFwdDir [in] view direction
643 //! @param theUpDir [in] the up direction vector.
644 //! @param theAxialScale [in] the axial scale vector.
645 //! @param theOutMx [in/out] the orientation matrix.
646 template <typename Elem_t>
648 LookOrientation (const NCollection_Vec3<Elem_t>& theEye,
649 const NCollection_Vec3<Elem_t>& theFwdDir,
650 const NCollection_Vec3<Elem_t>& theUpDir,
651 const NCollection_Vec3<Elem_t>& theAxialScale,
652 NCollection_Mat4<Elem_t>& theOutMx);
656 //! Enumerates vertices of view volume.
659 FrustumVert_LeftBottomNear,
660 FrustumVert_LeftBottomFar,
661 FrustumVert_LeftTopNear,
662 FrustumVert_LeftTopFar,
663 FrustumVert_RightBottomNear,
664 FrustumVert_RightBottomFar,
665 FrustumVert_RightTopNear,
666 FrustumVert_RightTopFar,
670 //! Fill array of current view frustum corners.
671 //! The size of this array is equal to FrustumVerticesNB.
672 //! The order of vertices is as defined in FrustumVert_* enumeration.
673 Standard_EXPORT void FrustumPoints (NCollection_Array1<Graphic3d_Vec3d>& thePoints,
674 const Graphic3d_Mat4d& theModelWorld = Graphic3d_Mat4d()) const;
678 gp_Dir myUp; //!< Camera up direction vector
679 gp_Dir myDirection;//!< Camera view direction (from eye)
680 gp_Pnt myEye; //!< Camera eye position
681 Standard_Real myDistance; //!< distance from Eye to Center
683 gp_XYZ myAxialScale; //!< World axial scale.
685 Projection myProjType; //!< Projection type used for rendering.
686 Standard_Real myFOVy; //!< Field Of View in y axis.
687 Standard_Real myFOVyTan; //!< Field Of View as Tan(DTR_HALF * myFOVy)
688 Standard_Real myZNear; //!< Distance to near clipping plane.
689 Standard_Real myZFar; //!< Distance to far clipping plane.
690 Standard_Real myAspect; //!< Width to height display ratio.
692 Standard_Real myScale; //!< Specifies parallel scale for orthographic projection.
693 Standard_Real myZFocus; //!< Stereographic focus value.
694 FocusType myZFocusType; //!< Stereographic focus definition type.
696 Standard_Real myIOD; //!< Intraocular distance value.
697 IODType myIODType; //!< Intraocular distance definition type.
699 Graphic3d_CameraTile myTile;//!< Tile defining sub-area for drawing
701 mutable TransformMatrices<Standard_Real> myMatricesD;
702 mutable TransformMatrices<Standard_ShortReal> myMatricesF;
704 mutable Graphic3d_WorldViewProjState myWorldViewProjState;
708 DEFINE_STANDARD_RTTIEXT(Graphic3d_Camera,Standard_Transient)
711 DEFINE_STANDARD_HANDLE (Graphic3d_Camera, Standard_Transient)
713 //! Linear interpolation tool for camera orientation and position.
714 //! This tool interpolates camera parameters scale, eye, center, rotation (up and direction vectors) independently.
716 //! Eye/Center interpolation is performed through defining an anchor point in-between Center and Eye.
717 //! The anchor position is defined as point near to the camera point which has smaller translation part.
718 //! The main idea is to keep the distance between Center and Eye
719 //! (which will change if Center and Eye translation will be interpolated independently).
721 //! - When both Center and Eye are moved at the same vector -> both will be just translated by straight line
722 //! - When Center is not moved -> camera Eye will move around Center through arc
723 //! - When Eye is not moved -> camera Center will move around Eye through arc
724 //! - When both Center and Eye are move by different vectors -> transformation will be something in between,
725 //! and will try interpolate linearly the distance between Center and Eye.
727 //! This transformation might be not in line with user expectations.
728 //! In this case, application might define intermediate camera positions for interpolation
729 //! or implement own interpolation logic.
731 Standard_EXPORT void NCollection_Lerp<Handle(Graphic3d_Camera)>::Interpolate (const double theT,
732 Handle(Graphic3d_Camera)& theResult) const;
733 typedef NCollection_Lerp<Handle(Graphic3d_Camera)> Graphic3d_CameraLerp;