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/model-components/model-primitive.h>
33 // Forward declarations.
40 * @addtogroup dali_scene3d_model_components_model_node
45 * @brief ModelNode is a class for representing the Node of Model in Scene3D.
46 * ModelNode contains multiple ModelPrimitives and allows easy access and modification of Material information that ModelPrimitive has.
47 * If a 3D format file is loaded by Model, ModelNode is created internally to construct the model.
48 * In addition, you can create a Custom ModelNode using ModelPrimitive and Material directly and add it to Model.
53 * ModelNode modelNode = ModelNode::New();
54 * ModelPrimitive modelPrimitive = ModelPrimitive::New();
55 * modelNode.AddModelPrimitive(modelPrimitive);
57 * Material material = Material::New();
58 * modelPrimitive.SetMaterial(material);
59 * material.SetProperty(PropertyIndex, PropertyValue);
62 class DALI_SCENE3D_API ModelNode : public Dali::CustomActor
66 * @brief Create an initialized ModelNode.
69 * @return A handle to a newly allocated Dali resource
71 static ModelNode New();
74 * @brief Creates an uninitialized ModelNode.
76 * Only derived versions can be instantiated. Calling member
77 * functions with an uninitialized Dali::Object is not allowed.
86 * This is non-virtual since derived Handle types must not contain data or virtual methods.
93 * @brief Copy constructor.
96 * @param[in] modelNode Handle to an object
98 ModelNode(const ModelNode& modelNode);
101 * @brief Move constructor
104 * @param[in] rhs A reference to the moved handle
106 ModelNode(ModelNode&& rhs);
109 * @brief Assignment operator.
112 * @param[in] modelNode Handle to an object
113 * @return reference to this
115 ModelNode& operator=(const ModelNode& modelNode);
118 * @brief Move assignment
121 * @param[in] rhs A reference to the moved handle
122 * @return A reference to this
124 ModelNode& operator=(ModelNode&& rhs);
127 * @brief Downcasts an Object handle to ModelNode.
129 * If handle points to a ModelNode, the downcast produces valid handle.
130 * If not, the returned handle is left uninitialized.
133 * @param[in] handle Handle to an object
134 * @return Handle to a ModelNode or an uninitialized handle
136 static ModelNode DownCast(BaseHandle handle);
138 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.
184 * @param[in] nodeName The name of the child ModelNode object you want to find.
185 * @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.
187 ModelNode FindChildModelNodeByName(std::string_view nodeName);
189 public: // Not intended for application developers
192 * @brief Creates a handle using the Scene3D::Internal implementation.
194 * @param[in] implementation The ModelNodel implementation
196 DALI_INTERNAL ModelNode(Internal::ModelNode& implementation);
199 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
201 * @param[in] internal A pointer to the internal CustomActor
203 DALI_INTERNAL ModelNode(Dali::Internal::CustomActor* internal);
210 } // namespace Scene3D
214 #endif // DALI_SCENE3D_MODEL_COMPONENTS_MODEL_NODE_H