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