2 * Copyright (c) 2017 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.
23 /// RelativeVector3 is a three-dimensional vector.
24 /// All values (x, y, z and w) should be between [0, 1].
26 public class RelativeVector3 : global::System.IDisposable
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 /// <since_tizen> 3 </since_tizen>
33 protected bool swigCMemOwn;
35 internal RelativeVector3(global::System.IntPtr cPtr, bool cMemoryOwn)
37 swigCMemOwn = cMemoryOwn;
38 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector3 obj)
43 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 //A Flag to check who called Dispose(). (By User or DisposeQueue)
47 private bool isDisposeQueued = false;
49 /// A Flat to check if it is already disposed.
51 /// <since_tizen> 3 </since_tizen>
52 protected bool disposed = false;
57 /// <since_tizen> 3 </since_tizen>
62 isDisposeQueued = true;
63 DisposeQueue.Instance.Add(this);
70 /// <since_tizen> 3 </since_tizen>
73 //Throw excpetion if Dispose() is called in separate thread.
74 if (!Window.IsInstalled())
76 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
81 Dispose(DisposeTypes.Implicit);
85 Dispose(DisposeTypes.Explicit);
86 System.GC.SuppressFinalize(this);
93 /// <since_tizen> 3 </since_tizen>
94 protected virtual void Dispose(DisposeTypes type)
101 if(type == DisposeTypes.Explicit)
104 //Release your own managed resources here.
105 //You should release all of your own disposable objects here.
108 //Release your own unmanaged resources here.
109 //You should not access any managed member here except static instance.
110 //because the execution order of Finalizes is non-deterministic.
112 if (swigCPtr.Handle != global::System.IntPtr.Zero)
117 NDalicPINVOKE.delete_Vector3(swigCPtr);
119 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
126 /// The addition operator.
128 /// <param name="arg1">The vector to add.</param>
129 /// <param name="arg2">Th vector to add.</param>
130 /// <returns>The vector containing the result of the addition.</returns>
131 /// <since_tizen> 3 </since_tizen>
132 public static RelativeVector3 operator +(RelativeVector3 arg1, RelativeVector3 arg2)
134 RelativeVector3 result = arg1.Add(arg2);
140 /// The subtraction operator.
142 /// <param name="arg1">The vector to subtract.</param>
143 /// <param name="arg2">The vector to subtract.</param>
144 /// <returns>The vector containing the result of the subtraction.</returns>
145 /// <since_tizen> 3 </since_tizen>
146 public static RelativeVector3 operator -(RelativeVector3 arg1, RelativeVector3 arg2)
148 RelativeVector3 result = arg1.Subtract(arg2);
154 /// The multiplication operator.
156 /// <param name="arg1">The vector to multiply.</param>
157 /// <param name="arg2">The vector to multiply.</param>
158 /// <returns>The vector containing the result of the multiplication.</returns>
159 /// <since_tizen> 3 </since_tizen>
160 public static RelativeVector3 operator *(RelativeVector3 arg1, RelativeVector3 arg2)
162 RelativeVector3 result = arg1.Multiply(arg2);
168 /// The multiplication operator.
170 /// <param name="arg1">The vector to multiply.</param>
171 /// <param name="arg2">The float value to scale the vector.</param>
172 /// <returns>The vector containing the result of the scaling.</returns>
173 /// <since_tizen> 3 </since_tizen>
174 public static RelativeVector3 operator *(RelativeVector3 arg1, float arg2)
176 RelativeVector3 result = arg1.Multiply(arg2);
182 /// The division operator.
184 /// <param name="arg1">The vector to divide.</param>
185 /// <param name="arg2">The vector to divide.</param>
186 /// <returns>The vector containing the result of the division.</returns>
187 /// <since_tizen> 3 </since_tizen>
188 public static RelativeVector3 operator /(RelativeVector3 arg1, RelativeVector3 arg2)
190 RelativeVector3 result = arg1.Divide(arg2);
196 /// The division operator.
198 /// <param name="arg1">The vector to divide.</param>
199 /// <param name="arg2">The float value to scale the vector by.</param>
200 /// <returns>The vector containing the result of the scaling.</returns>
201 /// <since_tizen> 3 </since_tizen>
202 public static RelativeVector3 operator /(RelativeVector3 arg1, float arg2)
204 RelativeVector3 result = arg1.Divide(arg2);
211 /// The const array subscript operator overload. Should be 0, 1 or 2.
213 /// <param name="index">The subscript index.</param>
214 /// <returns>The float at the given index.</returns>
215 /// <since_tizen> 3 </since_tizen>
216 public float this[uint index]
220 return ValueOfIndex(index);
226 internal static RelativeVector3 GetRelativeVector3FromPtr(global::System.IntPtr cPtr)
228 RelativeVector3 ret = new RelativeVector3(cPtr, false);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 /// <since_tizen> 3 </since_tizen>
238 public RelativeVector3() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 /// <param name="x">The x component.</param>
247 /// <param name="y">The y component.</param>
248 /// <param name="z">The z component.</param>
249 /// <since_tizen> 3 </since_tizen>
250 public RelativeVector3(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
255 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
262 /// <since_tizen> 3 </since_tizen>
263 public RelativeVector3(RelativeVector2 relativeVector2) : this(NDalicPINVOKE.new_Vector3__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 /// <param name="relativeVector4">The RelativeVector4 to create this vector from.</param>
272 /// <since_tizen> 3 </since_tizen>
273 public RelativeVector3(RelativeVector4 relativeVector4) : this(NDalicPINVOKE.new_Vector3__SWIG_4(RelativeVector4.getCPtr(relativeVector4)), true)
275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 private RelativeVector3 Add(RelativeVector3 rhs)
281 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Add(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 private RelativeVector3 Subtract(RelativeVector3 rhs)
288 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293 private RelativeVector3 Multiply(RelativeVector3 rhs)
295 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 private RelativeVector3 Multiply(float rhs)
302 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 private RelativeVector3 Divide(RelativeVector3 rhs)
309 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 private RelativeVector3 Divide(float rhs)
316 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 private float ValueOfIndex(uint index)
323 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 /// Compares if the rhs is equal to.
331 /// <param name="rhs">The vector to compare.</param>
332 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
333 /// <since_tizen> 3 </since_tizen>
334 public bool EqualTo(RelativeVector3 rhs)
336 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342 /// Compares if the rhs is not equal to.
344 /// <param name="rhs">The vector to compare.</param>
345 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
346 /// <since_tizen> 3 </since_tizen>
347 public bool NotEqualTo(RelativeVector3 rhs)
349 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 /// <since_tizen> 3 </since_tizen>
364 NDalicPINVOKE.Vector3_X_set(swigCPtr, value);
365 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 float ret = NDalicPINVOKE.Vector3_X_get(swigCPtr);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 /// <since_tizen> 3 </since_tizen>
384 NDalicPINVOKE.Vector3_Y_set(swigCPtr, value);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 float ret = NDalicPINVOKE.Vector3_Y_get(swigCPtr);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 /// <since_tizen> 3 </since_tizen>
404 NDalicPINVOKE.Vector3_Z_set(swigCPtr, value);
405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409 float ret = NDalicPINVOKE.Vector3_Z_get(swigCPtr);
410 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 /// <since_tizen> 3 </since_tizen>
418 public static implicit operator Vector3(RelativeVector3 relativeVector3)
420 return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
425 /// <since_tizen> 3 </since_tizen>
426 public static implicit operator RelativeVector3(Vector3 vec)
431 return new RelativeVector3(vec.X, vec.Y, vec.Z);
434 internal static void ValueCheck(RelativeVector3 relativeVector3)
436 if(relativeVector3.X < 0.0f)
438 relativeVector3.X = 0.0f;
439 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
441 else if(relativeVector3.X > 1.0f)
443 relativeVector3.X = 1.0f;
444 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
446 if(relativeVector3.Y < 0.0f)
448 relativeVector3.Y = 0.0f;
449 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
451 else if(relativeVector3.Y > 1.0f)
453 relativeVector3.Y = 1.0f;
454 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
456 if(relativeVector3.Z < 0.0f)
458 relativeVector3.Z = 0.0f;
459 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
461 else if(relativeVector3.Z > 1.0f)
463 relativeVector3.Z = 1.0f;
464 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
468 internal static void ValueCheck(float value)
473 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
475 else if(value > 1.0f)
478 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");