Ocean
PerspectiveView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_RENDERING_PERSPECTIVE_VIEW_H
9 #define META_OCEAN_RENDERING_PERSPECTIVE_VIEW_H
10 
12 #include "ocean/rendering/View.h"
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Rendering
20 {
21 
22 // Forward declaration
23 class PerspectiveView;
24 
25 /**
26  * Definition of a smart object reference holding a perspective view node.
27  * @see SmartObjectRef, PerspectiveView.
28  * @ingroup rendering
29  */
31 
32 /**
33  * This class is the base class for all perspective views.
34  * @ingroup rendering
35  */
36 class OCEAN_RENDERING_EXPORT PerspectiveView : virtual public View
37 {
38  public:
39 
40  /**
41  * Returns the horizontal field of view in radian.
42  * @return Horizontal field of view in radian, with range (0, PI)
43  * @exception NotSupportedException Is thrown if this function is not supported
44  */
45  virtual Scalar fovX() const;
46 
47  /**
48  * Sets the horizontal field of view in radian.
49  * @param fovx Horizontal field of view in radian, with range (0, PI)
50  * @return True, if the value is valid and could be set
51  * @exception NotSupportedException Is thrown if this function is not supported
52  */
53  virtual bool setFovX(const Scalar fovx);
54 
55  /**
56  * Calculates the ideal field of view matching to the current background.
57  * If the background holds a medium and no valid frame has been provided by this medium jet this function will return the view's field of view.
58  * @param validCamera Optional resulting state determining whether the background had a valid camera object
59  * @return Resulting field of view in radian
60  */
61  virtual Scalar idealFovX(bool* validCamera = nullptr) const;
62 
63  /**
64  * Updates the view's field of view to the ideal field of view matching with the current background.
65  */
66  virtual void updateToIdealFovX();
67 
68  /**
69  * Sets the projection matrix explicitly.
70  * @param clip_T_view The projection matrix to set
71  * @exception NotSupportedException Is thrown if this function is not supported
72  */
73  virtual void setProjectionMatrix(const SquareMatrix4& clip_T_view);
74 
75  /**
76  * Fits the camera to a given node.
77  * @see View::fitCamera().
78  */
79  void fitCamera(const NodeRef& node = NodeRef()) override;
80 
81  /**
82  * Returns the type of this object.
83  * @see Object::type().
84  */
85  ObjectType type() const override;
86 
87  protected:
88 
89  /**
90  * Creates a new perspective view object.
91  */
93 
94  /**
95  * Destructs a perspective view object.
96  */
97  ~PerspectiveView() override;
98 };
99 
100 }
101 
102 }
103 
104 #endif // META_OCEAN_RENDERING_PERSPECTIVE_VIEW_H
ObjectType
Definition of different object type.
Definition: Object.h:63
This class is the base class for all perspective views.
Definition: PerspectiveView.h:37
ObjectType type() const override
Returns the type of this object.
virtual Scalar fovX() const
Returns the horizontal field of view in radian.
PerspectiveView()
Creates a new perspective view object.
virtual void updateToIdealFovX()
Updates the view's field of view to the ideal field of view matching with the current background.
virtual bool setFovX(const Scalar fovx)
Sets the horizontal field of view in radian.
~PerspectiveView() override
Destructs a perspective view object.
virtual void setProjectionMatrix(const SquareMatrix4 &clip_T_view)
Sets the projection matrix explicitly.
void fitCamera(const NodeRef &node=NodeRef()) override
Fits the camera to a given node.
virtual Scalar idealFovX(bool *validCamera=nullptr) const
Calculates the ideal field of view matching to the current background.
This class implements a smart rendering object reference.
Definition: rendering/ObjectRef.h:34
This class is the base class for all rendering views.
Definition: View.h:46
float Scalar
Definition of a scalar type.
Definition: Math.h:128
SmartObjectRef< Node > NodeRef
Definition of a smart object reference holding a node.
Definition: rendering/Node.h:27
SmartObjectRef< PerspectiveView > PerspectiveViewRef
Definition of a smart object reference holding a perspective view node.
Definition: PerspectiveView.h:23
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15