[SRUK] Initial copy from Tizen 2.2 version
[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
114    */
115   void SetLeftClippingPlane(float leftClippingPlane);
116
117   /**
118    * @copydoc Dali::Camera::GetLeftClippingPlane
119    */
120   float GetLeftClippingPlane() const;
121
122   /**
123    * @copydoc Dali::Camera::SetRightClippingPlane
124    */
125   void SetRightClippingPlane(float rightClippingPlane);
126
127   /**
128    * @copydoc Dali::Camera::GetRightClippingPlane
129    */
130   float GetRightClippingPlane() const;
131
132   /**
133    * @copydoc Dali::Camera::SetTopClippingPlane
134    */
135   void SetTopClippingPlane(float topClippingPlane);
136
137   /**
138    * @copydoc Dali::Camera::GetTopClippingPlane
139    */
140   float GetTopClippingPlane() const;
141
142   /**
143    * @copydoc Dali::Camera::SetBottomClippingPlane
144    */
145   void SetBottomClippingPlane(float bottomClippingPlane);
146
147   /**
148    * @copydoc Dali::Camera::GetBottomClippingPlane
149    */
150   float GetBottomClippingPlane() const;
151
152   /**
153    * @copydoc Dali::Camera::SetNearClippingPlane
154    */
155   void SetNearClippingPlane(float nearClippingPlane);
156
157   /**
158    * @copydoc Dali::Camera::GetNearClippingPlane
159    */
160   float GetNearClippingPlane() const;
161
162   /**
163    * @copydoc Dali::Camera::SetFarClippingPlane
164    */
165   void SetFarClippingPlane(float farClippingPlane);
166
167   /**
168    * @copydoc Dali::Camera::GetFarClippingPlane
169    */
170   float GetFarClippingPlane() const;
171
172   /**
173    * Set the (lookAt) target for the camera
174    * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
175    * @param target Position of object we want to look at
176    */
177   void SetTargetPosition(Vector3 target);
178
179   /**
180    * Get the (lookAt) target for the camera
181    * @return the last set target
182    */
183   Vector3 GetTargetPosition();
184
185   /**
186    * Retrieve the view-matrix.
187    * @pre The attachment is on-stage.
188    * @return The view-matrix.
189    */
190   const Matrix& GetViewMatrix() const;
191
192   /**
193    * Retrieve the projection-matrix.
194    * @pre The attachment is on-stage.
195    * @return The projection-matrix.
196    */
197   const Matrix& GetProjectionMatrix() const;
198
199   /**
200    * Returns the inverse view-projection matrix
201    * @pre The attachment is on-stage.
202    * @return The inverse view-projection-matrix.
203    */
204   const Matrix& GetInverseViewProjectionMatrix() const;
205
206   /**
207    * Retrieve the view-matrix property querying interface.
208    * @pre The attachment is on-stage.
209    * @return The view-matrix property querying interface.
210    */
211   const PropertyInputImpl* GetViewMatrixProperty() const;
212
213   /**
214    * Retrieve the projection-matrix property querying interface.
215    * @pre The attachment is on-stage.
216    * @return The projection-matrix property querying interface.
217    */
218   const PropertyInputImpl* GetProjectionMatrixProperty() const;
219
220   /**
221    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
222    */
223   const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
224
225   /**
226    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
227    */
228   const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
229
230
231 private:
232
233   /**
234    * First stage construction of a CameraAttachment.
235    * @param[in] stage Used to send messages to scene-graph.
236    */
237   CameraAttachment( Stage& stage );
238
239   /**
240    * Creates the corresponding scene-graph CameraAttachment.
241    * @return A newly allocated scene object.
242    */
243   static SceneGraph::CameraAttachment* CreateSceneObject();
244
245   /**
246    * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
247    */
248   virtual void OnStageConnection();
249
250   /**
251    * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
252    */
253   virtual void OnStageDisconnection();
254
255 protected:
256
257   /**
258    * A reference counted object may only be deleted by calling Unreference()
259    */
260   virtual ~CameraAttachment();
261
262 private:
263
264   const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
265
266   Dali::Camera::Type mType;
267   Dali::Camera::ProjectionMode mProjectionMode;
268   bool               mInvertYAxis;
269   float              mFieldOfView;
270   float              mAspectRatio;
271   float              mLeftClippingPlane;
272   float              mRightClippingPlane;
273   float              mTopClippingPlane;
274   float              mBottomClippingPlane;
275   float              mNearClippingPlane;
276   float              mFarClippingPlane;
277   Vector3            mTargetPosition;
278 };
279
280 } // namespace Internal
281
282 } // namespace Dali
283
284 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__