[Tizen] Revert "Remove StereoMode"
[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   SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
413   SetFieldOfView( fieldOfView );
414   SetNearClippingPlane( nearClippingPlane );
415   SetFarClippingPlane( farClippingPlane );
416   SetAspectRatio( aspectRatio );
417   // sceneObject is being used in a separate thread; queue a message to set
418   SetStereoBiasMessage( GetEventThreadServices(), *mSceneObject, stereoBias );
419   SetZ( cameraZ );
420 }
421
422
423 void CameraActor::SetOrthographicProjection( const Vector2& size )
424 {
425   // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
426   float nearClippingPlane;
427   float farClippingPlane;
428   float cameraZ;
429   CalculateClippingAndZ( size.width, size.height, nearClippingPlane, farClippingPlane, cameraZ );
430   SetOrthographicProjection( -size.x*0.5f, size.x*0.5f, size.y*0.5f, -size.y*0.5f,
431                              nearClippingPlane, farClippingPlane );
432   SetZ( cameraZ );
433 }
434
435 void CameraActor::SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far )
436 {
437   SetLeftClippingPlane( left );
438   SetRightClippingPlane( right );
439   SetTopClippingPlane( top );
440   SetBottomClippingPlane( bottom );
441   SetNearClippingPlane( near );
442   SetFarClippingPlane( far );
443   SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
444 }
445
446 bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
447                                    const Viewport& viewport,
448                                    Vector4& rayOrigin,
449                                    Vector4& rayDirection )
450 {
451   bool success = true;
452   if( mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION )
453   {
454     // Build a picking ray in the world reference system.
455     // ray starts from the camera world position
456     rayOrigin = mNode.GetWorldMatrix(0).GetTranslation();
457     rayOrigin.w = 1.0f;
458
459     // Transform the touch point from the screen coordinate system to the world coordinates system.
460     Vector4 near( screenCoordinates.x - static_cast<float>(viewport.x),
461                   static_cast<float>( viewport.height ) - (screenCoordinates.y - static_cast<float>( viewport.y ) ),
462                   0.f, 1.f );
463     const Matrix& inverseViewProjection = mSceneObject->GetInverseViewProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
464     success = Unproject( near, inverseViewProjection, static_cast<float>( viewport.width ), static_cast<float>( viewport.height ), near );
465
466     // Compute the ray's director vector.
467     rayDirection.x = near.x - rayOrigin.x;
468     rayDirection.y = near.y - rayOrigin.y;
469     rayDirection.z = near.z - rayOrigin.z;
470     rayDirection.Normalize();
471     rayDirection.w = 1.f;
472   }
473   else
474   {
475     float nearPlaneDistance = GetNearClippingPlane();
476     BuildOrthoPickingRay( GetViewMatrix(),
477                           GetProjectionMatrix(),
478                           viewport, screenCoordinates.x,
479                           screenCoordinates.y,
480                           rayOrigin,
481                           rayDirection,
482                           nearPlaneDistance );
483   }
484
485   return success;
486 }
487
488 const Matrix& CameraActor::GetViewMatrix() const
489 {
490   if ( OnStage() )
491   {
492     return mSceneObject->GetViewMatrix( GetEventThreadServices().GetEventBufferIndex() );
493   }
494   else
495   {
496     return Matrix::IDENTITY;
497   }
498 }
499
500 const Matrix& CameraActor::GetProjectionMatrix() const
501 {
502   if ( OnStage() )
503   {
504     return mSceneObject->GetProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
505   }
506   else
507   {
508     return Matrix::IDENTITY;
509   }
510 }
511 const SceneGraph::Camera* CameraActor::GetCamera() const
512 {
513   return mSceneObject;
514 }
515
516 void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
517 {
518   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
519   {
520     Actor::SetDefaultProperty(index, propertyValue);
521   }
522   else
523   {
524     switch(index)
525     {
526       case Dali::CameraActor::Property::TYPE:
527       {
528         std::string s( propertyValue.Get<std::string>() );
529         if(s == "LOOK_AT_TARGET")
530         {
531           SetType( Dali::Camera::LOOK_AT_TARGET );
532         }
533         else if(s == "FREE_LOOK")
534         {
535           SetType( Dali::Camera::FREE_LOOK );
536         }
537         break;
538       }
539       case Dali::CameraActor::Property::PROJECTION_MODE:
540       {
541         std::string s( propertyValue.Get<std::string>() );
542         if( s == "PERSPECTIVE_PROJECTION" )
543         {
544           SetProjectionMode( Dali::Camera::PERSPECTIVE_PROJECTION );
545         }
546         else if( s == "ORTHOGRAPHIC_PROJECTION" )
547         {
548           SetProjectionMode( Dali::Camera::ORTHOGRAPHIC_PROJECTION );
549         }
550         break;
551       }
552       case Dali::CameraActor::Property::FIELD_OF_VIEW:
553       {
554         SetFieldOfView( propertyValue.Get<float>() ); // set to 0 in case property is not float
555         break;
556       }
557       case Dali::CameraActor::Property::ASPECT_RATIO:
558       {
559         SetAspectRatio( propertyValue.Get<float>() ); // set to 0 in case property is not float
560         break;
561       }
562       case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
563       {
564         SetNearClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
565         break;
566       }
567       case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
568       {
569         SetFarClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
570         break;
571       }
572       case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
573       {
574         SetLeftClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
575         break;
576       }
577       case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
578       {
579         SetRightClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
580         break;
581       }
582       case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
583       {
584         SetTopClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
585         break;
586       }
587       case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
588       {
589         SetBottomClippingPlane( propertyValue.Get<float>() ); // set to 0 in case property is not float
590         break;
591       }
592       case Dali::CameraActor::Property::TARGET_POSITION:
593       {
594         SetTarget( propertyValue.Get<Vector3>() ); // set to 0 in case property is not Vector3
595         break;
596       }
597       case Dali::CameraActor::Property::PROJECTION_MATRIX:
598       {
599         DALI_LOG_WARNING( "projection-matrix is read-only\n" );
600         break;
601       }
602       case Dali::CameraActor::Property::VIEW_MATRIX:
603       {
604         DALI_LOG_WARNING( "view-matrix is read-only\n" );
605         break;
606       }
607       case Dali::CameraActor::Property::INVERT_Y_AXIS:
608       {
609         SetInvertYAxis( propertyValue.Get<bool>() ); // set to false in case property is not bool
610         break;
611       }
612       default:
613       {
614         DALI_LOG_WARNING( "Unknown property (%d)\n", index );
615         break;
616       }
617     } // switch(index)
618
619   } // else
620 }
621
622 Property::Value CameraActor::GetDefaultProperty( Property::Index index ) const
623 {
624   Property::Value ret;
625   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
626   {
627     ret = Actor::GetDefaultProperty(index);
628   }
629   else
630   {
631     switch(index)
632     {
633       case Dali::CameraActor::Property::TYPE:
634       {
635         if( Dali::Camera::LOOK_AT_TARGET == mType )
636         {
637           ret = "LOOK_AT_TARGET";
638         }
639         else if( Dali::Camera::FREE_LOOK == mType )
640         {
641           ret = "FREE_LOOK";
642         }
643         break;
644       }
645       case Dali::CameraActor::Property::PROJECTION_MODE:
646       {
647         if( Dali::Camera::PERSPECTIVE_PROJECTION == mProjectionMode )
648         {
649           ret = "PERSPECTIVE_PROJECTION";
650         }
651         else if( Dali::Camera::ORTHOGRAPHIC_PROJECTION == mProjectionMode )
652         {
653           ret = "ORTHOGRAPHIC_PROJECTION";
654         }
655         break;
656       }
657       case Dali::CameraActor::Property::FIELD_OF_VIEW:
658       {
659         ret = mFieldOfView;
660         break;
661       }
662       case Dali::CameraActor::Property::ASPECT_RATIO:
663       {
664         ret = mAspectRatio;
665         break;
666       }
667       case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
668       {
669         ret = mNearClippingPlane;
670         break;
671       }
672       case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
673       {
674         ret = mFarClippingPlane;
675         break;
676       }
677       case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
678       {
679         ret = mLeftClippingPlane;
680         break;
681       }
682       case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
683       {
684         ret = mRightClippingPlane;
685         break;
686       }
687       case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
688       {
689         ret = mTopClippingPlane;
690         break;
691       }
692       case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
693       {
694         ret = mBottomClippingPlane;
695         break;
696       }
697       case Dali::CameraActor::Property::TARGET_POSITION:
698       {
699         ret = mTarget;
700         break;
701       }
702       case Dali::CameraActor::Property::PROJECTION_MATRIX:
703       {
704         ret = GetProjectionMatrix(); // Only on scene-graph
705         break;
706       }
707       case Dali::CameraActor::Property::VIEW_MATRIX:
708       {
709         ret = GetViewMatrix(); // Only on scene-graph
710         break;
711       }
712       case Dali::CameraActor::Property::INVERT_Y_AXIS:
713       {
714         ret = mInvertYAxis;
715         break;
716       }
717     } // switch(index)
718   }
719
720   return ret;
721 }
722
723 Property::Value CameraActor::GetDefaultPropertyCurrentValue( Property::Index index ) const
724 {
725   Property::Value ret;
726   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
727   {
728     ret = Actor::GetDefaultPropertyCurrentValue(index);
729   }
730   else
731   {
732     ret = GetDefaultProperty( index ); // Most are event-side properties, the scene-graph properties are only on the scene-graph
733   }
734
735   return ret;
736 }
737
738 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty( Property::Index index ) const
739 {
740   DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
741
742   const SceneGraph::PropertyBase* property( NULL );
743
744   // This method should only return a property of an object connected to the scene-graph
745   if ( !OnStage() )
746   {
747     return property;
748   }
749
750   // let actor handle animatable properties, we have no animatable properties
751   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
752   {
753     property = Actor::GetSceneObjectAnimatableProperty(index);
754   }
755
756   return property;
757 }
758
759 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty( Property::Index index ) const
760 {
761   const PropertyInputImpl* property( NULL );
762
763   // This method should only return a property of an object connected to the scene-graph
764   if ( !OnStage() )
765   {
766     return property;
767   }
768
769   // if its an actor default property or a custom property (actor already handles custom properties)
770   if( ( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) || ( index >= DEFAULT_PROPERTY_MAX_COUNT ) )
771   {
772     property = Actor::GetSceneObjectInputProperty( index );
773   }
774   else
775   {
776     switch( index )
777     {
778       case Dali::CameraActor::Property::PROJECTION_MATRIX:
779       {
780         property = mSceneObject->GetProjectionMatrix();
781         break;
782       }
783       case Dali::CameraActor::Property::VIEW_MATRIX:
784       {
785         property = mSceneObject->GetViewMatrix();
786         break;
787       }
788       default:
789         DALI_LOG_WARNING("Not an input property (%d)\n", index);
790         break;
791     }
792   }
793
794   return property;
795 }
796
797 } // namespace Internal
798
799 } // namespace Dali