1 #ifndef DALI_SCENE3D_MODEL_COMPONENTS_MODEL_NODE_H
2 #define DALI_SCENE3D_MODEL_COMPONENTS_MODEL_NODE_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/actors/custom-actor.h>
23 #include <dali/public-api/common/dali-common.h>
26 #include <dali-scene3d/public-api/api.h>
27 #include <dali-scene3d/public-api/loader/blend-shape-details.h> ///< For Loader::BlendShapes::Index
28 #include <dali-scene3d/public-api/model-components/model-primitive.h>
34 // Forward declarations.
41 * @addtogroup dali_scene3d_model_components_model_node
46 * @brief ModelNode is a class for representing the Node of Model in Scene3D.
47 * ModelNode contains multiple ModelPrimitives and allows easy access and modification of Material information that ModelPrimitive has.
48 * If a 3D format file is loaded by Model, ModelNode is created internally to construct the model.
49 * In addition, you can create a Custom ModelNode using ModelPrimitive and Material directly and add it to Model.
54 * ModelNode modelNode = ModelNode::New();
55 * ModelPrimitive modelPrimitive = ModelPrimitive::New();
56 * modelNode.AddModelPrimitive(modelPrimitive);
58 * Material material = Material::New();
59 * modelPrimitive.SetMaterial(material);
60 * material.SetProperty(PropertyIndex, PropertyValue);
63 class DALI_SCENE3D_API ModelNode : public Dali::CustomActor
67 * @brief Create an initialized ModelNode.
70 * @return A handle to a newly allocated Dali resource
72 static ModelNode New();
75 * @brief Creates an uninitialized ModelNode.
77 * Only derived versions can be instantiated. Calling member
78 * functions with an uninitialized Dali::Object is not allowed.
87 * This is non-virtual since derived Handle types must not contain data or virtual methods.
94 * @brief Copy constructor.
97 * @param[in] modelNode Handle to an object
99 ModelNode(const ModelNode& modelNode);
102 * @brief Move constructor
105 * @param[in] rhs A reference to the moved handle
107 ModelNode(ModelNode&& rhs) noexcept;
110 * @brief Assignment operator.
113 * @param[in] modelNode Handle to an object
114 * @return reference to this
116 ModelNode& operator=(const ModelNode& modelNode);
119 * @brief Move assignment
122 * @param[in] rhs A reference to the moved handle
123 * @return A reference to this
125 ModelNode& operator=(ModelNode&& rhs) noexcept;
128 * @brief Downcasts an Object handle to ModelNode.
130 * If handle points to a ModelNode, the downcast produces valid handle.
131 * If not, the returned handle is left uninitialized.
134 * @param[in] handle Handle to an object
135 * @return Handle to a ModelNode or an uninitialized handle
137 static ModelNode DownCast(BaseHandle handle);
139 public: // Public Method
141 * @brief Gets the number of ModelPrimitives this node has.
144 * @return The number of ModelPrimitives this node has.
146 uint32_t GetModelPrimitiveCount() const;
149 * @brief Appends a ModelPrimitive to this node.
152 * @param[in] modelPrimitive The ModelPrimitive to append.
154 void AddModelPrimitive(ModelPrimitive modelPrimitive);
157 * @brief Removes a ModelPrimitive from this node.
160 * @param[in] modelPrimitive The ModelPrimitive to remove.
162 void RemoveModelPrimitive(ModelPrimitive modelPrimitive);
165 * @brief Removes a ModelPrimitive from this node by index.
168 * @param[in] index The index of the ModelPrimitive to remove.
170 void RemoveModelPrimitive(uint32_t index);
173 * @brief Gets a ModelPrimitive by index.
176 * @param[in] index The index of the ModelPrimitive to get.
177 * @return The ModelPrimitive at the given index, or an empty handle if the index is out of range.
179 ModelPrimitive GetModelPrimitive(uint32_t index) const;
182 * @brief Returns a child ModelNode object with a name that matches nodeName.
185 * @param[in] nodeName The name of the child ModelNode object you want to find.
186 * @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.
188 ModelNode FindChildModelNodeByName(std::string_view nodeName);
191 * @brief Retrieve the list of blendshape name that current ModelNode hold.
192 * The name will be appended end of input list.
195 * @param[in, out] blendShapeNames The name of blendShape list collected.
197 void RetrieveBlendShapeNames(std::vector<std::string>& blendShapeNames) const;
200 * @brief Get the index of blend shape by given name.
203 * @param[in] blendShapeName The name of blendshape that is not empty.
204 * @return Index of blendshape, or return invalid if there is no blendshape with given name.
206 Loader::BlendShapes::Index GetBlendShapeIndexByName(std::string_view blendShapeName) const;
208 public: // Not intended for application developers
211 * @brief Creates a handle using the Scene3D::Internal implementation.
213 * @param[in] implementation The ModelNodel implementation
215 DALI_INTERNAL ModelNode(Internal::ModelNode& implementation);
218 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
220 * @param[in] internal A pointer to the internal CustomActor
222 DALI_INTERNAL ModelNode(Dali::Internal::CustomActor* internal);
229 } // namespace Scene3D
233 #endif // DALI_SCENE3D_MODEL_COMPONENTS_MODEL_NODE_H