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;
29 protected bool swigCMemOwn;
31 internal RelativeVector3(global::System.IntPtr cPtr, bool cMemoryOwn)
33 swigCMemOwn = cMemoryOwn;
34 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector3 obj)
39 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 //A Flag to check who called Dispose(). (By User or DisposeQueue)
43 private bool isDisposeQueued = false;
44 //A Flat to check if it is already disposed.
45 protected bool disposed = false;
51 isDisposeQueued = true;
52 DisposeQueue.Instance.Add(this);
58 //Throw excpetion if Dispose() is called in separate thread.
59 if (!Window.IsInstalled())
61 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
66 Dispose(DisposeTypes.Implicit);
70 Dispose(DisposeTypes.Explicit);
71 System.GC.SuppressFinalize(this);
75 protected virtual void Dispose(DisposeTypes type)
82 if(type == DisposeTypes.Explicit)
85 //Release your own managed resources here.
86 //You should release all of your own disposable objects here.
89 //Release your own unmanaged resources here.
90 //You should not access any managed member here except static instance.
91 //because the execution order of Finalizes is non-deterministic.
93 if (swigCPtr.Handle != global::System.IntPtr.Zero)
98 NDalicPINVOKE.delete_Vector3(swigCPtr);
100 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
107 /// The addition operator.
109 /// <param name="arg1">The vector to add.</param>
110 /// <param name="arg2">Th vector to add.</param>
111 /// <returns>The vector containing the result of the addition.</returns>
112 /// <since_tizen> 3 </since_tizen>
113 public static RelativeVector3 operator +(RelativeVector3 arg1, RelativeVector3 arg2)
115 RelativeVector3 result = arg1.Add(arg2);
121 /// The subtraction operator.
123 /// <param name="arg1">The vector to subtract.</param>
124 /// <param name="arg2">The vector to subtract.</param>
125 /// <returns>The vector containing the result of the subtraction.</returns>
126 /// <since_tizen> 3 </since_tizen>
127 public static RelativeVector3 operator -(RelativeVector3 arg1, RelativeVector3 arg2)
129 RelativeVector3 result = arg1.Subtract(arg2);
135 /// The multiplication operator.
137 /// <param name="arg1">The vector to multiply.</param>
138 /// <param name="arg2">The vector to multiply.</param>
139 /// <returns>The vector containing the result of the multiplication.</returns>
140 /// <since_tizen> 3 </since_tizen>
141 public static RelativeVector3 operator *(RelativeVector3 arg1, RelativeVector3 arg2)
143 RelativeVector3 result = arg1.Multiply(arg2);
149 /// The multiplication operator.
151 /// <param name="arg1">The vector to multiply.</param>
152 /// <param name="arg2">The float value to scale the vector.</param>
153 /// <returns>The vector containing the result of the scaling.</returns>
154 /// <since_tizen> 3 </since_tizen>
155 public static RelativeVector3 operator *(RelativeVector3 arg1, float arg2)
157 RelativeVector3 result = arg1.Multiply(arg2);
163 /// The division operator.
165 /// <param name="arg1">The vector to divide.</param>
166 /// <param name="arg2">The vector to divide.</param>
167 /// <returns>The vector containing the result of the division.</returns>
168 /// <since_tizen> 3 </since_tizen>
169 public static RelativeVector3 operator /(RelativeVector3 arg1, RelativeVector3 arg2)
171 RelativeVector3 result = arg1.Divide(arg2);
177 /// The division operator.
179 /// <param name="arg1">The vector to divide.</param>
180 /// <param name="arg2">The float value to scale the vector by.</param>
181 /// <returns>The vector containing the result of the scaling.</returns>
182 /// <since_tizen> 3 </since_tizen>
183 public static RelativeVector3 operator /(RelativeVector3 arg1, float arg2)
185 RelativeVector3 result = arg1.Divide(arg2);
192 /// The const array subscript operator overload. Should be 0, 1 or 2.
194 /// <param name="index">The subscript index.</param>
195 /// <returns>The float at the given index.</returns>
196 /// <since_tizen> 3 </since_tizen>
197 public float this[uint index]
201 return ValueOfIndex(index);
207 internal static RelativeVector3 GetRelativeVector3FromPtr(global::System.IntPtr cPtr)
209 RelativeVector3 ret = new RelativeVector3(cPtr, false);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 /// <since_tizen> 3 </since_tizen>
219 public RelativeVector3() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// <param name="x">The x component.</param>
228 /// <param name="y">The y component.</param>
229 /// <param name="z">The z component.</param>
230 /// <since_tizen> 3 </since_tizen>
231 public RelativeVector3(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
243 /// <since_tizen> 3 </since_tizen>
244 public RelativeVector3(RelativeVector2 relativeVector2) : this(NDalicPINVOKE.new_Vector3__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// <param name="relativeVector4">The RelativeVector4 to create this vector from.</param>
253 /// <since_tizen> 3 </since_tizen>
254 public RelativeVector3(RelativeVector4 relativeVector4) : this(NDalicPINVOKE.new_Vector3__SWIG_4(RelativeVector4.getCPtr(relativeVector4)), true)
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260 private RelativeVector3 Add(RelativeVector3 rhs)
262 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Add(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 private RelativeVector3 Subtract(RelativeVector3 rhs)
269 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 private RelativeVector3 Multiply(RelativeVector3 rhs)
276 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 private RelativeVector3 Multiply(float rhs)
283 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 private RelativeVector3 Divide(RelativeVector3 rhs)
290 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 private RelativeVector3 Divide(float rhs)
297 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 private float ValueOfIndex(uint index)
304 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 /// Compares if the rhs is equal to.
312 /// <param name="rhs">The vector to compare.</param>
313 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
314 /// <since_tizen> 3 </since_tizen>
315 public bool EqualTo(RelativeVector3 rhs)
317 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323 /// Compares if the rhs is not equal to.
325 /// <param name="rhs">The vector to compare.</param>
326 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
327 /// <since_tizen> 3 </since_tizen>
328 public bool NotEqualTo(RelativeVector3 rhs)
330 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 /// <since_tizen> 3 </since_tizen>
345 NDalicPINVOKE.Vector3_X_set(swigCPtr, value);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 float ret = NDalicPINVOKE.Vector3_X_get(swigCPtr);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 /// <since_tizen> 3 </since_tizen>
365 NDalicPINVOKE.Vector3_Y_set(swigCPtr, value);
366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 float ret = NDalicPINVOKE.Vector3_Y_get(swigCPtr);
371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 /// <since_tizen> 3 </since_tizen>
385 NDalicPINVOKE.Vector3_Z_set(swigCPtr, value);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 float ret = NDalicPINVOKE.Vector3_Z_get(swigCPtr);
391 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 /// <since_tizen> 3 </since_tizen>
399 public static implicit operator Vector3(RelativeVector3 relativeVector3)
401 return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
406 /// <since_tizen> 3 </since_tizen>
407 public static implicit operator RelativeVector3(Vector3 vec)
412 return new RelativeVector3(vec.X, vec.Y, vec.Z);
415 internal static void ValueCheck(RelativeVector3 relativeVector3)
417 if(relativeVector3.X < 0.0f)
419 relativeVector3.X = 0.0f;
420 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
422 else if(relativeVector3.X > 1.0f)
424 relativeVector3.X = 1.0f;
425 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
427 if(relativeVector3.Y < 0.0f)
429 relativeVector3.Y = 0.0f;
430 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
432 else if(relativeVector3.Y > 1.0f)
434 relativeVector3.Y = 1.0f;
435 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
437 if(relativeVector3.Z < 0.0f)
439 relativeVector3.Z = 0.0f;
440 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
442 else if(relativeVector3.Z > 1.0f)
444 relativeVector3.Z = 1.0f;
445 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
449 internal static void ValueCheck(float value)
454 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
456 else if(value > 1.0f)
459 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");