Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/internal/event/actors/camera-actor-impl.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/common/stage.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/internal/event/actor-attachments/camera-attachment-impl.h>
24 #include <dali/internal/event/common/property-index-ranges.h>
25 #include <dali/internal/event/common/stage-impl.h>
26 #include <dali/internal/event/render-tasks/render-task-impl.h>
27 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
28 #include <dali/internal/event/common/projection.h>
29 #include <dali/integration-api/debug.h>
30
31 namespace Dali
32 {
33
34 const Property::Index CameraActor::TYPE                    = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
35 const Property::Index CameraActor::PROJECTION_MODE         = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 1;
36 const Property::Index CameraActor::FIELD_OF_VIEW           = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 2;
37 const Property::Index CameraActor::ASPECT_RATIO            = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 3;
38 const Property::Index CameraActor::NEAR_PLANE_DISTANCE     = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 4;
39 const Property::Index CameraActor::FAR_PLANE_DISTANCE      = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 5;
40 const Property::Index CameraActor::LEFT_PLANE_DISTANCE     = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 6;
41 const Property::Index CameraActor::RIGHT_PLANE_DISTANCE    = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 7;
42 const Property::Index CameraActor::TOP_PLANE_DISTANCE      = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 8;
43 const Property::Index CameraActor::BOTTOM_PLANE_DISTANCE   = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 9;
44 const Property::Index CameraActor::TARGET_POSITION         = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 10;
45 const Property::Index CameraActor::PROJECTION_MATRIX       = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 11;
46 const Property::Index CameraActor::VIEW_MATRIX             = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 12;
47 const Property::Index CameraActor::INVERT_Y_AXIS           = Internal::DEFAULT_ACTOR_PROPERTY_MAX_COUNT + 13;
48
49 namespace Internal
50 {
51 bool CameraActor::mFirstInstance = true;
52 Actor::DefaultPropertyLookup* CameraActor::mDefaultCameraActorPropertyLookup = NULL;
53
54 namespace
55 {
56
57 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
58 void CalculateClippingAndZ( float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ )
59 {
60   nearClippingPlane = std::max( width, height );
61   farClippingPlane = nearClippingPlane + static_cast<float>( 0xFFFF >> 4 );
62   cameraZ = 2.0f * nearClippingPlane;
63 }
64
65 BaseHandle Create()
66 {
67   return Dali::CameraActor::New();
68 }
69
70 TypeRegistration mType( typeid(Dali::CameraActor), typeid(Dali::Actor), Create );
71
72 const std::string DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[] =
73 {
74   "type",
75   "projection-mode",
76   "field-of-view",
77   "aspect-ratio",
78   "near-plane-distance",
79   "far-plane-distance",
80   "left-plane-distance",
81   "right-plane-distance",
82   "top-plane-distance",
83   "bottom-plane-distance",
84   "target-position",
85   "projection-matrix",
86   "view-matrix",
87   "invert-y-axis"
88 };
89 const int DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES ) / sizeof( std::string );
90
91 const Property::Type DEFAULT_CAMERA_ACTOR_PROPERTY_TYPES[DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT] =
92 {
93   Property::STRING,   // "type",
94   Property::STRING,   // "projection-mode",
95   Property::FLOAT,    // "field-of-view",
96   Property::FLOAT,    // "aspect-ratio",
97   Property::FLOAT,    // "near-plane-distance",
98   Property::FLOAT,    // "far-plane-distance",
99   Property::FLOAT,    // "left-plane-distance",
100   Property::FLOAT,    // "right-plane-distance",
101   Property::FLOAT,    // "top-plane-distance",
102   Property::FLOAT,    // "bottom-plane-distance",
103   Property::VECTOR3,  // "target-position",
104   Property::MATRIX,   // "projection-matrix",
105   Property::MATRIX,   // "view-matrix",
106   Property::BOOLEAN,  // "invert-y-axis",
107 };
108
109 /**
110  * Builds the picking ray in the world reference system from an orthographic camera
111  * The ray origin is the screen coordinate in the near plane translated to a parallel
112  * plane at the camera origin. The ray direction is the direction the camera is facing
113  * (i.e. Z=-1 in view space).
114  */
115 void BuildOrthoPickingRay( const Matrix& viewMatrix,
116                            const Matrix& projectionMatrix,
117                            const Viewport& viewport,
118                            float screenX,
119                            float screenY,
120                            Vector4& rayOrigin,
121                            Vector4& rayDir,
122                            float nearPlaneDistance )
123 {
124   //          inv( modelMatrix )          inv( viewMatrix )    inv( projectionMatrix )           normalize
125   //          <-----------------         <-----------------         <--------------           <-------------
126   //  Local                      World                      Camera                 Normalized                 Screen
127   // reference                  reference                  reference                  clip                  coordinates
128   //  system                     system                     system                 coordinates
129   //          ----------------->         ----------------->         -------------->           ------------->
130   //             modelMatrix                 viewMatrix             projectionMatrix             viewport
131
132   // Transforms the touch point from the screen reference system to the world reference system.
133   Matrix invViewProjection( false ); // Don't initialize.
134   Matrix::Multiply( invViewProjection, viewMatrix, projectionMatrix );
135   if( !invViewProjection.Invert() )
136   {
137     DALI_ASSERT_DEBUG( false );
138   }
139
140   Vector4 near( screenX - viewport.x, viewport.height - (screenY - viewport.y), 0.f, 1.f );
141   if( !Unproject( near, invViewProjection, viewport.width, viewport.height, rayOrigin ) )
142   {
143     DALI_ASSERT_DEBUG( false );
144   }
145
146   Matrix invView = viewMatrix;
147   if( !invView.Invert() )
148   {
149     DALI_ASSERT_DEBUG( false );
150   }
151
152   Vector4 cameraOrigin = invView * Vector4( 0.f, 0.f, 0.f, 1.f );
153   Vector4 nearPlaneOrigin = invView * Vector4( 0.0f, 0.0f, -nearPlaneDistance, 1.0f);
154
155   // Vector pointing from the camera to the near plane
156   rayDir = cameraOrigin - nearPlaneOrigin;
157   rayOrigin -= rayDir;
158   rayDir.Normalize();
159   rayDir.w = 1.0f;
160 }
161
162 } // namespace
163
164 CameraActorPtr CameraActor::New( const Size& size )
165 {
166   CameraActorPtr actor(new CameraActor());
167
168   // Second-phase construction
169
170   actor->Initialize();
171
172   actor->SetName("DefaultCamera");
173
174   // Create the attachment
175   actor->mCameraAttachment = CameraAttachment::New( *actor->mNode );
176
177   actor->Attach(*actor->mCameraAttachment);
178
179   actor->SetPerspectiveProjection( size );
180
181   return actor;
182 }
183
184 void CameraActor::OnInitialize()
185 {
186   if(CameraActor::mFirstInstance)
187   {
188     mDefaultCameraActorPropertyLookup = new DefaultPropertyLookup();
189     const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
190     for ( int i = 0; i < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT; ++i )
191     {
192       (*mDefaultCameraActorPropertyLookup)[DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[i]] = i + start;
193     }
194     CameraActor::mFirstInstance = false;
195   }
196 }
197
198 CameraActor::CameraActor()
199 : Actor( Actor::BASIC )
200 {
201 }
202
203 CameraActor::~CameraActor()
204 {
205 }
206
207 void CameraActor::SetType( Dali::Camera::Type type )
208 {
209   mCameraAttachment->SetType(type);
210 }
211
212 Dali::Camera::Type CameraActor::GetType() const
213 {
214   return mCameraAttachment->GetType();
215 }
216
217 void CameraActor::SetProjectionMode( Dali::Camera::ProjectionMode mode )
218 {
219   mCameraAttachment->SetProjectionMode(mode);
220 }
221
222 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
223 {
224   return mCameraAttachment->GetProjectionMode();
225 }
226
227 void CameraActor::SetFieldOfView( float fieldOfView )
228 {
229   mCameraAttachment->SetFieldOfView(fieldOfView);
230 }
231
232 float CameraActor::GetFieldOfView( ) const
233 {
234   return mCameraAttachment->GetFieldOfView();
235 }
236
237 void CameraActor::SetAspectRatio( float aspectRatio )
238 {
239   mCameraAttachment->SetAspectRatio(aspectRatio);
240 }
241
242 float CameraActor::GetAspectRatio( ) const
243 {
244   return mCameraAttachment->GetAspectRatio();
245 }
246
247 void CameraActor::SetNearClippingPlane( float nearClippingPlane )
248 {
249   mCameraAttachment->SetNearClippingPlane(nearClippingPlane);
250 }
251
252 float CameraActor::GetNearClippingPlane( ) const
253 {
254   return mCameraAttachment->GetNearClippingPlane();
255 }
256
257 void CameraActor::SetFarClippingPlane( float farClippingPlane )
258 {
259   mCameraAttachment->SetFarClippingPlane(farClippingPlane);
260 }
261
262 float CameraActor::GetFarClippingPlane( ) const
263 {
264   return mCameraAttachment->GetFarClippingPlane();
265 }
266
267 void CameraActor::SetTargetPosition(const Vector3& target)
268 {
269   mCameraAttachment->SetTargetPosition(target);
270 }
271
272 Vector3 CameraActor::GetTargetPosition() const
273 {
274   return mCameraAttachment->GetTargetPosition();
275 }
276
277 void CameraActor::SetInvertYAxis(bool invertYAxis)
278 {
279   mCameraAttachment->SetInvertYAxis(invertYAxis);
280 }
281
282 bool CameraActor::GetInvertYAxis() const
283 {
284   return mCameraAttachment->GetInvertYAxis();
285 }
286
287 void CameraActor::SetPerspectiveProjection( const Size& size, float stereoBias /* = 0.0f */ )
288 {
289   float width = size.width;
290   float height = size.height;
291
292   if( Size::ZERO == size )
293   {
294     if( Stage::IsInstalled() )
295     {
296       const Size& stageSize = mStage->GetSize();
297
298       width = stageSize.width;
299       height = stageSize.height;
300     }
301   }
302
303   if( ( width < Math::MACHINE_EPSILON_1000 ) || ( height < Math::MACHINE_EPSILON_1000 ) )
304   {
305     // On the stage initialization this method is called but the size has not been set.
306     // There is no point to set any value if width or height is zero.
307     return;
308   }
309
310   float nearClippingPlane;
311   float farClippingPlane;
312   float cameraZ;
313   CalculateClippingAndZ( width, height, nearClippingPlane, farClippingPlane, cameraZ );
314
315   // calculate the position of the camera to have the desired aspect ratio
316   const float fieldOfView = 2.0f * std::atan( height * 0.5f / cameraZ );
317
318   // unless it is too small, we want at least as much space to the back as we have torwards the front
319   const float minClippingFarPlane = 2.f * nearClippingPlane;
320   if ( farClippingPlane < minClippingFarPlane )
321   {
322     farClippingPlane = minClippingFarPlane;
323   }
324
325   const float aspectRatio = width / height;
326
327   SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
328   SetFieldOfView( fieldOfView );
329   SetNearClippingPlane( nearClippingPlane );
330   SetFarClippingPlane( farClippingPlane );
331   SetAspectRatio( aspectRatio );
332   mCameraAttachment->SetStereoBias( stereoBias );
333   SetZ( cameraZ );
334 }
335
336
337 void CameraActor::SetOrthographicProjection( const Vector2& size )
338 {
339   // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
340   float nearClippingPlane;
341   float farClippingPlane;
342   float cameraZ;
343   CalculateClippingAndZ( size.width, size.height, nearClippingPlane, farClippingPlane, cameraZ );
344   SetOrthographicProjection( -size.x*0.5f, size.x*0.5f, size.y*0.5f, -size.y*0.5f,
345                              nearClippingPlane, farClippingPlane );
346   SetZ( cameraZ );
347 }
348
349 void CameraActor::SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far )
350 {
351   mCameraAttachment->SetLeftClippingPlane(left);
352   mCameraAttachment->SetRightClippingPlane(right);
353   mCameraAttachment->SetTopClippingPlane(top);
354   mCameraAttachment->SetBottomClippingPlane(bottom);
355   SetNearClippingPlane( near );
356   SetFarClippingPlane( far );
357   SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
358 }
359
360 bool CameraActor::BuildPickingRay( const Vector2& screenCoordinates,
361                                    const Viewport& viewport,
362                                    Vector4& rayOrigin,
363                                    Vector4& rayDirection )
364 {
365   bool success = true;
366   if( GetProjectionMode() == Dali::Camera::PERSPECTIVE_PROJECTION )
367   {
368     // Build a picking ray in the world reference system.
369     // ray starts from the camera world position
370     rayOrigin = mNode->GetWorldPosition( mStage->GetEventBufferIndex() );
371     rayOrigin.w = 1.0f;
372
373     // Transform the touch point from the screen coordinate system to the world coordinates system.
374     Vector4 near( screenCoordinates.x - viewport.x, viewport.height - (screenCoordinates.y - viewport.y), 0.f, 1.f );
375     if( !Unproject( near, mCameraAttachment->GetInverseViewProjectionMatrix(), viewport.width, viewport.height, near ) )
376     {
377       // unproject failed so no picking ray possible
378       success = false;
379     }
380
381     // Compute the ray's director vector.
382     rayDirection.x = near.x - rayOrigin.x;
383     rayDirection.y = near.y - rayOrigin.y;
384     rayDirection.z = near.z - rayOrigin.z;
385     rayDirection.Normalize();
386     rayDirection.w = 1.f;
387   }
388   else
389   {
390     float nearPlaneDistance = GetNearClippingPlane();
391     BuildOrthoPickingRay( GetViewMatrix(),
392                           GetProjectionMatrix(),
393                           viewport, screenCoordinates.x,
394                           screenCoordinates.y,
395                           rayOrigin,
396                           rayDirection,
397                           nearPlaneDistance );
398   }
399
400   return success;
401 }
402
403 const Matrix& CameraActor::GetViewMatrix() const
404 {
405   if ( OnStage() )
406   {
407     return mCameraAttachment->GetViewMatrix();
408   }
409   else
410   {
411     return Matrix::IDENTITY;
412   }
413 }
414
415 const Matrix& CameraActor::GetProjectionMatrix() const
416 {
417   if ( OnStage() )
418   {
419     return mCameraAttachment->GetProjectionMatrix();
420   }
421   else
422   {
423     return Matrix::IDENTITY;
424   }
425 }
426
427 unsigned int CameraActor::GetDefaultPropertyCount() const
428 {
429   return Actor::GetDefaultPropertyCount() + DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT;
430 }
431
432 void CameraActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
433 {
434   Actor::GetDefaultPropertyIndices( indices ); // Actor class properties
435
436   indices.reserve( indices.size() + DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT );
437
438   int index = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
439   for ( int i = 0; i < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT; ++i, ++index )
440   {
441     indices.push_back( index );
442   }
443 }
444
445 bool CameraActor::IsDefaultPropertyWritable( Property::Index index ) const
446 {
447   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
448   {
449     return Actor::IsDefaultPropertyWritable(index);
450   }
451   else
452   {
453     if( Dali::CameraActor::PROJECTION_MATRIX == index || Dali::CameraActor::VIEW_MATRIX == index )
454     {
455       return false;
456     }
457     else
458     {
459       return true;
460     }
461   }
462 }
463
464 bool CameraActor::IsDefaultPropertyAnimatable( Property::Index index ) const
465 {
466   bool animatable = false; // Our properties are not animatable.
467
468   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
469   {
470     animatable = Actor::IsDefaultPropertyAnimatable(index);
471   }
472   return animatable;
473 }
474
475 bool CameraActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
476 {
477   bool animatable = true; // Our properties can be used as inputs to constraints.
478
479   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
480   {
481     animatable = Actor::IsDefaultPropertyAConstraintInput(index);
482   }
483   return animatable;
484 }
485
486 Property::Type CameraActor::GetDefaultPropertyType( Property::Index index ) const
487 {
488   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
489   {
490     return Actor::GetDefaultPropertyType(index);
491   }
492   else
493   {
494     index -= DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
495
496     if ( ( index >= 0 ) && ( index < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT ) )
497     {
498       return DEFAULT_CAMERA_ACTOR_PROPERTY_TYPES[index];
499     }
500     else
501     {
502       // index out-of-bounds
503       return Property::NONE;
504     }
505   }
506 }
507
508 const std::string& CameraActor::GetDefaultPropertyName( Property::Index index ) const
509 {
510   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
511   {
512     return Actor::GetDefaultPropertyName(index);
513   }
514   else
515   {
516     index -= DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
517
518     if ( ( index >= 0 ) && ( index < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT ) )
519     {
520       return DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[index];
521     }
522     else
523     {
524       // index out-of-bounds
525       static const std::string INVALID_PROPERTY_NAME;
526       return INVALID_PROPERTY_NAME;
527     }
528   }
529 }
530
531 Property::Index CameraActor::GetDefaultPropertyIndex(const std::string& name) const
532 {
533   Property::Index index = Property::INVALID_INDEX;
534
535   DALI_ASSERT_DEBUG( NULL != mDefaultCameraActorPropertyLookup );
536
537   // Look for name in current class' default properties
538   DefaultPropertyLookup::const_iterator result = mDefaultCameraActorPropertyLookup->find( name );
539   if ( mDefaultCameraActorPropertyLookup->end() != result )
540   {
541     index = result->second;
542   }
543   else
544   {
545     // If not found, check in base class
546     index = Actor::GetDefaultPropertyIndex( name );
547   }
548
549   return index;
550 }
551
552 void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
553 {
554   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
555   {
556     Actor::SetDefaultProperty(index, propertyValue);
557   }
558   else
559   {
560     DALI_ASSERT_DEBUG(mCameraAttachment && "where is the camera?");
561     switch(index)
562     {
563       case Dali::CameraActor::TYPE:
564       {
565         std::string s(propertyValue.Get<std::string>());
566         if(s == "LOOK_AT_TARGET")
567         {
568           mCameraAttachment->SetType(Dali::Camera::LOOK_AT_TARGET);
569         }
570         else if(s == "FREE_LOOK")
571         {
572           mCameraAttachment->SetType(Dali::Camera::FREE_LOOK);
573         }
574         else
575         {
576           DALI_LOG_WARNING("Unknown camera type\n");
577         }
578         break;
579       }
580       case Dali::CameraActor::PROJECTION_MODE:
581       {
582         std::string s(propertyValue.Get<std::string>());
583         if(s == "PERSPECTIVE_PROJECTION")
584         {
585           mCameraAttachment->SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
586         }
587         else if(s == "ORTHOGRAPHIC_PROJECTION")
588         {
589           mCameraAttachment->SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
590         }
591         else
592         {
593           DALI_LOG_WARNING("Unknown projection mode\n");
594         }
595         break;
596       }
597       case Dali::CameraActor::FIELD_OF_VIEW:
598       {
599         mCameraAttachment->SetFieldOfView(propertyValue.Get<float>());
600         break;
601       }
602       case Dali::CameraActor::ASPECT_RATIO:
603       {
604         mCameraAttachment->SetAspectRatio(propertyValue.Get<float>());
605         break;
606       }
607       case Dali::CameraActor::LEFT_PLANE_DISTANCE:
608       {
609         mCameraAttachment->SetLeftClippingPlane(propertyValue.Get<float>());
610         break;
611       }
612       case Dali::CameraActor::RIGHT_PLANE_DISTANCE:
613       {
614         mCameraAttachment->SetRightClippingPlane(propertyValue.Get<float>());
615         break;
616       }
617       case Dali::CameraActor::TOP_PLANE_DISTANCE:
618       {
619         mCameraAttachment->SetTopClippingPlane(propertyValue.Get<float>());
620         break;
621       }
622       case Dali::CameraActor::BOTTOM_PLANE_DISTANCE:
623       {
624         mCameraAttachment->SetBottomClippingPlane(propertyValue.Get<float>());
625         break;
626       }
627       case Dali::CameraActor::NEAR_PLANE_DISTANCE:
628       {
629         mCameraAttachment->SetNearClippingPlane(propertyValue.Get<float>());
630         break;
631       }
632       case Dali::CameraActor::FAR_PLANE_DISTANCE:
633       {
634         mCameraAttachment->SetFarClippingPlane(propertyValue.Get<float>());
635         break;
636       }
637       case Dali::CameraActor::TARGET_POSITION:
638       {
639         mCameraAttachment->SetTargetPosition(propertyValue.Get<Vector3>());
640         break;
641       }
642       case Dali::CameraActor::PROJECTION_MATRIX:
643       {
644         DALI_LOG_WARNING("projection-matrix property is not animatable \n");
645         break;
646       }
647       case Dali::CameraActor::VIEW_MATRIX:
648       {
649         DALI_LOG_WARNING("view-matrix property is not animatable \n");
650         break;
651       }
652       case Dali::CameraActor::INVERT_Y_AXIS:
653       {
654         mCameraAttachment->SetInvertYAxis(propertyValue.Get<bool>());
655         break;
656       }
657       default:
658       {
659         DALI_LOG_WARNING("Unknown property (%d)\n", index);
660         break;
661       }
662     } // switch(index)
663
664   } // else
665 }
666
667 Property::Value CameraActor::GetDefaultProperty( Property::Index index ) const
668 {
669   Property::Value ret;
670   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
671   {
672     ret = Actor::GetDefaultProperty(index);
673   }
674   else
675   {
676     DALI_ASSERT_DEBUG(mCameraAttachment && "where is the camera?");
677     switch(index)
678     {
679
680       case Dali::CameraActor::TYPE:
681       {
682         if(mCameraAttachment->GetType() == Dali::Camera::LOOK_AT_TARGET)
683         {
684           ret = "LOOK_AT_TARGET";
685         }
686         else if(mCameraAttachment->GetType() == Dali::Camera::FREE_LOOK)
687         {
688           ret = "FREE_LOOK";
689         }
690         else
691         {
692           ret = "";
693           DALI_ASSERT_DEBUG("Unknown camera type\n");
694         }
695         break;
696       }
697
698
699       case Dali::CameraActor::PROJECTION_MODE:
700       {
701         if(mCameraAttachment->GetProjectionMode() == Dali::Camera::PERSPECTIVE_PROJECTION)
702         {
703           ret = "PERSPECTIVE_PROJECTION";
704         }
705         else if(mCameraAttachment->GetProjectionMode() == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
706         {
707           ret = "ORTHOGRAPHIC_PROJECTION";
708         }
709         else
710         {
711           ret = "";
712           DALI_ASSERT_DEBUG("Unknown projection mode\n");
713         }
714         break;
715       }
716       case Dali::CameraActor::FIELD_OF_VIEW:
717       {
718         ret = mCameraAttachment->GetFieldOfView();
719         break;
720       }
721       case Dali::CameraActor::ASPECT_RATIO:
722       {
723         ret = mCameraAttachment->GetAspectRatio();
724         break;
725       }
726       case Dali::CameraActor::LEFT_PLANE_DISTANCE:
727       {
728         ret = mCameraAttachment->GetLeftClippingPlane();
729         break;
730       }
731       case Dali::CameraActor::RIGHT_PLANE_DISTANCE:
732       {
733         ret = mCameraAttachment->GetRightClippingPlane();
734         break;
735       }
736       case Dali::CameraActor::TOP_PLANE_DISTANCE:
737       {
738         ret = mCameraAttachment->GetTopClippingPlane();
739         break;
740       }
741       case Dali::CameraActor::BOTTOM_PLANE_DISTANCE:
742       {
743         ret = mCameraAttachment->GetBottomClippingPlane();
744         break;
745       }
746       case Dali::CameraActor::NEAR_PLANE_DISTANCE:
747       {
748         ret = mCameraAttachment->GetNearClippingPlane();
749         break;
750       }
751       case Dali::CameraActor::FAR_PLANE_DISTANCE:
752       {
753         ret = mCameraAttachment->GetFarClippingPlane();
754         break;
755       }
756       case Dali::CameraActor::TARGET_POSITION:
757       {
758         ret = mCameraAttachment->GetTargetPosition();
759         break;
760       }
761       case Dali::CameraActor::PROJECTION_MATRIX:
762       {
763         ret = mCameraAttachment->GetProjectionMatrix();
764         break;
765       }
766       case Dali::CameraActor::VIEW_MATRIX:
767       {
768         ret = mCameraAttachment->GetViewMatrix();
769         break;
770       }
771       case Dali::CameraActor::INVERT_Y_AXIS:
772       {
773         ret = mCameraAttachment->GetInvertYAxis();
774         break;
775       }
776       default:
777       {
778         DALI_LOG_WARNING("Unknown property (%d)\n", index);
779         break;
780       }
781     } // switch(index)
782   }
783
784   return ret;
785 }
786
787 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty( Property::Index index ) const
788 {
789   DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
790
791   const SceneGraph::PropertyBase* property( NULL );
792
793   // This method should only return a property of an object connected to the scene-graph
794   if ( !OnStage() )
795   {
796     return property;
797   }
798
799   // let actor handle animatable properties, we have no animatable properties
800   if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
801   {
802     property = Actor::GetSceneObjectAnimatableProperty(index);
803   }
804
805   return property;
806 }
807
808 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty( Property::Index index ) const
809 {
810   const PropertyInputImpl* property( NULL );
811
812   // This method should only return a property of an object connected to the scene-graph
813   if ( !OnStage() )
814   {
815     return property;
816   }
817
818   // if its an actor default property or a custom property (actor already handles custom properties)
819   if( ( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) || ( index >= DEFAULT_PROPERTY_MAX_COUNT ) )
820   {
821     property = Actor::GetSceneObjectInputProperty(index);
822   }
823   else
824   {
825     switch( index )
826     {
827       case Dali::CameraActor::PROJECTION_MATRIX:
828       {
829         property = mCameraAttachment->GetProjectionMatrixProperty();
830         break;
831       }
832       case Dali::CameraActor::VIEW_MATRIX:
833       {
834         property = mCameraAttachment->GetViewMatrixProperty();
835         break;
836       }
837       default:
838         DALI_LOG_WARNING("Not an input property (%d)\n", index);
839         break;
840     }
841   }
842
843   return property;
844 }
845
846
847 } // namespace Internal
848
849 } // namespace Dali