Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / event / actor-attachments / camera-attachment-impl.h
1 #ifndef __DALI_INTERNAL_CAMERA_ATTACHMENT_H__
2 #define __DALI_INTERNAL_CAMERA_ATTACHMENT_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // INTERNAL INCLUDES
21 #include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
22 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
23 #include <dali/internal/update/common/animatable-property.h>
24 #include <dali/internal/update/common/inherited-property.h>
25 #include <dali/public-api/actors/camera-actor.h>
26 #include <dali/public-api/math/rect.h>
27
28 namespace Dali
29 {
30
31 class Matrix;
32 struct Vector3;
33
34 namespace Internal
35 {
36
37 class Camera;
38
39 namespace SceneGraph
40 {
41 class CameraAttachment;
42 class Node;
43 }
44
45 /**
46  * An attachment for managing the properties of a camera in the scene
47  */
48 class CameraAttachment : public ActorAttachment
49 {
50 public:
51   /**
52    * Create an initialised CameraAttachment.
53    * @param[in] parentNode The node to attach a scene-object to.
54    * @return A handle to a newly allocated Dali resource.
55    */
56   static CameraAttachmentPtr New( const SceneGraph::Node& parentNode );
57
58   /**
59    * @copydoc Dali::Camera::SetType
60    */
61   void SetType(Dali::Camera::Type type);
62
63   /**
64    * @copydoc Dali::Camera::GetType
65    */
66   Dali::Camera::Type GetType() const;
67
68   /**
69    * Set whether the Y Axis is inverted or not.
70    * Default camera inverts the Y axis to provide a +ve Y down LHS coordinate system
71    * Some cameras may require no inversion.
72    * @param[in] invertYAxis True if inverted, false otherwise
73    */
74   void SetInvertYAxis( bool invertYAxis );
75
76   /**
77    * Get the setting of InvertYAxis
78    * @return True if the Y Axis is inverted.
79    */
80   bool GetInvertYAxis() const;
81
82   /**
83    * @copydoc Dali::Camera::SetProjectionMode
84    */
85   void SetProjectionMode(Dali::Camera::ProjectionMode projectionMode);
86
87   /**
88    * @copydoc Dali::Camera::GetProjectionMode
89    */
90   Dali::Camera::ProjectionMode GetProjectionMode() const;
91
92   /**
93    * @copydoc Dali::Camera::SetFieldOfView
94    */
95   void SetFieldOfView(float fieldOfView);
96
97   /**
98    * @copydoc Dali::Camera::GetFieldOfView
99    */
100   float GetFieldOfView() const;
101
102   /**
103    * @copydoc Dali::Camera::SetAspectRatio
104    */
105   void SetAspectRatio(float aspectRatio);
106
107   /**
108    * @copydoc Dali::Camera::GetAspectRatio
109    */
110   float GetAspectRatio() const;
111
112   /**
113    * @copydoc Dali::Camera::SetLeftClippingPlane * Set stereo bias. The frustum offset for a 3D camera
114    * @param[in] stereoBias The frustum offset for the 3D camera
115    */
116   void SetStereoBias(float stereoBias);
117
118   /**
119    * Get stereo bias. The frustum offset for a 3D camera
120    * @return The frustum offset for the 3D camera
121    */
122   float GetStereoBias(float stereoBias) const;
123
124   /**
125    * @copydoc Dali::Camera::SetLeftClippingPlane
126    */
127   void SetLeftClippingPlane(float leftClippingPlane);
128
129   /**
130    * @copydoc Dali::Camera::GetLeftClippingPlane
131    */
132   float GetLeftClippingPlane() const;
133
134   /**
135    * @copydoc Dali::Camera::SetRightClippingPlane
136    */
137   void SetRightClippingPlane(float rightClippingPlane);
138
139   /**
140    * @copydoc Dali::Camera::GetRightClippingPlane
141    */
142   float GetRightClippingPlane() const;
143
144   /**
145    * @copydoc Dali::Camera::SetTopClippingPlane
146    */
147   void SetTopClippingPlane(float topClippingPlane);
148
149   /**
150    * @copydoc Dali::Camera::GetTopClippingPlane
151    */
152   float GetTopClippingPlane() const;
153
154   /**
155    * @copydoc Dali::Camera::SetBottomClippingPlane
156    */
157   void SetBottomClippingPlane(float bottomClippingPlane);
158
159   /**
160    * @copydoc Dali::Camera::GetBottomClippingPlane
161    */
162   float GetBottomClippingPlane() const;
163
164   /**
165    * @copydoc Dali::Camera::SetNearClippingPlane
166    */
167   void SetNearClippingPlane(float nearClippingPlane);
168
169   /**
170    * @copydoc Dali::Camera::GetNearClippingPlane
171    */
172   float GetNearClippingPlane() const;
173
174   /**
175    * @copydoc Dali::Camera::SetFarClippingPlane
176    */
177   void SetFarClippingPlane(float farClippingPlane);
178
179   /**
180    * @copydoc Dali::Camera::GetFarClippingPlane
181    */
182   float GetFarClippingPlane() const;
183
184   /**
185    * Set the (lookAt) target for the camera
186    * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
187    * @param target Position of object we want to look at
188    */
189   void SetTargetPosition(Vector3 target);
190
191   /**
192    * Get the (lookAt) target for the camera
193    * @return the last set target
194    */
195   Vector3 GetTargetPosition();
196
197   /**
198    * Retrieve the view-matrix.
199    * @pre The attachment is on-stage.
200    * @return The view-matrix.
201    */
202   const Matrix& GetViewMatrix() const;
203
204   /**
205    * Retrieve the projection-matrix.
206    * @pre The attachment is on-stage.
207    * @return The projection-matrix.
208    */
209   const Matrix& GetProjectionMatrix() const;
210
211   /**
212    * Returns the inverse view-projection matrix
213    * @pre The attachment is on-stage.
214    * @return The inverse view-projection-matrix.
215    */
216   const Matrix& GetInverseViewProjectionMatrix() const;
217
218   /**
219    * Retrieve the view-matrix property querying interface.
220    * @pre The attachment is on-stage.
221    * @return The view-matrix property querying interface.
222    */
223   const PropertyInputImpl* GetViewMatrixProperty() const;
224
225   /**
226    * Retrieve the projection-matrix property querying interface.
227    * @pre The attachment is on-stage.
228    * @return The projection-matrix property querying interface.
229    */
230   const PropertyInputImpl* GetProjectionMatrixProperty() const;
231
232   /**
233    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
234    */
235   const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
236
237   /**
238    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
239    */
240   const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
241
242
243 private:
244
245   /**
246    * First stage construction of a CameraAttachment.
247    * @param[in] stage Used to send messages to scene-graph.
248    */
249   CameraAttachment( Stage& stage );
250
251   /**
252    * Creates the corresponding scene-graph CameraAttachment.
253    * @return A newly allocated scene object.
254    */
255   static SceneGraph::CameraAttachment* CreateSceneObject();
256
257   /**
258    * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
259    */
260   virtual void OnStageConnection();
261
262   /**
263    * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
264    */
265   virtual void OnStageDisconnection();
266
267 protected:
268
269   /**
270    * A reference counted object may only be deleted by calling Unreference()
271    */
272   virtual ~CameraAttachment();
273
274 private:
275
276   const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
277
278   Dali::Camera::Type mType;
279   Dali::Camera::ProjectionMode mProjectionMode;
280   bool               mInvertYAxis;
281   float              mFieldOfView;
282   float              mAspectRatio;
283   float              mStereoBias;
284   float              mLeftClippingPlane;
285   float              mRightClippingPlane;
286   float              mTopClippingPlane;
287   float              mBottomClippingPlane;
288   float              mNearClippingPlane;
289   float              mFarClippingPlane;
290   Vector3            mTargetPosition;
291 };
292
293 } // namespace Internal
294
295 } // namespace Dali
296
297 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__