[Tizen] Make some camera actor animatable & constraint input
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.h
index 4463ba1..3a20af0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_CAMERA_ACTOR_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // INTERNAL INCLUES
-#include <dali/public-api/actors/camera-actor.h>
-#include <dali/internal/event/actors/actor-impl.h>
+#include <dali/devel-api/actors/camera-actor-devel.h>
 #include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/actor-impl.h>
+#include <dali/public-api/actors/camera-actor.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace SceneGraph
 {
 class Camera;
@@ -40,17 +39,17 @@ class Camera;
 class CameraActor : public Actor
 {
 public:
-
   /**
    * Create an initialised camera actor.
    *
-   * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
+   * If hintFor3D is false, Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
    *
    * @param[in] size The canvas size.
+   * @param[in] hintFor3D True if user set hint that this camera used for 3D. Default is false.
    *
    * @return A smart-pointer to a newly allocated camera actor.
    */
-  static CameraActorPtr New( const Size& size );
+  static CameraActorPtr New(const Size& size, bool hintFor3D = false);
 
   /**
    * Sets the reflection plane for the camera
@@ -59,12 +58,12 @@ public:
    *
    * @note plane.xyz are normal vector of the plane.
    */
-  void SetReflectByPlane( const Vector4& plane );
+  void SetReflectByPlane(const Vector4& plane);
 
   /**
    * @copydoc Dali::CameraActor::SetTargetPosition
    */
-  void SetTarget( const Vector3& targetPosition );
+  void SetTarget(const Vector3& targetPosition);
 
   /**
    * @copydoc Dali::CameraActor::GetTargetPosition
@@ -74,7 +73,7 @@ public:
   /**
    * @copydoc Dali::CameraActor::SetType
    */
-  void SetType( Dali::Camera::Type type );
+  void SetType(Dali::Camera::Type type);
 
   /**
    * @copydoc Dali::CameraActor::GetType
@@ -84,7 +83,7 @@ public:
   /**
    * @copydoc Dali::CameraActor::SetProjectionMode
    */
-  void SetProjectionMode( Dali::Camera::ProjectionMode mode );
+  void SetProjectionMode(Dali::Camera::ProjectionMode mode);
 
   /**
    * @copydoc Dali::CameraActor::GetProjectionMode
@@ -92,9 +91,16 @@ public:
   Dali::Camera::ProjectionMode GetProjectionMode() const;
 
   /**
+   * @brief Set the projection direction
+   *
+   * @param[in] direction Direction of projection
+   */
+  void SetProjectionDirection(Dali::DevelCameraActor::ProjectionDirection direction);
+
+  /**
    * @copydoc Dali::CameraActor::SetFieldOfView
    */
-  void SetFieldOfView( float fieldOfView );
+  void SetFieldOfView(float fieldOfView);
 
   /**
    * @copydoc Dali::CameraActor::GetFieldOfView
@@ -102,9 +108,25 @@ public:
   float GetFieldOfView() const;
 
   /**
+   * @brief Sets the orthographic size.
+   * Orthographic size will be used when ProjectoinMode is ORTHOGRAPHIC_PROJECTION.
+   *
+   * @param[in] orthographicSize The orthographic size.
+   */
+  void SetOrthographicSize(float orthographicSize);
+
+  /**
+   * @brief Gets the orthographic size.
+   *
+   * The default orthographic size is 400.0f.
+   * @return The orthographic size.
+   */
+  float GetOrthographicSize() const;
+
+  /**
    * @copydoc Dali::CameraActor::SetAspectRatio
    */
-  void SetAspectRatio( float aspectRatio );
+  void SetAspectRatio(float aspectRatio);
 
   /**
    * @copydoc Dali::CameraActor::GetAspectRatio
@@ -114,7 +136,7 @@ public:
   /**
    * @copydoc Dali::CameraActor::SetNearClippingPlane
    */
-  void SetNearClippingPlane( float nearClippingPlane );
+  void SetNearClippingPlane(float nearClippingPlane);
 
   /**
    * @copydoc Dali::CameraActor::GetNearClippingPlane
@@ -124,7 +146,7 @@ public:
   /**
    * @copydoc Dali::CameraActor::SetFarClippingPlane
    */
-  void SetFarClippingPlane( float farClippingPlane );
+  void SetFarClippingPlane(float farClippingPlane);
 
   /**
    * @copydoc Dali::CameraActor::GetFarClippingPlane
@@ -132,29 +154,9 @@ public:
   float GetFarClippingPlane() const;
 
   /**
-   * @param leftClippingPlane to use
-   */
-  void SetLeftClippingPlane( float leftClippingPlane );
-
-  /**
-   * @param rightClippingPlane to use
-   */
-  void SetRightClippingPlane( float rightClippingPlane );
-
-  /**
-   * @param topClippingPlane to use
-   */
-  void SetTopClippingPlane( float topClippingPlane );
-
-  /**
-   * @param bottomClippingPlane to use
-   */
-  void SetBottomClippingPlane( float bottomClippingPlane );
-
-  /**
    * @copydoc Dali::CameraActor::SetInvertYAxis
    */
-  void SetInvertYAxis( bool invertYAxis );
+  void SetInvertYAxis(bool invertYAxis);
 
   /**
    * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
@@ -164,17 +166,12 @@ public:
   /**
    * @copydoc Dali::CameraActor::SetPerspectiveProjection()
    */
-  void SetPerspectiveProjection( const Size& size );
-
-  /**
-   * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
-   */
-  void SetOrthographicProjection( const Vector2& size );
+  void SetPerspectiveProjection(const Size& size);
 
   /**
-   * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
+   * @copydoc Dali::CameraActor::SetOrthographicProjection(const Size& size);
    */
-  void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
+  void SetOrthographicProjection(const Size& size);
 
   /**
    * Build a picking ray with this camera and given screen coordinates
@@ -184,7 +181,7 @@ public:
    * @param [out] rayDirection for the picking ray
    * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
    */
-  bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
+  bool BuildPickingRay(const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection);
 
   /**
    * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
@@ -199,75 +196,130 @@ public:
   const Matrix& GetProjectionMatrix() const;
 
   /**
-   * Return the scene graph camera (for RenderTask)
+   * Return the scene graph camera
    * @return The scene graph camera.
    */
-  const SceneGraph::Camera* GetCamera() const;
+  const SceneGraph::Camera& GetCameraSceneObject() const;
 
-public: // properties
+  /**
+   * Rotate the projection.
+   * It is used in case that the target buffer direction is different from the window direction.
+   * @param [in] rotationAngle The rotation angle
+   */
+  void RotateProjection(int rotationAngle);
 
+public: // properties
   /**
    * copydoc Dali::Internal::Object::SetDefaultProperty()
    */
-  void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) override;
+  void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
 
   /**
    * copydoc Dali::Internal::Object::GetDefaultProperty()
    */
-  Property::Value GetDefaultProperty( Property::Index index ) const override;
+  Property::Value GetDefaultProperty(Property::Index index) const override;
 
   /**
    * copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
    */
-  Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+  Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
+
+  /**
+   * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
+   */
+  void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
+
+  /**
+   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
+   */
+  const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
 
   /**
    * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
    */
-  const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
+  const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
 
 private:
-
   /**
    * Constructor; see also CameraActor::New()
    * @param node the scene graph node
    */
-  CameraActor( const SceneGraph::Node& node );
+  CameraActor(const SceneGraph::Node& node);
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
    */
   ~CameraActor() override;
 
+  /**
+   * @copydoc Dali::Internal::Actor::OnSceneConnectionInternal()
+   */
+  void OnSceneConnectionInternal() override;
 
   /**
-   * @copydoc Dali::Internal::Actor::OnInitialize()
+   * @copydoc Internal::Object::OnPropertySet
    */
-  void OnInitialize() override;
+  void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
 
   /**
-   * @copydoc Dali::Internal::Actor::OnSceneConnectionInternal()
+   * @brief Set the camera projection values with mCanvasSize
    */
-  void OnSceneConnectionInternal() override;
+  void ApplyDefaultProjection();
 
-private: // Data
+private:
+  /**
+   * @brief Retrieve the CameraActor's field of view from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetFieldOfView() if the set message hasn't been processed yet.
+   * @return The field of view.
+   */
+  float GetCurrentFieldOfView() const;
+
+  /**
+   * @brief Retrieve the CameraActor's orthographic size from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetOrthographicSize() if the set message hasn't been processed yet.
+   * @return The orthographic size.
+   */
+  float GetCurrentOrthographicSize() const;
+
+  /**
+   * @brief Retrieve the CameraActor's aspect ratio from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetAspectRatio() if the set message hasn't been processed yet.
+   * @return The aspect ratio.
+   */
+  float GetCurrentAspectRatio() const;
+
+  /**
+   * @brief Retrieve the CameraActor's near clipping plane distance from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetNearClippingPlane() if the set message hasn't been processed yet.
+   * @return Near clipping plane distance.
+   */
+  float GetCurrentNearClippingPlane() const;
 
-  const SceneGraph::Camera* mSceneObject; ///< Not owned
-
-  Vector3            mTarget;
-  Vector2            mCanvasSize;
-  Dali::Camera::Type mType;
-  Dali::Camera::ProjectionMode mProjectionMode;
-  float              mFieldOfView;
-  float              mAspectRatio;
-  float              mNearClippingPlane;
-  float              mFarClippingPlane;
-  float              mLeftClippingPlane;
-  float              mRightClippingPlane;
-  float              mTopClippingPlane;
-  float              mBottomClippingPlane;
-  bool               mInvertYAxis;
+  /**
+   * @brief Retrieve the CameraActor's far clipping plane distance from update side.
+   * This is either the last value set, or the currently animating value.
+   * It may be defferent to GetFarClippingPlane() if the set message hasn't been processed yet.
+   * @return Far clipping plane distance.
+   */
+  float GetCurrentFarClippingPlane() const;
 
+private: // Data
+  Vector3                                     mTarget;
+  Vector2                                     mCanvasSize;
+  Dali::Camera::Type                          mType;
+  Dali::Camera::ProjectionMode                mProjectionMode;
+  Dali::DevelCameraActor::ProjectionDirection mProjectionDirection;
+  float                                       mFieldOfView;
+  float                                       mOrthographicSize;
+  float                                       mAspectRatio;
+  float                                       mNearClippingPlane;
+  float                                       mFarClippingPlane;
+  bool                                        mInvertYAxis;
+  bool                                        mPropertyChanged;
 };
 
 } // namespace Internal