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