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