1 // Created on: 2015-06-18
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2015 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_TransformPers_HeaderFile
17 #define _Graphic3d_TransformPers_HeaderFile
19 #include <Aspect_TypeOfTriedronPosition.hxx>
20 #include <Bnd_Box.hxx>
21 #include <BVH_Box.hxx>
22 #include <Graphic3d_Camera.hxx>
23 #include <Graphic3d_TransformUtils.hxx>
24 #include <Graphic3d_TransModeFlags.hxx>
25 #include <Graphic3d_Vec.hxx>
26 #include <NCollection_Mat4.hxx>
28 DEFINE_STANDARD_HANDLE(Graphic3d_TransformPers, Standard_Transient)
30 //! Transformation Persistence definition.
32 //! Transformation Persistence defines a mutable Local Coordinate system which depends on camera position,
33 //! so that visual appearance of the object becomes partially immutable while camera moves.
34 //! Object visually preserves particular property such as size, placement, rotation or their combination.
36 //! Graphic3d_TMF_ZoomPers, Graphic3d_TMF_RotatePers and Graphic3d_TMF_ZoomRotatePers define Local Coordinate system
37 //! having origin in specified anchor point defined in World Coordinate system,
38 //! while Graphic3d_TMF_TriedronPers and Graphic3d_TMF_2d define origin as 2D offset from screen corner in pixels.
40 //! Graphic3d_TMF_2d, Graphic3d_TMF_TriedronPers and Graphic3d_TMF_ZoomPers defines Local Coordinate system where length units are pixels.
41 //! Beware that Graphic3d_RenderingParams::ResolutionRatio() will be ignored!
42 //! For other Persistence flags, normal (world) length units will apply.
44 //! WARNING: Graphic3d_TMF_None is not permitted for defining instance of this class - NULL handle should be used for this purpose!
45 class Graphic3d_TransformPers : public Standard_Transient
47 DEFINE_STANDARD_RTTIEXT(Graphic3d_TransformPers, Standard_Transient)
50 //! Return true if specified mode is zoom/rotate transformation persistence.
51 static Standard_Boolean IsZoomOrRotate (Graphic3d_TransModeFlags theMode)
53 return (theMode & (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers)) != 0;
56 //! Return true if specified mode is 2d/trihedron transformation persistence.
57 static Standard_Boolean IsTrihedronOr2d (Graphic3d_TransModeFlags theMode)
59 return (theMode & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) != 0;
64 //! Set transformation persistence.
65 Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode)
68 if (IsZoomOrRotate (theMode))
70 SetPersistence (theMode, gp_Pnt(0.0, 0.0, 0.0));
72 else if (IsTrihedronOr2d (theMode))
74 SetPersistence (theMode, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (0, 0));
76 else if (theMode == Graphic3d_TMF_CameraPers)
82 throw Standard_ProgramError("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
86 //! Set Zoom/Rotate transformation persistence with an anchor 3D point.
87 //! Anchor point defines the origin of Local Coordinate system within World Coordinate system.
88 //! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
89 Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
91 : myMode (Graphic3d_TMF_None)
93 SetPersistence (theMode, thePnt);
96 //! Set 2d/trihedron transformation persistence with a corner and 2D offset.
97 //! 2D offset defines the origin of Local Coordinate system as projection of 2D point on screen plane into World Coordinate system.
98 //! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
99 //! The offset is a positive displacement from the view corner in pixels.
100 Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
101 const Aspect_TypeOfTriedronPosition theCorner,
102 const Graphic3d_Vec2i& theOffset = Graphic3d_Vec2i (0, 0))
103 : myMode (Graphic3d_TMF_None)
105 SetPersistence (theMode, theCorner, theOffset);
108 //! Return true for Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers modes.
109 Standard_Boolean IsZoomOrRotate() const { return IsZoomOrRotate (myMode); }
111 //! Return true for Graphic3d_TMF_TriedronPers and Graphic3d_TMF_2d modes.
112 Standard_Boolean IsTrihedronOr2d() const { return IsTrihedronOr2d (myMode); }
114 //! Transformation persistence mode flags.
115 Graphic3d_TransModeFlags Mode() const { return myMode; }
117 //! Transformation persistence mode flags.
118 Graphic3d_TransModeFlags Flags() const { return myMode; }
120 //! Set Zoom/Rotate transformation persistence with an anchor 3D point.
121 //! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
122 void SetPersistence (const Graphic3d_TransModeFlags theMode,
123 const gp_Pnt& thePnt)
125 if (!IsZoomOrRotate (theMode))
127 throw Standard_ProgramError("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
131 myParams.Params3d.PntX = thePnt.X();
132 myParams.Params3d.PntY = thePnt.Y();
133 myParams.Params3d.PntZ = thePnt.Z();
136 //! Set 2d/trihedron transformation persistence with a corner and 2D offset.
137 //! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
138 void SetPersistence (const Graphic3d_TransModeFlags theMode,
139 const Aspect_TypeOfTriedronPosition theCorner,
140 const Graphic3d_Vec2i& theOffset)
142 if (!IsTrihedronOr2d (theMode))
144 throw Standard_ProgramError("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
148 myParams.Params2d.Corner = theCorner;
149 myParams.Params2d.OffsetX = theOffset.x();
150 myParams.Params2d.OffsetY = theOffset.y();
155 //! Return the anchor point for zoom/rotate transformation persistence.
156 gp_Pnt AnchorPoint() const
158 if (!IsZoomOrRotate())
160 throw Standard_ProgramError("Graphic3d_TransformPers::AnchorPoint(), wrong persistence mode.");
163 return gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ);
166 //! Set the anchor point for zoom/rotate transformation persistence.
167 void SetAnchorPoint (const gp_Pnt& thePnt)
169 if (!IsZoomOrRotate())
171 throw Standard_ProgramError("Graphic3d_TransformPers::SetAnchorPoint(), wrong persistence mode.");
174 myParams.Params3d.PntX = thePnt.X();
175 myParams.Params3d.PntY = thePnt.Y();
176 myParams.Params3d.PntZ = thePnt.Z();
179 //! Return the corner for 2d/trihedron transformation persistence.
180 Aspect_TypeOfTriedronPosition Corner2d() const
182 if (!IsTrihedronOr2d())
184 throw Standard_ProgramError("Graphic3d_TransformPers::Corner2d(), wrong persistence mode.");
187 return myParams.Params2d.Corner;
190 //! Set the corner for 2d/trihedron transformation persistence.
191 void SetCorner2d (const Aspect_TypeOfTriedronPosition thePos)
193 if (!IsTrihedronOr2d())
195 throw Standard_ProgramError("Graphic3d_TransformPers::SetCorner2d(), wrong persistence mode.");
198 myParams.Params2d.Corner = thePos;
201 //! Return the offset from the corner for 2d/trihedron transformation persistence.
202 Graphic3d_Vec2i Offset2d() const
204 if (!IsTrihedronOr2d())
206 throw Standard_ProgramError("Graphic3d_TransformPers::Offset2d(), wrong persistence mode.");
209 return Graphic3d_Vec2i (myParams.Params2d.OffsetX, myParams.Params2d.OffsetY);
212 //! Set the offset from the corner for 2d/trihedron transformation persistence.
213 void SetOffset2d (const Graphic3d_Vec2i& theOffset)
215 if (!IsTrihedronOr2d())
217 throw Standard_ProgramError("Graphic3d_TransformPers::SetOffset2d(), wrong persistence mode.");
220 myParams.Params2d.OffsetX = theOffset.x();
221 myParams.Params2d.OffsetY = theOffset.y();
226 //! Apply transformation to bounding box of presentation.
227 //! @param theCamera [in] camera definition
228 //! @param theProjection [in] the projection transformation matrix.
229 //! @param theWorldView [in] the world view transformation matrix.
230 //! @param theViewportWidth [in] the width of viewport (for 2d persistence).
231 //! @param theViewportHeight [in] the height of viewport (for 2d persistence).
232 //! @param theBoundingBox [in/out] the bounding box to transform.
234 void Apply (const Handle(Graphic3d_Camera)& theCamera,
235 const NCollection_Mat4<T>& theProjection,
236 const NCollection_Mat4<T>& theWorldView,
237 const Standard_Integer theViewportWidth,
238 const Standard_Integer theViewportHeight,
239 Bnd_Box& theBoundingBox) const;
241 //! Apply transformation to bounding box of presentation
242 //! @param theCamera [in] camera definition
243 //! @param theProjection [in] the projection transformation matrix.
244 //! @param theWorldView [in] the world view transformation matrix.
245 //! @param theViewportWidth [in] the width of viewport (for 2d persistence).
246 //! @param theViewportHeight [in] the height of viewport (for 2d persistence).
247 //! @param theBoundingBox [in/out] the bounding box to transform.
249 void Apply (const Handle(Graphic3d_Camera)& theCamera,
250 const NCollection_Mat4<T>& theProjection,
251 const NCollection_Mat4<T>& theWorldView,
252 const Standard_Integer theViewportWidth,
253 const Standard_Integer theViewportHeight,
254 BVH_Box<T, 3>& theBoundingBox) const;
256 //! Compute transformation.
257 //! Computed matrix can be applied to model world transformation
258 //! of an object to implement effect of transformation persistence.
259 //! @param theCamera [in] camera definition
260 //! @param theProjection [in] the projection transformation matrix.
261 //! @param theWorldView [in] the world view transformation matrix.
262 //! @param theViewportWidth [in] the width of viewport (for 2d persistence).
263 //! @param theViewportHeight [in] the height of viewport (for 2d persistence).
264 //! @return transformation matrix to be applied to model world transformation of an object.
266 NCollection_Mat4<T> Compute (const Handle(Graphic3d_Camera)& theCamera,
267 const NCollection_Mat4<T>& theProjection,
268 const NCollection_Mat4<T>& theWorldView,
269 const Standard_Integer theViewportWidth,
270 const Standard_Integer theViewportHeight) const;
272 //! Apply transformation persistence on specified matrices.
273 //! @param theCamera camera definition
274 //! @param theProjection projection matrix to modify
275 //! @param theWorldView world-view matrix to modify
276 //! @param theViewportWidth viewport width
277 //! @param theViewportHeight viewport height
279 void Apply (const Handle(Graphic3d_Camera)& theCamera,
280 const NCollection_Mat4<T>& theProjection,
281 NCollection_Mat4<T>& theWorldView,
282 const Standard_Integer theViewportWidth,
283 const Standard_Integer theViewportHeight) const;
285 //! Dumps the content of me into the stream
286 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
290 //! 3D anchor point for zoom/rotate transformation persistence.
297 //! Dumps the content of me into the stream
298 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
301 //! 2d/trihedron transformation persistence parameters.
304 Standard_Integer OffsetX;
305 Standard_Integer OffsetY;
306 Aspect_TypeOfTriedronPosition Corner;
308 //! Dumps the content of me into the stream
309 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
314 Graphic3d_TransModeFlags myMode; //!< Transformation persistence mode flags
317 PersParams3d Params3d;
318 PersParams2d Params2d;
323 // =======================================================================
325 // purpose : Apply transformation to world view and projection matrices.
326 // =======================================================================
328 void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
329 const NCollection_Mat4<T>& theProjection,
330 NCollection_Mat4<T>& theWorldView,
331 const Standard_Integer theViewportWidth,
332 const Standard_Integer theViewportHeight) const
334 (void )theViewportWidth;
335 (void )theProjection;
336 if (myMode == Graphic3d_TMF_None
337 || theViewportHeight == 0)
342 // use total size when tiling is active
343 const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight;
345 // a small enough jitter compensation offset
346 // to avoid image dragging within single pixel in corner cases
347 const Standard_Real aJitterComp = 0.001;
348 if (myMode == Graphic3d_TMF_TriedronPers)
350 // reset Z focus for trihedron persistence
351 const Standard_Real aFocus = theCamera->IsOrthographic()
352 ? theCamera->Distance()
353 : (theCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
354 ? Standard_Real(theCamera->ZFocus() * theCamera->Distance())
355 : Standard_Real(theCamera->ZFocus()));
357 // scale factor to pixels
358 const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
359 const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
360 const gp_Dir aForward = theCamera->Direction();
361 gp_XYZ aCenter = theCamera->Center().XYZ() + aForward.XYZ() * (aFocus - theCamera->Distance());
362 if ((myParams.Params2d.Corner & (Aspect_TOTP_LEFT | Aspect_TOTP_RIGHT)) != 0)
364 const Standard_Real anOffsetX = (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale;
365 const gp_Dir aSide = aForward.Crossed (theCamera->Up());
366 const gp_XYZ aDeltaX = aSide.XYZ() * (Abs(aViewDim.X()) * theCamera->NDC2dOffsetX() - anOffsetX);
367 if ((myParams.Params2d.Corner & Aspect_TOTP_RIGHT) != 0)
376 if ((myParams.Params2d.Corner & (Aspect_TOTP_TOP | Aspect_TOTP_BOTTOM)) != 0)
378 const Standard_Real anOffsetY = (Standard_Real(myParams.Params2d.OffsetY) + aJitterComp) * aScale;
379 const gp_XYZ aDeltaY = theCamera->Up().XYZ() * (Abs(aViewDim.Y()) * theCamera->NDC2dOffsetY() - anOffsetY);
380 if ((myParams.Params2d.Corner & Aspect_TOTP_TOP) != 0)
390 NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
391 Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
392 Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
393 theWorldView.ConvertFrom (aWorldView);
396 else if (myMode == Graphic3d_TMF_2d)
398 const Standard_Real aFocus = theCamera->IsOrthographic()
399 ? theCamera->Distance()
400 : (theCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
401 ? Standard_Real(theCamera->ZFocus() * theCamera->Distance())
402 : Standard_Real(theCamera->ZFocus()));
404 // scale factor to pixels
405 const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
406 const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
407 gp_XYZ aCenter (0.0, 0.0, -aFocus);
408 if ((myParams.Params2d.Corner & (Aspect_TOTP_LEFT | Aspect_TOTP_RIGHT)) != 0)
410 aCenter.SetX (-aViewDim.X() * theCamera->NDC2dOffsetX() + (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale);
411 if ((myParams.Params2d.Corner & Aspect_TOTP_RIGHT) != 0)
413 aCenter.SetX (-aCenter.X());
416 if ((myParams.Params2d.Corner & (Aspect_TOTP_TOP | Aspect_TOTP_BOTTOM)) != 0)
418 aCenter.SetY (-aViewDim.Y() * theCamera->NDC2dOffsetY() + (Standard_Real(myParams.Params2d.OffsetY) + aJitterComp) * aScale);
419 if ((myParams.Params2d.Corner & Aspect_TOTP_TOP) != 0)
421 aCenter.SetY (-aCenter.Y());
425 theWorldView.InitIdentity();
426 Graphic3d_TransformUtils::Translate (theWorldView, T(aCenter.X()), T(aCenter.Y()), T(aCenter.Z()));
427 Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
430 else if ((myMode & Graphic3d_TMF_CameraPers) != 0)
432 theWorldView.InitIdentity();
436 // Compute reference point for transformation in untransformed projection space.
437 NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
438 Graphic3d_TransformUtils::Translate (aWorldView, myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ);
439 if ((myMode & Graphic3d_TMF_RotatePers) != 0)
441 // lock rotation by nullifying rotation component
442 aWorldView.SetValue (0, 0, 1.0);
443 aWorldView.SetValue (1, 0, 0.0);
444 aWorldView.SetValue (2, 0, 0.0);
446 aWorldView.SetValue (0, 1, 0.0);
447 aWorldView.SetValue (1, 1, 1.0);
448 aWorldView.SetValue (2, 1, 0.0);
450 aWorldView.SetValue (0, 2, 0.0);
451 aWorldView.SetValue (1, 2, 0.0);
452 aWorldView.SetValue (2, 2, 1.0);
455 if ((myMode & Graphic3d_TMF_ZoomPers) != 0)
458 gp_Vec aVecToEye (theCamera->Direction());
459 gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
460 const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
461 const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
462 const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
463 Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
465 theWorldView.ConvertFrom (aWorldView);
470 // =======================================================================
472 // purpose : Apply transformation to bounding box of presentation.
473 // =======================================================================
475 void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
476 const NCollection_Mat4<T>& theProjection,
477 const NCollection_Mat4<T>& theWorldView,
478 const Standard_Integer theViewportWidth,
479 const Standard_Integer theViewportHeight,
480 Bnd_Box& theBoundingBox) const
482 if (theBoundingBox.IsVoid())
487 T aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
489 theBoundingBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
491 typename BVH_Box<T, 3>::BVH_VecNt aMin (aXmin, aYmin, aZmin);
492 typename BVH_Box<T, 3>::BVH_VecNt aMax (aXmax, aYmax, aZmax);
493 BVH_Box<T, 3> aBBox (aMin, aMax);
495 Apply (theCamera, theProjection, theWorldView, theViewportWidth, theViewportHeight, aBBox);
497 theBoundingBox = Bnd_Box();
498 theBoundingBox.Update (aBBox.CornerMin().x(), aBBox.CornerMin().y(), aBBox.CornerMin().z(),
499 aBBox.CornerMax().x(), aBBox.CornerMax().y(), aBBox.CornerMax().z());
502 // =======================================================================
504 // purpose : Apply transformation to bounding box of presentation.
505 // =======================================================================
507 void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
508 const NCollection_Mat4<T>& theProjection,
509 const NCollection_Mat4<T>& theWorldView,
510 const Standard_Integer theViewportWidth,
511 const Standard_Integer theViewportHeight,
512 BVH_Box<T, 3>& theBoundingBox) const
514 NCollection_Mat4<T> aTPers = Compute (theCamera, theProjection, theWorldView, theViewportWidth, theViewportHeight);
515 if (aTPers.IsIdentity()
516 || !theBoundingBox.IsValid())
521 const typename BVH_Box<T, 3>::BVH_VecNt& aMin = theBoundingBox.CornerMin();
522 const typename BVH_Box<T, 3>::BVH_VecNt& aMax = theBoundingBox.CornerMax();
524 typename BVH_Box<T, 4>::BVH_VecNt anArrayOfCorners[8];
525 anArrayOfCorners[0] = typename BVH_Box<T, 4>::BVH_VecNt (aMin.x(), aMin.y(), aMin.z(), static_cast<T> (1.0));
526 anArrayOfCorners[1] = typename BVH_Box<T, 4>::BVH_VecNt (aMin.x(), aMin.y(), aMax.z(), static_cast<T> (1.0));
527 anArrayOfCorners[2] = typename BVH_Box<T, 4>::BVH_VecNt (aMin.x(), aMax.y(), aMin.z(), static_cast<T> (1.0));
528 anArrayOfCorners[3] = typename BVH_Box<T, 4>::BVH_VecNt (aMin.x(), aMax.y(), aMax.z(), static_cast<T> (1.0));
529 anArrayOfCorners[4] = typename BVH_Box<T, 4>::BVH_VecNt (aMax.x(), aMin.y(), aMin.z(), static_cast<T> (1.0));
530 anArrayOfCorners[5] = typename BVH_Box<T, 4>::BVH_VecNt (aMax.x(), aMin.y(), aMax.z(), static_cast<T> (1.0));
531 anArrayOfCorners[6] = typename BVH_Box<T, 4>::BVH_VecNt (aMax.x(), aMax.y(), aMin.z(), static_cast<T> (1.0));
532 anArrayOfCorners[7] = typename BVH_Box<T, 4>::BVH_VecNt (aMax.x(), aMax.y(), aMax.z(), static_cast<T> (1.0));
534 theBoundingBox.Clear();
535 for (Standard_Integer anIt = 0; anIt < 8; ++anIt)
537 typename BVH_Box<T, 4>::BVH_VecNt& aCorner = anArrayOfCorners[anIt];
538 aCorner = aTPers * aCorner;
539 aCorner = aCorner / aCorner.w();
540 theBoundingBox.Add (typename BVH_Box<T, 3>::BVH_VecNt (aCorner.x(), aCorner.y(), aCorner.z()));
544 // =======================================================================
545 // function : Compute
546 // purpose : Compute transformation.
547 // =======================================================================
549 NCollection_Mat4<T> Graphic3d_TransformPers::Compute (const Handle(Graphic3d_Camera)& theCamera,
550 const NCollection_Mat4<T>& theProjection,
551 const NCollection_Mat4<T>& theWorldView,
552 const Standard_Integer theViewportWidth,
553 const Standard_Integer theViewportHeight) const
555 if (myMode == Graphic3d_TMF_None)
557 return NCollection_Mat4<T>();
560 NCollection_Mat4<T> aWorldView (theWorldView);
561 NCollection_Mat4<T> anUnviewMat;
562 if (!theWorldView.Inverted (anUnviewMat))
564 return NCollection_Mat4<T>();
567 // compute only world-view matrix difference to avoid floating point instability
568 // caused by projection matrix modifications outside of this algorithm (e.g. by Z-fit)
569 Apply (theCamera, theProjection, aWorldView, theViewportWidth, theViewportHeight);
570 return anUnviewMat * aWorldView;
573 #endif // _Graphic3d_TransformPers_HeaderFile