[Tizen] Revert "Remove TypeRegistration from deprecated Image classes"
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/actors/camera-actor-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <cmath>
23 #include <cstring> // for strcmp
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/stage.h>
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/integration-api/debug.h>
29 #include <dali/internal/event/common/property-helper.h>
30 #include <dali/internal/event/common/stage-impl.h>
31 #include <dali/internal/event/render-tasks/render-task-impl.h>
32 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
33 #include <dali/internal/event/common/projection.h>
34 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
35
36 namespace Dali
37 {
38
39 namespace Internal
40 {
41
42 namespace
43 {
44
45 // Properties
46
47 /**
48  * We want to discourage the use of property strings (minimize string comparisons),
49  * particularly for the default properties.
50  *              Name                     Type   writable animatable constraint-input  enum for index-checking
51  */
52 DALI_PROPERTY_TABLE_BEGIN
53 DALI_PROPERTY( "type",                   STRING,   true,    false,   true,   Dali::CameraActor::Property::TYPE                  )
54 DALI_PROPERTY( "projectionMode",         STRING,   true,    false,   true,   Dali::CameraActor::Property::PROJECTION_MODE       )
55 DALI_PROPERTY( "fieldOfView",            FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FIELD_OF_VIEW         )
56 DALI_PROPERTY( "aspectRatio",            FLOAT,    true,    false,   true,   Dali::CameraActor::Property::ASPECT_RATIO          )
57 DALI_PROPERTY( "nearPlaneDistance",      FLOAT,    true,    false,   true,   Dali::CameraActor::Property::NEAR_PLANE_DISTANCE   )
58 DALI_PROPERTY( "farPlaneDistance",       FLOAT,    true,    false,   true,   Dali::CameraActor::Property::FAR_PLANE_DISTANCE    )
59 DALI_PROPERTY( "leftPlaneDistance",      FLOAT,    true,    false,   true,   Dali::CameraActor::Property::LEFT_PLANE_DISTANCE   )
60 DALI_PROPERTY( "rightPlaneDistance",     FLOAT,    true,    false,   true,   Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE  )
61 DALI_PROPERTY( "topPlaneDistance",       FLOAT,    true,    false,   true,   Dali::CameraActor::Property::TOP_PLANE_DISTANCE    )
62 DALI_PROPERTY( "bottomPlaneDistance",    FLOAT,    true,    false,   true,   Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE )
63 DALI_PROPERTY( "targetPosition",         VECTOR3,  true,    false,   true,   Dali::CameraActor::Property::TARGET_POSITION       )
64 DALI_PROPERTY( "projectionMatrix",       MATRIX,   false,   false,   true,   Dali::CameraActor::Property::PROJECTION_MATRIX     )
65 DALI_PROPERTY( "viewMatrix",             MATRIX,   false,   false,   true,   Dali::CameraActor::Property::VIEW_MATRIX           )
66 DALI_PROPERTY( "invertYAxis",            BOOLEAN,  true,    false,   true,   Dali::CameraActor::Property::INVERT_Y_AXIS         )
67 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
68
69 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
70 void CalculateClippingAndZ( float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ )
71 {
72   nearClippingPlane = std::max( width, height );
73   farClippingPlane = nearClippingPlane + static_cast<float>( 0xFFFF >> 4 );
74   cameraZ = 2.0f * nearClippingPlane;
75 }
76
77 BaseHandle Create()
78 {
79   return Dali::CameraActor::New();
80 }
81
82 TypeRegistration mType( typeid( Dali::CameraActor ), typeid( Dali::Actor ), Create, CameraDefaultProperties );
83
84 /**
85  * Builds the picking ray in the world reference system from an orthographic camera
86  * The ray origin is the screen coordinate in the near plane translated to a parallel
87  * plane at the camera origin. The ray direction is the direction the camera is facing
88  * (i.e. Z=-1 in view space).
89  */
90 void BuildOrthoPickingRay( const Matrix& viewMatrix,
91                            const Matrix& projectionMatrix,
92                            const Viewport& viewport,
93                            float screenX,
94                            float screenY,
95                            Vector4& rayOrigin,
96                            Vector4& rayDir,
97                            float nearPlaneDistance )
98 {
99   //          inv( modelMatrix )          inv( viewMatrix )    inv( projectionMatrix )           normalize
100   //          <-----------------         <-----------------         <--------------           <-------------
101   //  Local                      World                      Camera                 Normalized                 Screen
102   // reference                  reference                  reference                  clip                  coordinates
103   //  system                     system                     system                 coordinates
104   //          ----------------->         ----------------->         -------------->           ------------->
105   //             modelMatrix                 viewMatrix             projectionMatrix             viewport
106
107   // Transforms the touch point from the screen reference system to the world reference system.
108   Matrix invViewProjection( false ); // Don't initialize.
109   Matrix::Multiply( invViewProjection, viewMatrix, projectionMatrix );
110   if( !invViewProjection.Invert() )
111   {
112     DALI_ASSERT_DEBUG( false );
113   }
114
115   Vector4 near( screenX - static_cast<float>( viewport.x ),
116                 static_cast<float>( viewport.height ) - (screenY - static_cast<float>( viewport.y ) ),
117                 0.f, 1.f );
118   if( !Unproject( near, invViewProjection, static_cast<float>( viewport.width ), static_cast<float>( viewport.height ), rayOrigin ) )
119   {
120     DALI_ASSERT_DEBUG( false );
121   }
122
123   Matrix invView = viewMatrix;
124   if( !invView.Invert() )
125   {
126     DALI_ASSERT_DEBUG( false );
127   }
128
129   Vector4 cameraOrigin = invView * Vector4( 0.f, 0.f, 0.f, 1.f );
130   Vector4 nearPlaneOrigin = invView * Vector4( 0.0f, 0.0f, -nearPlaneDistance, 1.0f);
131
132   // Vector pointing from the camera to the near plane
133   rayDir = cameraOrigin - nearPlaneOrigin;
134   rayOrigin -= rayDir;
135   rayDir.Normalize();
136   rayDir.w = 1.0f;
137 }
138
139 } // namespace
140
141 CameraActorPtr CameraActor::New( const Size& size )
142 {
143   CameraActorPtr actor( new CameraActor( *CreateNode() ) );
144
145   // Second-phase construction
146   actor->Initialize();
147
148   actor->SetName( "DefaultCamera" );
149   actor->SetPerspectiveProjection( size );
150
151   // By default Actors face in the positive Z direction in world space
152   // CameraActors should face in the negative Z direction, towards the other actors
153   actor->SetOrientation( Quaternion( Dali::ANGLE_180, Vector3::YAXIS ) );
154
155   return actor;
156 }
157
158 CameraActor::CameraActor( const SceneGraph::Node& node )
159 : Actor( Actor::BASIC, node ),
160   mSceneObject( NULL ),
161   mTarget( SceneGraph::Camera::DEFAULT_TARGET_POSITION ),
162   mType( SceneGraph::Camera::DEFAULT_TYPE ),
163   mProjectionMode( SceneGraph::Camera::DEFAULT_MODE ),
164   mFieldOfView( SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW ),
165   mAspectRatio( SceneGraph::Camera::DEFAULT_ASPECT_RATIO ),
166   mNearClippingPlane( SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE ),
167   mFarClippingPlane( SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE ),
168   mLeftClippingPlane( SceneGraph::Camera::DEFAULT_LEFT_CLIPPING_PLANE ),
169   mRightClippingPlane( SceneGraph::Camera::DEFAULT_RIGHT_CLIPPING_PLANE ),
170   mTopClippingPlane( SceneGraph::Camera::DEFAULT_TOP_CLIPPING_PLANE ),
171   mBottomClippingPlane( SceneGraph::Camera::DEFAULT_BOTTOM_CLIPPING_PLANE ),
172   mInvertYAxis( SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS )
173 {
174 }
175
176 CameraActor::~CameraActor()
177 {
178   if( EventThreadServices::IsCoreRunning() )
179   {
180     // Create scene-object and transfer ownership through message
181     RemoveCameraMessage( GetEventThreadServices().GetUpdateManager(), mSceneObject );
182   }
183 }
184
185 void CameraActor::OnInitialize()
186 {
187   // Create scene-object and keep raw pointer for message passing.
188   SceneGraph::Camera* sceneGraphCamera = SceneGraph::Camera::New();
189
190   // Store a pointer to this camera node inside the scene-graph camera.
191   sceneGraphCamera->SetNode( &mNode );
192
193   mSceneObject = sceneGraphCamera;
194   OwnerPointer< SceneGraph::Camera > sceneGraphCameraOwner( sceneGraphCamera );
195
196   // Send message to inform update of this camera (and move ownership).
197   AddCameraMessage( GetEventThreadServices().GetUpdateManager(), sceneGraphCameraOwner );
198 }
199
200 void CameraActor::SetTarget( const Vector3& target )
201 {
202   if( target != mTarget ) // using range epsilon
203   {
204     mTarget = target;
205
206     SetTargetPositionMessage( GetEventThreadServices(),  *mSceneObject, mTarget );
207   }
208 }
209
210 Vector3 CameraActor::GetTarget() const
211 {
212   return mTarget;
213 }
214
215 void CameraActor::SetType( Dali::Camera::Type type )
216 {
217   if( type != mType )
218   {
219     mType = type;
220
221     // sceneObject is being used in a separate thread; queue a message to set
222     SetTypeMessage( GetEventThreadServices(), *mSceneObject, mType );
223   }
224 }
225
226 Dali::Camera::Type CameraActor::GetType() const
227 {
228   return mType;
229 }
230
231 void CameraActor::SetProjectionMode( Dali::Camera::ProjectionMode mode )
232 {
233   if( mode != mProjectionMode )
234   {
235     mProjectionMode = mode;
236
237     // sceneObject is being used in a separate thread; queue a message to set
238     SetProjectionModeMessage( GetEventThreadServices(), *mSceneObject, mProjectionMode );
239   }
240 }
241
242 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
243 {
244   return mProjectionMode;
245 }
246
247 void CameraActor::SetFieldOfView( float fieldOfView )
248 {
249   if( ! Equals( fieldOfView, mFieldOfView ) )
250   {
251     mFieldOfView = fieldOfView;
252
253     // sceneObject is being used in a separate thread; queue a message to set
254     SetFieldOfViewMessage( GetEventThreadServices(), *mSceneObject, mFieldOfView );
255   }
256 }
257
258 float CameraActor::GetFieldOfView() const
259 {
260   return mFieldOfView;
261 }
262
263 void CameraActor::SetAspectRatio( float aspectRatio )
264 {
265   if( ! Equals( aspectRatio, mAspectRatio ) )
266   {
267     mAspectRatio = aspectRatio;
268
269     // sceneObject is being used in a separate thread; queue a message to set
270     SetAspectRatioMessage( GetEventThreadServices(), *mSceneObject, mAspectRatio );
271   }
272 }
273
274 float CameraActor::GetAspectRatio() const
275 {
276   return mAspectRatio;
277 }
278
279 void CameraActor::SetNearClippingPlane( float nearClippingPlane )
280 {
281   if( ! Equals( nearClippingPlane, mNearClippingPlane ) )
282   {
283     mNearClippingPlane = nearClippingPlane;
284
285     // sceneObject is being used in a separate thread; queue a message to set
286     SetNearClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mNearClippingPlane );
287   }
288 }
289
290 float CameraActor::GetNearClippingPlane() const
291 {
292   return mNearClippingPlane;
293 }
294
295 void CameraActor::SetFarClippingPlane( float farClippingPlane )
296 {
297   if( ! Equals( farClippingPlane, mFarClippingPlane ) )
298   {
299     mFarClippingPlane = farClippingPlane;
300
301     // sceneObject is being used in a separate thread; queue a message to set
302     SetFarClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mFarClippingPlane );
303   }
304 }
305
306 float CameraActor::GetFarClippingPlane() const
307 {
308   return mFarClippingPlane;
309 }
310
311 void CameraActor::SetLeftClippingPlane( float leftClippingPlane )
312 {
313   if( ! Equals( leftClippingPlane, mLeftClippingPlane ) )
314   {
315     mLeftClippingPlane = leftClippingPlane;
316
317     // sceneObject is being used in a separate thread; queue a message to set
318     SetLeftClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mLeftClippingPlane );
319   }
320 }
321
322 void CameraActor::SetRightClippingPlane( float rightClippingPlane )
323 {
324   if( ! Equals( rightClippingPlane, mRightClippingPlane ) )
325   {
326     mRightClippingPlane = rightClippingPlane;
327
328     // sceneObject is being used in a separate thread; queue a message to set
329     SetRightClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mRightClippingPlane );
330   }
331 }
332
333 void CameraActor::SetTopClippingPlane( float topClippingPlane )
334 {
335   if( ! Equals( topClippingPlane, mTopClippingPlane ) )
336   {
337     mTopClippingPlane = topClippingPlane;
338
339     // sceneObject is being used in a separate thread; queue a message to set
340     SetTopClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mTopClippingPlane );
341   }
342 }
343
344 void CameraActor::SetBottomClippingPlane( float bottomClippingPlane )
345 {
346   if( ! Equals( bottomClippingPlane, mBottomClippingPlane ) )
347   {
348     mBottomClippingPlane = bottomClippingPlane;
349
350     // sceneObject is being used in a separate thread; queue a message to set
351     SetBottomClippingPlaneMessage( GetEventThreadServices(), *mSceneObject, mBottomClippingPlane );
352   }
353 }
354
355 void CameraActor::SetInvertYAxis(bool invertYAxis)
356 {
357   if( invertYAxis != mInvertYAxis )
358   {
359     mInvertYAxis = invertYAxis;
360
361     // sceneObject is being used in a separate thread; queue a message to set
362     SetInvertYAxisMessage( GetEventThreadServices(), *mSceneObject, mInvertYAxis );
363   }
364 }
365
366 bool CameraActor::GetInvertYAxis() const
367 {
368   return mInvertYAxis;
369 }
370
371 void CameraActor::SetPerspectiveProjection( const Size& size, const Vector2& stereoBias /* = Vector2::ZERO */ )
372 {
373   float width = size.width;
374   float height = size.height;
375
376   if( Size::ZERO == size )
377   {
378     StagePtr stage = Stage::GetCurrent();
379     if( stage )
380     {
381       const Size& stageSize = stage->GetSize();
382
383       width = stageSize.width;
384       height = stageSize.height;
385     }
386   }
387
388   if( ( width < Math::MACHINE_EPSILON_1000 ) || ( height < Math::MACHINE_EPSILON_1000 ) )
389   {
390     // On the stage initialization this method is called but the size has not been set.
391     // There is no point to set any value if width or height is zero.
392     return;
393   }
394
395   float nearClippingPlane;
396   float farClippingPlane;
397   float cameraZ;
398   CalculateClippingAndZ( width, height, nearClippingPlane, farClippingPlane, cameraZ );
399
400   // calculate the position of the camera to have the desired aspect ratio
401   const float fieldOfView = 2.0f * std::atan( height * 0.5f / cameraZ );
402
403   // unless it is too small, we want at least as much space to the back as we have torwards the front
404   const float minClippingFarPlane = 2.f * nearClippingPlane;
405   if ( farClippingPlane < minClippingFarPlane )
406   {
407     farClippingPlane = minClippingFarPlane;
408   }
409
410   const float aspectRatio = width / height;
411
412   // sceneObject is being used in a separate thread; queue a message to set
413   SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
414   SetFieldOfView( fieldOfView );
415   SetNearClippingPlane( nearClippingPlane );
416   SetFarClippingPlane( farClippingPlane );
417   SetAspectRatio( aspectRatio );
418   SetZ( cameraZ );
419 }
420
421
422 void CameraActor::SetOrthographicProjection( const Vector2& size )
423 {
424   // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
425   float nearClippingPlane;
426   float farClippingPlane;
427   float cameraZ;
428   CalculateClippingAndZ( size.width, size.height, nearClippingPlane, farClippingPlane, cameraZ );
429   SetOrthographicProjection( -size.x*0.5f, size.x*0.5f, size.y*0.5f, -size.y*0.5f,
430                              nearClippingPlane, farClippingPlane );
431   SetZ( cameraZ );
432 }
433
434 void CameraActor::SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far )
435 {
436   SetLeftClippingPlane( left );
437   SetRightClippingPlane( right );
438   SetTopClippingPlane( top );
439   SetBottomClippingPlane( bottom );
440   SetNearClippingPlane( near );
441   SetFarClippingPlane( far );
442   SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
443 }
444
445 bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
446                                    const Viewport& viewport,
447                                    Vector4& rayOrigin,
448                                    Vector4& rayDirection )
449 {
450   bool success = true;
451   if( mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION )
452   {
453     // Build a picking ray in the world reference system.
454     // ray starts from the camera world position
455     rayOrigin = mNode.GetWorldMatrix(0).GetTranslation();
456     rayOrigin.w = 1.0f;
457
458     // Transform the touch point from the screen coordinate system to the world coordinates system.
459     Vector4 near( screenCoordinates.x - static_cast<float>(viewport.x),
460                   static_cast<float>( viewport.height ) - (screenCoordinates.y - static_cast<float>( viewport.y ) ),
461                   0.f, 1.f );
462     const Matrix& inverseViewProjection = mSceneObject->GetInverseViewProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
463     success = Unproject( near, inverseViewProjection, static_cast<float>( viewport.width ), static_cast<float>( viewport.height ), near );
464
465     // Compute the ray's director vector.
466     rayDirection.x = near.x - rayOrigin.x;
467     rayDirection.y = near.y - rayOrigin.y;
468     rayDirection.z = near.z - rayOrigin.z;
469     rayDirection.Normalize();
470     rayDirection.w = 1.f;
471   }
472   else
473   {
474     float nearPlaneDistance = GetNearClippingPlane();
475     BuildOrthoPickingRay( GetViewMatrix(),
476                           GetProjectionMatrix(),
477                           viewport, screenCoordinates.x,
478                           screenCoordinates.y,
479                           rayOrigin,
480                           rayDirection,
481                           nearPlaneDistance );
482   }
483
484   return success;
485 }
486
487 const Matrix& CameraActor::GetViewMatrix() const
488 {
489   if ( OnStage() )
490   {
491     return mSceneObject->GetViewMatrix( GetEventThreadServices().GetEventBufferIndex() );
492   }
493   else
494   {
495     return Matrix::IDENTITY;
496   }
497 }
498
499 const Matrix& CameraActor::GetProjectionMatrix() const
500 {
501   if ( OnStage() )
502   {
503     return mSceneObject->GetProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
504   }
505   else
506   {
507     return Matrix::IDENTITY;
508   }
509 }
510 const SceneGraph::Camera* CameraActor::GetCamera() const
511 {
512   return mSceneObject;
513 }
514
515 void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
516 {
517   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
518   {
519     Actor::SetDefaultProperty(index, propertyValue);
520   }
521   else
522   {
523     switch(index)
524     {
525       case Dali::CameraActor::Property::TYPE:
526       {
527         std::string s( propertyValue.Get<std::string>() );
528         if(s == "LOOK_AT_TARGET")
529         {
530           SetType( Dali::Camera::LOOK_AT_TARGET );
531         }
532         else if(s == "FREE_LOOK")
533         {
534           SetType( Dali::Camera::FREE_LOOK );
535         }
536         break;
537       }
538       case Dali::CameraActor::Property::PROJECTION_MODE:
539       {
540         std::string s( propertyValue.Get<std::string>() );
541         if( s == "PERSPECTIVE_PROJECTION" )
542         {
543           SetProjectionMode( Dali::Camera::PERSPECTIVE_PROJECTION );
544         }
545         else if( s == "ORTHOGRAPHIC_PROJECTION" )
546         {
547           SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
548         }
549         break;
550       }
551       case Dali::CameraActor::Property::FIELD_OF_VIEW:
552       {
553         SetFieldOfView( propertyValue.Get<float>() ); // set to 0 in case property is not float
554         break;
555       }
556       case Dali::CameraActor::Property::ASPECT_RATIO:
557       {
558         SetAspectRatio( propertyValue.Get<float>() ); // set to 0 in case property is not float
559         break;
560       }
561       case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
562       {
563         SetNearClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
564         break;
565       }
566       case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
567       {
568         SetFarClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
569         break;
570       }
571       case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
572       {
573         SetLeftClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
574         break;
575       }
576       case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
577       {
578         SetRightClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
579         break;
580       }
581       case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
582       {
583         SetTopClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
584         break;
585       }
586       case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
587       {
588         SetBottomClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
589         break;
590       }
591       case Dali::CameraActor::Property::TARGET_POSITION:
592       {
593         SetTarget( propertyValue.Get<Vector3>() ); // set to 0 in case property is not Vector3
594         break;
595       }
596       case Dali::CameraActor::Property::PROJECTION_MATRIX:
597       {
598         DALI_LOG_WARNING( "projection-matrix is read-only\n" );
599         break;
600       }
601       case Dali::CameraActor::Property::VIEW_MATRIX:
602       {
603         DALI_LOG_WARNING( "view-matrix is read-only\n" );
604         break;
605       }
606       case Dali::CameraActor::Property::INVERT_Y_AXIS:
607       {
608         SetInvertYAxis( propertyValue.Get<bool>() ); // set to false in case property is not bool
609         break;
610       }
611       default:
612       {
613         DALI_LOG_WARNING( "Unknown property (%d)\n", index );
614         break;
615       }
616     } // switch(index)
617
618   } // else
619 }
620
621 Property::Value CameraActor::GetDefaultProperty( Property::Index index ) const
622 {
623   Property::Value ret;
624   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
625   {
626     ret = Actor::GetDefaultProperty(index);
627   }
628   else
629   {
630     switch(index)
631     {
632       case Dali::CameraActor::Property::TYPE:
633       {
634         if( Dali::Camera::LOOK_AT_TARGET == mType )
635         {
636           ret = "LOOK_AT_TARGET";
637         }
638         else if( Dali::Camera::FREE_LOOK == mType )
639         {
640           ret = "FREE_LOOK";
641         }
642         break;
643       }
644       case Dali::CameraActor::Property::PROJECTION_MODE:
645       {
646         if( Dali::Camera::PERSPECTIVE_PROJECTION == mProjectionMode )
647         {
648           ret = "PERSPECTIVE_PROJECTION";
649         }
650         else if( Dali::Camera::ORTHOGRAPHIC_PROJECTION == mProjectionMode )
651         {
652           ret = "ORTHOGRAPHIC_PROJECTION";
653         }
654         break;
655       }
656       case Dali::CameraActor::Property::FIELD_OF_VIEW:
657       {
658         ret = mFieldOfView;
659         break;
660       }
661       case Dali::CameraActor::Property::ASPECT_RATIO:
662       {
663         ret = mAspectRatio;
664         break;
665       }
666       case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
667       {
668         ret = mNearClippingPlane;
669         break;
670       }
671       case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
672       {
673         ret = mFarClippingPlane;
674         break;
675       }
676       case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
677       {
678         ret = mLeftClippingPlane;
679         break;
680       }
681       case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
682       {
683         ret = mRightClippingPlane;
684         break;
685       }
686       case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
687       {
688         ret = mTopClippingPlane;
689         break;
690       }
691       case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
692       {
693         ret = mBottomClippingPlane;
694         break;
695       }
696       case Dali::CameraActor::Property::TARGET_POSITION:
697       {
698         ret = mTarget;
699         break;
700       }
701       case Dali::CameraActor::Property::PROJECTION_MATRIX:
702       {
703         ret = GetProjectionMatrix(); // Only on scene-graph
704         break;
705       }
706       case Dali::CameraActor::Property::VIEW_MATRIX:
707       {
708         ret = GetViewMatrix(); // Only on scene-graph
709         break;
710       }
711       case Dali::CameraActor::Property::INVERT_Y_AXIS:
712       {
713         ret = mInvertYAxis;
714         break;
715       }
716     } // switch(index)
717   }
718
719   return ret;
720 }
721
722 Property::Value CameraActor::GetDefaultPropertyCurrentValue( Property::Index index ) const
723 {
724   Property::Value ret;
725   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
726   {
727     ret = Actor::GetDefaultPropertyCurrentValue(index);
728   }
729   else
730   {
731     ret = GetDefaultProperty( index ); // Most are event-side properties, the scene-graph properties are only on the scene-graph
732   }
733
734   return ret;
735 }
736
737 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty( Property::Index index ) const
738 {
739   DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
740
741   const SceneGraph::PropertyBase* property( NULL );
742
743   // This method should only return a property of an object connected to the scene-graph
744   if ( !OnStage() )
745   {
746     return property;
747   }
748
749   // let actor handle animatable properties, we have no animatable properties
750   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
751   {
752     property = Actor::GetSceneObjectAnimatableProperty(index);
753   }
754
755   return property;
756 }
757
758 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty( Property::Index index ) const
759 {
760   const PropertyInputImpl* property( NULL );
761
762   // This method should only return a property of an object connected to the scene-graph
763   if ( !OnStage() )
764   {
765     return property;
766   }
767
768   // if its an actor default property or a custom property (actor already handles custom properties)
769   if( ( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) || ( index >= DEFAULT_PROPERTY_MAX_COUNT ) )
770   {
771     property = Actor::GetSceneObjectInputProperty( index );
772   }
773   else
774   {
775     switch( index )
776     {
777       case Dali::CameraActor::Property::PROJECTION_MATRIX:
778       {
779         property = mSceneObject->GetProjectionMatrix();
780         break;
781       }
782       case Dali::CameraActor::Property::VIEW_MATRIX:
783       {
784         property = mSceneObject->GetViewMatrix();
785         break;
786       }
787       default:
788         DALI_LOG_WARNING("Not an input property (%d)\n", index);
789         break;
790     }
791   }
792
793   return property;
794 }
795
796 } // namespace Internal
797
798 } // namespace Dali