Removal of unnecessary Actor-attachment classes, part I - event thread
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.h
1 #ifndef __DALI_INTERNAL_CAMERA_ACTOR_H__
2 #define __DALI_INTERNAL_CAMERA_ACTOR_H__
3
4 /*
5  * Copyright (c) 2016 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 INCLUES
22 #include <dali/public-api/actors/camera-actor.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/internal/event/actors/actor-declarations.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace SceneGraph
33 {
34 class CameraAttachment;
35 }
36
37 /**
38  * An actor with CameraAttachment.
39  */
40 class CameraActor : public Actor
41 {
42 public:
43
44   /**
45    * Create an initialised camera actor.
46    *
47    * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
48    *
49    * @param[in] size The canvas size.
50    *
51    * @return A smart-pointer to a newly allocated camera actor.
52    */
53   static CameraActorPtr New( const Size& size );
54
55   /**
56    * @copydoc Dali::CameraActor::SetTargetPosition
57    */
58   void SetTarget( const Vector3& targetPosition );
59
60   /**
61    * @copydoc Dali::CameraActor::GetTargetPosition
62    */
63   Vector3 GetTarget() const;
64
65   /**
66    * @copydoc Dali::CameraActor::SetType
67    */
68   void SetType( Dali::Camera::Type type );
69
70   /**
71    * @copydoc Dali::CameraActor::GetType
72    */
73   Dali::Camera::Type GetType() const;
74
75   /**
76    * @copydoc Dali::CameraActor::SetProjectionMode
77    */
78   void SetProjectionMode( Dali::Camera::ProjectionMode mode );
79
80   /**
81    * @copydoc Dali::CameraActor::GetProjectionMode
82    */
83   Dali::Camera::ProjectionMode GetProjectionMode() const;
84
85   /**
86    * @copydoc Dali::CameraActor::SetFieldOfView
87    */
88   void SetFieldOfView( float fieldOfView );
89
90   /**
91    * @copydoc Dali::CameraActor::GetFieldOfView
92    */
93   float GetFieldOfView() const;
94
95   /**
96    * @copydoc Dali::CameraActor::SetAspectRatio
97    */
98   void SetAspectRatio( float aspectRatio );
99
100   /**
101    * @copydoc Dali::CameraActor::GetAspectRatio
102    */
103   float GetAspectRatio() const;
104
105   /**
106    * @copydoc Dali::CameraActor::SetNearClippingPlane
107    */
108   void SetNearClippingPlane( float nearClippingPlane );
109
110   /**
111    * @copydoc Dali::CameraActor::GetNearClippingPlane
112    */
113   float GetNearClippingPlane() const;
114
115   /**
116    * @copydoc Dali::CameraActor::SetFarClippingPlane
117    */
118   void SetFarClippingPlane( float farClippingPlane );
119
120   /**
121    * @copydoc Dali::CameraActor::GetFarClippingPlane
122    */
123   float GetFarClippingPlane() const;
124
125   /**
126    * @param leftClippingPlane to use
127    */
128   void SetLeftClippingPlane( float leftClippingPlane );
129
130   /**
131    * @param rightClippingPlane to use
132    */
133   void SetRightClippingPlane( float rightClippingPlane );
134
135   /**
136    * @param topClippingPlane to use
137    */
138   void SetTopClippingPlane( float topClippingPlane );
139
140   /**
141    * @param bottomClippingPlane to use
142    */
143   void SetBottomClippingPlane( float bottomClippingPlane );
144
145   /**
146    * @copydoc Dali::CameraActor::SetInvertYAxis
147    */
148   void SetInvertYAxis( bool invertYAxis );
149
150   /**
151    * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
152    */
153   bool GetInvertYAxis() const;
154
155   /**
156    * @copydoc Dali::CameraActor::SetPerspectiveProjection()
157    * @param[in] stereoBias The frustum horizontal and vertical offset for stereoscopic cameras
158    */
159   void SetPerspectiveProjection( const Size& size, const Vector2& stereoBias = Vector2::ZERO );
160
161   /**
162    * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
163    */
164   void SetOrthographicProjection( const Vector2& size );
165
166   /**
167    * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
168    */
169   void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
170
171   /**
172    * Build a picking ray with this camera and given screen coordinates
173    * @param [in] screenCoordinates the ray passed through
174    * @param [in] viewport to use
175    * @param [out] rayOrigin for the picking ray
176    * @param [out] rayDirection for the picking ray
177    * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
178    */
179   bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
180
181   /**
182    * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
183    * @return The view-matrix.
184    */
185   const Matrix& GetViewMatrix() const;
186
187   /**
188    * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
189    * @return The projection-matrix.
190    */
191   const Matrix& GetProjectionMatrix() const;
192
193 public: // properties
194
195   /**
196    * copydoc Dali::Internal::Object
197    */
198   virtual unsigned int GetDefaultPropertyCount() const;
199
200   /**
201    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
202    */
203   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
204
205   /**
206    * copydoc Dali::Internal::Object
207    */
208   virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
209
210   /**
211    * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
212    */
213   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
214
215   /**
216    * copydoc Dali::Internal::Object
217    */
218   virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
219
220   /**
221    * copydoc Dali::Internal::Object
222    */
223   virtual const char* GetDefaultPropertyName( Property::Index index ) const;
224
225   /**
226    * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
227    */
228   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
229
230   /**
231    * copydoc Dali::Internal::Object
232    */
233   virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
234
235   /**
236    * copydoc Dali::Internal::Object
237    */
238   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
239
240   /**
241    * copydoc Dali::Internal::Object
242    */
243   virtual bool IsDefaultPropertyWritable( Property::Index index ) const ;
244
245   /**
246    * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
247    */
248   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
249
250   /**
251    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
252    */
253   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
254
255 private:
256
257   /**
258    * Constructor; see also CameraActor::New()
259    */
260   CameraActor();
261
262   /**
263    * A reference counted object may only be deleted by calling Unreference()
264    */
265   virtual ~CameraActor();
266
267 private: // Data
268
269   const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
270
271   Vector3            mTarget;
272   Dali::Camera::Type mType;
273   Dali::Camera::ProjectionMode mProjectionMode;
274   float              mFieldOfView;
275   float              mAspectRatio;
276   float              mNearClippingPlane;
277   float              mFarClippingPlane;
278   float              mLeftClippingPlane;
279   float              mRightClippingPlane;
280   float              mTopClippingPlane;
281   float              mBottomClippingPlane;
282   bool               mInvertYAxis;
283
284 };
285
286 } // namespace Internal
287
288 // Helpers for public-api forwarding methods
289
290 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
291 {
292   DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
293
294   BaseObject& handle = camera.GetBaseObject();
295
296   return static_cast<Internal::CameraActor&>(handle);
297 }
298
299 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
300 {
301   DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
302
303   const BaseObject& handle = camera.GetBaseObject();
304
305   return static_cast<const Internal::CameraActor&>(handle);
306 }
307
308 } // namespace Dali
309
310 #endif // __DALI_INTERNAL_CAMERA_ACTOR_H__