[NUI] Public open MotionData
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Scene3D / src / public / Controls / Model.cs
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 using System;
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
21 using Tizen.NUI;
22 using Tizen.NUI.Binding;
23 using Tizen.NUI.BaseComponents;
24
25 namespace Tizen.NUI.Scene3D
26 {
27     /// <summary>
28     /// Model is a Class to show 3D mesh objects.
29     /// Model supports glTF 2.0 and DLI model formats.
30     /// Physically Based Rendering with Image Based Lighting is also supported.
31     /// </summary>
32     ///
33     /// <remarks>
34     /// Since NUI uses a left-handed coordinate system, loaded models are transformed into a left-handed coordinate system with Y pointing down.
35     /// The Animations defined in the glTF or DLI are also loaded and can be retrieved by using <see cref="GetAnimation(uint)"/> and <see cref="GetAnimation(string)"/> methods.
36     /// The number of animation is also retrieved by GetAnimationCount() method.
37     ///
38     /// Model also supports Physically Based Rendering(PBR) with Image Based Lighting(IBL).
39     /// For the IBL, two cube map textures(diffuse and specular) are required.
40     /// Model supports 4 types layout for Cube Map: Vertical/Horizontal Cross layouts, and Vertical/Horizontal Array layouts.
41     /// And also, ktx format with cube map is supported.
42     ///
43     /// The model and IBL textures start to be loaded asynchronously when the Model object is on Window.
44     /// ResourcesLoaded signal notifies that the loading of the model and IBL resources have been completed.
45     /// If Model or IBL is requested to be loaded before the other loading is completed, the ResourcesLoaded signal is called after all resources are loaded.
46     /// <see cref="GetAnimation(uint)"/> and <see cref="GetAnimation(string)"/> methods can be used after the model loading is finished.
47     ///
48     /// By default, the loaded mesh has its own size and <see cref="PivotPoint"/> inferred from position of vertices.
49     /// The <see cref="PivotPoint"/> can be modified after model loading is finished.
50     /// If user set size property, the mesh will be scaled to the input size.
51     /// Default value of <see cref="ParentOrigin"/> of the Model is Center.
52     /// </remarks>
53     ///
54     /// <example>
55     /// <code>
56     /// Model model = new Model(modelUrl)
57     /// {
58     ///     Size = new Size(width, height),
59     /// };
60     /// model.ResourcesLoaded += (s, e) =>
61     /// {
62     ///     model.PivotPoint = new Vector3(0.5f, 0.5f, 0.5f); // Use center as a Pivot.
63     ///
64     ///     int animationCount = model.GetAnimationCount();
65     ///     if(animationCount > 0)
66     ///     {
67     ///         // Play an Animation of index 0.
68     ///         model.GetAnimation(0).Play();
69     ///     }
70     /// };
71     /// model.SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor);
72     /// window.Add(model);
73     ///
74     /// </code>
75     /// </example>
76     /// <since_tizen> 10 </since_tizen>
77     public partial class Model : View
78     {
79         internal Model(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
80         {
81         }
82
83         /// <summary>
84         /// Create an initialized Model.
85         /// </summary>
86         /// <param name="modelUrl">model file url.(e.g. glTF, and DLI).</param>
87         /// <param name="resourceDirectoryUrl"> The url to derectory containing resources: binary, image etc.</param>
88         /// <remarks>
89         /// If resourceDirectoryUrl is empty, the parent directory url of modelUrl is used for resource url.
90         ///
91         /// http://tizen.org/privilege/mediastorage for local files in media storage.
92         /// http://tizen.org/privilege/externalstorage for local files in external storage.
93         /// </remarks>
94         /// <since_tizen> 10 </since_tizen>
95         public Model(string modelUrl, string resourceDirectoryUrl = "") : this(Interop.Model.ModelNew(modelUrl, resourceDirectoryUrl), true)
96         {
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             this.PositionUsesAnchorPoint = true;
99         }
100
101         /// <summary>
102         /// Create an initialized Model.
103         /// </summary>
104         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public Model() : this(Interop.Model.ModelNew(), true)
107         {
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109             this.PositionUsesAnchorPoint = true;
110         }
111
112         /// <summary>
113         /// Copy constructor.
114         /// </summary>
115         /// <param name="model">Source object to copy.</param>
116         /// <since_tizen> 10 </since_tizen>
117         public Model(Model model) : this(Interop.Model.NewModel(Model.getCPtr(model)), true)
118         {
119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120         }
121
122         /// <summary>
123         /// Assignment operator.
124         /// </summary>
125         /// <param name="model">Source object to be assigned.</param>
126         /// <returns>Reference to this.</returns>
127         internal Model Assign(Model model)
128         {
129             Model ret = new Model(Interop.Model.ModelAssign(SwigCPtr, Model.getCPtr(model)), false);
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131             return ret;
132         }
133
134         /// <summary>
135         /// Set/Get the ImageBasedLight ScaleFactor.
136         /// Scale factor controls light source intensity in [0.0f, 1.0f]
137         /// </summary>
138         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
139         [EditorBrowsable(EditorBrowsableState.Never)]
140         public float ImageBasedLightScaleFactor
141         {
142             set
143             {
144                 SetImageBasedLightScaleFactor(value);
145             }
146             get
147             {
148                 return GetImageBasedLightScaleFactor();
149             }
150         }
151
152         /// <summary>
153         /// Retrieves root ModelNode of this Model.
154         /// </summary>
155         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
156         [EditorBrowsable(EditorBrowsableState.Never)]
157         public ModelNode ModelRoot
158         {
159             get
160             {
161                 return GetModelRoot();
162             }
163         }
164
165         /// <summary>
166         /// Adds modelNode to this Model.
167         /// </summary>
168         /// <param name="modelNode">Root of a ModelNode tree</param>
169         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
170         [EditorBrowsable(EditorBrowsableState.Never)]
171         public void AddModelNode(ModelNode modelNode)
172         {
173             Interop.Model.AddModelNode(SwigCPtr, ModelNode.getCPtr(modelNode));
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175         }
176
177         /// <summary>
178         /// Removes modelNode from this Model.
179         /// </summary>
180         /// <param name="modelNode">Root of a ModelNode tree to be removed</param>
181         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
182         [EditorBrowsable(EditorBrowsableState.Never)]
183         public void RemoveModelNode(ModelNode modelNode)
184         {
185             Interop.Model.RemoveModelNode(SwigCPtr, ModelNode.getCPtr(modelNode));
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187         }
188
189         /// <summary>
190         /// Removes Returns a child ModelNode object with a name that matches nodeName.
191         /// </summary>
192         /// <param name="nodeName">The name of the child ModelNode object you want to find.</param>
193         /// <returns>Child ModelNode that has nodeName as name.</returns>
194         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
195         [EditorBrowsable(EditorBrowsableState.Never)]
196         public ModelNode FindChildModelNodeByName(string nodeName)
197         {
198             global::System.IntPtr cPtr = Interop.Model.FindChildModelNodeByName(SwigCPtr, nodeName);
199             ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode;
200             if (ret == null)
201             {
202                 // Register new animatable into Registry.
203                 ret = new ModelNode(cPtr, true);
204             }
205             else
206             {
207                 // We found matched NUI animatable. Reduce cPtr reference count.
208                 HandleRef handle = new HandleRef(this, cPtr);
209                 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
210                 handle = new HandleRef(null, IntPtr.Zero);
211             }
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         /// <summary>
217         /// Changes Image Based Light according to the given input textures.
218         /// </summary>
219         /// <param name="diffuseUrl">The path of Cube map image that will be used as a diffuse IBL source.</param>
220         /// <param name="specularUrl">The path of Cube map image that will be used as a specular IBL source.</param>
221         /// <param name="scaleFactor">Scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f.</param>
222         /// <remarks>
223         /// http://tizen.org/privilege/mediastorage for local files in media storage.
224         /// http://tizen.org/privilege/externalstorage for local files in external storage.
225         /// </remarks>
226         /// <since_tizen> 10 </since_tizen>
227         public void SetImageBasedLightSource(string diffuseUrl, string specularUrl, float scaleFactor = 1.0f)
228         {
229             Interop.Model.SetImageBasedLightSource(SwigCPtr, diffuseUrl, specularUrl, scaleFactor);
230             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231         }
232
233         /// <summary>
234         /// Gets number of animations that has been loaded from model file.
235         /// </summary>
236         /// <remarks>
237         /// This method should be called after Model load has been finished.
238         /// </remarks>
239         /// <returns>The number of loaded animations.</returns>
240         /// <since_tizen> 10 </since_tizen>
241         public uint GetAnimationCount()
242         {
243             uint ret = Interop.Model.GetAnimationCount(SwigCPtr);
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245             return ret;
246         }
247
248         /// <summary>
249         /// Gets animation at the index.
250         /// </summary>
251         /// <remarks>
252         /// This method should be called after Model load has been finished.
253         /// </remarks>
254         /// <param name="index">Index of animation to be retrieved.</param>
255         /// <returns>Animation at the index.</returns>
256         /// <since_tizen> 10 </since_tizen>
257         public Animation GetAnimation(uint index)
258         {
259             global::System.IntPtr cPtr = Interop.Model.GetAnimation(SwigCPtr, index);
260             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
261             if (ret == null)
262             {
263                 // Register new animation into Registry.
264                 ret = new Animation(cPtr, true);
265             }
266             else
267             {
268                 // We found matched NUI animation. Reduce cPtr reference count.
269                 HandleRef handle = new HandleRef(this, cPtr);
270                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
271                 handle = new HandleRef(null, IntPtr.Zero);
272             }
273             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274             return ret;
275         }
276
277         /// <summary>
278         /// Retrieves animation with the given name.
279         /// Note: This method should be called after Model load finished.
280         /// </summary>
281         /// <param name="name">String name of animation to be retrieved.</param>
282         /// <returns>Animation that has the given name.</returns>
283         /// <since_tizen> 10 </since_tizen>
284         public Animation GetAnimation(string name)
285         {
286             global::System.IntPtr cPtr = Interop.Model.GetAnimation(SwigCPtr, name);
287             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
288             if (ret == null)
289             {
290                 // Register new animation into Registry.
291                 ret = new Animation(cPtr, true);
292             }
293             else
294             {
295                 // We found matched NUI animation. Reduce cPtr reference count.
296                 HandleRef handle = new HandleRef(this, cPtr);
297                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
298                 handle = new HandleRef(null, IntPtr.Zero);
299             }
300             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301             return ret;
302         }
303
304         /// <summary>
305         /// Gets number of camera parameters that has been loaded from model file.
306         /// </summary>
307         /// <remarks>
308         /// This method should be called after Model load has been finished.
309         /// </remarks>
310         /// <returns>The number of loaded camera parameters.</returns>
311         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
312         [EditorBrowsable(EditorBrowsableState.Never)]
313         public uint GetCameraCount()
314         {
315             uint ret = Interop.Model.GetCameraCount(SwigCPtr);
316             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317             return ret;
318         }
319
320         /// <summary>
321         /// Generate Camera using camera parameters at the index.
322         /// If camera parameter is valid, create new Camera.
323         /// Else, return empty Handle.
324         /// </summary>
325         /// <remarks>
326         /// This method should be called after Model load has been finished.
327         /// </remarks>
328         /// <param name="index">Index of camera to be generated.</param>
329         /// <returns>Generated Camera by the index, or empty Handle if generation failed.</returns>
330         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
331         [EditorBrowsable(EditorBrowsableState.Never)]
332         public Camera GenerateCamera(uint index)
333         {
334             global::System.IntPtr cPtr = Interop.Model.GenerateCamera(SwigCPtr, index);
335             Camera ret = new Camera(cPtr, true); // Always create new camera.
336             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
337             return ret;
338         }
339
340         /// <summary>
341         /// Apply camera parameters at the index to inputed Camera.
342         /// If camera parameter is valid and camera is not empty, apply parameters.
343         /// It will change camera's transform and near / far / fov or orthographic size / aspect ratio (if defined)
344         /// </summary>
345         /// <remarks>
346         /// This method should be called after Model load has been finished.
347         /// </remarks>
348         /// <param name="index">Index of camera to be retrieved.</param>
349         /// <param name="camera">Camera to be applied parameter.</param>
350         /// <returns>True if Apply successed. False otherwise.</returns>
351         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
352         [EditorBrowsable(EditorBrowsableState.Never)]
353         public bool ApplyCamera(uint index, Camera camera)
354         {
355             bool ret = false;
356             if (camera?.HasBody() == true)
357             {
358                 ret = Interop.Model.ApplyCamera(SwigCPtr, index, Camera.getCPtr(camera));
359                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360             }
361             return ret;
362         }
363
364         /// <summary>
365         /// Load bvh animation and assign to model.
366         /// Scale is additional scale factor of bvh animation. It is possible that
367         /// Model's scale may not matched with bvh animation scale.
368         /// If scale is null, default use as Vector3.ONE
369         /// </summary>
370         /// <param name="bvhFilename">Name of bvh format file.</param>
371         /// <param name="scale">Scale value of bvh animation match with model.</param>
372         /// <param name="translateRootFromModelNode">Whether we should translate the bvh root from it's ModelNode position or not.</param>
373         /// <returns>Animaion of bvh</returns>
374         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
375         [EditorBrowsable(EditorBrowsableState.Never)]
376         [Obsolete("Do not use this LoadBvhAnimation. Use MotionData.LoadMotionCaptureAnimation and GenerateMotionDataAnimation instead.")]
377         public Animation LoadBvhAnimation(string bvhFilename, Vector3 scale = null, bool translateRootFromModelNode = true)
378         {
379             global::System.IntPtr cPtr = Interop.Model.LoadBvhAnimation(SwigCPtr, bvhFilename, Vector3.getCPtr(scale), translateRootFromModelNode);
380             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
381             if (ret == null)
382             {
383                 // Register new animation into Registry.
384                 ret = new Animation(cPtr, true);
385             }
386             else
387             {
388                 // We found matched NUI animation. Reduce cPtr reference count.
389                 HandleRef handle = new HandleRef(this, cPtr);
390                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
391                 handle = new HandleRef(null, IntPtr.Zero);
392             }
393             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394             return ret;
395         }
396
397         /// <summary>
398         /// Load bvh animation and assign to model.
399         /// Scale is additional scale factor of bvh animation. It is possible that
400         /// Model's scale may not matched with bvh animation scale.
401         /// If scale is null, default use as Vector3.ONE
402         /// </summary>
403         /// <param name="bvhBuffer">Contents of bvh format file.</param>
404         /// <param name="scale">Scale value of bvh animation match with model.</param>
405         /// <param name="translateRootFromModelNode">Whether we should translate the bvh root from it's ModelNode position or not.</param>
406         /// <returns>Animaion of bvh</returns>
407         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
408         [EditorBrowsable(EditorBrowsableState.Never)]
409         [Obsolete("Do not use this LoadBvhAnimationFromBuffer. Use MotionData.LoadMotionCaptureAnimationFromBuffer and GenerateMotionDataAnimation instead.")]
410         public Animation LoadBvhAnimationFromBuffer(string bvhBuffer, Vector3 scale = null, bool translateRootFromModelNode = true)
411         {
412             global::System.IntPtr cPtr = Interop.Model.LoadBvhAnimationFromBuffer(SwigCPtr, bvhBuffer, bvhBuffer.Length, Vector3.getCPtr(scale), translateRootFromModelNode);
413             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
414             if (ret == null)
415             {
416                 // Register new animation into Registry.
417                 ret = new Animation(cPtr, true);
418             }
419             else
420             {
421                 // We found matched NUI animation. Reduce cPtr reference count.
422                 HandleRef handle = new HandleRef(this, cPtr);
423                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
424                 handle = new HandleRef(null, IntPtr.Zero);
425             }
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427             return ret;
428         }
429
430         /// <summary>
431         /// Load facial animation and assign to model.
432         /// </summary>
433         /// <param name="facialFilename">Name of json format file what we predefined.</param>
434         /// <returns>Animaion of facial</returns>
435         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
436         [EditorBrowsable(EditorBrowsableState.Never)]
437         [Obsolete("Do not use this LoadFacialAnimation. Use MotionData.LoadBlendShapeAnimation and GenerateMotionDataAnimation instead.")]
438         public Animation LoadFacialAnimation(string facialFilename)
439         {
440             return LoadBlendShapeAnimation(facialFilename);
441         }
442
443         /// <summary>
444         /// Load facial animation and assign to model.
445         /// </summary>
446         /// <param name="facialBuffer">Contents of json format file what we predefined.</param>
447         /// <returns>Animaion of facial</returns>
448         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
449         [EditorBrowsable(EditorBrowsableState.Never)]
450         [Obsolete("Do not use this LoadFacialAnimationFromBuffer. Use MotionData.LoadBlendShapeAnimationFromBuffer and GenerateMotionDataAnimation instead.")]
451         public Animation LoadFacialAnimationFromBuffer(string facialBuffer)
452         {
453             return LoadBlendShapeAnimationFromBuffer(facialBuffer);
454         }
455
456         /// <summary>
457         /// Load blendshape animation and assign to model from json file.
458         /// </summary>
459         /// <param name="jsonFilename">Name of json format file what we predefined.</param>
460         /// <returns>Animaion of facial</returns>
461         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
462         [EditorBrowsable(EditorBrowsableState.Never)]
463         [Obsolete("Do not use this LoadBlendShapeAnimation. Use MotionData.LoadBlendShapeAnimation and GenerateMotionDataAnimation instead.")]
464         public Animation LoadBlendShapeAnimation(string jsonFilename)
465         {
466             global::System.IntPtr cPtr = Interop.Model.LoadBlendShapeAnimation(SwigCPtr, jsonFilename);
467             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
468             if (ret == null)
469             {
470                 // Register new animation into Registry.
471                 ret = new Animation(cPtr, true);
472             }
473             else
474             {
475                 // We found matched NUI animation. Reduce cPtr reference count.
476                 HandleRef handle = new HandleRef(this, cPtr);
477                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
478                 handle = new HandleRef(null, IntPtr.Zero);
479             }
480             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481             return ret;
482         }
483
484         /// <summary>
485         /// Load morphing animation and assign to model from json string.
486         /// </summary>
487         /// <param name="jsonBuffer">Contents of json format file what we predefined.</param>
488         /// <returns>Animaion of facial</returns>
489         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
490         [EditorBrowsable(EditorBrowsableState.Never)]
491         [Obsolete("Do not use this LoadBlendShapeAnimationFromBuffer. Use MotionData.LoadBlendShapeAnimationFromBuffer and GenerateMotionDataAnimation instead.")]
492         public Animation LoadBlendShapeAnimationFromBuffer(string jsonBuffer)
493         {
494             global::System.IntPtr cPtr = Interop.Model.LoadBlendShapeAnimationFromBuffer(SwigCPtr, jsonBuffer, jsonBuffer.Length);
495             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
496             if (ret == null)
497             {
498                 // Register new animation into Registry.
499                 ret = new Animation(cPtr, true);
500             }
501             else
502             {
503                 // We found matched NUI animation. Reduce cPtr reference count.
504                 HandleRef handle = new HandleRef(this, cPtr);
505                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
506                 handle = new HandleRef(null, IntPtr.Zero);
507             }
508             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509             return ret;
510         }
511
512         /// <summary>
513         /// Generate animation by MotionData.
514         /// If there is no animatable item for MotionData, return null.
515         /// </summary>
516         /// <param name="motionData">Source motion data.</param>
517         /// <returns>Generated animation from then given motion data, or null if there is no animatable item in <paramref name="motionData"/></returns>
518         /// <since_tizen> 11 </since_tizen>
519         public Animation GenerateMotionDataAnimation(MotionData motionData)
520         {
521             global::System.IntPtr cPtr = Interop.Model.GenerateMotionDataAnimation(SwigCPtr, MotionData.getCPtr(motionData));
522             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animation;
523             if (ret == null)
524             {
525                 // Register new animation into Registry.
526                 ret = new Animation(cPtr, true);
527             }
528             else
529             {
530                 // We found matched NUI animation. Reduce cPtr reference count.
531                 HandleRef handle = new HandleRef(this, cPtr);
532                 Tizen.NUI.Interop.Animation.DeleteAnimation(handle);
533                 handle = new HandleRef(null, IntPtr.Zero);
534             }
535             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536
537             // It is possible if there is no animatable properties exist on inputed motionData.
538             // In this case, let we return null.
539             if (!ret.HasBody())
540             {
541                 ret.Dispose();
542                 ret = null;
543             }
544             return ret;
545         }
546
547         /// <summary>
548         /// Set values from MotionData.
549         /// Note that this method doesn not apply KeyFrames animation.
550         /// If you want to apply the animation, please use <see cref="GenerateMotionDataAnimation(MotionData)"/> and play the result.
551         /// </summary>
552         /// <param name="motionData">Source motion data.</param>
553         /// <since_tizen> 11 </since_tizen>
554         public void SetMotionData(MotionData motionData)
555         {
556             Interop.Model.SetMotionData(SwigCPtr, MotionData.getCPtr(motionData));
557             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
558         }
559
560         /// <summary>
561         /// Retrieves model root Actor.
562         /// </summary>
563         /// <returns>Root View of the model.</returns>
564         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
565         [EditorBrowsable(EditorBrowsableState.Never)]
566         private ModelNode GetModelRoot()
567         {
568             global::System.IntPtr cPtr = Interop.Model.GetModelRoot(SwigCPtr);
569             ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode;
570             if (ret == null)
571             {
572                 // Register new animatable into Registry.
573                 ret = new ModelNode(cPtr, true);
574             }
575             else
576             {
577                 // We found matched NUI animatable. Reduce cPtr reference count.
578                 HandleRef handle = new HandleRef(this, cPtr);
579                 Tizen.NUI.Interop.BaseHandle.DeleteBaseHandle(handle);
580                 handle = new HandleRef(null, IntPtr.Zero);
581             }
582             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583             return ret;
584         }
585
586         /// <summary>
587         /// Set the ImageBasedLight ScaleFactor.
588         /// </summary>
589         /// <param name="scaleFactor">Scale factor that controls light source intensity in [0.0f, 1.0f].</param>
590         private void SetImageBasedLightScaleFactor(float scaleFactor)
591         {
592             Interop.Model.SetImageBasedLightScaleFactor(SwigCPtr, scaleFactor);
593             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594         }
595
596         /// <summary>
597         /// Get the ImageBasedLight ScaleFactor.
598         /// </summary>
599         /// <returns>ImageBasedLightScaleFactor that controls light source intensity.</returns>
600         private float GetImageBasedLightScaleFactor()
601         {
602             float scaleFactor = Interop.Model.GetImageBasedLightScaleFactor(SwigCPtr);
603             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604             return scaleFactor;
605         }
606
607         /// <summary>
608         /// Release swigCPtr.
609         /// </summary>
610         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
611         [EditorBrowsable(EditorBrowsableState.Never)]
612         protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
613         {
614             Interop.Model.DeleteModel(swigCPtr);
615         }
616     }
617 }