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/event/common/projection.h>
28 #include <dali/internal/event/common/property-helper.h>
29 #include <dali/internal/event/common/thread-local-storage.h>
30 #include <dali/public-api/object/type-registry.h>
32 #include <dali/internal/update/common/property-base.h>
33 #include <dali/internal/update/manager/update-manager.h>
44 * We want to discourage the use of property strings (minimize string comparisons),
45 * particularly for the default properties.
46 * Name Type writable animatable constraint-input enum for index-checking
49 DALI_PROPERTY_TABLE_BEGIN
50 DALI_PROPERTY( "type", INTEGER, true, false, true, Dali::CameraActor::Property::TYPE )
51 DALI_PROPERTY( "projectionMode", INTEGER, true, false, true, Dali::CameraActor::Property::PROJECTION_MODE )
52 DALI_PROPERTY( "fieldOfView", FLOAT, true, true, true, Dali::CameraActor::Property::FIELD_OF_VIEW )
53 DALI_PROPERTY( "aspectRatio", FLOAT, true, false, true, Dali::CameraActor::Property::ASPECT_RATIO )
54 DALI_PROPERTY( "nearPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::NEAR_PLANE_DISTANCE )
55 DALI_PROPERTY( "farPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::FAR_PLANE_DISTANCE )
56 DALI_PROPERTY( "leftPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::LEFT_PLANE_DISTANCE )
57 DALI_PROPERTY( "rightPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE )
58 DALI_PROPERTY( "topPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::TOP_PLANE_DISTANCE )
59 DALI_PROPERTY( "bottomPlaneDistance", FLOAT, true, false, true, Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE )
60 DALI_PROPERTY( "targetPosition", VECTOR3, true, false, true, Dali::CameraActor::Property::TARGET_POSITION )
61 DALI_PROPERTY( "projectionMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::PROJECTION_MATRIX )
62 DALI_PROPERTY( "viewMatrix", MATRIX, false, false, true, Dali::CameraActor::Property::VIEW_MATRIX )
63 DALI_PROPERTY( "invertYAxis", BOOLEAN, true, false, true, Dali::CameraActor::Property::INVERT_Y_AXIS )
64 DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, CameraDefaultProperties )
67 // calculate the far plane distance for a 16bit depth buffer with 4 bits per unit precision
68 void CalculateClippingAndZ(float width, float height, float& nearClippingPlane, float& farClippingPlane, float& cameraZ)
70 nearClippingPlane = std::max(width, height);
71 farClippingPlane = nearClippingPlane + static_cast<float>(0xFFFF >> 4);
72 cameraZ = 2.0f * nearClippingPlane;
77 return Dali::CameraActor::New();
80 TypeRegistration mType(typeid(Dali::CameraActor), typeid(Dali::Actor), Create, CameraDefaultProperties);
83 * Builds the picking ray in the world reference system from an orthographic camera
84 * The ray origin is the screen coordinate in the near plane translated to a parallel
85 * plane at the camera origin. The ray direction is the direction the camera is facing
86 * (i.e. Z=-1 in view space).
88 void BuildOrthoPickingRay(const Matrix& viewMatrix,
89 const Matrix& projectionMatrix,
90 const Viewport& viewport,
95 float nearPlaneDistance)
97 // inv( modelMatrix ) inv( viewMatrix ) inv( projectionMatrix ) normalize
98 // <----------------- <----------------- <-------------- <-------------
99 // Local World Camera Normalized Screen
100 // reference reference reference clip coordinates
101 // system system system coordinates
102 // -----------------> -----------------> --------------> ------------->
103 // modelMatrix viewMatrix projectionMatrix viewport
105 // Transforms the touch point from the screen reference system to the world reference system.
106 Matrix invViewProjection(false); // Don't initialize.
107 Matrix::Multiply(invViewProjection, viewMatrix, projectionMatrix);
108 if(!invViewProjection.Invert())
110 DALI_ASSERT_DEBUG(false);
113 Vector4 near(screenX - static_cast<float>(viewport.x),
114 static_cast<float>(viewport.height) - (screenY - static_cast<float>(viewport.y)),
117 if(!Unproject(near, invViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), rayOrigin))
119 DALI_ASSERT_DEBUG(false);
122 Matrix invView = viewMatrix;
123 if(!invView.Invert())
125 DALI_ASSERT_DEBUG(false);
128 Vector4 cameraOrigin = invView * Vector4(0.f, 0.f, 0.f, 1.f);
129 Vector4 nearPlaneOrigin = invView * Vector4(0.0f, 0.0f, -nearPlaneDistance, 1.0f);
131 // Vector pointing from the camera to the near plane
132 rayDir = cameraOrigin - nearPlaneOrigin;
140 CameraActorPtr CameraActor::New(const Size& size)
142 // create camera. Cameras are owned by the update manager
143 SceneGraph::Camera* camera = SceneGraph::Camera::New();
144 OwnerPointer<SceneGraph::Node> transferOwnership(camera);
145 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
147 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
149 // Send ownership of camera.
150 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
152 CameraActorPtr actor(new CameraActor(*camera));
154 // Second-phase construction
157 actor->SetName("DefaultCamera");
158 actor->SetPerspectiveProjection(size);
160 // By default Actors face in the positive Z direction in world space
161 // CameraActors should face in the negative Z direction, towards the other actors
162 actor->SetOrientation(Quaternion(Dali::ANGLE_180, Vector3::YAXIS));
167 CameraActor::CameraActor(const SceneGraph::Node& node)
168 : Actor(Actor::BASIC, node),
169 mTarget(SceneGraph::Camera::DEFAULT_TARGET_POSITION),
170 mType(SceneGraph::Camera::DEFAULT_TYPE),
171 mProjectionMode(SceneGraph::Camera::DEFAULT_MODE),
172 mProjectionDirection(SceneGraph::Camera::DEFAULT_PROJECTION_DIRECTION),
173 mFieldOfView(SceneGraph::Camera::DEFAULT_FIELD_OF_VIEW),
174 mAspectRatio(SceneGraph::Camera::DEFAULT_ASPECT_RATIO),
175 mNearClippingPlane(SceneGraph::Camera::DEFAULT_NEAR_CLIPPING_PLANE),
176 mFarClippingPlane(SceneGraph::Camera::DEFAULT_FAR_CLIPPING_PLANE),
177 mLeftClippingPlane(SceneGraph::Camera::DEFAULT_LEFT_CLIPPING_PLANE),
178 mRightClippingPlane(SceneGraph::Camera::DEFAULT_RIGHT_CLIPPING_PLANE),
179 mTopClippingPlane(SceneGraph::Camera::DEFAULT_TOP_CLIPPING_PLANE),
180 mBottomClippingPlane(SceneGraph::Camera::DEFAULT_BOTTOM_CLIPPING_PLANE),
181 mInvertYAxis(SceneGraph::Camera::DEFAULT_INVERT_Y_AXIS),
182 mPropertyChanged(false)
186 CameraActor::~CameraActor()
190 void CameraActor::OnSceneConnectionInternal()
192 // If the canvas size has not been set, then use the size of the scene to which we've been added
193 // in order to set up the current projection
194 if(!mPropertyChanged && ((mCanvasSize.width < Math::MACHINE_EPSILON_1000) || (mCanvasSize.height < Math::MACHINE_EPSILON_1000)))
196 if(mProjectionMode == Dali::Camera::ORTHOGRAPHIC_PROJECTION)
198 SetOrthographicProjection(GetScene().GetSize());
200 else //if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
202 SetPerspectiveProjection(GetScene().GetSize());
207 void CameraActor::SetReflectByPlane(const Vector4& plane)
209 SetReflectByPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), plane);
212 void CameraActor::SetTarget(const Vector3& target)
214 mPropertyChanged = true;
215 if(target != mTarget) // using range epsilon
219 SetTargetPositionMessage(GetEventThreadServices(), GetCameraSceneObject(), mTarget);
223 Vector3 CameraActor::GetTarget() const
228 void CameraActor::SetType(Dali::Camera::Type type)
234 // sceneObject is being used in a separate thread; queue a message to set
235 SetTypeMessage(GetEventThreadServices(), GetCameraSceneObject(), mType);
239 Dali::Camera::Type CameraActor::GetType() const
244 void CameraActor::SetProjectionMode(Dali::Camera::ProjectionMode mode)
246 if(mode != mProjectionMode)
248 mProjectionMode = mode;
250 // sceneObject is being used in a separate thread; queue a message to set
251 SetProjectionModeMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionMode);
255 Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const
257 return mProjectionMode;
260 void CameraActor::SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction)
262 mPropertyChanged = true;
263 if(direction != mProjectionDirection)
265 mProjectionDirection = direction;
267 // sceneObject is being used in a separate thread; queue a message to set
268 SetProjectionDirectionMessage(GetEventThreadServices(), GetCameraSceneObject(), mProjectionDirection);
272 void CameraActor::SetFieldOfView(float fieldOfView)
274 mPropertyChanged = true;
275 if(!Equals(fieldOfView, mFieldOfView))
277 mFieldOfView = fieldOfView;
279 // sceneObject is being used in a separate thread; queue a message to set
280 BakeFieldOfViewMessage(GetEventThreadServices(), GetCameraSceneObject(), mFieldOfView);
284 float CameraActor::GetFieldOfView() const
289 float CameraActor::GetCurrentFieldOfView() const
291 // node is being used in a separate thread; copy the value from the previous update
292 return GetCameraSceneObject().GetFieldOfView(GetEventThreadServices().GetEventBufferIndex());
295 void CameraActor::SetAspectRatio(float aspectRatio)
297 mPropertyChanged = true;
298 if(!Equals(aspectRatio, mAspectRatio))
300 mAspectRatio = aspectRatio;
302 // sceneObject is being used in a separate thread; queue a message to set
303 SetAspectRatioMessage(GetEventThreadServices(), GetCameraSceneObject(), mAspectRatio);
307 float CameraActor::GetAspectRatio() const
312 void CameraActor::SetNearClippingPlane(float nearClippingPlane)
314 mPropertyChanged = true;
315 if(!Equals(nearClippingPlane, mNearClippingPlane))
317 mNearClippingPlane = nearClippingPlane;
319 // sceneObject is being used in a separate thread; queue a message to set
320 SetNearClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mNearClippingPlane);
324 float CameraActor::GetNearClippingPlane() const
326 return mNearClippingPlane;
329 void CameraActor::SetFarClippingPlane(float farClippingPlane)
331 mPropertyChanged = true;
332 if(!Equals(farClippingPlane, mFarClippingPlane))
334 mFarClippingPlane = farClippingPlane;
336 // sceneObject is being used in a separate thread; queue a message to set
337 SetFarClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mFarClippingPlane);
341 float CameraActor::GetFarClippingPlane() const
343 return mFarClippingPlane;
346 void CameraActor::SetLeftClippingPlane(float leftClippingPlane)
348 mPropertyChanged = true;
349 if(!Equals(leftClippingPlane, mLeftClippingPlane))
351 mLeftClippingPlane = leftClippingPlane;
353 // sceneObject is being used in a separate thread; queue a message to set
354 SetLeftClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mLeftClippingPlane);
358 void CameraActor::SetRightClippingPlane(float rightClippingPlane)
360 mPropertyChanged = true;
361 if(!Equals(rightClippingPlane, mRightClippingPlane))
363 mRightClippingPlane = rightClippingPlane;
365 // sceneObject is being used in a separate thread; queue a message to set
366 SetRightClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mRightClippingPlane);
370 void CameraActor::SetTopClippingPlane(float topClippingPlane)
372 mPropertyChanged = true;
373 if(!Equals(topClippingPlane, mTopClippingPlane))
375 mTopClippingPlane = topClippingPlane;
377 // sceneObject is being used in a separate thread; queue a message to set
378 SetTopClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mTopClippingPlane);
382 void CameraActor::SetBottomClippingPlane(float bottomClippingPlane)
384 mPropertyChanged = true;
385 if(!Equals(bottomClippingPlane, mBottomClippingPlane))
387 mBottomClippingPlane = bottomClippingPlane;
389 // sceneObject is being used in a separate thread; queue a message to set
390 SetBottomClippingPlaneMessage(GetEventThreadServices(), GetCameraSceneObject(), mBottomClippingPlane);
394 void CameraActor::SetInvertYAxis(bool invertYAxis)
396 if(invertYAxis != mInvertYAxis)
398 mInvertYAxis = invertYAxis;
400 // sceneObject is being used in a separate thread; queue a message to set
401 SetInvertYAxisMessage(GetEventThreadServices(), GetCameraSceneObject(), mInvertYAxis);
405 bool CameraActor::GetInvertYAxis() const
410 void CameraActor::SetPerspectiveProjection(const Size& size)
412 SetProjectionMode(Dali::Camera::PERSPECTIVE_PROJECTION);
415 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
417 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
420 // We've been added to a scene already, set the canvas size to the scene's size
421 mCanvasSize = GetScene().GetSize();
425 // We've not been added to a scene yet, so just return.
426 // We'll set the canvas size when we get added to a scene later
431 float width = mCanvasSize.width;
432 float height = mCanvasSize.height;
434 float nearClippingPlane;
435 float farClippingPlane;
437 CalculateClippingAndZ(width, height, nearClippingPlane, farClippingPlane, cameraZ);
439 // calculate the position of the camera to have the desired aspect ratio
440 const float fieldOfView = 2.0f * std::atan((mProjectionDirection == DevelCameraActor::ProjectionDirection::VERTICAL ? height : width) * 0.5f / cameraZ);
442 // unless it is too small, we want at least as much space to the back as we have torwards the front
443 const float minClippingFarPlane = 2.f * nearClippingPlane;
444 if(farClippingPlane < minClippingFarPlane)
446 farClippingPlane = minClippingFarPlane;
449 const float aspectRatio = width / height;
451 // sceneObject is being used in a separate thread; queue a message to set
452 SetFieldOfView(fieldOfView);
453 SetNearClippingPlane(nearClippingPlane);
454 SetFarClippingPlane(farClippingPlane);
455 SetLeftClippingPlane(width * -0.5f);
456 SetRightClippingPlane(width * 0.5f);
457 SetTopClippingPlane(height * 0.5f); // Top is +ve to keep consistency with orthographic values
458 SetBottomClippingPlane(height * -0.5f); // Bottom is -ve to keep consistency with orthographic values
459 SetAspectRatio(aspectRatio);
463 void CameraActor::SetOrthographicProjection(const Vector2& size)
465 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
468 if((size.width < Math::MACHINE_EPSILON_1000) || (size.height < Math::MACHINE_EPSILON_1000))
470 // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
473 // We've been added to a scene already, set the canvas size to the scene's size
474 mCanvasSize = GetScene().GetSize();
478 // We've not been added to a scene yet, so just return.
479 // We'll set the canvas size when we get added to a scene later
484 // Choose near, far and Z parameters to match the SetPerspectiveProjection above.
485 float nearClippingPlane;
486 float farClippingPlane;
488 CalculateClippingAndZ(size.width, size.height, nearClippingPlane, farClippingPlane, cameraZ);
489 SetOrthographicProjection(-size.x * 0.5f, size.x * 0.5f, size.y * 0.5f, size.y * -0.5f, nearClippingPlane, farClippingPlane);
493 void CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
495 SetProjectionMode(Dali::Camera::ORTHOGRAPHIC_PROJECTION);
496 SetLeftClippingPlane(left);
497 SetRightClippingPlane(right);
498 SetTopClippingPlane(top);
499 SetBottomClippingPlane(bottom);
500 SetNearClippingPlane(near);
501 SetFarClippingPlane(far);
504 bool CameraActor::BuildPickingRay(const Vector2& screenCoordinates,
505 const Viewport& viewport,
507 Vector4& rayDirection)
510 if(mProjectionMode == Dali::Camera::PERSPECTIVE_PROJECTION)
512 // Build a picking ray in the world reference system.
513 // ray starts from the camera world position
514 rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
517 // Transform the touch point from the screen coordinate system to the world coordinates system.
518 Vector4 near(screenCoordinates.x - static_cast<float>(viewport.x),
519 static_cast<float>(viewport.height) - (screenCoordinates.y - static_cast<float>(viewport.y)),
522 const Matrix& inverseViewProjection = GetCameraSceneObject().GetInverseViewProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
523 success = Unproject(near, inverseViewProjection, static_cast<float>(viewport.width), static_cast<float>(viewport.height), near);
525 // Compute the ray's director vector.
526 rayDirection.x = near.x - rayOrigin.x;
527 rayDirection.y = near.y - rayOrigin.y;
528 rayDirection.z = near.z - rayOrigin.z;
529 rayDirection.Normalize();
530 rayDirection.w = 1.f;
534 float nearPlaneDistance = GetNearClippingPlane();
535 BuildOrthoPickingRay(GetViewMatrix(),
536 GetProjectionMatrix(),
548 const Matrix& CameraActor::GetViewMatrix() const
552 return GetCameraSceneObject().GetViewMatrix(GetEventThreadServices().GetEventBufferIndex());
556 return Matrix::IDENTITY;
560 const Matrix& CameraActor::GetProjectionMatrix() const
564 return GetCameraSceneObject().GetProjectionMatrix(GetEventThreadServices().GetEventBufferIndex());
568 return Matrix::IDENTITY;
571 const SceneGraph::Camera& CameraActor::GetCameraSceneObject() const
573 return static_cast<const SceneGraph::Camera&>(GetNode());
576 void CameraActor::RotateProjection(int rotationAngle)
578 // sceneObject is being used in a separate thread; queue a message to set
579 RotateProjectionMessage(GetEventThreadServices(), GetCameraSceneObject(), rotationAngle);
582 void CameraActor::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
584 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
586 Actor::SetDefaultProperty(index, propertyValue);
592 case Dali::CameraActor::Property::TYPE:
594 Dali::Camera::Type cameraType = Dali::Camera::Type(propertyValue.Get<int>());
598 case Dali::CameraActor::Property::PROJECTION_MODE:
600 Dali::Camera::ProjectionMode projectionMode = Dali::Camera::ProjectionMode(propertyValue.Get<int>());
601 SetProjectionMode(projectionMode);
604 case Dali::CameraActor::Property::FIELD_OF_VIEW:
606 SetFieldOfView(propertyValue.Get<float>()); // set to 0 in case property is not float
609 case Dali::CameraActor::Property::ASPECT_RATIO:
611 SetAspectRatio(propertyValue.Get<float>()); // set to 0 in case property is not float
614 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
616 SetNearClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
619 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
621 SetFarClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
624 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
626 SetLeftClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
629 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
631 SetRightClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
634 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
636 SetTopClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
639 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
641 SetBottomClippingPlane(propertyValue.Get<float>()); // set to 0 in case property is not float
644 case Dali::CameraActor::Property::TARGET_POSITION:
646 SetTarget(propertyValue.Get<Vector3>()); // set to 0 in case property is not Vector3
649 case Dali::CameraActor::Property::PROJECTION_MATRIX:
651 DALI_LOG_WARNING("projection-matrix is read-only\n");
654 case Dali::CameraActor::Property::VIEW_MATRIX:
656 DALI_LOG_WARNING("view-matrix is read-only\n");
659 case Dali::CameraActor::Property::INVERT_Y_AXIS:
661 SetInvertYAxis(propertyValue.Get<bool>()); // set to false in case property is not bool
664 case Dali::DevelCameraActor::Property::REFLECTION_PLANE:
666 SetReflectByPlane(propertyValue.Get<Vector4>());
669 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
671 Dali::DevelCameraActor::ProjectionDirection projectionDirection = Dali::DevelCameraActor::ProjectionDirection(propertyValue.Get<int>());
672 SetProjectionDirection(projectionDirection);
678 DALI_LOG_WARNING("Unknown property (%d)\n", index);
686 Property::Value CameraActor::GetDefaultProperty(Property::Index index) const
689 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
691 ret = Actor::GetDefaultProperty(index);
697 case Dali::CameraActor::Property::TYPE:
702 case Dali::CameraActor::Property::PROJECTION_MODE:
704 ret = mProjectionMode;
707 case Dali::CameraActor::Property::FIELD_OF_VIEW:
712 case Dali::CameraActor::Property::ASPECT_RATIO:
717 case Dali::CameraActor::Property::NEAR_PLANE_DISTANCE:
719 ret = mNearClippingPlane;
722 case Dali::CameraActor::Property::FAR_PLANE_DISTANCE:
724 ret = mFarClippingPlane;
727 case Dali::CameraActor::Property::LEFT_PLANE_DISTANCE:
729 ret = mLeftClippingPlane;
732 case Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE:
734 ret = mRightClippingPlane;
737 case Dali::CameraActor::Property::TOP_PLANE_DISTANCE:
739 ret = mTopClippingPlane;
742 case Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE:
744 ret = mBottomClippingPlane;
747 case Dali::CameraActor::Property::TARGET_POSITION:
752 case Dali::CameraActor::Property::PROJECTION_MATRIX:
754 ret = GetProjectionMatrix(); // Only on scene-graph
757 case Dali::CameraActor::Property::VIEW_MATRIX:
759 ret = GetViewMatrix(); // Only on scene-graph
762 case Dali::CameraActor::Property::INVERT_Y_AXIS:
767 case Dali::DevelCameraActor::Property::PROJECTION_DIRECTION:
769 ret = mProjectionDirection;
778 Property::Value CameraActor::GetDefaultPropertyCurrentValue(Property::Index index) const
781 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
783 ret = Actor::GetDefaultPropertyCurrentValue(index);
789 case Dali::CameraActor::Property::FIELD_OF_VIEW:
791 ret = GetCurrentFieldOfView();
796 ret = GetDefaultProperty(index); // Most are event-side properties, the scene-graph properties are only on the scene-graph
804 void CameraActor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
806 if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
808 Actor::OnNotifyDefaultPropertyAnimation(animation, index, value, animationType);
812 switch(animationType)
815 case Animation::BETWEEN:
819 case Dali::CameraActor::Property::FIELD_OF_VIEW:
821 value.Get(mFieldOfView);
831 case Dali::CameraActor::Property::FIELD_OF_VIEW:
833 AdjustValue<float>(mFieldOfView, value);
843 const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty(Property::Index index) const
845 const SceneGraph::PropertyBase* property(nullptr);
848 case Dali::CameraActor::Property::FIELD_OF_VIEW:
850 property = GetCameraSceneObject().GetFieldOfView();
853 // no default on purpose as we chain method up to actor
857 // not our property, ask base
858 property = Actor::GetSceneObjectAnimatableProperty(index);
863 const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty(Property::Index index) const
865 const PropertyInputImpl* property(nullptr);
869 case Dali::CameraActor::Property::FIELD_OF_VIEW:
871 property = GetCameraSceneObject().GetFieldOfView();
874 case Dali::CameraActor::Property::PROJECTION_MATRIX:
876 property = GetCameraSceneObject().GetProjectionMatrix();
879 case Dali::CameraActor::Property::VIEW_MATRIX:
881 property = GetCameraSceneObject().GetViewMatrix();
884 // no default on purpose as we chain method up to actor
888 property = Actor::GetSceneObjectInputProperty(index);
894 void CameraActor::OnPropertySet(Property::Index index, const Property::Value& propertyValue)
896 // If Position or Orientation are explicitly set, make mPropertyChanged flag true.
897 if(index == Dali::Actor::Property::POSITION ||
898 index == Dali::Actor::Property::POSITION_X ||
899 index == Dali::Actor::Property::POSITION_Y ||
900 index == Dali::Actor::Property::POSITION_Z ||
901 index == Dali::Actor::Property::ORIENTATION)
903 mPropertyChanged = true;
907 } // namespace Internal