[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / navigation-mesh-factory.h
1 #ifndef DALI_SCENE3D_LOADER_NAVIGATION_MESH_FACTORY_H
2 #define DALI_SCENE3D_LOADER_NAVIGATION_MESH_FACTORY_H
3
4 /*
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/rendering/geometry.h>
22 #include <dali/public-api/rendering/texture.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-scene3d/public-api/algorithm/navigation-mesh.h>
26 #include <dali-scene3d/public-api/api.h>
27
28 namespace Dali::Scene3D::Loader
29 {
30 /**
31  * @brief Factory to create a NavigationMesh from various sources.
32  * @SINCE_2_2.12
33  */
34 struct DALI_SCENE3D_API NavigationMeshFactory
35 {
36 public:
37   /**
38    * @brief Creates NavigationMesh object from file
39    *
40    * @SINCE_2_2.12
41    * @param[in] filename file to load
42    * @return Valid NavigationMesh or nullptr
43    */
44   static std::unique_ptr<Algorithm::NavigationMesh> CreateFromFile(std::string filename);
45
46   /**
47    * @brief Creates NavigationMesh object from binary buffer
48    *
49    * @SINCE_2_2.12
50    * @param[in] buffer buffer with data
51    * @return Valid NavigationMesh or nullptr
52    */
53   static std::unique_ptr<Algorithm::NavigationMesh> CreateFromBuffer(const std::vector<uint8_t>& buffer);
54
55   /**
56    * @brief Creates new mesh from lists of vertices and faces
57    *
58    * List of faces contains indices into the vertex list
59    *
60    * @SINCE_2_2.53
61    * @param[in] vertices List of Vector3 vertices
62    * @param[in] vertexNormals List of Vector3 vertices
63    * @param[in] faceIndices List of faces
64    * @return Valid NavigationMesh or nullptr
65    */
66   static std::unique_ptr<Algorithm::NavigationMesh> CreateFromVertexFaceList(const std::vector<Vector3>& vertices, const std::vector<Vector3>& vertexNormals, const std::vector<uint32_t>& faceIndices);
67
68   /**
69    * @brief Creates new mesh from lists of vertices and faces
70    *
71    * List of faces contains indices into the vertex list
72    *
73    * This function reduces number of array copys when called from NUI.
74    *
75    * @SINCE_2_2.53
76    * @param[in] vertices Pointer to C-style array of vertices
77    * @param[in] vertexCount Number of vertices
78    * @param[in] vertexNormals to C-style array of vertex normals
79    * @param[in] faceIndices Pointer to C-style array of face elements indices
80    * @param[in] indexCount Number of indices
81    * @return Valid NavigationMesh or nullptr
82    */
83   static std::unique_ptr<Algorithm::NavigationMesh> CreateFromVertexFaceList(const Vector3* vertices, const Vector3* vertexNormals, uint32_t vertexCount, const uint32_t* faceIndices, uint32_t indexCount);
84
85   /**
86    * @brief Serializes mesh data to the binary format.
87    *
88    * The binary data returned by the function can be used
89    * as an input for NavigationMeshFactory::CreateFromBuffer()
90    *
91    * @SINCE_2_2.53
92    * @param[in] navigationMesh Navigation mesh to serialize
93    * @return Buffer containing serialized mesh data
94    */
95   static std::vector<uint8_t> GetMeshBinary(const Dali::Scene3D::Algorithm::NavigationMesh& navigationMesh);
96 };
97 } // namespace Dali::Scene3D::Loader
98
99 #endif // DALI_SCENE3D_INTERNAL_LOADER_NAVIGATION_MESH_FACTORY_H