[Tizen] Make some camera actor animatable & constraint input
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.h
index 6d0bb17..3a20af0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_CAMERA_ACTOR_H
 
 /*
- * Copyright (c) 2021 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.
@@ -19,6 +19,7 @@
  */
 
 // INTERNAL INCLUES
+#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>
@@ -41,13 +42,14 @@ 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
@@ -89,6 +91,13 @@ 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);
@@ -99,6 +108,22 @@ 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);
@@ -129,26 +154,6 @@ 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);
@@ -164,14 +169,9 @@ public:
   void SetPerspectiveProjection(const Size& size);
 
   /**
-   * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
+   * @copydoc Dali::CameraActor::SetOrthographicProjection(const Size& size);
    */
-  void SetOrthographicProjection(const Vector2& size);
-
-  /**
-   * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
-   */
-  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
@@ -196,10 +196,10 @@ 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;
 
   /**
    * Rotate the projection.
@@ -225,6 +225,16 @@ public: // properties
   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;
@@ -242,31 +252,74 @@ private:
   ~CameraActor() override;
 
   /**
-   * @copydoc Dali::Internal::Actor::OnInitialize()
+   * @copydoc Dali::Internal::Actor::OnSceneConnectionInternal()
+   */
+  void OnSceneConnectionInternal() override;
+
+  /**
+   * @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:
+  /**
+   * @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;
+
+  /**
+   * @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
-  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;
+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