f751596e |
1 | // Created on: 2014-11-24 |
2 | // Created by: Varvara POSKONINA |
3 | // Copyright (c) 2005-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _SelectMgr_FrustumBuilder_HeaderFile |
17 | #define _SelectMgr_FrustumBuilder_HeaderFile |
18 | |
ec357c5c |
19 | #include <Standard_Type.hxx> |
bf3977c9 |
20 | |
f751596e |
21 | #include <Graphic3d_Camera.hxx> |
825aa485 |
22 | #include <Graphic3d_WorldViewProjState.hxx> |
f751596e |
23 | #include <Precision.hxx> |
24 | #include <SelectMgr_VectorTypes.hxx> |
25 | |
26 | //! The purpose of this class is to provide unified interface for building |
27 | //! selecting frustum depending on current camera projection and orientation |
28 | //! matrices, window size and viewport parameters. |
bf3977c9 |
29 | class SelectMgr_FrustumBuilder : public Standard_Transient |
f751596e |
30 | { |
31 | public: |
32 | //! Creates new frustum builder with empty matrices |
1a6726da |
33 | Standard_EXPORT SelectMgr_FrustumBuilder(); |
f751596e |
34 | |
825aa485 |
35 | //! Stores current world view transformation matrix |
1f3913c6 |
36 | Standard_EXPORT void SetWorldViewMatrix (const Graphic3d_Mat4d& theWorldViewMatrix); |
825aa485 |
37 | |
38 | //! @return current world view transformation matrix |
1f3913c6 |
39 | Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const; |
f751596e |
40 | |
41 | //! Stores current projection matrix |
e70625d6 |
42 | Standard_EXPORT void SetProjectionMatrix (const Graphic3d_Mat4d& theProjection, |
43 | const Standard_Boolean theIsZeroToOneDepth); |
825aa485 |
44 | |
45 | //! @return current projection matrix |
1f3913c6 |
46 | Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const; |
825aa485 |
47 | |
48 | //! Stores current world view projection matrix state for the orientation and projection matrices |
1f3913c6 |
49 | Standard_EXPORT void SetWorldViewProjState (const Graphic3d_WorldViewProjState& theState); |
825aa485 |
50 | |
51 | //! @return current world view projection state |
1f3913c6 |
52 | Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const; |
f751596e |
53 | |
54 | //! Stores current window width and height |
1f3913c6 |
55 | Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, |
56 | const Standard_Integer theHeight); |
f751596e |
57 | |
58 | //! Stores current viewport coordinates |
1f3913c6 |
59 | Standard_EXPORT void SetViewport (const Standard_Real theX, |
60 | const Standard_Real theY, |
61 | const Standard_Real theWidth, |
62 | const Standard_Real theHeight); |
f751596e |
63 | |
1f3913c6 |
64 | Standard_EXPORT void InvalidateViewport(); |
f751596e |
65 | |
91d96372 |
66 | Standard_EXPORT void WindowSize (Standard_Integer& theWidth, |
099f3513 |
67 | Standard_Integer& theHeight) const; |
91d96372 |
68 | |
f751596e |
69 | //! Calculates signed distance between plane with equation |
70 | //! theEq and point thePnt |
1f3913c6 |
71 | Standard_EXPORT Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq, |
72 | const SelectMgr_Vec3& thePnt) const; |
f751596e |
73 | |
f751596e |
74 | //! Projects 2d screen point onto view frustum plane: |
75 | //! theZ = 0 - near plane, |
76 | //! theZ = 1 - far plane |
3bf9a45f |
77 | Standard_EXPORT gp_Pnt ProjectPntOnViewPlane (const Standard_Real& theX, |
78 | const Standard_Real& theY, |
79 | const Standard_Real& theZ) const; |
f751596e |
80 | |
92efcf78 |
81 | DEFINE_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder,Standard_Transient) |
bf3977c9 |
82 | |
f751596e |
83 | private: |
84 | |
85 | //! Unprojects point from NDC coords to 3d world space |
3bf9a45f |
86 | gp_Pnt unProject (const gp_Pnt& thePnt) const; |
f751596e |
87 | |
88 | private: |
89 | |
825aa485 |
90 | Graphic3d_Mat4d myWorldView; |
f751596e |
91 | Graphic3d_Mat4d myProjection; |
825aa485 |
92 | Graphic3d_WorldViewProjState myWorldViewProjState; |
f751596e |
93 | Standard_Integer myWidth; |
94 | Standard_Integer myHeight; |
95 | NCollection_Vec4<Standard_Real> myViewport; |
96 | Standard_Boolean myIsViewportSet; |
e70625d6 |
97 | Standard_Boolean myIsZeroToOneDepth; |
f751596e |
98 | }; |
99 | |
bf3977c9 |
100 | DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient) |
101 | |
f751596e |
102 | #endif // _SelectMgr_FrustumBuilder_HeaderFile |