cb009579e43a8da93d3db2034aa058ed00e5a565
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Scene3D / src / public / ModelMotion / MotionIndex / BlendShapeIndex.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.ComponentModel;
20 using System.Collections.Generic;
21 using Tizen.NUI;
22
23 namespace Tizen.NUI.Scene3D
24 {
25     /// <summary>
26     /// Specialized <see cref="MotionIndex"/> to control blend shape.
27     /// We can control the blend shape by index (when we set BlendShapeId as IndexKey),
28     /// or by name (when we set BlendShapeId as StringKey).
29     /// </summary>
30     /// <remarks>
31     /// <see cref="MotionValue"/> should be float type.
32     /// </remarks>
33     /// <example>
34     /// <code>
35     /// BlendShapeIndex blendShapeIndex0 = new BlendShapeIndex(new PropertyKey("nodeName"), new PropertyKey(0u));
36     /// BlendShapeIndex blendShapeIndex1 = new BlendShapeIndex(new PropertyKey("nodeName"), new PropertyKey("Target_1"));
37     ///
38     /// // We can change the property later.
39     /// BlendShapeIndex blendShapeIndex2 = new BlendShapeIndex;
40     /// blendShapeIndex2.ModelNodeId = new PropertyKey("nodeName");
41     /// blendShapeIndex2.BlendShapeId = new PropertyKey("Target_2");
42     /// </code>
43     /// </example>
44     /// <example>
45     /// Specially, if ModelNodeId is invalid and BlendShapeId is StringKey,
46     /// It will control all ModelNode that has the inputed blend shape name.
47     ///
48     /// <code>
49     /// // If "node0" and "node1" has same BlendShape named "Smile",
50     /// // blendShapeIndexAll will control both nodes.
51     /// BlendShapeIndex blendShapeIndexAll = new BlendShapeIndex(new PropertyKey("Smile"));
52     ///
53     /// BlendShapeIndex blendShapeIndex0 = new BlendShapeIndex(new PropertyKey("node0"), new PropertyKey("Smile"));
54     /// BlendShapeIndex blendShapeIndex1 = new BlendShapeIndex(new PropertyKey("node1"), new PropertyKey("Smile"));
55     /// </code>
56     /// </example>
57     /// <since_tizen> 11 </since_tizen>
58     public class BlendShapeIndex : MotionIndex
59     {
60         /// <summary>
61         /// Create an initialized blend shape index.
62         /// </summary>
63         /// <since_tizen> 11 </since_tizen>
64         public BlendShapeIndex() : this(Interop.MotionIndex.BlendShapeIndexNew(), true)
65         {
66             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
67         }
68
69         /// <summary>
70         /// Create an initialized blend shape index with invalid node ID, and given blend shape ID.
71         /// </summary>
72         /// <param name="blendShapeId">Blend shape ID for this motion index</param>
73         /// <since_tizen> 11 </since_tizen>
74         public BlendShapeIndex(PropertyKey blendShapeId) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(blendShapeId)), true)
75         {
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77         }
78
79         /// <summary>
80         /// Create an initialized blend shape index with given node ID and blend shape ID.
81         /// </summary>
82         /// <param name="modelNodeId">Node ID for this motion index</param>
83         /// <param name="blendShapeId">Blend shape ID for this motion index</param>
84         /// <since_tizen> 11 </since_tizen>
85         public BlendShapeIndex(PropertyKey modelNodeId, PropertyKey blendShapeId) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(modelNodeId), PropertyKey.getCPtr(blendShapeId)), true)
86         {
87             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88         }
89
90         /// <summary>
91         /// Create an initialized blend shape index with invalid node ID, and given blend shape string ID.
92         /// </summary>
93         /// <param name="blendShapeName">Blend shape string ID for this motion index</param>
94         /// <since_tizen> 11 </since_tizen>
95         public BlendShapeIndex(string blendShapeName) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(new PropertyKey(blendShapeName))), true)
96         {
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98         }
99
100         /// <summary>
101         /// Create an initialized blend shape index with given node string ID and blend shape string ID.
102         /// </summary>
103         /// <param name="modelNodeName">Node string ID for this motion index</param>
104         /// <param name="blendShapeName">Blend shape string ID for this motion index</param>
105         /// <since_tizen> 11 </since_tizen>
106         public BlendShapeIndex(string modelNodeName, string blendShapeName) : this(Interop.MotionIndex.BlendShapeIndexNew(PropertyKey.getCPtr(new PropertyKey(modelNodeName)), PropertyKey.getCPtr(new PropertyKey(blendShapeName))), true)
107         {
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109         }
110
111         /// <summary>
112         /// Copy constructor.
113         /// </summary>
114         /// <param name="blendShapeIndex">Source object to copy.</param>
115         /// <since_tizen> 11 </since_tizen>
116         public BlendShapeIndex(BlendShapeIndex blendShapeIndex) : this(Interop.MotionIndex.NewBlendShapeIndex(BlendShapeIndex.getCPtr(blendShapeIndex)), true, false)
117         {
118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119         }
120
121         /// <summary>
122         /// Assignment operator.
123         /// </summary>
124         /// <param name="blendShapeIndex">Source object to be assigned.</param>
125         /// <returns>Reference to this.</returns>
126         internal BlendShapeIndex Assign(BlendShapeIndex blendShapeIndex)
127         {
128             BlendShapeIndex ret = new BlendShapeIndex(Interop.MotionIndex.BlendShapeIndexAssign(SwigCPtr, BlendShapeIndex.getCPtr(blendShapeIndex)), false);
129             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130             return ret;
131         }
132
133         internal BlendShapeIndex(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
134         {
135         }
136
137         internal BlendShapeIndex(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
138         {
139         }
140
141         /// <summary>
142         /// The key of blend shape.
143         /// </summary>
144         /// <since_tizen> 11 </since_tizen>
145         public PropertyKey BlendShapeId
146         {
147             get
148             {
149                 return GetBlendShapeId();
150             }
151             set
152             {
153                 SetBlendShapeId(value);
154             }
155         }
156
157         internal void SetBlendShapeId(PropertyKey blendShapeId)
158         {
159             Interop.MotionIndex.SetBlendShapeId(SwigCPtr, Property.getCPtr(blendShapeId));
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161         }
162
163         internal PropertyKey GetBlendShapeId()
164         {
165             IntPtr cPtr = Interop.MotionIndex.GetBlendShapeId(SwigCPtr);
166             PropertyKey ret = new PropertyKey(cPtr, true);
167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168             return ret;
169         }
170
171         /// <summary>
172         /// Release swigCPtr.
173         /// </summary>
174         // This will be public opened.
175         [EditorBrowsable(EditorBrowsableState.Never)]
176         protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
177         {
178             Interop.MotionIndex.DeleteBlendShapeIndex(swigCPtr);
179         }
180     }
181 }