2 * Copyright (c) 2023 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/controls/model/model.h>
20 #include <dali-scene3d/public-api/loader/bvh-loader.h>
21 #include <dali-scene3d/public-api/loader/facial-animation-loader.h>
30 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_0(char* csModelPath, char* csResourcePath)
32 Dali::Scene3D::Model result;
36 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
39 std::string modelPath(csModelPath);
43 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
46 std::string resourcePath(csResourcePath);
51 result = Dali::Scene3D::Model::New(modelPath, resourcePath);
53 CALL_CATCH_EXCEPTION(0);
56 return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
59 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_1()
61 Dali::Scene3D::Model result;
66 result = Dali::Scene3D::Model::New();
68 CALL_CATCH_EXCEPTION(0);
71 return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
74 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_0()
76 Dali::Scene3D::Model* result = 0;
81 result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model();
83 CALL_CATCH_EXCEPTION(0);
89 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_1(void* csModel)
91 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
92 Dali::Scene3D::Model* result = 0;
96 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
102 result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model((Dali::Scene3D::Model const&)*model);
104 CALL_CATCH_EXCEPTION(0);
107 return (void*)result;
110 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Model(void* csModel)
112 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
118 CALL_CATCH_EXCEPTION();
122 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_Assign(void* csDestination, void* csSource)
124 Dali::Scene3D::Model* destination = (Dali::Scene3D::Model*)csDestination;
125 Dali::Scene3D::Model* source = (Dali::Scene3D::Model*)csSource;
126 Dali::Scene3D::Model* result = 0;
130 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
136 result = (Dali::Scene3D::Model*)&(destination)->operator=((Dali::Scene3D::Model const&)*source);
138 CALL_CATCH_EXCEPTION(0);
141 return (void*)result;
144 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_DownCast(void* csHandle)
146 Dali::BaseHandle* handle = (Dali::BaseHandle*)csHandle;
147 Dali::Scene3D::Model result;
151 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
157 result = Dali::Scene3D::Model::DownCast(*handle);
159 CALL_CATCH_EXCEPTION(0);
162 return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
165 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetModelRoot(void* csModel)
167 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
168 Dali::Scene3D::ModelNode result;
172 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
178 result = model->GetModelRoot();
180 CALL_CATCH_EXCEPTION(0);
183 return new Dali::Scene3D::ModelNode((const Dali::Scene3D::ModelNode&)result);
186 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_AddModelNode(void* csModel, void* csModelNode)
188 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
189 Dali::Scene3D::ModelNode* modelNode = (Dali::Scene3D::ModelNode*)csModelNode;
193 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
199 model->AddModelNode(*modelNode);
201 CALL_CATCH_EXCEPTION();
204 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_RemoveModelNode(void* csModel, void* csModelNode)
206 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
207 Dali::Scene3D::ModelNode* modelNode = (Dali::Scene3D::ModelNode*)csModelNode;
211 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
217 model->RemoveModelNode(*modelNode);
219 CALL_CATCH_EXCEPTION();
222 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetChildrenSensitive(void* csModel, bool enable)
224 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
228 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
234 model->SetChildrenSensitive(enable);
236 CALL_CATCH_EXCEPTION();
240 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_GetChildrenSensitive(void* csModel)
242 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
247 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
253 result = model->GetChildrenSensitive();
255 CALL_CATCH_EXCEPTION(0);
260 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightSource(void* csModel, char* csDiffuseUrl, char* csSpecularUrl, float scaleFactor)
262 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
266 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
271 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
274 std::string diffuseUrl(csDiffuseUrl);
277 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
280 std::string specularUrl(csSpecularUrl);
284 model->SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
286 CALL_CATCH_EXCEPTION();
290 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightScaleFactor(void* csModel, float scaleFactor)
292 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
296 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
302 model->SetImageBasedLightScaleFactor(scaleFactor);
304 CALL_CATCH_EXCEPTION();
308 SWIGEXPORT float SWIGSTDCALL CSharp_Dali_Model_GetImageBasedLightScaleFactor(void* csModel)
310 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
311 float scaleFactor = 1.0f;
315 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
321 scaleFactor = model->GetImageBasedLightScaleFactor();
323 CALL_CATCH_EXCEPTION(0.0f);
328 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetAnimationCount(void* csModel)
330 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
335 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
341 result = model->GetAnimationCount();
343 CALL_CATCH_EXCEPTION(0);
349 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_1(void* csModel, unsigned int index)
351 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
352 Dali::Animation result;
356 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
362 result = model->GetAnimation(index);
364 CALL_CATCH_EXCEPTION(0);
367 return new Dali::Animation((const Dali::Animation&)result);
370 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_2(void* csModel, char* csName)
372 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
373 Dali::Animation result;
377 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
382 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
385 std::string name(csName);
389 result = model->GetAnimation(name);
391 CALL_CATCH_EXCEPTION(0);
394 return new Dali::Animation((const Dali::Animation&)result);
397 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetCameraCount(void* csModel)
399 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
404 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
410 result = model->GetCameraCount();
412 CALL_CATCH_EXCEPTION(0);
418 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GenerateCamera(void* csModel, unsigned int index)
420 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
421 Dali::CameraActor result;
425 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
431 result = model->GenerateCamera(index);
433 CALL_CATCH_EXCEPTION(0);
436 return new Dali::CameraActor((const Dali::CameraActor&)result);
439 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_ApplyCamera(void* csModel, unsigned int index, void* csCameraActor)
441 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
442 Dali::CameraActor* cameraActor = (Dali::CameraActor*)csCameraActor;
447 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
452 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::CameraActor", 0);
458 result = model->ApplyCamera(index, *cameraActor);
460 CALL_CATCH_EXCEPTION(0);
466 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_FindChildModelNodeByName(void* csModel, char* nodeName)
468 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
469 Dali::Scene3D::ModelNode result;
473 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
479 result = model->FindChildModelNodeByName(std::string_view(nodeName));
481 CALL_CATCH_EXCEPTION(nullptr);
483 return new Dali::Scene3D::ModelNode((const Dali::Scene3D::ModelNode&)result);
486 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadBvhAnimation_1(void* csModel, char* csFileName, void* csScale)
488 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
489 Dali::Animation result;
493 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
498 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for filename", 0);
502 Dali::Vector3 scale = Dali::Vector3::ONE;
503 // csScale is option.
504 if(csScale != nullptr)
506 scale = Dali::Vector3(*static_cast<const Dali::Vector3*>(csScale));
508 std::string filename(csFileName);
512 Dali::Scene3D::Loader::AnimationDefinition animationDefinition = Dali::Scene3D::Loader::LoadBvh(filename, "LoadedBvhAnimation", scale);
513 Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
514 return model->FindChildByName(property.mNodeName);
516 result = animationDefinition.ReAnimate(getActor);
518 CALL_CATCH_EXCEPTION(0);
521 return new Dali::Animation((const Dali::Animation&)result);
524 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadFacialAnimation_1(void* csModel, char* csFileName)
526 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
527 Dali::Animation result;
531 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
536 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for filename", 0);
540 std::string filename(csFileName);
544 Dali::Scene3D::Loader::AnimationDefinition animationDefinition = Dali::Scene3D::Loader::LoadFacialAnimation(filename);
545 Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
546 return model->FindChildByName(property.mNodeName);
548 result = animationDefinition.ReAnimate(getActor);
550 CALL_CATCH_EXCEPTION(0);
553 return new Dali::Animation((const Dali::Animation&)result);