[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / model-components / model-primitive.h
1 #ifndef DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_H
2 #define DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/rendering/renderer.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-scene3d/public-api/api.h>
28 #include <dali-scene3d/public-api/model-components/material.h>
29
30 namespace Dali
31 {
32 namespace Scene3D
33 {
34 //Forward declarations.
35 namespace Internal
36 {
37 class ModelPrimitive;
38 } // namespace Internal
39
40 /**
41  * @addtogroup dali_scene3d_model_components_model_primitive
42  * @{
43  */
44
45 /**
46  * @brief This ModelPrimitive class is required to draw the mesh geometry defined by the user.
47  * Users can set Dali::Geometry and Material to ModelPrimitive using SetGeometry and SetMaterial methods respectively.
48  * When ModelPrimitive added to ModelNode using ModelNode::AddModelPrimitive() method, the Geometry is rendered on the screen according to the Material settings.
49  *
50  * @SINCE_2_2.22
51  *
52  * If you load resources from 3D format files such as glTF using Model class, ModelPrimitive is also created internally.
53  * In this case, blendShape morphing or skeletal animation defined in the format can be used.
54  * However, for the custom ModelPrimitive that is created by user, blendShape morphing or skeletal animation is not supported.
55  */
56 class DALI_SCENE3D_API ModelPrimitive : public Dali::BaseHandle
57 {
58 public: // Creation & Destruction
59   /**
60    * @brief Create an initialized ModelPrimitive.
61    *
62    * @SINCE_2_2.22
63    * @return A handle to a newly allocated Dali resource
64    */
65   static ModelPrimitive New();
66
67   /**
68    * @brief Creates an uninitialized ModelPrimitive.
69    *
70    * Only derived versions can be instantiated. Calling member
71    * functions with an uninitialized Dali::Object is not allowed.
72    *
73    * @SINCE_2_2.22
74    */
75   ModelPrimitive();
76
77   /**
78    * @brief Destructor.
79    *
80    * This is non-virtual since derived Handle types must not contain data or virtual methods.
81    *
82    * @SINCE_2_2.22
83    */
84   ~ModelPrimitive();
85
86   /**
87    * @brief Copy constructor.
88    *
89    * @SINCE_2_2.22
90    * @param[in] modelPrimtive Handle to an object
91    */
92   ModelPrimitive(const ModelPrimitive& modelPrimtive);
93
94   /**
95    * @brief Move constructor
96    *
97    * @SINCE_2_2.22
98    * @param[in] rhs A reference to the moved handle
99    */
100   ModelPrimitive(ModelPrimitive&& rhs) noexcept;
101
102   /**
103    * @brief Assignment operator.
104    *
105    * @SINCE_2_2.22
106    * @param[in] modelPrimitive Handle to an object
107    * @return reference to this
108    */
109   ModelPrimitive& operator=(const ModelPrimitive& modelPrimitive);
110
111   /**
112    * @brief Move assignment
113    *
114    * @SINCE_2_2.22
115    * @param[in] rhs A reference to the moved handle
116    * @return A reference to this
117    */
118   ModelPrimitive& operator=(ModelPrimitive&& rhs) noexcept;
119
120   /**
121    * @brief Downcasts an Object handle to ModelPrimitive.
122    *
123    * If handle points to a ModelPrimitive, the downcast produces valid handle.
124    * If not, the returned handle is left uninitialized.
125    *
126    * @SINCE_2_2.22
127    * @param[in] handle Handle to an object
128    * @return Handle to a ModelPrimitive or an uninitialized handle
129    */
130   static ModelPrimitive DownCast(BaseHandle handle);
131
132 public: // Public Method
133   /**
134    * @brief Set the geometry for this renderer.
135    *
136    * @SINCE_2_2.22
137    * @param[in] geometry The geometry to set.
138    */
139   void SetGeometry(Dali::Geometry geometry);
140
141   /**
142    * @brief Get the geometry for this renderer.
143    *
144    * @SINCE_2_2.22
145    * @return The geometry for this renderer.
146    */
147   Dali::Geometry GetGeometry() const;
148
149   /**
150    * @brief Sets the material for this primitive.
151    *
152    * @SINCE_2_2.22
153    * @param[in] material The material
154    */
155   void SetMaterial(Material material);
156
157   /**
158    * @brief Retrieves a material.
159    *
160    * @SINCE_2_2.22
161    * @return The material handle
162    */
163   Material GetMaterial() const;
164
165 public: // Not intended for application developers
166   /// @cond internal
167   /**
168    * @brief Creates a handle using the Scene3D::Internal implementation.
169    *
170    * @param[in] implementation The ModelPrimitive implementation
171    */
172   DALI_INTERNAL ModelPrimitive(Dali::Scene3D::Internal::ModelPrimitive* implementation);
173   /// @endcond
174 };
175
176 /**
177  * @}
178  */
179
180 } // namespace Scene3D
181
182 } // namespace Dali
183
184 #endif // DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_H