1 #ifndef DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_H
2 #define DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 #include <dali-scene3d/public-api/api.h>
28 #include <dali-scene3d/public-api/model-components/material.h>
34 //Forward declarations.
38 } // namespace Internal
41 * @addtogroup dali_scene3d_model_components_model_primitive
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.
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.
56 class DALI_SCENE3D_API ModelPrimitive : public Dali::BaseHandle
58 public: // Creation & Destruction
60 * @brief Create an initialized ModelPrimitive.
63 * @return A handle to a newly allocated Dali resource
65 static ModelPrimitive New();
68 * @brief Creates an uninitialized ModelPrimitive.
70 * Only derived versions can be instantiated. Calling member
71 * functions with an uninitialized Dali::Object is not allowed.
80 * This is non-virtual since derived Handle types must not contain data or virtual methods.
87 * @brief Copy constructor.
90 * @param[in] modelPrimtive Handle to an object
92 ModelPrimitive(const ModelPrimitive& modelPrimtive);
95 * @brief Move constructor
98 * @param[in] rhs A reference to the moved handle
100 ModelPrimitive(ModelPrimitive&& rhs) noexcept;
103 * @brief Assignment operator.
106 * @param[in] modelPrimitive Handle to an object
107 * @return reference to this
109 ModelPrimitive& operator=(const ModelPrimitive& modelPrimitive);
112 * @brief Move assignment
115 * @param[in] rhs A reference to the moved handle
116 * @return A reference to this
118 ModelPrimitive& operator=(ModelPrimitive&& rhs) noexcept;
121 * @brief Downcasts an Object handle to ModelPrimitive.
123 * If handle points to a ModelPrimitive, the downcast produces valid handle.
124 * If not, the returned handle is left uninitialized.
127 * @param[in] handle Handle to an object
128 * @return Handle to a ModelPrimitive or an uninitialized handle
130 static ModelPrimitive DownCast(BaseHandle handle);
132 public: // Public Method
134 * @brief Set the geometry for this renderer.
137 * @param[in] geometry The geometry to set.
139 void SetGeometry(Dali::Geometry geometry);
142 * @brief Get the geometry for this renderer.
145 * @return The geometry for this renderer.
147 Dali::Geometry GetGeometry() const;
150 * @brief Sets the material for this primitive.
153 * @param[in] material The material
155 void SetMaterial(Material material);
158 * @brief Retrieves a material.
161 * @return The material handle
163 Material GetMaterial() const;
165 public: // Not intended for application developers
168 * @brief Creates a handle using the Scene3D::Internal implementation.
170 * @param[in] implementation The ModelPrimitive implementation
172 DALI_INTERNAL ModelPrimitive(Dali::Scene3D::Internal::ModelPrimitive* implementation);
180 } // namespace Scene3D
184 #endif // DALI_SCENE3D_MODEL_COMPONENTS_MODEL_PRIMITIVE_H