f4d282cebd7dc43c5de3b87f69e14e8047b83f0d
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / dali-scene3d / model-wrap.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // EXTERNAL INCLUDES
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>
22 #include <dali-scene3d/public-api/model-motion/motion-data.h>
23 #include <dali/devel-api/animation/key-frames-devel.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-csharp-binder/common/common.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_0(char* csModelPath, char* csResourcePath)
33 {
34   Dali::Scene3D::Model result;
35
36   if(!csModelPath)
37   {
38     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
39     return 0;
40   }
41   std::string modelPath(csModelPath);
42
43   if(!csResourcePath)
44   {
45     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
46     return 0;
47   }
48   std::string resourcePath(csResourcePath);
49
50   {
51     try
52     {
53       result = Dali::Scene3D::Model::New(modelPath, resourcePath);
54     }
55     CALL_CATCH_EXCEPTION(0);
56   }
57
58   return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
59 }
60
61 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_New_SWIG_1()
62 {
63   Dali::Scene3D::Model result;
64
65   {
66     try
67     {
68       result = Dali::Scene3D::Model::New();
69     }
70     CALL_CATCH_EXCEPTION(0);
71   }
72
73   return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
74 }
75
76 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_0()
77 {
78   Dali::Scene3D::Model* result = 0;
79
80   {
81     try
82     {
83       result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model();
84     }
85     CALL_CATCH_EXCEPTION(0);
86   }
87
88   return (void*)result;
89 }
90
91 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_new_Model_SWIG_1(void* csModel)
92 {
93   Dali::Scene3D::Model* model  = (Dali::Scene3D::Model*)csModel;
94   Dali::Scene3D::Model* result = 0;
95
96   if(!model)
97   {
98     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
99     return 0;
100   }
101   {
102     try
103     {
104       result = (Dali::Scene3D::Model*)new Dali::Scene3D::Model((Dali::Scene3D::Model const&)*model);
105     }
106     CALL_CATCH_EXCEPTION(0);
107   }
108
109   return (void*)result;
110 }
111
112 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Model(void* csModel)
113 {
114   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
115   {
116     try
117     {
118       delete model;
119     }
120     CALL_CATCH_EXCEPTION();
121   }
122 }
123
124 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_Assign(void* csDestination, void* csSource)
125 {
126   Dali::Scene3D::Model* destination = (Dali::Scene3D::Model*)csDestination;
127   Dali::Scene3D::Model* source      = (Dali::Scene3D::Model*)csSource;
128   Dali::Scene3D::Model* result      = 0;
129
130   if(!source)
131   {
132     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Scene3D::Model const & type is null", 0);
133     return 0;
134   }
135   {
136     try
137     {
138       result = (Dali::Scene3D::Model*)&(destination)->operator=((Dali::Scene3D::Model const&)*source);
139     }
140     CALL_CATCH_EXCEPTION(0);
141   }
142
143   return (void*)result;
144 }
145
146 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_DownCast(void* csHandle)
147 {
148   Dali::BaseHandle*    handle = (Dali::BaseHandle*)csHandle;
149   Dali::Scene3D::Model result;
150
151   if(!handle)
152   {
153     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
154     return 0;
155   }
156   {
157     try
158     {
159       result = Dali::Scene3D::Model::DownCast(*handle);
160     }
161     CALL_CATCH_EXCEPTION(0);
162   }
163
164   return new Dali::Scene3D::Model((const Dali::Scene3D::Model&)result);
165 }
166
167 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetModelRoot(void* csModel)
168 {
169   Dali::Scene3D::Model*    model = (Dali::Scene3D::Model*)csModel;
170   Dali::Scene3D::ModelNode result;
171
172   if(!model)
173   {
174     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
175     return 0;
176   }
177   {
178     try
179     {
180       result = model->GetModelRoot();
181     }
182     CALL_CATCH_EXCEPTION(0);
183   }
184
185   return new Dali::Scene3D::ModelNode((const Dali::Scene3D::ModelNode&)result);
186 }
187
188 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_AddModelNode(void* csModel, void* csModelNode)
189 {
190   Dali::Scene3D::Model*     model     = (Dali::Scene3D::Model*)csModel;
191   Dali::Scene3D::ModelNode* modelNode = (Dali::Scene3D::ModelNode*)csModelNode;
192
193   if(!model)
194   {
195     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
196     return;
197   }
198
199   try
200   {
201     model->AddModelNode(*modelNode);
202   }
203   CALL_CATCH_EXCEPTION();
204 }
205
206 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_RemoveModelNode(void* csModel, void* csModelNode)
207 {
208   Dali::Scene3D::Model*     model     = (Dali::Scene3D::Model*)csModel;
209   Dali::Scene3D::ModelNode* modelNode = (Dali::Scene3D::ModelNode*)csModelNode;
210
211   if(!model)
212   {
213     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
214     return;
215   }
216
217   try
218   {
219     model->RemoveModelNode(*modelNode);
220   }
221   CALL_CATCH_EXCEPTION();
222 }
223
224 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetChildrenSensitive(void* csModel, bool enable)
225 {
226   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
227
228   if(!model)
229   {
230     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
231     return;
232   }
233   {
234     try
235     {
236       model->SetChildrenSensitive(enable);
237     }
238     CALL_CATCH_EXCEPTION();
239   }
240 }
241
242 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_GetChildrenSensitive(void* csModel)
243 {
244   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
245   bool                  result;
246
247   if(!model)
248   {
249     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
250     return false;
251   }
252   {
253     try
254     {
255       result = model->GetChildrenSensitive();
256     }
257     CALL_CATCH_EXCEPTION(0);
258   }
259   return result;
260 }
261
262 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightSource(void* csModel, char* csDiffuseUrl, char* csSpecularUrl, float scaleFactor)
263 {
264   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
265
266   if(!model)
267   {
268     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
269     return;
270   }
271   if(!csDiffuseUrl)
272   {
273     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
274     return;
275   }
276   std::string diffuseUrl(csDiffuseUrl);
277   if(!csSpecularUrl)
278   {
279     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
280     return;
281   }
282   std::string specularUrl(csSpecularUrl);
283   {
284     try
285     {
286       model->SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
287     }
288     CALL_CATCH_EXCEPTION();
289   }
290 }
291
292 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetImageBasedLightScaleFactor(void* csModel, float scaleFactor)
293 {
294   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
295
296   if(!model)
297   {
298     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
299     return;
300   }
301   {
302     try
303     {
304       model->SetImageBasedLightScaleFactor(scaleFactor);
305     }
306     CALL_CATCH_EXCEPTION();
307   }
308 }
309
310 SWIGEXPORT float SWIGSTDCALL CSharp_Dali_Model_GetImageBasedLightScaleFactor(void* csModel)
311 {
312   Dali::Scene3D::Model* model       = (Dali::Scene3D::Model*)csModel;
313   float                 scaleFactor = 1.0f;
314
315   if(!model)
316   {
317     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
318     return scaleFactor;
319   }
320   {
321     try
322     {
323       scaleFactor = model->GetImageBasedLightScaleFactor();
324     }
325     CALL_CATCH_EXCEPTION(0.0f);
326   }
327   return scaleFactor;
328 }
329
330 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetAnimationCount(void* csModel)
331 {
332   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
333   unsigned int          result;
334
335   if(!model)
336   {
337     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
338     return 0;
339   }
340   {
341     try
342     {
343       result = model->GetAnimationCount();
344     }
345     CALL_CATCH_EXCEPTION(0);
346   }
347
348   return result;
349 }
350
351 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_1(void* csModel, unsigned int index)
352 {
353   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
354   Dali::Animation       result;
355
356   if(!model)
357   {
358     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
359     return 0;
360   }
361   {
362     try
363     {
364       result = model->GetAnimation(index);
365     }
366     CALL_CATCH_EXCEPTION(0);
367   }
368
369   return new Dali::Animation((const Dali::Animation&)result);
370 }
371
372 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GetAnimation_2(void* csModel, char* csName)
373 {
374   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
375   Dali::Animation       result;
376
377   if(!model)
378   {
379     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
380     return 0;
381   }
382   if(!csName)
383   {
384     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
385     return 0;
386   }
387   std::string name(csName);
388   {
389     try
390     {
391       result = model->GetAnimation(name);
392     }
393     CALL_CATCH_EXCEPTION(0);
394   }
395
396   return new Dali::Animation((const Dali::Animation&)result);
397 }
398
399 SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Model_GetCameraCount(void* csModel)
400 {
401   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
402   unsigned int          result;
403
404   if(!model)
405   {
406     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
407     return 0;
408   }
409   {
410     try
411     {
412       result = model->GetCameraCount();
413     }
414     CALL_CATCH_EXCEPTION(0);
415   }
416
417   return result;
418 }
419
420 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GenerateCamera(void* csModel, unsigned int index)
421 {
422   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
423   Dali::CameraActor     result;
424
425   if(!model)
426   {
427     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
428     return 0;
429   }
430   {
431     try
432     {
433       result = model->GenerateCamera(index);
434     }
435     CALL_CATCH_EXCEPTION(0);
436   }
437
438   return new Dali::CameraActor((const Dali::CameraActor&)result);
439 }
440
441 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_Model_ApplyCamera(void* csModel, unsigned int index, void* csCameraActor)
442 {
443   Dali::Scene3D::Model* model       = (Dali::Scene3D::Model*)csModel;
444   Dali::CameraActor*    cameraActor = (Dali::CameraActor*)csCameraActor;
445   bool                  result;
446
447   if(!model)
448   {
449     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
450     return 0;
451   }
452   if(!cameraActor)
453   {
454     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::CameraActor", 0);
455     return 0;
456   }
457   {
458     try
459     {
460       result = model->ApplyCamera(index, *cameraActor);
461     }
462     CALL_CATCH_EXCEPTION(0);
463   }
464
465   return result;
466 }
467
468 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_FindChildModelNodeByName(void* csModel, char* nodeName)
469 {
470   Dali::Scene3D::Model*    model = (Dali::Scene3D::Model*)csModel;
471   Dali::Scene3D::ModelNode result;
472
473   if(!model)
474   {
475     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
476     return nullptr;
477   }
478
479   try
480   {
481     result = model->FindChildModelNodeByName(std::string_view(nodeName));
482   }
483   CALL_CATCH_EXCEPTION(nullptr);
484
485   return new Dali::Scene3D::ModelNode((const Dali::Scene3D::ModelNode&)result);
486 }
487
488 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_GenerateMotionDataAnimation(void* csModel, void* csMotionData)
489 {
490   Dali::Scene3D::Model*      model      = (Dali::Scene3D::Model*)csModel;
491   Dali::Scene3D::MotionData* motionData = (Dali::Scene3D::MotionData*)csMotionData;
492   Dali::Animation            result;
493
494   if(!model)
495   {
496     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
497     return nullptr;
498   }
499   if(!motionData)
500   {
501     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::MotionData", 0);
502     return nullptr;
503   }
504
505   try
506   {
507     result = model->GenerateMotionDataAnimation(*motionData);
508   }
509   CALL_CATCH_EXCEPTION(nullptr);
510
511   return new Dali::Animation((const Dali::Animation&)result);
512 }
513
514 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Model_SetMotionData(void* csModel, void* csMotionData)
515 {
516   Dali::Scene3D::Model*      model      = (Dali::Scene3D::Model*)csModel;
517   Dali::Scene3D::MotionData* motionData = (Dali::Scene3D::MotionData*)csMotionData;
518
519   if(!model)
520   {
521     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
522     return;
523   }
524   if(!motionData)
525   {
526     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::MotionData", 0);
527     return;
528   }
529
530   try
531   {
532     model->SetMotionData(*motionData);
533   }
534   CALL_CATCH_EXCEPTION();
535 }
536
537 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadBvhAnimation_1(void* csModel, char* csFileName, void* csScale, bool csUseRootNodeTranslate)
538 {
539   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
540   Dali::Animation       result;
541
542   if(!model)
543   {
544     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
545     return 0;
546   }
547   if(!csFileName)
548   {
549     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for filename", 0);
550     return 0;
551   }
552
553   Dali::Vector3 scale = Dali::Vector3::ONE;
554   // csScale is option.
555   if(csScale != nullptr)
556   {
557     scale = Dali::Vector3(*static_cast<const Dali::Vector3*>(csScale));
558   }
559
560   std::string filename(csFileName);
561   {
562     try
563     {
564       Dali::Scene3D::Loader::AnimationDefinition animationDefinition = Dali::Scene3D::Loader::LoadBvh(filename, "LoadedBvhAnimation", scale);
565
566       if(csUseRootNodeTranslate && animationDefinition.GetPropertyCount() > 0u)
567       {
568         // We can assume that 0's property is for root translate
569         auto& property = animationDefinition.GetPropertyAt(0u);
570         auto& keyFrames = property.mKeyFrames;
571
572         // Let we check that we can change animatable property
573         // TODO : If AnimateBetweenBy feature prepared, we can remove below logic.
574         if(keyFrames)
575         {
576           auto rootNode = model->FindChildByName(property.mNodeName);
577           if(rootNode)
578           {
579             // Get root node's current position and apply it into property animation.
580             auto rootNodePosition = rootNode.GetProperty<Dali::Vector3>(Dali::Actor::Property::POSITION);
581
582             auto frameCount = Dali::DevelKeyFrames::GetKeyFrameCount(keyFrames);
583             for(auto i = 0u; i < frameCount; ++i)
584             {
585               float                 keyFrameProgress;
586               Dali::Property::Value keyFrameValue;
587               Dali::Vector3         valuePosition;
588
589               Dali::DevelKeyFrames::GetKeyFrame(keyFrames, i, keyFrameProgress, keyFrameValue);
590               if(DALI_LIKELY(keyFrameValue.Get(valuePosition)))
591               {
592                 Dali::DevelKeyFrames::SetKeyFrameValue(keyFrames, i, rootNodePosition + valuePosition);
593               }
594             }
595           }
596         }
597       }
598
599       Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
600         return model->FindChildByName(property.mNodeName);
601       };
602       result = animationDefinition.ReAnimate(getActor);
603     }
604     CALL_CATCH_EXCEPTION(0);
605   }
606
607   return new Dali::Animation((const Dali::Animation&)result);
608 }
609
610 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadBvhAnimation_2(void* csModel, char* csBuffer, int csBufferLength, void* csScale, bool csUseRootNodeTranslate)
611 {
612   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
613   Dali::Animation       result;
614
615   if(!model)
616   {
617     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
618     return 0;
619   }
620   if(!csBuffer)
621   {
622     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for buffer", 0);
623     return 0;
624   }
625
626   Dali::Vector3 scale = Dali::Vector3::ONE;
627   // csScale is option.
628   if(csScale != nullptr)
629   {
630     scale = Dali::Vector3(*static_cast<const Dali::Vector3*>(csScale));
631   }
632
633   const uint8_t* rawBuffer = reinterpret_cast<const uint8_t*>(csBuffer);
634   {
635     try
636     {
637       Dali::Scene3D::Loader::AnimationDefinition animationDefinition = Dali::Scene3D::Loader::LoadBvhFromBuffer(rawBuffer, csBufferLength, "LoadedBvhAnimation", scale);
638
639       if(csUseRootNodeTranslate && animationDefinition.GetPropertyCount() > 0u)
640       {
641         // We can assume that 0's property is for root translate
642         auto& property = animationDefinition.GetPropertyAt(0u);
643         auto& keyFrames = property.mKeyFrames;
644
645         // Let we check that we can change animatable property
646         // TODO : If AnimateBetweenBy feature prepared, we can remove below logic.
647         if(keyFrames)
648         {
649           auto rootNode = model->FindChildByName(property.mNodeName);
650           if(rootNode)
651           {
652             // Get root node's current position and apply it into property animation.
653             auto rootNodePosition = rootNode.GetProperty<Dali::Vector3>(Dali::Actor::Property::POSITION);
654
655             auto frameCount = Dali::DevelKeyFrames::GetKeyFrameCount(keyFrames);
656             for(auto i = 0u; i < frameCount; ++i)
657             {
658               float                 keyFrameProgress;
659               Dali::Property::Value keyFrameValue;
660               Dali::Vector3         valuePosition;
661               Dali::DevelKeyFrames::GetKeyFrame(keyFrames, i, keyFrameProgress, keyFrameValue);
662               if(DALI_LIKELY(keyFrameValue.Get(valuePosition)))
663               {
664                 Dali::DevelKeyFrames::SetKeyFrameValue(keyFrames, i, rootNodePosition + valuePosition);
665               }
666             }
667           }
668         }
669       }
670
671       Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
672         return model->FindChildByName(property.mNodeName);
673       };
674       result = animationDefinition.ReAnimate(getActor);
675     }
676     CALL_CATCH_EXCEPTION(0);
677   }
678
679   return new Dali::Animation((const Dali::Animation&)result);
680 }
681
682 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadFacialAnimation_1(void* csModel, char* csFileName)
683 {
684   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
685   Dali::Animation       result;
686
687   if(!model)
688   {
689     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
690     return 0;
691   }
692   if(!csFileName)
693   {
694     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for filename", 0);
695     return 0;
696   }
697
698   std::string filename(csFileName);
699   {
700     try
701     {
702       Dali::Scene3D::Loader::AnimationDefinition        animationDefinition = Dali::Scene3D::Loader::LoadFacialAnimation(filename);
703       Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor            = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
704         return model->FindChildByName(property.mNodeName);
705       };
706       result = animationDefinition.ReAnimate(getActor);
707     }
708     CALL_CATCH_EXCEPTION(0);
709   }
710
711   return new Dali::Animation((const Dali::Animation&)result);
712 }
713
714 SWIGEXPORT void* SWIGSTDCALL CSharp_Dali_Model_LoadFacialAnimation_2(void* csModel, char* csBuffer, int csBufferLength)
715 {
716   Dali::Scene3D::Model* model = (Dali::Scene3D::Model*)csModel;
717   Dali::Animation       result;
718
719   if(!model)
720   {
721     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null Dali::Scene3D::Model", 0);
722     return 0;
723   }
724   if(!csBuffer)
725   {
726     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string for buffer", 0);
727     return 0;
728   }
729
730   const uint8_t* rawBuffer = reinterpret_cast<const uint8_t*>(csBuffer);
731   {
732     try
733     {
734       Dali::Scene3D::Loader::AnimationDefinition        animationDefinition = Dali::Scene3D::Loader::LoadFacialAnimationFromBuffer(rawBuffer, csBufferLength);
735       Dali::Scene3D::Loader::AnimatedProperty::GetActor getActor            = [&model](const Dali::Scene3D::Loader::AnimatedProperty& property) -> Dali::Actor {
736         return model->FindChildByName(property.mNodeName);
737       };
738       result = animationDefinition.ReAnimate(getActor);
739     }
740     CALL_CATCH_EXCEPTION(0);
741   }
742
743   return new Dali::Animation((const Dali::Animation&)result);
744 }
745
746 #ifdef __cplusplus
747 }
748 #endif