2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/public-api/model-components/model-node.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/actors/custom-actor.h>
26 #include <dali-scene3d/internal/model-components/model-node-impl.h>
32 ModelNode ModelNode::New()
34 return Scene3D::Internal::ModelNode::New();
37 ModelNode::ModelNode()
41 ModelNode::ModelNode(const ModelNode& modelNode) = default;
43 ModelNode::ModelNode(ModelNode&& rhs) noexcept = default;
45 ModelNode::~ModelNode()
49 ModelNode& ModelNode::operator=(const ModelNode& handle) = default;
51 ModelNode& ModelNode::operator=(ModelNode&& rhs) noexcept = default;
53 ModelNode ModelNode::DownCast(BaseHandle handle)
57 CustomActor custom = Dali::CustomActor::DownCast(handle);
60 CustomActorImpl& customImpl = custom.GetImplementation();
62 Internal::ModelNode* impl = dynamic_cast<Internal::ModelNode*>(&customImpl);
66 result = ModelNode(customImpl.GetOwner());
73 ModelNode::ModelNode(Internal::ModelNode& implementation)
74 : Control(implementation)
78 ModelNode::ModelNode(Dali::Internal::CustomActor* internal)
81 // Can have a NULL pointer so we only need to check if the internal implementation is our class
82 // when there is a value.
85 DALI_ASSERT_DEBUG(dynamic_cast<Internal::ModelNode*>(&CustomActor(internal).GetImplementation()));
91 uint32_t ModelNode::GetModelPrimitiveCount() const
93 return Internal::GetImplementation(*this).GetModelPrimitiveCount();
96 void ModelNode::AddModelPrimitive(ModelPrimitive modelPrimitive)
98 Internal::GetImplementation(*this).AddModelPrimitive(modelPrimitive, 0u);
101 void ModelNode::RemoveModelPrimitive(Dali::Scene3D::ModelPrimitive modelPrimitive)
103 Internal::GetImplementation(*this).RemoveModelPrimitive(modelPrimitive);
106 void ModelNode::RemoveModelPrimitive(uint32_t index)
108 Internal::GetImplementation(*this).RemoveModelPrimitive(index);
111 ModelPrimitive ModelNode::GetModelPrimitive(uint32_t index) const
113 return Internal::GetImplementation(*this).GetModelPrimitive(index);
116 ModelNode ModelNode::FindChildModelNodeByName(std::string_view nodeName)
118 return Internal::GetImplementation(*this).FindChildModelNodeByName(nodeName);
121 void ModelNode::RetrieveBlendShapeNames(std::vector<std::string>& blendShapeNames) const
123 return Internal::GetImplementation(*this).RetrieveBlendShapeNames(blendShapeNames);
126 Loader::BlendShapes::Index ModelNode::GetBlendShapeIndexByName(std::string_view blendShapeName) const
128 return Internal::GetImplementation(*this).GetBlendShapeIndexByName(blendShapeName);
131 void ModelNode::SetColliderMesh(std::unique_ptr<Algorithm::ColliderMesh>&& colliderMesh)
133 Internal::GetImplementation(*this).SetColliderMesh(std::move(colliderMesh));
136 const Algorithm::ColliderMesh& ModelNode::GetColliderMesh()
138 return Internal::GetImplementation(*this).GetColliderMesh();
141 bool ModelNode::HasColliderMesh() const
143 return Internal::GetImplementation(*this).HasColliderMesh();
146 void ModelNode::CastShadow(bool castShadow)
148 Internal::GetImplementation(*this).CastShadow(castShadow);
151 bool ModelNode::IsShadowCasting() const
153 return Internal::GetImplementation(*this).IsShadowCasting();
156 void ModelNode::ReceiveShadow(bool receiveShadow)
158 Internal::GetImplementation(*this).ReceiveShadow(receiveShadow);
161 bool ModelNode::IsShadowReceiving() const
163 return Internal::GetImplementation(*this).IsShadowReceiving();
166 } // namespace Scene3D