[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / controls / model / model.h
index 39e7723..88bc524 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SCENE3D_MODEL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
  */
 
 // EXTERNAL INCLUDES
+#include <memory>
+
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/rendering/texture.h>
 
 // INTERNAL INCLUDES
+#include <dali-scene3d/public-api/algorithm/navigation-mesh.h>
 #include <dali-scene3d/public-api/api.h>
+#include <dali-scene3d/public-api/model-components/model-node.h>
+#include <dali-scene3d/public-api/model-motion/motion-data.h>
 
 namespace Dali
 {
@@ -51,6 +56,8 @@ class Model;
  *
  * By default, The loaded model has its own position and size which are defined in vertex buffer regardless of the Control size.
  *
+ * @note We support to render model well only if glsl version is higher than 300.
+ *
  * @SINCE_2_1.41
  * @code
  *
@@ -69,16 +76,21 @@ class Model;
 class DALI_SCENE3D_API Model : public Dali::Toolkit::Control
 {
 public:
+  // Typedefs
+  using MeshHitSignalType = Signal<bool(Model, Scene3D::ModelNode)>; ///< Mesh hit signal type @SINCE_2_2.53
+  using ColliderMeshPtr   = std::unique_ptr<Algorithm::NavigationMesh>;
+
   /**
    * @brief Create an initialized Model.
    *
    * @SINCE_2_1.41
    * @param[in] modelUrl model file path.(e.g., glTF, and DLI).
    * @param[in] resourceDirectoryUrl resource file path that includes binary, image etc.
+   * @note If modelUrl is empty, it will not load resouces. Only ModelRoot will be created.
    * @note If resourceDirectoryUrl is empty, the parent directory path of modelUrl is used for resource path.
    * @return A handle to a newly allocated Dali resource
    */
-  static Model New(const std::string& modelUrl, const std::string& resourceDirectoryUrl = std::string());
+  static Model New(const std::string& modelUrl = std::string(), const std::string& resourceDirectoryUrl = std::string());
 
   /**
    * @brief Creates an uninitialized Model.
@@ -113,7 +125,7 @@ public:
    * @SINCE_2_1.41
    * @param[in] rhs A reference to the moved handle
    */
-  Model(Model&& rhs);
+  Model(Model&& rhs) noexcept;
 
   /**
    * @brief Assignment operator.
@@ -131,7 +143,7 @@ public:
    * @param[in] rhs A reference to the moved handle
    * @return A reference to this
    */
-  Model& operator=(Model&& rhs);
+  Model& operator=(Model&& rhs) noexcept;
 
   /**
    * @brief Downcasts an Object handle to Model.
@@ -146,12 +158,29 @@ public:
   static Model DownCast(BaseHandle handle);
 
   /**
-   * @brief Retrieves model root Actor.
+   * @brief Retrieves model root Node.
    *
    * @SINCE_2_1.41
-   * @return Root Actor of the model.
+   * @return Root Node of the model.
+   */
+  const ModelNode GetModelRoot() const;
+
+  /**
+   * @brief Add new ModelNode to this Model.
+   * This modelNode will become child of ModelRoot.
+   *
+   * @SINCE_2_2.22
+   * @param[in] modelNode the root of ModelNode tree to be added.
    */
-  const Actor GetModelRoot() const;
+  void AddModelNode(ModelNode modelNode);
+
+  /**
+   * @brief Remove ModelNode from this Model.
+   *
+   * @SINCE_2_2.22
+   * @param[in] modelNode the root of ModelNode tree to be removed.
+   */
+  void RemoveModelNode(ModelNode modelNode);
 
   /**
    * @brief Whether allow this model's children actor to use events.
@@ -296,6 +325,112 @@ public:
    */
   bool ApplyCamera(uint32_t index, Dali::CameraActor camera) const;
 
+  /**
+   * @brief Returns a child ModelNode object with a name that matches nodeName.
+   *
+   * @SINCE_2_2.34
+   * @param[in] nodeName The name of the child ModelNode object you want to find.
+   * @return Returns a child ModelNode object with a name that matches nodeName. If there is no corresponding child ModelNode object, it returns an empty ModelNode object.
+   */
+  ModelNode FindChildModelNodeByName(std::string_view nodeName);
+
+  /**
+   * @brief Retrieves the list of blendshape name that current Model hold.
+   * The name will be appended end of input list.
+   *
+   * @SINCE_2_2.34
+   * @param[in, out] blendShapeNames The name of blendShape list collected.
+   * @note This method should be called after Model load finished.
+   */
+  void RetrieveBlendShapeNames(std::vector<std::string>& blendShapeNames) const;
+
+  /**
+   * @brief Retrieves the list of ModelNode that contains given blend shape name.
+   * The ModelNode will be appended end of input list.
+   *
+   * @SINCE_2_2.34
+   * @param[in] blendShapeName The name of blendShape that want to collect.
+   * @param[in, out] modelNodes The ModelNode list collected.
+   * @note This method should be called after Model load finished.
+   */
+  void RetrieveModelNodesByBlendShapeName(std::string_view blendShapeName, std::vector<ModelNode>& modelNodes) const;
+
+  /**
+   * @brief Generates specific animation of this Model by inputed MotionData.
+   *
+   * @SINCE_2_2.34
+   * @param[in] motionData the data of motion animation.
+   * @return Animation that be generated by MotionData. Or empty handle if there is no valid animation generated.
+   * @note This method should be called after Model load finished.
+   */
+  Dali::Animation GenerateMotionDataAnimation(MotionData motionData);
+
+  /**
+   * @brief Sets specific values of this Model by inputed MotionData.
+   * @note If MotionValue's ValueType is ValueType::KEY_FRAMES, the last value will be set.
+   *
+   * @SINCE_2_2.34
+   * @param[in] motionData the data of motion to be set.
+   * @note This method should be called after Model load finished.
+   */
+  void SetMotionData(Scene3D::MotionData motionData);
+
+  /**
+   * @brief Sets whether this Model casts shadow or not.
+   * If it is true, this model is drawn on Shadow Map.
+   *
+   * @SINCE_2_3.99
+   * @param[in] castShadow Whether this Model casts shadow or not.
+   * @note This method affects all of the child ModelNode.
+   * However, same property of each child ModelNode can be changed respectively and it not changes parent's property.
+   */
+  void CastShadow(bool castShadow);
+
+  /**
+   * @brief Retrieves whether the Model casts shadow or not for Light.
+   *
+   * @SINCE_2_3.99
+   * @return True if this model casts shadow.
+   * @note IBL does not cast any shadow.
+   */
+  bool IsShadowCasting() const;
+
+  /**
+   * @brief Sets whether this Model receives shadow or not.
+   * If it is true, shadows are drawn on this model.
+   *
+   * @SINCE_2_3.99
+   * @param[in] receiveShadow Whether this Model receives shadow or not.
+   * @note This method affects all of the child ModelNode.
+   * However, same property of each child ModelNode can be changed respectively and it not changes parent's property.
+   */
+  void ReceiveShadow(bool receiveShadow);
+
+  /**
+   * @brief Retrieves whether the Model receives shadow or not for Light.
+   *
+   * @SINCE_2_3.99
+   * @return True if this model receives shadow.
+   */
+  bool IsShadowReceiving() const;
+
+  /**
+   * @brief This signal is emitted when the collider mesh is touched/hit.
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   bool YourCallbackName(Model model, ModelNode modelNode);
+   * @endcode
+   * Here the model is the model that is hit and the ModelNode containing the collider mesh
+   * was applied to.
+   * The return value of True, indicates that the hover event should be consumed.
+   * Otherwise the signal will be emitted on the next sensitive parent of the actor.
+   *
+   * @SINCE_2_2.53
+   * @return The signal to connect to
+   */
+  MeshHitSignalType& MeshHitSignal();
+
 public: // Not intended for application developers
   /// @cond internal
   /**