2 * Copyright (c) 2022 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>
29 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_0(char* csModelPath, char* csResourcePath)
31 Dali::Scene3D::Model result;
35 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
38 std::string modelPath(csModelPath);
42 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
45 std::string resourcePath(csResourcePath);
50 result = Dali::Scene3D::Model::New(modelPath, resourcePath);
52 CALL_CATCH_EXCEPTION(0);
55 return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
58 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_0()
60 Dali::Scene3D::Model* result = 0;
65 result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model();
67 CALL_CATCH_EXCEPTION(0);
73 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_1(void* csModel)
75 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
76 Dali::Scene3D::Model* result = 0;
80 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
86 result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model((Dali::Scene3D::Model const&)*model);
88 CALL_CATCH_EXCEPTION(0);
94 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Model(void* csModel)
96 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
102 CALL_CATCH_EXCEPTION();
106 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_Assign(void* csDestination, void* csSource)
108 Dali::Scene3D::Model* destination = (Dali::Scene3D::Model*)csDestination;
109 Dali::Scene3D::Model* source = (Dali::Scene3D::Model*)csSource;
110 Dali::Scene3D::Model* result = 0;
114 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
120 result = (Dali::Scene3D::Model*)&(destination)->operator=((Dali::Scene3D::Model const&)*source);
122 CALL_CATCH_EXCEPTION(0);
125 return (void*)result;
128 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_DownCast(void* csHandle)
130 Dali::BaseHandle* handle = (Dali::BaseHandle*)csHandle;
131 Dali::Scene3D::Model result;
135 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
141 result = Dali::Scene3D::Model::DownCast(*handle);
143 CALL_CATCH_EXCEPTION(0);
146 return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
149 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetModelRoot(void* csModel)
151 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
156 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
162 result = model->GetModelRoot();
164 CALL_CATCH_EXCEPTION(0);
167 return new Dali::Actor((const Dali::Actor&)result);
170 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetChildrenSensitive(void* csModel, bool enable)
172 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
176 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
182 model->SetChildrenSensitive(enable);
184 CALL_CATCH_EXCEPTION();
188 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_GetChildrenSensitive(void* csModel)
190 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
195 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
201 result = model->GetChildrenSensitive();
203 CALL_CATCH_EXCEPTION(0);
208 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightSource(void* csModel, char* csDiffuseUrl, char* csSpecularUrl, float scaleFactor)
210 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
214 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
219 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
222 std::string diffuseUrl(csDiffuseUrl);
225 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
228 std::string specularUrl(csSpecularUrl);
232 model->SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
234 CALL_CATCH_EXCEPTION();
238 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightScaleFactor(void* csModel, float scaleFactor)
240 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
244 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
250 model->SetImageBasedLightScaleFactor(scaleFactor);
252 CALL_CATCH_EXCEPTION();
256 SWIGEXPORT float SWIGSTDCALL CSharp_Dali_Model_GetImageBasedLightScaleFactor(void* csModel)
258 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
259 float scaleFactor = 1.0f;
263 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
269 scaleFactor = model->GetImageBasedLightScaleFactor();
271 CALL_CATCH_EXCEPTION(0.0f);
276 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetAnimationCount(void* csModel)
278 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
283 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
289 result = model->GetAnimationCount();
291 CALL_CATCH_EXCEPTION(0);
297 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_1(void* csModel, unsigned int index)
299 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
300 Dali::Animation result;
304 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
310 result = model->GetAnimation(index);
312 CALL_CATCH_EXCEPTION(0);
315 return new Dali::Animation((const Dali::Animation&)result);
318 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_2(void* csModel, char* csName)
320 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
321 Dali::Animation result;
325 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
330 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
333 std::string name(csName);
337 result = model->GetAnimation(name);
339 CALL_CATCH_EXCEPTION(0);
342 return new Dali::Animation((const Dali::Animation&)result);
345 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadBvhAnimation_1(void* csModel, char* csFileName, void* csScale)
347 Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
348 Dali::Animation result;
352 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
357 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for filename", 0);
361 Dali::Vector3 scale = Dali::Vector3::ONE;
362 // csScale is option.
363 if(csScale != nullptr)
365 scale = Dali::Vector3(*static_cast<const Dali::Vector3 *>(csScale));
367 std::string filename(csFileName);
371 Dali::Scene3D::Loader::AnimationDefinition animationDefinition = Dali::Scene3D::Loader::LoadBvh(filename, "LoadedBvhAnimation", scale);
372 Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property)->Dali::Actor{
373 return model->FindChildByName(property.mNodeName);
375 result = animationDefinition.ReAnimate(getActor);
377 CALL_CATCH_EXCEPTION(0);
380 return new Dali::Animation((const Dali::Animation&)result);