2 * Copyright (c) 2023 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>
35 #include <dali/internal/update/render-tasks/scene-graph-camera-messages.h>
46 * We want to discourage the use of property strings (minimize string comparisons),
47 * particularly for the default properties.
48 * Name Type writable animatable constraint-input enum for index-checking
51 DALI_PROPERTY_TABLE_BEGIN
52 DALI_PROPERTY( "type", INTEGER, true, false, true, Dali::CameraActor::Property::TYPE )
53 DALI_PROPERTY( "projectionMode", INTEGER, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE )
54 DALI_PROPERTY( "fieldOfView", FLOAT, true, true, true, Dali::CameraActor::Property::FIELD_OF_VIEW )
55 DALI_PROPERTY( "aspectRatio", FLOAT, true, true, true, Dali::CameraActor::Property::ASPECT_RATIO )
56 DALI_PROPERTY( "nearPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE )
57 DALI_PROPERTY( "farPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE )
58 DALI_PROPERTY( "leftPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE )
59 DALI_PROPERTY( "rightPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE )
60 DALI_PROPERTY( "topPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE )
61 DALI_PROPERTY( "bottomPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE )
62 DALI_PROPERTY( "targetPosition", VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION )
63 DALI_PROPERTY( "projectionMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX )
64 DALI_PROPERTY( "viewMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX )
65 DALI_PROPERTY( "invertYAxis", BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS )
66 DALI_PROPERTY( "orthographicSize", FLOAT, true, true, true, Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE )
67 DALI_PROPERTY( "projectionDirection", INTEGER, true, false, true, Dali::DevelCameraActor::Property::PROJECTION_DIRECTION )
68 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
71 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
72 void CalculateClippingAndZ(float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ)
74 nearClippingPlane = std::max(width, height);
75 farClippingPlane = nearClippingPlane + static_cast<float>(0xFFFF >> 4);
76 cameraZ = 2.0f * nearClippingPlane;
81 return Dali::CameraActor::New();
84 TypeRegistration mType(typeid(Dali::CameraActor), typeid(Dali::Actor), Create, CameraDefaultProperties);
87 * Builds the picking ray in the world reference system from an orthographic camera
88 * The ray origin is the screen coordinate in the near plane translated to a parallel
89 * plane at the camera origin. The ray direction is the direction the camera is facing
90 * (i.e. Z=-1 in view space).
92 void BuildOrthoPickingRay(const Matrix& viewMatrix,
93 const Matrix& projectionMatrix,
94 const Viewport& viewport,
99 float nearPlaneDistance)
101 // inv( modelMatrix ) inv( viewMatrix ) inv( projectionMatrix ) normalize
102 // <----------------- <----------------- <-------------- <-------------
103 // Local World Camera Normalized Screen
104 // reference reference reference clip coordinates
105 // system system system coordinates
106 // -----------------> -----------------> --------------> ------------->
107 // modelMatrix viewMatrix projectionMatrix viewport
109 // Transforms the touch point from the screen reference system to the world reference system.
110 Matrix invViewProjection(false); // Don't initialize.
111 MatrixUtils::MultiplyProjectionMatrix(invViewProjection, viewMatrix, projectionMatrix);
112 if(!invViewProjection.Invert())
114 DALI_ASSERT_DEBUG(false);
117 Vector4 near(screenX - static_cast<float>(viewport.x),
118 static_cast<float>(viewport.height) - (screenY - static_cast<float>(viewport.y)),
121 if(!Unproject(near, invViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), rayOrigin))
123 DALI_ASSERT_DEBUG(false);
126 Matrix invView = viewMatrix;
127 if(!invView.Invert())
129 DALI_ASSERT_DEBUG(false);
132 Vector4 cameraOrigin = invView * Vector4(0.f, 0.f, 0.f, 1.f);
133 Vector4 nearPlaneOrigin = invView * Vector4(0.0f, 0.0f, -nearPlaneDistance, 1.0f);
135 // Vector pointing from the camera to the near plane
136 rayDir = cameraOrigin - nearPlaneOrigin;
143 * @brief Helper class to calculate left/right/top/bottom plane distance by orthographicSize and something other info.
144 * It will resolve some confuse case of plane distance value.
145 * (Something like, Is top plane distance is positive or negative? is aspect ratio is width/height or height/width?)
147 struct OrthographicSizeConverter
149 constexpr OrthographicSizeConverter(float orthographicSize, float aspectRatio, Dali::DevelCameraActor::ProjectionDirection projectionDirection)
150 : mOrthographicSize(orthographicSize),
151 mAspectRatio(aspectRatio),
152 mProjectionDirection(projectionDirection)
156 inline float LeftPlaneDistance() const
158 return -(mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize * mAspectRatio : mOrthographicSize);
161 inline float RightPlaneDistance() const
163 return (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize * mAspectRatio : mOrthographicSize);
166 inline float TopPlaneDistance() const
168 return (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize : mOrthographicSize / mAspectRatio);
171 inline float BottomPlaneDistance() const
173 return -(mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize : mOrthographicSize / mAspectRatio);
176 float mOrthographicSize;
178 Dali::DevelCameraActor::ProjectionDirection mProjectionDirection;
183 CameraActorPtr CameraActor::New(const Size& size)
185 // create camera. Cameras are owned by the update manager
186 SceneGraph::Camera* camera = SceneGraph::Camera::New();
187 OwnerPointer<SceneGraph::Node> transferOwnership(camera);
188 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
190 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
192 // Send ownership of camera.
193 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
195 CameraActorPtr actor(new CameraActor(*camera));
197 // Second-phase construction
200 actor->SetName("DefaultCamera");
201 actor->SetPerspectiveProjection(size);
203 // By default Actors face in the positive Z direction in world space
204 // CameraActors should face in the negative Z direction, towards the other actors
205 actor->SetOrientation(Quaternion(Dali::ANGLE_180, Vector3::YAXIS));
210 CameraActor::CameraActor(const SceneGraph::Node& node)
211 : Actor(Actor::BASIC, node),
212 mTarget(SceneGraph::Camera::DEFAULT_TARGET_POSITION),
213 mType(SceneGraph::Camera::DEFAULT_TYPE),
214 mProjectionMode(SceneGraph::Camera::DEFAULT_MODE),
215 mProjectionDirection(SceneGraph::Camera::DEFAULT_PROJECTION_DIRECTION),
216 mFieldOfView(SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW),
217 mOrthographicSize(SceneGraph::Camera::DEFAULT_ORTHOGRAPHIC_SIZE),
218 mAspectRatio(SceneGraph::Camera::DEFAULT_ASPECT_RATIO),
219 mNearClippingPlane(SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE),
220 mFarClippingPlane(SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE),
221 mInvertYAxis(SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS),
222 mPropertyChanged(false)
226 CameraActor::~CameraActor()
230 void CameraActor::OnSceneConnectionInternal()
232 // If the canvas size has not been set, then use the size of the scene to which we've been added
233 // in order to set up the current projection
234 if(!mPropertyChanged && ((mCanvasSize.width < Math::MACHINE_EPSILON_1000) || (mCanvasSize.height < Math::MACHINE_EPSILON_1000)))
236 if(mProjectionMode == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
238 SetOrthographicProjection(GetScene().GetSize());
240 else //if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
242 SetPerspectiveProjection(GetScene().GetSize());
247 void CameraActor::SetReflectByPlane(const Vector4& plane)
249 SetReflectByPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), plane);
252 void CameraActor::SetTarget(const Vector3& target)
254 mPropertyChanged = true;
255 if(target != mTarget) // using range epsilon
259 SetTargetPositionMessage(GetEventThreadServices(), GetCameraSceneObject(), mTarget);
263 Vector3 CameraActor::GetTarget() const
268 void CameraActor::SetType(Dali::Camera::Type type)
274 // sceneObject is being used in a separate thread; queue a message to set
275 SetTypeMessage(GetEventThreadServices(), GetCameraSceneObject(), mType);
279 Dali::Camera::Type CameraActor::GetType() const
284 void CameraActor::SetProjectionMode(Dali::Camera::ProjectionMode mode)
286 if(mode != mProjectionMode)
288 mProjectionMode = mode;
290 // sceneObject is being used in a separate thread; queue a message to set
291 SetProjectionModeMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionMode);
295 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
297 return mProjectionMode;
300 void CameraActor::SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction)
302 mPropertyChanged = true;
303 if(direction != mProjectionDirection)
305 mProjectionDirection = direction;
307 // sceneObject is being used in a separate thread; queue a message to set
308 SetProjectionDirectionMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionDirection);
312 void CameraActor::SetFieldOfView(float fieldOfView)
314 mPropertyChanged = true;
315 if(!Equals(fieldOfView, mFieldOfView))
317 mFieldOfView = fieldOfView;
319 // sceneObject is being used in a separate thread; queue a message to set
320 BakeFieldOfViewMessage(GetEventThreadServices(), GetCameraSceneObject(), mFieldOfView);
324 float CameraActor::GetFieldOfView() const
329 float CameraActor::GetCurrentFieldOfView() const
331 // node is being used in a separate thread; copy the value from the previous update
332 return GetCameraSceneObject().GetFieldOfView(GetEventThreadServices().GetEventBufferIndex());
335 void CameraActor::SetOrthographicSize(float orthographicSize)
337 mPropertyChanged = true;
338 if(!Equals(orthographicSize, mOrthographicSize))
340 mOrthographicSize = orthographicSize;
342 // sceneObject is being used in a separate thread; queue a message to set
343 BakeOrthographicSizeMessage(GetEventThreadServices(), GetCameraSceneObject(), mOrthographicSize);
347 float CameraActor::GetOrthographicSize() const
349 return mOrthographicSize;
352 float CameraActor::GetCurrentOrthographicSize() const
354 // node is being used in a separate thread; copy the value from the previous update
355 return GetCameraSceneObject().GetOrthographicSize(GetEventThreadServices().GetEventBufferIndex());
358 void CameraActor::SetAspectRatio(float aspectRatio)
360 mPropertyChanged = true;
361 if(!Equals(aspectRatio, mAspectRatio))
363 mAspectRatio = aspectRatio;
365 // sceneObject is being used in a separate thread; queue a message to set
366 BakeAspectRatioMessage(GetEventThreadServices(), GetCameraSceneObject(), mAspectRatio);
370 float CameraActor::GetAspectRatio() const
375 float CameraActor::GetCurrentAspectRatio() const
377 // node is being used in a separate thread; copy the value from the previous update
378 return GetCameraSceneObject().GetAspectRatio(GetEventThreadServices().GetEventBufferIndex());
381 void CameraActor::SetNearClippingPlane(float nearClippingPlane)
383 mPropertyChanged = true;
384 if(!Equals(nearClippingPlane, mNearClippingPlane))
386 mNearClippingPlane = nearClippingPlane;
388 // sceneObject is being used in a separate thread; queue a message to set
389 SetNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
393 float CameraActor::GetNearClippingPlane() const
395 return mNearClippingPlane;
398 void CameraActor::SetFarClippingPlane(float farClippingPlane)
400 mPropertyChanged = true;
401 if(!Equals(farClippingPlane, mFarClippingPlane))
403 mFarClippingPlane = farClippingPlane;
405 // sceneObject is being used in a separate thread; queue a message to set
406 SetFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
410 float CameraActor::GetFarClippingPlane() const
412 return mFarClippingPlane;
415 void CameraActor::SetInvertYAxis(bool invertYAxis)
417 if(invertYAxis != mInvertYAxis)
419 mInvertYAxis = invertYAxis;
421 // sceneObject is being used in a separate thread; queue a message to set
422 SetInvertYAxisMessage(GetEventThreadServices(), GetCameraSceneObject(), mInvertYAxis);
426 bool CameraActor::GetInvertYAxis() const
431 void CameraActor::SetPerspectiveProjection(const Size& size)
433 SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
434 mCanvasSize = static_cast<const Vector2>(size);
436 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
438 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
441 // We've been added to a scene already, set the canvas size to the scene's size
442 mCanvasSize = GetScene().GetSize();
446 // We've not been added to a scene yet, so just return.
447 // We'll set the canvas size when we get added to a scene later
451 ApplyDefaultProjection();
454 void CameraActor::SetOrthographicProjection(const Size& size)
456 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
457 mCanvasSize = static_cast<const Vector2>(size);
459 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
461 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
464 // We've been added to a scene already, set the canvas size to the scene's size
465 mCanvasSize = GetScene().GetSize();
469 // We've not been added to a scene yet, so just return.
470 // We'll set the canvas size when we get added to a scene later
475 ApplyDefaultProjection();
478 void CameraActor::ApplyDefaultProjection()
480 const float width = mCanvasSize.width;
481 const float height = mCanvasSize.height;
483 // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
484 float nearClippingPlane;
485 float farClippingPlane;
487 CalculateClippingAndZ(width, height, nearClippingPlane, farClippingPlane, cameraZ);
489 // calculate orthographic size.
490 const float orthographicSize = (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? height : width) * 0.5f;
492 // calculate the position of the camera to have the desired aspect ratio
493 const float fieldOfView = 2.0f * std::atan(orthographicSize / cameraZ);
495 // unless it is too small, we want at least as much space to the back as we have torwards the front
496 const float minClippingFarPlane = 2.f * nearClippingPlane;
497 if(farClippingPlane < minClippingFarPlane)
499 farClippingPlane = minClippingFarPlane;
502 const float aspectRatio = width / height;
504 // sceneObject is being used in a separate thread; queue a message to set
505 SetFieldOfView(fieldOfView);
506 SetNearClippingPlane(nearClippingPlane);
507 SetFarClippingPlane(farClippingPlane);
508 SetAspectRatio(aspectRatio);
509 SetOrthographicSize(orthographicSize);
513 bool CameraActor::BuildPickingRay(const Vector2& screenCoordinates,
514 const Viewport& viewport,
516 Vector4& rayDirection)
519 if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
521 // Build a picking ray in the world reference system.
522 // ray starts from the camera world position
523 rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
526 // Transform the touch point from the screen coordinate system to the world coordinates system.
527 Vector4 near(screenCoordinates.x - static_cast<float>(viewport.x),
528 static_cast<float>(viewport.height) - (screenCoordinates.y - static_cast<float>(viewport.y)),
531 const Matrix& inverseViewProjection = GetCameraSceneObject().GetInverseViewProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
532 success = Unproject(near, inverseViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), near);
534 // Compute the ray's director vector.
535 rayDirection.x = near.x - rayOrigin.x;
536 rayDirection.y = near.y - rayOrigin.y;
537 rayDirection.z = near.z - rayOrigin.z;
538 rayDirection.Normalize();
539 rayDirection.w = 1.f;
543 float nearPlaneDistance = GetNearClippingPlane();
544 BuildOrthoPickingRay(GetViewMatrix(),
545 GetProjectionMatrix(),
557 const Matrix& CameraActor::GetViewMatrix() const
561 return GetCameraSceneObject().GetViewMatrix(GetEventThreadServices().GetEventBufferIndex());
565 return Matrix::IDENTITY;
569 const Matrix& CameraActor::GetProjectionMatrix() const
573 return GetCameraSceneObject().GetProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
577 return Matrix::IDENTITY;
580 const SceneGraph::Camera& CameraActor::GetCameraSceneObject() const
582 return static_cast<const SceneGraph::Camera&>(GetNode());
585 void CameraActor::RotateProjection(int rotationAngle)
587 // sceneObject is being used in a separate thread; queue a message to set
588 RotateProjectionMessage(GetEventThreadServices(), GetCameraSceneObject(), rotationAngle);
591 void CameraActor::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
593 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
595 Actor::SetDefaultProperty(index, propertyValue);
601 case Dali::CameraActor::Property::TYPE:
603 Dali::Camera::Type cameraType = Dali::Camera::Type(propertyValue.Get<int>());
607 case Dali::CameraActor::Property::PROJECTION_MODE:
609 Dali::Camera::ProjectionMode projectionMode = Dali::Camera::ProjectionMode(propertyValue.Get<int>());
610 SetProjectionMode(projectionMode);
613 case Dali::CameraActor::Property::FIELD_OF_VIEW:
615 SetFieldOfView(propertyValue.Get<float>()); // set to 0 in case property is not float
618 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
620 SetOrthographicSize(propertyValue.Get<float>()); // set to 0 in case property is not float
623 case Dali::CameraActor::Property::ASPECT_RATIO:
625 SetAspectRatio(propertyValue.Get<float>()); // set to 0 in case property is not float
628 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
630 SetNearClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
633 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
635 SetFarClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
638 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
640 DALI_LOG_WARNING("LEFT_PLANE_DISTANCE is read-only\n");
643 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
645 DALI_LOG_WARNING("RIGHT_PLANE_DISTANCE is read-only\n");
648 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
650 DALI_LOG_WARNING("TOP_PLANE_DISTANCE is read-only\n");
653 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
655 DALI_LOG_WARNING("BOTTOM_PLANE_DISTANCE is read-only\n");
658 case Dali::CameraActor::Property::TARGET_POSITION:
660 SetTarget(propertyValue.Get<Vector3>()); // set to 0 in case property is not Vector3
663 case Dali::CameraActor::Property::PROJECTION_MATRIX:
665 DALI_LOG_WARNING("projection-matrix is read-only\n");
668 case Dali::CameraActor::Property::VIEW_MATRIX:
670 DALI_LOG_WARNING("view-matrix is read-only\n");
673 case Dali::CameraActor::Property::INVERT_Y_AXIS:
675 SetInvertYAxis(propertyValue.Get<bool>()); // set to false in case property is not bool
678 case Dali::DevelCameraActor::Property::REFLECTION_PLANE:
680 SetReflectByPlane(propertyValue.Get<Vector4>());
683 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
685 Dali::DevelCameraActor::ProjectionDirection projectionDirection = Dali::DevelCameraActor::ProjectionDirection(propertyValue.Get<int>());
686 SetProjectionDirection(projectionDirection);
692 DALI_LOG_WARNING("Unknown property (%d)\n", index);
700 Property::Value CameraActor::GetDefaultProperty(Property::Index index) const
703 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
705 ret = Actor::GetDefaultProperty(index);
711 case Dali::CameraActor::Property::TYPE:
716 case Dali::CameraActor::Property::PROJECTION_MODE:
718 ret = mProjectionMode;
721 case Dali::CameraActor::Property::FIELD_OF_VIEW:
726 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
728 ret = mOrthographicSize;
731 case Dali::CameraActor::Property::ASPECT_RATIO:
736 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
738 ret = mNearClippingPlane;
741 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
743 ret = mFarClippingPlane;
746 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
748 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).LeftPlaneDistance();
751 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
753 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).RightPlaneDistance();
756 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
758 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).TopPlaneDistance();
761 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
763 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).BottomPlaneDistance();
766 case Dali::CameraActor::Property::TARGET_POSITION:
771 case Dali::CameraActor::Property::PROJECTION_MATRIX:
773 ret = GetProjectionMatrix(); // Only on scene-graph
776 case Dali::CameraActor::Property::VIEW_MATRIX:
778 ret = GetViewMatrix(); // Only on scene-graph
781 case Dali::CameraActor::Property::INVERT_Y_AXIS:
786 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
788 ret = mProjectionDirection;
797 Property::Value CameraActor::GetDefaultPropertyCurrentValue(Property::Index index) const
800 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
802 ret = Actor::GetDefaultPropertyCurrentValue(index);
808 case Dali::CameraActor::Property::FIELD_OF_VIEW:
810 ret = GetCurrentFieldOfView();
813 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
815 ret = GetCurrentOrthographicSize();
818 case Dali::CameraActor::Property::ASPECT_RATIO:
820 ret = GetCurrentAspectRatio();
823 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
825 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).LeftPlaneDistance();
828 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
830 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).RightPlaneDistance();
833 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
835 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).TopPlaneDistance();
838 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
840 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).BottomPlaneDistance();
845 ret = GetDefaultProperty(index); // Most are event-side properties, the scene-graph properties are only on the scene-graph
853 void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
855 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
857 Actor::OnNotifyDefaultPropertyAnimation(animation, index, value, animationType);
861 switch(animationType)
864 case Animation::BETWEEN:
868 case Dali::CameraActor::Property::FIELD_OF_VIEW:
870 value.Get(mFieldOfView);
873 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
875 value.Get(mOrthographicSize);
878 case Dali::CameraActor::Property::ASPECT_RATIO:
880 value.Get(mAspectRatio);
890 case Dali::CameraActor::Property::FIELD_OF_VIEW:
892 AdjustValue<float>(mFieldOfView, value);
895 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
897 AdjustValue<float>(mOrthographicSize, value);
900 case Dali::CameraActor::Property::ASPECT_RATIO:
902 AdjustValue<float>(mAspectRatio, value);
912 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty(Property::Index index) const
914 const SceneGraph::PropertyBase* property(nullptr);
917 case Dali::CameraActor::Property::FIELD_OF_VIEW:
919 property = GetCameraSceneObject().GetFieldOfView();
922 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
924 property = GetCameraSceneObject().GetOrthographicSize();
927 case Dali::CameraActor::Property::ASPECT_RATIO:
929 property = GetCameraSceneObject().GetAspectRatio();
932 // no default on purpose as we chain method up to actor
936 // not our property, ask base
937 property = Actor::GetSceneObjectAnimatableProperty(index);
943 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Index index) const
945 const PropertyInputImpl* property(nullptr);
949 case Dali::CameraActor::Property::FIELD_OF_VIEW:
951 property = GetCameraSceneObject().GetFieldOfView();
954 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
956 property = GetCameraSceneObject().GetOrthographicSize();
959 case Dali::CameraActor::Property::ASPECT_RATIO:
961 property = GetCameraSceneObject().GetAspectRatio();
964 case Dali::CameraActor::Property::PROJECTION_MATRIX:
966 property = GetCameraSceneObject().GetProjectionMatrix();
969 case Dali::CameraActor::Property::VIEW_MATRIX:
971 property = GetCameraSceneObject().GetViewMatrix();
974 // no default on purpose as we chain method up to actor
978 property = Actor::GetSceneObjectInputProperty(index);
984 void CameraActor::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
986 // If Position or Orientation are explicitly set, make mPropertyChanged flag true.
987 if(index == Dali::Actor::Property::POSITION ||
988 index == Dali::Actor::Property::POSITION_X ||
989 index == Dali::Actor::Property::POSITION_Y ||
990 index == Dali::Actor::Property::POSITION_Z ||
991 index == Dali::Actor::Property::ORIENTATION)
993 mPropertyChanged = true;
997 } // namespace Internal