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