0025264: Mesh very slow for Revol shape
[occt.git] / src / Graphic3d / Graphic3d_Camera.hxx
CommitLineData
b5ac8292 1// Created on: 2013-05-29
2// Created by: Anton POLETAEV
3// Copyright (c) 1999-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
d5f74e42 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
b5ac8292 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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _Graphic3d_Camera_HeaderFile
17#define _Graphic3d_Camera_HeaderFile
18
3bffef55 19#include <Graphic3d_CameraTile.hxx>
197ac94e 20#include <Graphic3d_Mat4d.hxx>
b5ac8292 21#include <Graphic3d_Mat4.hxx>
22#include <Graphic3d_Vec3.hxx>
825aa485 23#include <Graphic3d_WorldViewProjState.hxx>
b5ac8292 24
25#include <gp_Dir.hxx>
26#include <gp_Pnt.hxx>
27
28#include <Standard_Macro.hxx>
29#include <Standard_TypeDef.hxx>
30
6bc6a6fc 31#include <Bnd_Box.hxx>
32
494782f6 33//! Forward declaration
825aa485 34class Graphic3d_WorldViewProjState;
b5ac8292 35
36//! Camera class provides object-oriented approach to setting up projection
37//! and orientation properties of 3D view.
38class Graphic3d_Camera : public Standard_Transient
39{
197ac94e 40private:
41
42 //! Template container for cached matrices or Real/ShortReal types.
43 template<typename Elem_t>
44 struct TransformMatrices
45 {
778cd667 46
47 //! Default constructor.
48 TransformMatrices() : myIsOrientationValid (Standard_False), myIsProjectionValid (Standard_False) {}
49
50 //! Initialize orientation.
197ac94e 51 void InitOrientation()
52 {
778cd667 53 myIsOrientationValid = Standard_True;
54 Orientation.InitIdentity();
197ac94e 55 }
56
778cd667 57 //! Initialize projection.
197ac94e 58 void InitProjection()
59 {
778cd667 60 myIsProjectionValid = Standard_True;
61 MProjection.InitIdentity();
62 LProjection.InitIdentity();
63 RProjection.InitIdentity();
197ac94e 64 }
65
778cd667 66 //! Invalidate orientation.
67 void ResetOrientation() { myIsOrientationValid = Standard_False; }
197ac94e 68
778cd667 69 //! Invalidate projection.
70 void ResetProjection() { myIsProjectionValid = Standard_False; }
197ac94e 71
778cd667 72 //! Return true if Orientation was not invalidated.
73 Standard_Boolean IsOrientationValid() const { return myIsOrientationValid; }
197ac94e 74
778cd667 75 //! Return true if Projection was not invalidated.
76 Standard_Boolean IsProjectionValid() const { return myIsProjectionValid; }
77
78 public:
79
80 NCollection_Mat4<Elem_t> Orientation;
81 NCollection_Mat4<Elem_t> MProjection;
82 NCollection_Mat4<Elem_t> LProjection;
83 NCollection_Mat4<Elem_t> RProjection;
84
85 private:
86
87 Standard_Boolean myIsOrientationValid;
88 Standard_Boolean myIsProjectionValid;
197ac94e 89
197ac94e 90 };
b5ac8292 91
92public:
93
94 //! Enumerates supported monographic projections.
95 //! - Projection_Orthographic : orthographic projection.
96 //! - Projection_Perspective : perspective projection.
38a0206f 97 //! - Projection_Stereo : stereographic projection.
b5ac8292 98 //! - Projection_MonoLeftEye : mono projection for stereo left eye.
99 //! - Projection_MonoRightEye : mono projection for stereo right eye.
100 enum Projection
101 {
102 Projection_Orthographic,
103 Projection_Perspective,
104 Projection_Stereo,
105 Projection_MonoLeftEye,
106 Projection_MonoRightEye
107 };
108
109 //! Enumerates approaches to define stereographic focus.
110 //! - FocusType_Absolute : focus is specified as absolute value.
111 //! - FocusType_Relative : focus is specified relative to
112 //! (as coefficient of) camera focal length.
113 enum FocusType
114 {
115 FocusType_Absolute,
116 FocusType_Relative
117 };
118
119 //! Enumerates approaches to define Intraocular distance.
120 //! - IODType_Absolute : Intraocular distance is defined as absolute value.
121 //! - IODType_Relative : Intraocular distance is defined relative to
122 //! (as coefficient of) camera focal length.
123 enum IODType
124 {
125 IODType_Absolute,
126 IODType_Relative
127 };
128
129public:
130
131 //! Default constructor.
132 //! Initializes camera with the following properties:
133 //! Eye (0, 0, -2); Center (0, 0, 0); Up (0, 1, 0);
134 //! Type (Orthographic); FOVy (45); Scale (1000); IsStereo(false);
197ac94e 135 //! ZNear (0.001); ZFar (3000.0); Aspect(1);
b5ac8292 136 //! ZFocus(1.0); ZFocusType(Relative); IOD(0.05); IODType(Relative)
137 Standard_EXPORT Graphic3d_Camera();
138
139 //! Copy constructor.
140 //! @param theOther [in] the camera to copy from.
141 Standard_EXPORT Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther);
142
143 //! Initialize mapping related parameters from other camera handle.
144 Standard_EXPORT void CopyMappingData (const Handle(Graphic3d_Camera)& theOtherCamera);
145
146 //! Initialize orientation related parameters from other camera handle.
147 Standard_EXPORT void CopyOrientationData (const Handle(Graphic3d_Camera)& theOtherCamera);
148
149 //! Copy properties of another camera.
150 //! @param theOther [in] the camera to copy from.
151 Standard_EXPORT void Copy (const Handle(Graphic3d_Camera)& theOther);
152
197ac94e 153//! @name Public camera properties
154public:
b5ac8292 155
156 //! Sets camera Eye position.
157 //! @param theEye [in] the location of camera's Eye.
158 Standard_EXPORT void SetEye (const gp_Pnt& theEye);
159
160 //! Get camera Eye position.
161 //! @return camera eye location.
162 const gp_Pnt& Eye() const
163 {
164 return myEye;
165 }
166
167 //! Sets Center of the camera.
168 //! @param theCenter [in] the point where the camera looks at.
169 Standard_EXPORT void SetCenter (const gp_Pnt& theCenter);
170
171 //! Get Center of the camera.
172 //! @return the point where the camera looks at.
173 const gp_Pnt& Center() const
174 {
175 return myCenter;
176 }
177
197ac94e 178 //! Sets camera Up direction vector, orthogonal to camera direction.
b5ac8292 179 //! @param theUp [in] the Up direction vector.
180 Standard_EXPORT void SetUp (const gp_Dir& theUp);
181
197ac94e 182 //! Orthogonalize up direction vector.
183 Standard_EXPORT void OrthogonalizeUp();
184
185 //! Return a copy of orthogonalized up direction vector.
186 Standard_EXPORT gp_Dir OrthogonalizedUp() const;
187
b5ac8292 188 //! Get camera Up direction vector.
189 //! @return Camera's Up direction vector.
190 const gp_Dir& Up() const
191 {
192 return myUp;
193 }
194
ebc93ae7 195 //! Set camera axial scale.
b5ac8292 196 //! @param theAxialScale [in] the axial scale vector.
197ac94e 197 Standard_EXPORT void SetAxialScale (const gp_XYZ& theAxialScale);
b5ac8292 198
199 //! Get camera axial scale.
200 //! @return Camera's axial scale.
197ac94e 201 const gp_XYZ& AxialScale() const
b5ac8292 202 {
203 return myAxialScale;
204 }
205
206 //! Set distance of Eye from camera Center.
207 //! @param theDistance [in] the distance.
208 Standard_EXPORT void SetDistance (const Standard_Real theDistance);
209
210 //! Get distance of Eye from camera Center.
211 //! @return the distance.
212 Standard_EXPORT Standard_Real Distance() const;
213
214 //! Sets camera look direction.
215 //! @param theDir [in] the direction.
216 Standard_EXPORT void SetDirection (const gp_Dir& theDir);
217
218 //! Get camera look direction.
219 //! @return camera look direction.
220 Standard_EXPORT gp_Dir Direction() const;
221
222 //! Sets camera scale. For orthographic projection the scale factor
223 //! corresponds to parallel scale of view mapping (i.e. size
224 //! of viewport). For perspective camera scale is converted to
3dfe95cd 225 //! distance. The scale specifies equal size of the view projection in
226 //! both dimensions assuming that the aspect is 1.0. The projection height
227 //! and width are specified with the scale and correspondingly multiplied
228 //! by the aspect.
b5ac8292 229 //! @param theScale [in] the scale factor.
230 Standard_EXPORT void SetScale (const Standard_Real theScale);
231
232 //! Get camera scale.
233 //! @return camera scale factor.
234 Standard_EXPORT Standard_Real Scale() const;
235
236 //! Change camera projection type.
197ac94e 237 //! When switching to perspective projection from orthographic one,
238 //! the ZNear and ZFar are reset to default values (0.001, 3000.0)
239 //! if less than 0.0.
b5ac8292 240 //! @param theProjectionType [in] the camera projection type.
241 Standard_EXPORT void SetProjectionType (const Projection theProjection);
242
243 //! @return camera projection type.
244 Projection ProjectionType() const
245 {
246 return myProjType;
247 }
248
249 //! Check that the camera projection is orthographic.
250 //! @return boolean flag that indicates whether the camera's projection is
251 //! orthographic or not.
252 Standard_Boolean IsOrthographic() const
253 {
254 return (myProjType == Projection_Orthographic);
255 }
256
257 //! Check whether the camera projection is stereo.
258 //! Please note that stereo rendering is now implemented with support of
259 //! Quad buffering.
260 //! @return boolean flag indicating whether the stereographic L/R projection
261 //! is chosen.
262 Standard_Boolean IsStereo() const
263 {
264 return (myProjType == Projection_Stereo);
265 }
266
267 //! Set Field Of View (FOV) in y axis for perspective projection.
268 //! @param theFOVy [in] the FOV in degrees.
269 Standard_EXPORT void SetFOVy (const Standard_Real theFOVy);
270
271 //! Get Field Of View (FOV) in y axis.
272 //! @return the FOV value in degrees.
273 Standard_Real FOVy() const
274 {
275 return myFOVy;
276 }
277
10dbdf34 278 //! Estimate Z-min and Z-max planes of projection volume to match the
6bc6a6fc 279 //! displayed objects. The methods ensures that view volume will
280 //! be close by depth range to the displayed objects. Fitting assumes that
281 //! for orthogonal projection the view volume contains the displayed objects
282 //! completely. For zoomed perspective view, the view volume is adjusted such
283 //! that it contains the objects or their parts, located in front of the camera.
284 //! @param theScaleFactor [in] the scale factor for Z-range.
285 //! The range between Z-min, Z-max projection volume planes
286 //! evaluated by z fitting method will be scaled using this coefficient.
287 //! Program error exception is thrown if negative or zero value is passed.
288 //! @param theMinMax [in] applicative min max boundaries.
289 //! @param theScaleFactor [in] real graphical boundaries (not accounting infinite flag).
10dbdf34 290 Standard_EXPORT bool ZFitAll (const Standard_Real theScaleFactor,
291 const Bnd_Box& theMinMax,
292 const Bnd_Box& theGraphicBB,
293 Standard_Real& theZNear,
294 Standard_Real& theZFar) const;
295
296 //! Change Z-min and Z-max planes of projection volume to match the displayed objects.
297 void ZFitAll (const Standard_Real theScaleFactor, const Bnd_Box& theMinMax, const Bnd_Box& theGraphicBB)
298 {
299 Standard_Real aZNear = 0.0, aZFar = 1.0;
300 ZFitAll (theScaleFactor, theMinMax, theGraphicBB, aZNear, aZFar);
301 SetZRange (aZNear, aZFar);
302 }
6bc6a6fc 303
197ac94e 304 //! Change the Near and Far Z-clipping plane positions.
305 //! For orthographic projection, theZNear, theZFar can be negative or positive.
306 //! For perspective projection, only positive values are allowed.
307 //! Program error exception is raised if non-positive values are
308 //! specified for perspective projection or theZNear >= theZFar.
b5ac8292 309 //! @param theZNear [in] the distance of the plane from the Eye.
197ac94e 310 //! @param theZFar [in] the distance of the plane from the Eye.
311 Standard_EXPORT void SetZRange (const Standard_Real theZNear, const Standard_Real theZFar);
b5ac8292 312
313 //! Get the Near Z-clipping plane position.
314 //! @return the distance of the plane from the Eye.
315 Standard_Real ZNear() const
316 {
317 return myZNear;
318 }
319
b5ac8292 320 //! Get the Far Z-clipping plane position.
321 //! @return the distance of the plane from the Eye.
322 Standard_Real ZFar() const
323 {
324 return myZFar;
325 }
326
3dfe95cd 327 //! Changes width / height display ratio.
b5ac8292 328 //! @param theAspect [in] the display ratio.
329 Standard_EXPORT void SetAspect (const Standard_Real theAspect);
330
331 //! Get camera display ratio.
332 //! @return display ratio.
333 Standard_Real Aspect() const
334 {
335 return myAspect;
336 }
337
338 //! Sets stereographic focus distance.
339 //! @param theType [in] the focus definition type. Focus can be defined
340 //! as absolute value or relatively to (as coefficient of) coefficient of
341 //! camera focal length.
342 //! @param theZFocus [in] the focus absolute value or coefficient depending
343 //! on the passed definition type.
344 Standard_EXPORT void SetZFocus (const FocusType theType, const Standard_Real theZFocus);
345
346 //! Get stereographic focus value.
347 //! @return absolute or relative stereographic focus value
348 //! depending on its definition type.
349 Standard_Real ZFocus() const
350 {
351 return myZFocus;
352 }
353
354 //! Get stereographic focus definition type.
355 //! @return definition type used for stereographic focus.
356 FocusType ZFocusType() const
357 {
358 return myZFocusType;
359 }
360
361 //! Sets Intraocular distance.
362 //! @param theType [in] the IOD definition type. IOD can be defined as
363 //! absolute value or relatively to (as coefficient of) camera focal length.
364 //! @param theIOD [in] the Intraocular distance.
365 Standard_EXPORT void SetIOD (const IODType theType, const Standard_Real theIOD);
366
367 //! Get Intraocular distance value.
368 //! @return absolute or relative IOD value depending on its definition type.
369 Standard_Real IOD() const
370 {
371 return myIOD;
372 }
373
374 //! Get Intraocular distance definition type.
375 //! @return definition type used for Intraocular distance.
376 IODType GetIODType() const
377 {
378 return myIODType;
379 }
380
3bffef55 381 //! Get current tile.
382 const Graphic3d_CameraTile& Tile() const { return myTile; }
383
384 //! Sets the Tile defining the drawing sub-area within View.
385 //! Note that tile defining a region outside the view boundaries is also valid - use method Graphic3d_CameraTile::Cropped() to assign a cropped copy.
386 //! @param theTile tile definition
387 Standard_EXPORT void SetTile (const Graphic3d_CameraTile& theTile);
388
197ac94e 389//! @name Basic camera operations
b5ac8292 390public:
391
392 //! Transform orientation components of the camera:
393 //! Eye, Up and Center points.
394 //! @param theTrsf [in] the transformation to apply.
395 Standard_EXPORT void Transform (const gp_Trsf& theTrsf);
396
397 //! Calculate view plane size at center (target) point
398 //! and distance between ZFar and ZNear planes.
399 //! @return values in form of gp_Pnt (Width, Height, Depth).
3fe9ce0e 400 gp_XYZ ViewDimensions() const
401 {
402 return ViewDimensions (Distance());
403 }
404
405 //! Calculate view plane size at center point with specified Z offset
406 //! and distance between ZFar and ZNear planes.
407 //! @param theZValue [in] the distance from the eye in eye-to-center direction
408 //! @return values in form of gp_Pnt (Width, Height, Depth).
409 Standard_EXPORT gp_XYZ ViewDimensions (const Standard_Real theZValue) const;
197ac94e 410
411 //! Calculate WCS frustum planes for the camera projection volume.
412 //! Frustum is a convex volume determined by six planes directing
413 //! inwards.
414 //! The frustum planes are usually used as inputs for camera algorithms.
415 //! Thus, if any changes to projection matrix calculation are necessary,
416 //! the frustum planes calculation should be also touched.
417 //! @param theLeft [out] the frustum plane for left side of view.
418 //! @param theRight [out] the frustum plane for right side of view.
419 //! @param theBottom [out] the frustum plane for bottom side of view.
420 //! @param theTop [out] the frustum plane for top side of view.
421 //! @param theNear [out] the frustum plane for near side of view.
422 //! @param theFar [out] the frustum plane for far side of view.
423 Standard_EXPORT void Frustum (gp_Pln& theLeft,
424 gp_Pln& theRight,
425 gp_Pln& theBottom,
426 gp_Pln& theTop,
427 gp_Pln& theNear,
428 gp_Pln& theFar) const;
429
430//! @name Projection methods
b5ac8292 431public:
432
433 //! Project point from world coordinate space to
434 //! normalized device coordinates (mapping).
435 //! @param thePnt [in] the 3D point in WCS.
436 //! @return mapped point in NDC.
437 Standard_EXPORT gp_Pnt Project (const gp_Pnt& thePnt) const;
438
439 //! Unproject point from normalized device coordinates
440 //! to world coordinate space.
441 //! @param thePnt [in] the NDC point.
442 //! @return 3D point in WCS.
443 Standard_EXPORT gp_Pnt UnProject (const gp_Pnt& thePnt) const;
444
445 //! Convert point from view coordinate space to
446 //! projection coordinate space.
447 //! @param thePnt [in] the point in VCS.
448 //! @return point in NDC.
449 Standard_EXPORT gp_Pnt ConvertView2Proj (const gp_Pnt& thePnt) const;
450
451 //! Convert point from projection coordinate space
452 //! to view coordinate space.
453 //! @param thePnt [in] the point in NDC.
454 //! @return point in VCS.
455 Standard_EXPORT gp_Pnt ConvertProj2View (const gp_Pnt& thePnt) const;
456
457 //! Convert point from world coordinate space to
458 //! view coordinate space.
459 //! @param thePnt [in] the 3D point in WCS.
460 //! @return point in VCS.
461 Standard_EXPORT gp_Pnt ConvertWorld2View (const gp_Pnt& thePnt) const;
462
463 //! Convert point from view coordinate space to
464 //! world coordinates.
465 //! @param thePnt [in] the 3D point in VCS.
466 //! @return point in WCS.
467 Standard_EXPORT gp_Pnt ConvertView2World (const gp_Pnt& thePnt) const;
468
197ac94e 469//! @name Camera modification state
b5ac8292 470public:
471
825aa485 472 //! @return projection modification state of the camera.
473 const Graphic3d_WorldViewProjState& WorldViewProjState() const
474 {
475 return myWorldViewProjState;
476 }
477
478
197ac94e 479 //! Returns modification state of camera projection matrix
480 Standard_Size ProjectionState() const
481 {
825aa485 482 return myWorldViewProjState.ProjectionState();
197ac94e 483 }
484
825aa485 485 //! Returns modification state of camera world view transformation matrix.
486 Standard_Size WorldViewState() const
197ac94e 487 {
825aa485 488 return myWorldViewProjState.WorldViewState();
197ac94e 489 }
490
491//! @name Lazily-computed orientation and projection matrices derived from camera parameters
492public:
b5ac8292 493
197ac94e 494 //! Get orientation matrix.
495 //! @return camera orientation matrix.
496 Standard_EXPORT const Graphic3d_Mat4d& OrientationMatrix() const;
497
498 //! Get orientation matrix of Standard_ShortReal precision.
499 //! @return camera orientation matrix.
500 Standard_EXPORT const Graphic3d_Mat4& OrientationMatrixF() const;
501
502 //! Get monographic or middle point projection matrix used for monographic
503 //! rendering and for point projection / unprojection.
504 //! @return monographic projection matrix.
505 Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
506
507 //! Get monographic or middle point projection matrix of Standard_ShortReal precision used for monographic
508 //! rendering and for point projection / unprojection.
509 //! @return monographic projection matrix.
510 Standard_EXPORT const Graphic3d_Mat4& ProjectionMatrixF() const;
511
512 //! @return stereographic matrix computed for left eye. Please note
513 //! that this method is used for rendering for <i>Projection_Stereo</i>.
514 Standard_EXPORT const Graphic3d_Mat4d& ProjectionStereoLeft() const;
515
516 //! @return stereographic matrix of Standard_ShortReal precision computed for left eye.
517 //! Please note that this method is used for rendering for <i>Projection_Stereo</i>.
518 Standard_EXPORT const Graphic3d_Mat4& ProjectionStereoLeftF() const;
519
520 //! @return stereographic matrix computed for right eye. Please note
521 //! that this method is used for rendering for <i>Projection_Stereo</i>.
522 Standard_EXPORT const Graphic3d_Mat4d& ProjectionStereoRight() const;
523
524 //! @return stereographic matrix of Standard_ShortReal precision computed for right eye.
525 //! Please note that this method is used for rendering for <i>Projection_Stereo</i>.
526 Standard_EXPORT const Graphic3d_Mat4& ProjectionStereoRightF() const;
527
05e2200b 528 //! Invalidate state of projection matrix.
529 //! The matrix will be updated on request.
530 Standard_EXPORT void InvalidateProjection();
531
532 //! Invalidate orientation matrix.
533 //! The matrix will be updated on request.
534 Standard_EXPORT void InvalidateOrientation();
535
197ac94e 536//! @name Managing projection and orientation cache
537private:
538
539 //! Compute projection matrices.
540 //! @param theMatrices [in] the matrices data container.
541 template <typename Elem_t>
542 Standard_EXPORT
543 TransformMatrices<Elem_t>& UpdateProjection (TransformMatrices<Elem_t>& theMatrices) const;
544
545 //! Compute orientation matrix.
546 //! @param theMatrices [in] the matrices data container.
547 template <typename Elem_t>
548 Standard_EXPORT
549 TransformMatrices<Elem_t>& UpdateOrientation (TransformMatrices<Elem_t>& theMatrices) const;
550
b5ac8292 551private:
552
553 //! Compose orthographic projection matrix for
554 //! the passed camera volume mapping.
555 //! @param theLeft [in] the left mapping (clipping) coordinate.
556 //! @param theRight [in] the right mapping (clipping) coordinate.
557 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
558 //! @param theTop [in] the top mapping (clipping) coordinate.
559 //! @param theNear [in] the near mapping (clipping) coordinate.
560 //! @param theFar [in] the far mapping (clipping) coordinate.
b5ac8292 561 //! @param theOutMx [out] the projection matrix.
197ac94e 562 template <typename Elem_t>
b5ac8292 563 static void
197ac94e 564 OrthoProj (const Elem_t theLeft,
565 const Elem_t theRight,
566 const Elem_t theBottom,
567 const Elem_t theTop,
568 const Elem_t theNear,
569 const Elem_t theFar,
570 NCollection_Mat4<Elem_t>& theOutMx);
b5ac8292 571
572 //! Compose perspective projection matrix for
573 //! the passed camera volume mapping.
574 //! @param theLeft [in] the left mapping (clipping) coordinate.
575 //! @param theRight [in] the right mapping (clipping) coordinate.
576 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
577 //! @param theTop [in] the top mapping (clipping) coordinate.
578 //! @param theNear [in] the near mapping (clipping) coordinate.
579 //! @param theFar [in] the far mapping (clipping) coordinate.
b5ac8292 580 //! @param theOutMx [out] the projection matrix.
197ac94e 581 template <typename Elem_t>
b5ac8292 582 static void
197ac94e 583 PerspectiveProj (const Elem_t theLeft,
584 const Elem_t theRight,
585 const Elem_t theBottom,
586 const Elem_t theTop,
587 const Elem_t theNear,
588 const Elem_t theFar,
589 NCollection_Mat4<Elem_t>& theOutMx);
b5ac8292 590
591 //! Compose projection matrix for L/R stereo eyes.
592 //! @param theLeft [in] the left mapping (clipping) coordinate.
593 //! @param theRight [in] the right mapping (clipping) coordinate.
594 //! @param theBottom [in] the bottom mapping (clipping) coordinate.
595 //! @param theTop [in] the top mapping (clipping) coordinate.
596 //! @param theNear [in] the near mapping (clipping) coordinate.
597 //! @param theFar [in] the far mapping (clipping) coordinate.
598 //! @param theIOD [in] the Intraocular distance.
599 //! @param theZFocus [in] the z coordinate of off-axis
600 //! projection plane with zero parallax.
b5ac8292 601 //! @param theIsLeft [in] boolean flag to choose between L/R eyes.
602 //! @param theOutMx [out] the projection matrix.
197ac94e 603 template <typename Elem_t>
b5ac8292 604 static void
197ac94e 605 StereoEyeProj (const Elem_t theLeft,
606 const Elem_t theRight,
607 const Elem_t theBottom,
608 const Elem_t theTop,
609 const Elem_t theNear,
610 const Elem_t theFar,
611 const Elem_t theIOD,
612 const Elem_t theZFocus,
613 const Standard_Boolean theIsLeft,
614 NCollection_Mat4<Elem_t>& theOutMx);
b5ac8292 615
616 //! Construct "look at" orientation transformation.
617 //! Reference point differs for perspective and ortho modes
618 //! (made for compatibility, to be improved..).
619 //! @param theEye [in] the eye coordinates in 3D space.
620 //! @param theLookAt [in] the point the camera looks at.
621 //! @param theUpDir [in] the up direction vector.
622 //! @param theAxialScale [in] the axial scale vector.
623 //! @param theOutMx [in/out] the orientation matrix.
197ac94e 624 template <typename Elem_t>
b5ac8292 625 static void
197ac94e 626 LookOrientation (const NCollection_Vec3<Elem_t>& theEye,
627 const NCollection_Vec3<Elem_t>& theLookAt,
628 const NCollection_Vec3<Elem_t>& theUpDir,
629 const NCollection_Vec3<Elem_t>& theAxialScale,
630 NCollection_Mat4<Elem_t>& theOutMx);
b5ac8292 631
632private:
633
634 gp_Dir myUp; //!< Camera up direction vector.
635 gp_Pnt myEye; //!< Camera eye position.
636 gp_Pnt myCenter; //!< Camera center.
637
197ac94e 638 gp_XYZ myAxialScale; //!< World axial scale.
b5ac8292 639
197ac94e 640 Projection myProjType; //!< Projection type used for rendering.
641 Standard_Real myFOVy; //!< Field Of View in y axis.
778cd667 642 Standard_Real myFOVyTan; //!< Field Of View as Tan(DTR_HALF * myFOVy)
197ac94e 643 Standard_Real myZNear; //!< Distance to near clipping plane.
644 Standard_Real myZFar; //!< Distance to far clipping plane.
645 Standard_Real myAspect; //!< Width to height display ratio.
b5ac8292 646
647 Standard_Real myScale; //!< Specifies parallel scale for orthographic projection.
648 Standard_Real myZFocus; //!< Stereographic focus value.
649 FocusType myZFocusType; //!< Stereographic focus definition type.
650
651 Standard_Real myIOD; //!< Intraocular distance value.
652 IODType myIODType; //!< Intraocular distance definition type.
653
3bffef55 654 Graphic3d_CameraTile myTile;//!< Tile defining sub-area for drawing
655
197ac94e 656 mutable TransformMatrices<Standard_Real> myMatricesD;
657 mutable TransformMatrices<Standard_ShortReal> myMatricesF;
b5ac8292 658
825aa485 659 mutable Graphic3d_WorldViewProjState myWorldViewProjState;
b5ac8292 660
661public:
662
a3f6f591 663 DEFINE_STANDARD_RTTIEXT(Graphic3d_Camera,Standard_Transient)
b5ac8292 664};
665
494782f6 666DEFINE_STANDARD_HANDLE (Graphic3d_Camera, Standard_Transient)
667
b5ac8292 668#endif