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