2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/actors/camera-actor-impl.h>
23 #include <cstring> // for strcmp
26 #include <dali/devel-api/actors/camera-actor-devel.h>
27 #include <dali/internal/common/matrix-utils.h>
28 #include <dali/internal/event/common/projection.h>
29 #include <dali/internal/event/common/property-helper.h>
30 #include <dali/internal/event/common/thread-local-storage.h>
31 #include <dali/public-api/object/type-registry.h>
33 #include <dali/internal/update/common/property-base.h>
34 #include <dali/internal/update/manager/update-manager.h>
45 * We want to discourage the use of property strings (minimize string comparisons),
46 * particularly for the default properties.
47 * Name Type writable animatable constraint-input enum for index-checking
50 DALI_PROPERTY_TABLE_BEGIN
51 DALI_PROPERTY( "type", INTEGER, true, false, true, Dali::CameraActor::Property::TYPE )
52 DALI_PROPERTY( "projectionMode", INTEGER, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE )
53 DALI_PROPERTY( "fieldOfView", FLOAT, true, true, true, Dali::CameraActor::Property::FIELD_OF_VIEW )
54 DALI_PROPERTY( "aspectRatio", FLOAT, true, false, true, Dali::CameraActor::Property::ASPECT_RATIO )
55 DALI_PROPERTY( "nearPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE )
56 DALI_PROPERTY( "farPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE )
57 DALI_PROPERTY( "leftPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE )
58 DALI_PROPERTY( "rightPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE )
59 DALI_PROPERTY( "topPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE )
60 DALI_PROPERTY( "bottomPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE )
61 DALI_PROPERTY( "targetPosition", VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION )
62 DALI_PROPERTY( "projectionMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX )
63 DALI_PROPERTY( "viewMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX )
64 DALI_PROPERTY( "invertYAxis", BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS )
65 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
68 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
69 void CalculateClippingAndZ(float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ)
71 nearClippingPlane = std::max(width, height);
72 farClippingPlane = nearClippingPlane + static_cast<float>(0xFFFF >> 4);
73 cameraZ = 2.0f * nearClippingPlane;
78 return Dali::CameraActor::New();
81 TypeRegistration mType(typeid(Dali::CameraActor), typeid(Dali::Actor), Create, CameraDefaultProperties);
84 * Builds the picking ray in the world reference system from an orthographic camera
85 * The ray origin is the screen coordinate in the near plane translated to a parallel
86 * plane at the camera origin. The ray direction is the direction the camera is facing
87 * (i.e. Z=-1 in view space).
89 void BuildOrthoPickingRay(const Matrix& viewMatrix,
90 const Matrix& projectionMatrix,
91 const Viewport& viewport,
96 float nearPlaneDistance)
98 // inv( modelMatrix ) inv( viewMatrix ) inv( projectionMatrix ) normalize
99 // <----------------- <----------------- <-------------- <-------------
100 // Local World Camera Normalized Screen
101 // reference reference reference clip coordinates
102 // system system system coordinates
103 // -----------------> -----------------> --------------> ------------->
104 // modelMatrix viewMatrix projectionMatrix viewport
106 // Transforms the touch point from the screen reference system to the world reference system.
107 Matrix invViewProjection(false); // Don't initialize.
108 MatrixUtils::Multiply(invViewProjection, viewMatrix, projectionMatrix);
109 if(!invViewProjection.Invert())
111 DALI_ASSERT_DEBUG(false);
114 Vector4 near(screenX - static_cast<float>(viewport.x),
115 static_cast<float>(viewport.height) - (screenY - static_cast<float>(viewport.y)),
118 if(!Unproject(near, invViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), rayOrigin))
120 DALI_ASSERT_DEBUG(false);
123 Matrix invView = viewMatrix;
124 if(!invView.Invert())
126 DALI_ASSERT_DEBUG(false);
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);
132 // Vector pointing from the camera to the near plane
133 rayDir = cameraOrigin - nearPlaneOrigin;
141 CameraActorPtr CameraActor::New(const Size& size)
143 // create camera. Cameras are owned by the update manager
144 SceneGraph::Camera* camera = SceneGraph::Camera::New();
145 OwnerPointer<SceneGraph::Node> transferOwnership(camera);
146 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
148 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
150 // Send ownership of camera.
151 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
153 CameraActorPtr actor(new CameraActor(*camera));
155 // Second-phase construction
158 actor->SetName("DefaultCamera");
159 actor->SetPerspectiveProjection(size);
161 // By default Actors face in the positive Z direction in world space
162 // CameraActors should face in the negative Z direction, towards the other actors
163 actor->SetOrientation(Quaternion(Dali::ANGLE_180, Vector3::YAXIS));
168 CameraActor::CameraActor(const SceneGraph::Node& node)
169 : Actor(Actor::BASIC, node),
170 mTarget(SceneGraph::Camera::DEFAULT_TARGET_POSITION),
171 mType(SceneGraph::Camera::DEFAULT_TYPE),
172 mProjectionMode(SceneGraph::Camera::DEFAULT_MODE),
173 mProjectionDirection(SceneGraph::Camera::DEFAULT_PROJECTION_DIRECTION),
174 mFieldOfView(SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW),
175 mAspectRatio(SceneGraph::Camera::DEFAULT_ASPECT_RATIO),
176 mNearClippingPlane(SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE),
177 mFarClippingPlane(SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE),
178 mLeftClippingPlane(SceneGraph::Camera::DEFAULT_LEFT_CLIPPING_PLANE),
179 mRightClippingPlane(SceneGraph::Camera::DEFAULT_RIGHT_CLIPPING_PLANE),
180 mTopClippingPlane(SceneGraph::Camera::DEFAULT_TOP_CLIPPING_PLANE),
181 mBottomClippingPlane(SceneGraph::Camera::DEFAULT_BOTTOM_CLIPPING_PLANE),
182 mInvertYAxis(SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS),
183 mPropertyChanged(false)
187 CameraActor::~CameraActor()
191 void CameraActor::OnSceneConnectionInternal()
193 // If the canvas size has not been set, then use the size of the scene to which we've been added
194 // in order to set up the current projection
195 if(!mPropertyChanged && ((mCanvasSize.width < Math::MACHINE_EPSILON_1000) || (mCanvasSize.height < Math::MACHINE_EPSILON_1000)))
197 if(mProjectionMode == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
199 SetOrthographicProjection(GetScene().GetSize());
201 else //if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
203 SetPerspectiveProjection(GetScene().GetSize());
208 void CameraActor::SetReflectByPlane(const Vector4& plane)
210 SetReflectByPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), plane);
213 void CameraActor::SetTarget(const Vector3& target)
215 mPropertyChanged = true;
216 if(target != mTarget) // using range epsilon
220 SetTargetPositionMessage(GetEventThreadServices(), GetCameraSceneObject(), mTarget);
224 Vector3 CameraActor::GetTarget() const
229 void CameraActor::SetType(Dali::Camera::Type type)
235 // sceneObject is being used in a separate thread; queue a message to set
236 SetTypeMessage(GetEventThreadServices(), GetCameraSceneObject(), mType);
240 Dali::Camera::Type CameraActor::GetType() const
245 void CameraActor::SetProjectionMode(Dali::Camera::ProjectionMode mode)
247 if(mode != mProjectionMode)
249 mProjectionMode = mode;
251 // sceneObject is being used in a separate thread; queue a message to set
252 SetProjectionModeMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionMode);
256 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
258 return mProjectionMode;
261 void CameraActor::SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction)
263 mPropertyChanged = true;
264 if(direction != mProjectionDirection)
266 mProjectionDirection = direction;
268 // sceneObject is being used in a separate thread; queue a message to set
269 SetProjectionDirectionMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionDirection);
273 void CameraActor::SetFieldOfView(float fieldOfView)
275 mPropertyChanged = true;
276 if(!Equals(fieldOfView, mFieldOfView))
278 mFieldOfView = fieldOfView;
280 // sceneObject is being used in a separate thread; queue a message to set
281 BakeFieldOfViewMessage(GetEventThreadServices(), GetCameraSceneObject(), mFieldOfView);
285 float CameraActor::GetFieldOfView() const
290 float CameraActor::GetCurrentFieldOfView() const
292 // node is being used in a separate thread; copy the value from the previous update
293 return GetCameraSceneObject().GetFieldOfView(GetEventThreadServices().GetEventBufferIndex());
296 void CameraActor::SetAspectRatio(float aspectRatio)
298 mPropertyChanged = true;
299 if(!Equals(aspectRatio, mAspectRatio))
301 mAspectRatio = aspectRatio;
303 // sceneObject is being used in a separate thread; queue a message to set
304 SetAspectRatioMessage(GetEventThreadServices(), GetCameraSceneObject(), mAspectRatio);
308 float CameraActor::GetAspectRatio() const
313 void CameraActor::SetNearClippingPlane(float nearClippingPlane)
315 mPropertyChanged = true;
316 if(!Equals(nearClippingPlane, mNearClippingPlane))
318 mNearClippingPlane = nearClippingPlane;
320 // sceneObject is being used in a separate thread; queue a message to set
321 SetNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
325 float CameraActor::GetNearClippingPlane() const
327 return mNearClippingPlane;
330 void CameraActor::SetFarClippingPlane(float farClippingPlane)
332 mPropertyChanged = true;
333 if(!Equals(farClippingPlane, mFarClippingPlane))
335 mFarClippingPlane = farClippingPlane;
337 // sceneObject is being used in a separate thread; queue a message to set
338 SetFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
342 float CameraActor::GetFarClippingPlane() const
344 return mFarClippingPlane;
347 void CameraActor::SetLeftClippingPlane(float leftClippingPlane)
349 mPropertyChanged = true;
350 if(!Equals(leftClippingPlane, mLeftClippingPlane))
352 mLeftClippingPlane = leftClippingPlane;
354 // sceneObject is being used in a separate thread; queue a message to set
355 SetLeftClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mLeftClippingPlane);
359 void CameraActor::SetRightClippingPlane(float rightClippingPlane)
361 mPropertyChanged = true;
362 if(!Equals(rightClippingPlane, mRightClippingPlane))
364 mRightClippingPlane = rightClippingPlane;
366 // sceneObject is being used in a separate thread; queue a message to set
367 SetRightClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mRightClippingPlane);
371 void CameraActor::SetTopClippingPlane(float topClippingPlane)
373 mPropertyChanged = true;
374 if(!Equals(topClippingPlane, mTopClippingPlane))
376 mTopClippingPlane = topClippingPlane;
378 // sceneObject is being used in a separate thread; queue a message to set
379 SetTopClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mTopClippingPlane);
383 void CameraActor::SetBottomClippingPlane(float bottomClippingPlane)
385 mPropertyChanged = true;
386 if(!Equals(bottomClippingPlane, mBottomClippingPlane))
388 mBottomClippingPlane = bottomClippingPlane;
390 // sceneObject is being used in a separate thread; queue a message to set
391 SetBottomClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mBottomClippingPlane);
395 void CameraActor::SetInvertYAxis(bool invertYAxis)
397 if(invertYAxis != mInvertYAxis)
399 mInvertYAxis = invertYAxis;
401 // sceneObject is being used in a separate thread; queue a message to set
402 SetInvertYAxisMessage(GetEventThreadServices(), GetCameraSceneObject(), mInvertYAxis);
406 bool CameraActor::GetInvertYAxis() const
411 void CameraActor::SetPerspectiveProjection(const Size& size)
413 SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
416 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
418 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
421 // We've been added to a scene already, set the canvas size to the scene's size
422 mCanvasSize = GetScene().GetSize();
426 // We've not been added to a scene yet, so just return.
427 // We'll set the canvas size when we get added to a scene later
432 float width = mCanvasSize.width;
433 float height = mCanvasSize.height;
435 float nearClippingPlane;
436 float farClippingPlane;
438 CalculateClippingAndZ(width, height, nearClippingPlane, farClippingPlane, cameraZ);
440 // calculate the position of the camera to have the desired aspect ratio
441 const float fieldOfView = 2.0f * std::atan((mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? height : width) * 0.5f / cameraZ);
443 // unless it is too small, we want at least as much space to the back as we have torwards the front
444 const float minClippingFarPlane = 2.f * nearClippingPlane;
445 if(farClippingPlane < minClippingFarPlane)
447 farClippingPlane = minClippingFarPlane;
450 const float aspectRatio = width / height;
452 // sceneObject is being used in a separate thread; queue a message to set
453 SetFieldOfView(fieldOfView);
454 SetNearClippingPlane(nearClippingPlane);
455 SetFarClippingPlane(farClippingPlane);
456 SetLeftClippingPlane(width * -0.5f);
457 SetRightClippingPlane(width * 0.5f);
458 SetTopClippingPlane(height * 0.5f); // Top is +ve to keep consistency with orthographic values
459 SetBottomClippingPlane(height * -0.5f); // Bottom is -ve to keep consistency with orthographic values
460 SetAspectRatio(aspectRatio);
464 void CameraActor::SetOrthographicProjection(const Vector2& size)
466 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
469 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
471 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
474 // We've been added to a scene already, set the canvas size to the scene's size
475 mCanvasSize = GetScene().GetSize();
479 // We've not been added to a scene yet, so just return.
480 // We'll set the canvas size when we get added to a scene later
485 // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
486 float nearClippingPlane;
487 float farClippingPlane;
489 CalculateClippingAndZ(size.width, size.height, nearClippingPlane, farClippingPlane, cameraZ);
490 SetOrthographicProjection(-size.x * 0.5f, size.x * 0.5f, size.y * 0.5f, size.y * -0.5f, nearClippingPlane, farClippingPlane);
494 void CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
496 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
497 SetLeftClippingPlane(left);
498 SetRightClippingPlane(right);
499 SetTopClippingPlane(top);
500 SetBottomClippingPlane(bottom);
501 SetNearClippingPlane(near);
502 SetFarClippingPlane(far);
505 bool CameraActor::BuildPickingRay(const Vector2& screenCoordinates,
506 const Viewport& viewport,
508 Vector4& rayDirection)
511 if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
513 // Build a picking ray in the world reference system.
514 // ray starts from the camera world position
515 rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
518 // Transform the touch point from the screen coordinate system to the world coordinates system.
519 Vector4 near(screenCoordinates.x - static_cast<float>(viewport.x),
520 static_cast<float>(viewport.height) - (screenCoordinates.y - static_cast<float>(viewport.y)),
523 const Matrix& inverseViewProjection = GetCameraSceneObject().GetInverseViewProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
524 success = Unproject(near, inverseViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), near);
526 // Compute the ray's director vector.
527 rayDirection.x = near.x - rayOrigin.x;
528 rayDirection.y = near.y - rayOrigin.y;
529 rayDirection.z = near.z - rayOrigin.z;
530 rayDirection.Normalize();
531 rayDirection.w = 1.f;
535 float nearPlaneDistance = GetNearClippingPlane();
536 BuildOrthoPickingRay(GetViewMatrix(),
537 GetProjectionMatrix(),
549 const Matrix& CameraActor::GetViewMatrix() const
553 return GetCameraSceneObject().GetViewMatrix(GetEventThreadServices().GetEventBufferIndex());
557 return Matrix::IDENTITY;
561 const Matrix& CameraActor::GetProjectionMatrix() const
565 return GetCameraSceneObject().GetProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
569 return Matrix::IDENTITY;
572 const SceneGraph::Camera& CameraActor::GetCameraSceneObject() const
574 return static_cast<const SceneGraph::Camera&>(GetNode());
577 void CameraActor::RotateProjection(int rotationAngle)
579 // sceneObject is being used in a separate thread; queue a message to set
580 RotateProjectionMessage(GetEventThreadServices(), GetCameraSceneObject(), rotationAngle);
583 void CameraActor::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
585 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
587 Actor::SetDefaultProperty(index, propertyValue);
593 case Dali::CameraActor::Property::TYPE:
595 Dali::Camera::Type cameraType = Dali::Camera::Type(propertyValue.Get<int>());
599 case Dali::CameraActor::Property::PROJECTION_MODE:
601 Dali::Camera::ProjectionMode projectionMode = Dali::Camera::ProjectionMode(propertyValue.Get<int>());
602 SetProjectionMode(projectionMode);
605 case Dali::CameraActor::Property::FIELD_OF_VIEW:
607 SetFieldOfView(propertyValue.Get<float>()); // set to 0 in case property is not float
610 case Dali::CameraActor::Property::ASPECT_RATIO:
612 SetAspectRatio(propertyValue.Get<float>()); // set to 0 in case property is not float
615 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
617 SetNearClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
620 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
622 SetFarClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
625 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
627 SetLeftClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
630 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
632 SetRightClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
635 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
637 SetTopClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
640 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
642 SetBottomClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
645 case Dali::CameraActor::Property::TARGET_POSITION:
647 SetTarget(propertyValue.Get<Vector3>()); // set to 0 in case property is not Vector3
650 case Dali::CameraActor::Property::PROJECTION_MATRIX:
652 DALI_LOG_WARNING("projection-matrix is read-only\n");
655 case Dali::CameraActor::Property::VIEW_MATRIX:
657 DALI_LOG_WARNING("view-matrix is read-only\n");
660 case Dali::CameraActor::Property::INVERT_Y_AXIS:
662 SetInvertYAxis(propertyValue.Get<bool>()); // set to false in case property is not bool
665 case Dali::DevelCameraActor::Property::REFLECTION_PLANE:
667 SetReflectByPlane(propertyValue.Get<Vector4>());
670 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
672 Dali::DevelCameraActor::ProjectionDirection projectionDirection = Dali::DevelCameraActor::ProjectionDirection(propertyValue.Get<int>());
673 SetProjectionDirection(projectionDirection);
679 DALI_LOG_WARNING("Unknown property (%d)\n", index);
687 Property::Value CameraActor::GetDefaultProperty(Property::Index index) const
690 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
692 ret = Actor::GetDefaultProperty(index);
698 case Dali::CameraActor::Property::TYPE:
703 case Dali::CameraActor::Property::PROJECTION_MODE:
705 ret = mProjectionMode;
708 case Dali::CameraActor::Property::FIELD_OF_VIEW:
713 case Dali::CameraActor::Property::ASPECT_RATIO:
718 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
720 ret = mNearClippingPlane;
723 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
725 ret = mFarClippingPlane;
728 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
730 ret = mLeftClippingPlane;
733 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
735 ret = mRightClippingPlane;
738 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
740 ret = mTopClippingPlane;
743 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
745 ret = mBottomClippingPlane;
748 case Dali::CameraActor::Property::TARGET_POSITION:
753 case Dali::CameraActor::Property::PROJECTION_MATRIX:
755 ret = GetProjectionMatrix(); // Only on scene-graph
758 case Dali::CameraActor::Property::VIEW_MATRIX:
760 ret = GetViewMatrix(); // Only on scene-graph
763 case Dali::CameraActor::Property::INVERT_Y_AXIS:
768 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
770 ret = mProjectionDirection;
779 Property::Value CameraActor::GetDefaultPropertyCurrentValue(Property::Index index) const
782 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
784 ret = Actor::GetDefaultPropertyCurrentValue(index);
790 case Dali::CameraActor::Property::FIELD_OF_VIEW:
792 ret = GetCurrentFieldOfView();
797 ret = GetDefaultProperty(index); // Most are event-side properties, the scene-graph properties are only on the scene-graph
805 void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
807 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
809 Actor::OnNotifyDefaultPropertyAnimation(animation, index, value, animationType);
813 switch(animationType)
816 case Animation::BETWEEN:
820 case Dali::CameraActor::Property::FIELD_OF_VIEW:
822 value.Get(mFieldOfView);
832 case Dali::CameraActor::Property::FIELD_OF_VIEW:
834 AdjustValue<float>(mFieldOfView, value);
844 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty(Property::Index index) const
846 const SceneGraph::PropertyBase* property(nullptr);
849 case Dali::CameraActor::Property::FIELD_OF_VIEW:
851 property = GetCameraSceneObject().GetFieldOfView();
854 // no default on purpose as we chain method up to actor
858 // not our property, ask base
859 property = Actor::GetSceneObjectAnimatableProperty(index);
864 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Index index) const
866 const PropertyInputImpl* property(nullptr);
870 case Dali::CameraActor::Property::FIELD_OF_VIEW:
872 property = GetCameraSceneObject().GetFieldOfView();
875 case Dali::CameraActor::Property::PROJECTION_MATRIX:
877 property = GetCameraSceneObject().GetProjectionMatrix();
880 case Dali::CameraActor::Property::VIEW_MATRIX:
882 property = GetCameraSceneObject().GetViewMatrix();
885 // no default on purpose as we chain method up to actor
889 property = Actor::GetSceneObjectInputProperty(index);
895 void CameraActor::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
897 // If Position or Orientation are explicitly set, make mPropertyChanged flag true.
898 if(index == Dali::Actor::Property::POSITION ||
899 index == Dali::Actor::Property::POSITION_X ||
900 index == Dali::Actor::Property::POSITION_Y ||
901 index == Dali::Actor::Property::POSITION_Z ||
902 index == Dali::Actor::Property::ORIENTATION)
904 mPropertyChanged = true;
908 } // namespace Internal