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>
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, true, 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, false, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE )
58 DALI_PROPERTY( "rightPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE )
59 DALI_PROPERTY( "topPlaneDistance", FLOAT, false, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE )
60 DALI_PROPERTY( "bottomPlaneDistance", FLOAT, false, 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( "orthographicSize", FLOAT, true, true, true, Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE )
66 DALI_PROPERTY( "projectionDirection", INTEGER, true, false, true, Dali::DevelCameraActor::Property::PROJECTION_DIRECTION )
67 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
70 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
71 void CalculateClippingAndZ(float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ)
73 nearClippingPlane = std::max(width, height);
74 farClippingPlane = nearClippingPlane + static_cast<float>(0xFFFF >> 4);
75 cameraZ = 2.0f * nearClippingPlane;
80 return Dali::CameraActor::New();
83 TypeRegistration mType(typeid(Dali::CameraActor), typeid(Dali::Actor), Create, CameraDefaultProperties);
86 * Builds the picking ray in the world reference system from an orthographic camera
87 * The ray origin is the screen coordinate in the near plane translated to a parallel
88 * plane at the camera origin. The ray direction is the direction the camera is facing
89 * (i.e. Z=-1 in view space).
91 void BuildOrthoPickingRay(const Matrix& viewMatrix,
92 const Matrix& projectionMatrix,
93 const Viewport& viewport,
98 float nearPlaneDistance)
100 // inv( modelMatrix ) inv( viewMatrix ) inv( projectionMatrix ) normalize
101 // <----------------- <----------------- <-------------- <-------------
102 // Local World Camera Normalized Screen
103 // reference reference reference clip coordinates
104 // system system system coordinates
105 // -----------------> -----------------> --------------> ------------->
106 // modelMatrix viewMatrix projectionMatrix viewport
108 // Transforms the touch point from the screen reference system to the world reference system.
109 Matrix invViewProjection(false); // Don't initialize.
110 MatrixUtils::MultiplyProjectionMatrix(invViewProjection, viewMatrix, projectionMatrix);
111 if(!invViewProjection.Invert())
113 DALI_ASSERT_DEBUG(false);
116 Vector4 near(screenX - static_cast<float>(viewport.x),
117 static_cast<float>(viewport.height) - (screenY - static_cast<float>(viewport.y)),
120 if(!Unproject(near, invViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), rayOrigin))
122 DALI_ASSERT_DEBUG(false);
125 Matrix invView = viewMatrix;
126 if(!invView.Invert())
128 DALI_ASSERT_DEBUG(false);
131 Vector4 cameraOrigin = invView * Vector4(0.f, 0.f, 0.f, 1.f);
132 Vector4 nearPlaneOrigin = invView * Vector4(0.0f, 0.0f, -nearPlaneDistance, 1.0f);
134 // Vector pointing from the camera to the near plane
135 rayDir = cameraOrigin - nearPlaneOrigin;
142 * @brief Helper class to calculate left/right/top/bottom plane distance by orthographicSize and something other info.
143 * It will resolve some confuse case of plane distance value.
144 * (Something like, Is top plane distance is positive or negative? is aspect ratio is width/height or height/width?)
146 struct OrthographicSizeConverter
148 constexpr OrthographicSizeConverter(float orthographicSize, float aspectRatio, Dali::DevelCameraActor::ProjectionDirection projectionDirection)
149 : mOrthographicSize(orthographicSize),
150 mAspectRatio(aspectRatio),
151 mProjectionDirection(projectionDirection)
155 inline float LeftPlaneDistance() const
157 return -(mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize * mAspectRatio : mOrthographicSize);
160 inline float RightPlaneDistance() const
162 return (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize * mAspectRatio : mOrthographicSize);
165 inline float TopPlaneDistance() const
167 return (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize : mOrthographicSize / mAspectRatio);
170 inline float BottomPlaneDistance() const
172 return -(mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? mOrthographicSize : mOrthographicSize / mAspectRatio);
175 float mOrthographicSize;
177 Dali::DevelCameraActor::ProjectionDirection mProjectionDirection;
182 CameraActorPtr CameraActor::New(const Size& size)
184 // create camera. Cameras are owned by the update manager
185 SceneGraph::Camera* camera = SceneGraph::Camera::New();
186 OwnerPointer<SceneGraph::Node> transferOwnership(camera);
187 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
189 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
191 // Send ownership of camera.
192 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
194 CameraActorPtr actor(new CameraActor(*camera));
196 // Second-phase construction
199 actor->SetName("DefaultCamera");
200 actor->SetPerspectiveProjection(size);
202 // By default Actors face in the positive Z direction in world space
203 // CameraActors should face in the negative Z direction, towards the other actors
204 actor->SetOrientation(Quaternion(Dali::ANGLE_180, Vector3::YAXIS));
209 CameraActor::CameraActor(const SceneGraph::Node& node)
210 : Actor(Actor::BASIC, node),
211 mTarget(SceneGraph::Camera::DEFAULT_TARGET_POSITION),
212 mType(SceneGraph::Camera::DEFAULT_TYPE),
213 mProjectionMode(SceneGraph::Camera::DEFAULT_MODE),
214 mProjectionDirection(SceneGraph::Camera::DEFAULT_PROJECTION_DIRECTION),
215 mFieldOfView(SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW),
216 mOrthographicSize(SceneGraph::Camera::DEFAULT_ORTHOGRAPHIC_SIZE),
217 mAspectRatio(SceneGraph::Camera::DEFAULT_ASPECT_RATIO),
218 mNearClippingPlane(SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE),
219 mFarClippingPlane(SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE),
220 mInvertYAxis(SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS),
221 mPropertyChanged(false)
225 CameraActor::~CameraActor()
229 void CameraActor::OnSceneConnectionInternal()
231 // If the canvas size has not been set, then use the size of the scene to which we've been added
232 // in order to set up the current projection
233 if(!mPropertyChanged && ((mCanvasSize.width < Math::MACHINE_EPSILON_1000) || (mCanvasSize.height < Math::MACHINE_EPSILON_1000)))
235 if(mProjectionMode == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
237 SetOrthographicProjection(GetScene().GetSize());
239 else //if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
241 SetPerspectiveProjection(GetScene().GetSize());
246 void CameraActor::SetReflectByPlane(const Vector4& plane)
248 SetReflectByPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), plane);
251 void CameraActor::SetTarget(const Vector3& target)
253 mPropertyChanged = true;
254 if(target != mTarget) // using range epsilon
258 SetTargetPositionMessage(GetEventThreadServices(), GetCameraSceneObject(), mTarget);
262 Vector3 CameraActor::GetTarget() const
267 void CameraActor::SetType(Dali::Camera::Type type)
273 // sceneObject is being used in a separate thread; queue a message to set
274 SetTypeMessage(GetEventThreadServices(), GetCameraSceneObject(), mType);
278 Dali::Camera::Type CameraActor::GetType() const
283 void CameraActor::SetProjectionMode(Dali::Camera::ProjectionMode mode)
285 if(mode != mProjectionMode)
287 mProjectionMode = mode;
289 // sceneObject is being used in a separate thread; queue a message to set
290 SetProjectionModeMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionMode);
294 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
296 return mProjectionMode;
299 void CameraActor::SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction)
301 mPropertyChanged = true;
302 if(direction != mProjectionDirection)
304 mProjectionDirection = direction;
306 // sceneObject is being used in a separate thread; queue a message to set
307 SetProjectionDirectionMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionDirection);
311 void CameraActor::SetFieldOfView(float fieldOfView)
313 mPropertyChanged = true;
314 if(!Equals(fieldOfView, mFieldOfView))
316 mFieldOfView = fieldOfView;
318 // sceneObject is being used in a separate thread; queue a message to set
319 BakeFieldOfViewMessage(GetEventThreadServices(), GetCameraSceneObject(), mFieldOfView);
323 float CameraActor::GetFieldOfView() const
328 float CameraActor::GetCurrentFieldOfView() const
330 // node is being used in a separate thread; copy the value from the previous update
331 return GetCameraSceneObject().GetFieldOfView(GetEventThreadServices().GetEventBufferIndex());
334 void CameraActor::SetOrthographicSize(float orthographicSize)
336 mPropertyChanged = true;
337 if(!Equals(orthographicSize, mOrthographicSize))
339 mOrthographicSize = orthographicSize;
341 // sceneObject is being used in a separate thread; queue a message to set
342 BakeOrthographicSizeMessage(GetEventThreadServices(), GetCameraSceneObject(), mOrthographicSize);
346 float CameraActor::GetOrthographicSize() const
348 return mOrthographicSize;
351 float CameraActor::GetCurrentOrthographicSize() const
353 // node is being used in a separate thread; copy the value from the previous update
354 return GetCameraSceneObject().GetOrthographicSize(GetEventThreadServices().GetEventBufferIndex());
357 void CameraActor::SetAspectRatio(float aspectRatio)
359 mPropertyChanged = true;
360 if(!Equals(aspectRatio, mAspectRatio))
362 mAspectRatio = aspectRatio;
364 // sceneObject is being used in a separate thread; queue a message to set
365 BakeAspectRatioMessage(GetEventThreadServices(), GetCameraSceneObject(), mAspectRatio);
369 float CameraActor::GetAspectRatio() const
374 float CameraActor::GetCurrentAspectRatio() const
376 // node is being used in a separate thread; copy the value from the previous update
377 return GetCameraSceneObject().GetAspectRatio(GetEventThreadServices().GetEventBufferIndex());
380 void CameraActor::SetNearClippingPlane(float nearClippingPlane)
382 mPropertyChanged = true;
383 if(!Equals(nearClippingPlane, mNearClippingPlane))
385 mNearClippingPlane = nearClippingPlane;
387 // sceneObject is being used in a separate thread; queue a message to set
388 SetNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
392 float CameraActor::GetNearClippingPlane() const
394 return mNearClippingPlane;
397 void CameraActor::SetFarClippingPlane(float farClippingPlane)
399 mPropertyChanged = true;
400 if(!Equals(farClippingPlane, mFarClippingPlane))
402 mFarClippingPlane = farClippingPlane;
404 // sceneObject is being used in a separate thread; queue a message to set
405 SetFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
409 float CameraActor::GetFarClippingPlane() const
411 return mFarClippingPlane;
414 void CameraActor::SetInvertYAxis(bool invertYAxis)
416 if(invertYAxis != mInvertYAxis)
418 mInvertYAxis = invertYAxis;
420 // sceneObject is being used in a separate thread; queue a message to set
421 SetInvertYAxisMessage(GetEventThreadServices(), GetCameraSceneObject(), mInvertYAxis);
425 bool CameraActor::GetInvertYAxis() const
430 void CameraActor::SetPerspectiveProjection(const Size& size)
432 SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
433 mCanvasSize = static_cast<const Vector2>(size);
435 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
437 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
440 // We've been added to a scene already, set the canvas size to the scene's size
441 mCanvasSize = GetScene().GetSize();
445 // We've not been added to a scene yet, so just return.
446 // We'll set the canvas size when we get added to a scene later
450 ApplyDefaultProjection();
453 void CameraActor::SetOrthographicProjection(const Size& size)
455 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
456 mCanvasSize = static_cast<const Vector2>(size);
458 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
460 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
463 // We've been added to a scene already, set the canvas size to the scene's size
464 mCanvasSize = GetScene().GetSize();
468 // We've not been added to a scene yet, so just return.
469 // We'll set the canvas size when we get added to a scene later
474 ApplyDefaultProjection();
477 void CameraActor::ApplyDefaultProjection()
479 const float width = mCanvasSize.width;
480 const float height = mCanvasSize.height;
482 // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
483 float nearClippingPlane;
484 float farClippingPlane;
486 CalculateClippingAndZ(width, height, nearClippingPlane, farClippingPlane, cameraZ);
488 // calculate orthographic size.
489 const float orthographicSize = (mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? height : width) * 0.5f;
491 // calculate the position of the camera to have the desired aspect ratio
492 const float fieldOfView = 2.0f * std::atan(orthographicSize / cameraZ);
494 // unless it is too small, we want at least as much space to the back as we have torwards the front
495 const float minClippingFarPlane = 2.f * nearClippingPlane;
496 if(farClippingPlane < minClippingFarPlane)
498 farClippingPlane = minClippingFarPlane;
501 const float aspectRatio = width / height;
503 // sceneObject is being used in a separate thread; queue a message to set
504 SetFieldOfView(fieldOfView);
505 SetNearClippingPlane(nearClippingPlane);
506 SetFarClippingPlane(farClippingPlane);
507 SetAspectRatio(aspectRatio);
508 SetOrthographicSize(orthographicSize);
512 bool CameraActor::BuildPickingRay(const Vector2& screenCoordinates,
513 const Viewport& viewport,
515 Vector4& rayDirection)
518 if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
520 // Build a picking ray in the world reference system.
521 // ray starts from the camera world position
522 rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
525 // Transform the touch point from the screen coordinate system to the world coordinates system.
526 Vector4 near(screenCoordinates.x - static_cast<float>(viewport.x),
527 static_cast<float>(viewport.height) - (screenCoordinates.y - static_cast<float>(viewport.y)),
530 const Matrix& inverseViewProjection = GetCameraSceneObject().GetInverseViewProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
531 success = Unproject(near, inverseViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), near);
533 // Compute the ray's director vector.
534 rayDirection.x = near.x - rayOrigin.x;
535 rayDirection.y = near.y - rayOrigin.y;
536 rayDirection.z = near.z - rayOrigin.z;
537 rayDirection.Normalize();
538 rayDirection.w = 1.f;
542 float nearPlaneDistance = GetNearClippingPlane();
543 BuildOrthoPickingRay(GetViewMatrix(),
544 GetProjectionMatrix(),
556 const Matrix& CameraActor::GetViewMatrix() const
560 return GetCameraSceneObject().GetViewMatrix(GetEventThreadServices().GetEventBufferIndex());
564 return Matrix::IDENTITY;
568 const Matrix& CameraActor::GetProjectionMatrix() const
572 return GetCameraSceneObject().GetProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
576 return Matrix::IDENTITY;
579 const SceneGraph::Camera& CameraActor::GetCameraSceneObject() const
581 return static_cast<const SceneGraph::Camera&>(GetNode());
584 void CameraActor::RotateProjection(int rotationAngle)
586 // sceneObject is being used in a separate thread; queue a message to set
587 RotateProjectionMessage(GetEventThreadServices(), GetCameraSceneObject(), rotationAngle);
590 void CameraActor::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
592 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
594 Actor::SetDefaultProperty(index, propertyValue);
600 case Dali::CameraActor::Property::TYPE:
602 Dali::Camera::Type cameraType = Dali::Camera::Type(propertyValue.Get<int>());
606 case Dali::CameraActor::Property::PROJECTION_MODE:
608 Dali::Camera::ProjectionMode projectionMode = Dali::Camera::ProjectionMode(propertyValue.Get<int>());
609 SetProjectionMode(projectionMode);
612 case Dali::CameraActor::Property::FIELD_OF_VIEW:
614 SetFieldOfView(propertyValue.Get<float>()); // set to 0 in case property is not float
617 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
619 SetOrthographicSize(propertyValue.Get<float>()); // set to 0 in case property is not float
622 case Dali::CameraActor::Property::ASPECT_RATIO:
624 SetAspectRatio(propertyValue.Get<float>()); // set to 0 in case property is not float
627 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
629 SetNearClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
632 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
634 SetFarClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
637 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
639 DALI_LOG_WARNING("LEFT_PLANE_DISTANCE is read-only\n");
642 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
644 DALI_LOG_WARNING("RIGHT_PLANE_DISTANCE is read-only\n");
647 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
649 DALI_LOG_WARNING("TOP_PLANE_DISTANCE is read-only\n");
652 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
654 DALI_LOG_WARNING("BOTTOM_PLANE_DISTANCE is read-only\n");
657 case Dali::CameraActor::Property::TARGET_POSITION:
659 SetTarget(propertyValue.Get<Vector3>()); // set to 0 in case property is not Vector3
662 case Dali::CameraActor::Property::PROJECTION_MATRIX:
664 DALI_LOG_WARNING("projection-matrix is read-only\n");
667 case Dali::CameraActor::Property::VIEW_MATRIX:
669 DALI_LOG_WARNING("view-matrix is read-only\n");
672 case Dali::CameraActor::Property::INVERT_Y_AXIS:
674 SetInvertYAxis(propertyValue.Get<bool>()); // set to false in case property is not bool
677 case Dali::DevelCameraActor::Property::REFLECTION_PLANE:
679 SetReflectByPlane(propertyValue.Get<Vector4>());
682 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
684 Dali::DevelCameraActor::ProjectionDirection projectionDirection = Dali::DevelCameraActor::ProjectionDirection(propertyValue.Get<int>());
685 SetProjectionDirection(projectionDirection);
691 DALI_LOG_WARNING("Unknown property (%d)\n", index);
699 Property::Value CameraActor::GetDefaultProperty(Property::Index index) const
702 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
704 ret = Actor::GetDefaultProperty(index);
710 case Dali::CameraActor::Property::TYPE:
715 case Dali::CameraActor::Property::PROJECTION_MODE:
717 ret = mProjectionMode;
720 case Dali::CameraActor::Property::FIELD_OF_VIEW:
725 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
727 ret = mOrthographicSize;
730 case Dali::CameraActor::Property::ASPECT_RATIO:
735 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
737 ret = mNearClippingPlane;
740 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
742 ret = mFarClippingPlane;
745 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
747 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).LeftPlaneDistance();
750 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
752 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).RightPlaneDistance();
755 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
757 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).TopPlaneDistance();
760 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
762 ret = OrthographicSizeConverter(mOrthographicSize, mAspectRatio, mProjectionDirection).BottomPlaneDistance();
765 case Dali::CameraActor::Property::TARGET_POSITION:
770 case Dali::CameraActor::Property::PROJECTION_MATRIX:
772 ret = GetProjectionMatrix(); // Only on scene-graph
775 case Dali::CameraActor::Property::VIEW_MATRIX:
777 ret = GetViewMatrix(); // Only on scene-graph
780 case Dali::CameraActor::Property::INVERT_Y_AXIS:
785 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
787 ret = mProjectionDirection;
796 Property::Value CameraActor::GetDefaultPropertyCurrentValue(Property::Index index) const
799 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
801 ret = Actor::GetDefaultPropertyCurrentValue(index);
807 case Dali::CameraActor::Property::FIELD_OF_VIEW:
809 ret = GetCurrentFieldOfView();
812 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
814 ret = GetCurrentOrthographicSize();
817 case Dali::CameraActor::Property::ASPECT_RATIO:
819 ret = GetCurrentAspectRatio();
822 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
824 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).LeftPlaneDistance();
827 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
829 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).RightPlaneDistance();
832 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
834 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).TopPlaneDistance();
837 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
839 ret = OrthographicSizeConverter(GetCurrentOrthographicSize(), GetCurrentAspectRatio(), mProjectionDirection).BottomPlaneDistance();
844 ret = GetDefaultProperty(index); // Most are event-side properties, the scene-graph properties are only on the scene-graph
852 void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
854 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
856 Actor::OnNotifyDefaultPropertyAnimation(animation, index, value, animationType);
860 switch(animationType)
863 case Animation::BETWEEN:
867 case Dali::CameraActor::Property::FIELD_OF_VIEW:
869 value.Get(mFieldOfView);
872 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
874 value.Get(mOrthographicSize);
877 case Dali::CameraActor::Property::ASPECT_RATIO:
879 value.Get(mAspectRatio);
889 case Dali::CameraActor::Property::FIELD_OF_VIEW:
891 AdjustValue<float>(mFieldOfView, value);
894 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
896 AdjustValue<float>(mOrthographicSize, value);
899 case Dali::CameraActor::Property::ASPECT_RATIO:
901 AdjustValue<float>(mAspectRatio, value);
911 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty(Property::Index index) const
913 const SceneGraph::PropertyBase* property(nullptr);
916 case Dali::CameraActor::Property::FIELD_OF_VIEW:
918 property = GetCameraSceneObject().GetFieldOfView();
921 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
923 property = GetCameraSceneObject().GetOrthographicSize();
926 case Dali::CameraActor::Property::ASPECT_RATIO:
928 property = GetCameraSceneObject().GetAspectRatio();
931 // no default on purpose as we chain method up to actor
935 // not our property, ask base
936 property = Actor::GetSceneObjectAnimatableProperty(index);
942 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Index index) const
944 const PropertyInputImpl* property(nullptr);
948 case Dali::CameraActor::Property::FIELD_OF_VIEW:
950 property = GetCameraSceneObject().GetFieldOfView();
953 case Dali::DevelCameraActor::Property::ORTHOGRAPHIC_SIZE:
955 property = GetCameraSceneObject().GetOrthographicSize();
958 case Dali::CameraActor::Property::ASPECT_RATIO:
960 property = GetCameraSceneObject().GetAspectRatio();
963 case Dali::CameraActor::Property::PROJECTION_MATRIX:
965 property = GetCameraSceneObject().GetProjectionMatrix();
968 case Dali::CameraActor::Property::VIEW_MATRIX:
970 property = GetCameraSceneObject().GetViewMatrix();
973 // no default on purpose as we chain method up to actor
977 property = Actor::GetSceneObjectInputProperty(index);
983 void CameraActor::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
985 // If Position or Orientation are explicitly set, make mPropertyChanged flag true.
986 if(index == Dali::Actor::Property::POSITION ||
987 index == Dali::Actor::Property::POSITION_X ||
988 index == Dali::Actor::Property::POSITION_Y ||
989 index == Dali::Actor::Property::POSITION_Z ||
990 index == Dali::Actor::Property::ORIENTATION)
992 mPropertyChanged = true;
996 } // namespace Internal